1 /*
2  * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include <memory>
17 #include <sys/types.h>
18 
19 #include "gtest/gtest.h"
20 
21 #include "base/json/json_util.h"
22 #include "base/utils/utils.h"
23 
24 using namespace testing;
25 using namespace testing::ext;
26 
27 namespace OHOS::Ace {
28 namespace {
29 const std::string TEST_STRING = "Ace Unittest";
30 const std::string TEST_KEY = "JsonObjectTypeTest";
31 const std::string TEST_FALSE_KEY = "FalseKey";
32 } // namespace
33 
34 class JsonUtilTest : public testing::Test {};
35 
36 /**
37  * @tc.name: JsonUtilTest001
38  * @tc.desc: Check json util function for bool type value
39  * @tc.type: FUNC
40  */
41 HWTEST_F(JsonUtilTest, JsonUtilTest001, TestSize.Level1)
42 {
43     /**
44      * @tc.steps: step1. construct the test string with bool value.
45      */
46     std::string testJson = "true";
47 
48     /**
49      * @tc.steps: step2. get JsonValue and check results of IsValid, IsNull, IsBool and GetBool.
50      * @tc.expected: step2. get the JsonValue successfully and the results are correct.
51      */
52     std::unique_ptr<JsonValue> boolValue = JsonUtil::ParseJsonString(testJson);
53     ASSERT_TRUE(boolValue);
54     EXPECT_TRUE(boolValue->IsValid());
55     EXPECT_FALSE(boolValue->IsNull());
56     EXPECT_TRUE(boolValue->IsBool());
57     EXPECT_TRUE(boolValue->GetBool());
58 }
59 
60 /**
61  * @tc.name: JsonUtilTest002
62  * @tc.desc: Check json util function for bool type value
63  * @tc.type: FUNC
64  */
65 HWTEST_F(JsonUtilTest, JsonUtilTest002, TestSize.Level1)
66 {
67     /**
68      * @tc.steps: step1. construct the test string with bool value.
69      */
70     std::string testJson = "false";
71 
72     /**
73      * @tc.steps: step2. get JsonValue and check results of IsValid, IsNull, IsBool and GetBool.
74      * @tc.expected: step2. get the JsonValue successfully and the results are correct.
75      */
76     std::unique_ptr<JsonValue> boolValue = JsonUtil::ParseJsonString(testJson);
77     ASSERT_TRUE(boolValue);
78     EXPECT_TRUE(boolValue->IsValid());
79     EXPECT_FALSE(boolValue->IsNull());
80     EXPECT_TRUE(boolValue->IsBool());
81     EXPECT_FALSE(boolValue->GetBool());
82 }
83 
84 /**
85  * @tc.name: JsonUtilTest004
86  * @tc.desc: Check json util function for unsigned integer
87  * @tc.type: FUNC
88  */
89 HWTEST_F(JsonUtilTest, JsonUtilTest004, TestSize.Level1)
90 {
91     /**
92      * @tc.steps: step1. construct the test string with unsigned integer.
93      */
94     std::string testJson = "1";
95     int32_t intNum = 1;
96     uint32_t uintNum = 1;
97     double doubleNum = 1;
98 
99     /**
100      * @tc.steps: step2. get JsonValue and check results of IsValid, IsNull, IsNumber, GetInt, GetUInt and GetDouble.
101      * @tc.expected: step2. get the JsonValue successfully and the results are correct.
102      */
103     std::unique_ptr<JsonValue> uintValue = JsonUtil::ParseJsonString(testJson);
104     ASSERT_TRUE(uintValue);
105     EXPECT_TRUE(uintValue->IsValid());
106     EXPECT_FALSE(uintValue->IsNull());
107     EXPECT_TRUE(uintValue->IsNumber());
108     EXPECT_TRUE(uintValue->GetInt() == intNum);
109     EXPECT_TRUE(uintValue->GetUInt() == uintNum);
110     EXPECT_TRUE(NearEqual(uintValue->GetDouble(), doubleNum));
111 }
112 
113 /**
114  * @tc.name: JsonUtilTest005
115  * @tc.desc: Check json util function for decimal number
116  * @tc.type: FUNC
117  */
118 HWTEST_F(JsonUtilTest, JsonUtilTest005, TestSize.Level1)
119 {
120     /**
121      * @tc.steps: step1. construct the test string with decimal number.
122      */
123     std::string testJson = "6.66";
124     int32_t intNum = 6;
125     uint32_t uintNum = 6;
126     double doubleNum = 6.66;
127 
128     /**
129      * @tc.steps: step2. get JsonValue and check results of IsValid, IsNull, IsNumber, GetInt, GetUInt and GetDouble.
130      * @tc.expected: step2. get the JsonValue successfully and the results are correct.
131      */
132     std::unique_ptr<JsonValue> doubleValue = JsonUtil::ParseJsonString(testJson);
133     ASSERT_TRUE(doubleValue);
134     EXPECT_TRUE(doubleValue->IsValid());
135     EXPECT_FALSE(doubleValue->IsNull());
136     EXPECT_TRUE(doubleValue->IsNumber());
137     EXPECT_TRUE(doubleValue->GetInt() == intNum);
138     EXPECT_TRUE(doubleValue->GetUInt() == uintNum);
139     EXPECT_TRUE(NearEqual(doubleValue->GetDouble(), doubleNum));
140 }
141 
142 /**
143  * @tc.name: JsonUtilTest006
144  * @tc.desc: Check json util function for string
145  * @tc.type: FUNC
146  */
147 HWTEST_F(JsonUtilTest, JsonUtilTest006, TestSize.Level1)
148 {
149     /**
150      * @tc.steps: step1. construct the test string with string.
151      */
152     std::string testJson = "\"Ace Unittest\"";
153 
154     /**
155      * @tc.steps: step2. get JsonValue and check results of IsValid, IsNull, IsString and GetString.
156      * @tc.expected: step2. get the JsonValue successfully and the results are correct.
157      */
158     std::unique_ptr<JsonValue> stringValue = JsonUtil::ParseJsonString(testJson);
159     ASSERT_TRUE(stringValue);
160     EXPECT_TRUE(stringValue->IsValid());
161     EXPECT_FALSE(stringValue->IsNull());
162     EXPECT_TRUE(stringValue->IsString());
163     EXPECT_TRUE(stringValue->GetString() == TEST_STRING);
164 }
165 
166 /**
167  * @tc.name: JsonUtilTest007
168  * @tc.desc: Check json util function for empty string
169  * @tc.type: FUNC
170  */
171 HWTEST_F(JsonUtilTest, JsonUtilTest007, TestSize.Level1)
172 {
173     /**
174      * @tc.steps: step1. construct the test string with empty string.
175      */
176     std::string testJson = "\"\"";
177 
178     /**
179      * @tc.steps: step2. get JsonValue and check results of IsValid, IsNull, IsString and GetString.
180      * @tc.expected: step2. get the JsonValue successfully and the results are correct.
181      */
182     std::unique_ptr<JsonValue> emptyStringValue = JsonUtil::ParseJsonString(testJson);
183     ASSERT_TRUE(emptyStringValue);
184     EXPECT_TRUE(emptyStringValue->IsValid());
185     EXPECT_FALSE(emptyStringValue->IsNull());
186     EXPECT_TRUE(emptyStringValue->IsString());
187     EXPECT_TRUE(emptyStringValue->GetString().empty());
188 }
189 
190 /**
191  * @tc.name: JsonUtilTest008
192  * @tc.desc: Check json util function for JsonObject
193  * @tc.type: FUNC
194  */
195 HWTEST_F(JsonUtilTest, JsonUtilTest008, TestSize.Level1)
196 {
197     /**
198      * @tc.steps: step1. construct the test string with JsonObject.
199      */
200     std::string testJson = R"({"JsonObjectTypeTest": "Ace Unittest"})";
201 
202     /**
203      * @tc.steps: step2. get JsonValue and check results of IsValid, IsNull, IsObject, Contains and GetValue.
204      * @tc.expected: step2. get the JsonValue successfully and the results are correct.
205      */
206     std::unique_ptr<JsonValue> objectValue = JsonUtil::ParseJsonString(testJson);
207     ASSERT_TRUE(objectValue);
208     EXPECT_TRUE(objectValue->IsValid());
209     EXPECT_FALSE(objectValue->IsNull());
210     EXPECT_TRUE(objectValue->IsObject());
211     EXPECT_TRUE(objectValue->Contains(TEST_KEY));
212     EXPECT_FALSE(objectValue->Contains(TEST_FALSE_KEY));
213     EXPECT_TRUE(objectValue->GetValue(TEST_KEY)->GetString() == TEST_STRING);
214     EXPECT_TRUE(objectValue->GetValue(TEST_FALSE_KEY)->GetString().empty());
215 }
216 
217 /**
218  * @tc.name: JsonUtilTest009
219  * @tc.desc: Check json util function for incorrect JsonObject
220  * @tc.type: FUNC
221  */
222 HWTEST_F(JsonUtilTest, JsonUtilTest009, TestSize.Level1)
223 {
224     /**
225      * @tc.steps: step1. construct the test string with incorrect JsonObject.
226      */
227     std::string testJson = R"({"JsonObjectTypeTest": ""})";
228 
229     /**
230      * @tc.steps: step2. get JsonValue and check results of IsValid, IsNull, IsObject, Contains and GetValue.
231      * @tc.expected: step2. get the JsonValue successfully and the results are correct.
232      */
233     std::unique_ptr<JsonValue> objectValue = JsonUtil::ParseJsonString(testJson);
234     ASSERT_TRUE(objectValue);
235     EXPECT_TRUE(objectValue->IsValid());
236     EXPECT_FALSE(objectValue->IsNull());
237     EXPECT_TRUE(objectValue->IsObject());
238     EXPECT_TRUE(objectValue->Contains(TEST_KEY));
239     EXPECT_TRUE(objectValue->GetValue(TEST_KEY)->GetString().empty());
240 }
241 
242 /**
243  * @tc.name: JsonUtilTest010
244  * @tc.desc: Check json util function for array
245  * @tc.type: FUNC
246  */
247 HWTEST_F(JsonUtilTest, JsonUtilTest010, TestSize.Level1)
248 {
249     /**
250      * @tc.steps: step1. construct the test string with array.
251      */
252     std::string testJson = "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]";
253     int32_t testArraySize = 10;
254     int32_t testArrayIndex = 5;
255     int32_t testArrayValue = 5;
256 
257     /**
258      * @tc.steps: step2. get JsonValue and check results of IsValid, IsNull, IsArray, GetArraySize and GetArrayItem.
259      * @tc.expected: step2. get the JsonValue successfully and the results are correct.
260      */
261     std::unique_ptr<JsonValue> arrayValue = JsonUtil::ParseJsonString(testJson);
262     ASSERT_TRUE(arrayValue);
263     EXPECT_TRUE(arrayValue->IsValid());
264     EXPECT_FALSE(arrayValue->IsNull());
265     EXPECT_TRUE(arrayValue->IsArray());
266     EXPECT_TRUE(arrayValue->GetArraySize() == testArraySize);
267     EXPECT_TRUE(arrayValue->GetArrayItem(testArrayIndex)->GetInt() == testArrayValue);
268 }
269 
270 /**
271  * @tc.name: JsonUtilTest011
272  * @tc.desc: Check json util function for empty array
273  * @tc.type: FUNC
274  */
275 HWTEST_F(JsonUtilTest, JsonUtilTest011, TestSize.Level1)
276 {
277     /**
278      * @tc.steps: step1. construct the test string with empty array.
279      */
280     std::string testJson = "[]";
281 
282     /**
283      * @tc.steps: step2. get JsonValue and check results of IsValid, IsNull, IsArray, GetArraySize and GetArrayItem.
284      * @tc.expected: step2. get the JsonValue successfully and the results are correct.
285      */
286     std::unique_ptr<JsonValue> arrayValue = JsonUtil::ParseJsonString(testJson);
287     ASSERT_TRUE(arrayValue);
288     EXPECT_TRUE(arrayValue->IsValid());
289     EXPECT_FALSE(arrayValue->IsNull());
290     EXPECT_TRUE(arrayValue->IsArray());
291     EXPECT_TRUE(arrayValue->GetArraySize() == 0);
292 }
293 
294 /**
295  * @tc.name: JsonUtilTest012
296  * @tc.desc: Check json util function for empty test string
297  * @tc.type: FUNC
298  */
299 HWTEST_F(JsonUtilTest, JsonUtilTest012, TestSize.Level1)
300 {
301     /**
302      * @tc.steps: step1. construct the empty test string.
303      */
304     std::string testJson;
305 
306     /**
307      * @tc.steps: step2. get JsonValue and check results of IsValid, IsNull.
308      * @tc.expected: step2. get the JsonValue successfully and the results are correct.
309      */
310     std::unique_ptr<JsonValue> emptyValue = JsonUtil::ParseJsonString(testJson);
311     ASSERT_TRUE(emptyValue);
312     EXPECT_FALSE(emptyValue->IsValid());
313     EXPECT_TRUE(emptyValue->IsNull());
314 }
315 
316 /**
317  * @tc.name: JsonUtilTest013
318  * @tc.desc: Check json util function for illegal type value
319  * @tc.type: FUNC
320  */
321 HWTEST_F(JsonUtilTest, JsonUtilTest013, TestSize.Level1)
322 {
323     /**
324      * @tc.steps: step1. construct the test string with illegal type value.
325      */
326     std::string testJson = "{Ace Unittest}";
327 
328     /**
329      * @tc.steps: step2. get JsonValue and check results of IsValid, IsNull.
330      * @tc.expected: step2. get the JsonValue successfully and the results are correct.
331      */
332     std::unique_ptr<JsonValue> illegalValue = JsonUtil::ParseJsonString(testJson);
333     ASSERT_TRUE(illegalValue);
334     EXPECT_FALSE(illegalValue->IsValid());
335     EXPECT_TRUE(illegalValue->IsNull());
336 }
337 
338 /**
339  * @tc.name: JsonUtilTest014
340  * @tc.desc: Check json util function Put(const char* key, const char* value) for nullptr key or value
341  * @tc.type: FUNC
342  */
343 HWTEST_F(JsonUtilTest, JsonUtilTest014, TestSize.Level1)
344 {
345     /**
346      * @tc.steps: step1. construct the nullptr key.
347      */
348     const char* key = nullptr;
349     const char* value = nullptr;
350     JsonValue jsonValue;
351     /**
352      * @tc.steps: step2. get results
353      * @tc.expected: step2.  the results are correct.
354      */
355     bool ret = jsonValue.Put(key, value);
356     EXPECT_FALSE(ret);
357 
358     /**
359      * @tc.steps: step3. construct the nullptr value.
360      */
361     char c = '5';
362     const char* key2 = &c;
363     const char* value2 = nullptr;
364     /**
365      * @tc.steps: step4. get results
366      * @tc.expected: step4.  the results are correct.
367      */
368     bool ret2 = jsonValue.Put(key2, value2);
369     EXPECT_FALSE(ret2);
370 
371     /**
372      * @tc.steps: step5. construct value not null
373      */
374     char c2 = 'v';
375     const char* value3 = &c2;
376     bool ret3 = jsonValue.Put(key2, value3);
377     EXPECT_TRUE(ret3);
378     bool ret4 = jsonValue.Put(key, value3);
379     EXPECT_FALSE(ret4);
380 }
381 
382 /**
383  * @tc.name: JsonUtilTest015
384  * @tc.desc: Check json util function Put(const char* key, bool value) for nullptr key
385  * @tc.type: FUNC
386  */
387 HWTEST_F(JsonUtilTest, JsonUtilTest015, TestSize.Level1)
388 {
389     /**
390      * @tc.steps: step1. construct the nullptr key.
391      */
392     const char* key = nullptr;
393     bool value = true;
394     JsonValue jsonValue;
395     /**
396      * @tc.steps: step2. get  results
397      * @tc.expected: step2.  the results are correct.
398      */
399     bool ret = jsonValue.Put(key, value);
400     EXPECT_FALSE(ret);
401 }
402 
403 /**
404  * @tc.name: JsonUtilTest016
405  * @tc.desc: Check json util function Put(const char* key, const std::unique_ptr<JsonValue>& value)
406  * for nullptr key or nullptr value
407  * @tc.type: FUNC
408  */
409 HWTEST_F(JsonUtilTest, JsonUtilTest016, TestSize.Level1)
410 {
411     /**
412      * @tc.steps: step1. construct the nullptr key.
413      */
414     const char* key = nullptr;
415     const std::unique_ptr<JsonValue>& value = nullptr;
416     JsonValue jsonValue;
417     /**
418      * @tc.steps: step2. get  results
419      * @tc.expected: step2.  the results are correct.
420      */
421     bool ret = jsonValue.Put(key, value);
422     EXPECT_FALSE(ret);
423 
424     /**
425      * @tc.steps: step1. construct the nullptr value.
426      */
427     char c = '5';
428     const char* key2 = &c;
429     const std::unique_ptr<JsonValue>& value2 = nullptr;
430     /**
431      * @tc.steps: step2. get  results
432      * @tc.expected: step2.  the results are correct.
433      */
434     bool ret2 = jsonValue.Put(key2, value2);
435     EXPECT_FALSE(ret2);
436 
437     /**
438      * @tc.steps: step3. construct the value not null
439      */
440     char valueStr = '5';
441     const char* valueTemp = &valueStr;
442     bool ret3 = jsonValue.Put(key2, valueTemp);
443     EXPECT_TRUE(ret3);
444     bool ret4 = jsonValue.Put(key, valueTemp);
445     EXPECT_FALSE(ret4);
446 }
447 
448 /**
449  * @tc.name: JsonUtilTest017
450  * @tc.desc: Check json util function Put(const char* key, size_t value) for nullptr key
451  * @tc.type: FUNC
452  */
453 HWTEST_F(JsonUtilTest, JsonUtilTest017, TestSize.Level1)
454 {
455     /**
456      * @tc.steps: step1. construct the nullptr key.
457      */
458     const char* key = nullptr;
459     size_t value = 8;
460     JsonValue jsonValue;
461     /**
462      * @tc.steps: step2. get  results
463      * @tc.expected: step2.  the results are correct.
464      */
465     bool ret = jsonValue.Put(key, value);
466     EXPECT_FALSE(ret);
467 
468     /**
469      * @tc.steps: step1. construct the nullptr value.
470      */
471     char c = '5';
472     const char* key2 = &c;
473     /**
474      * @tc.steps: step2. get  results
475      * @tc.expected: step2.  the results are correct.
476      */
477     bool ret2 = jsonValue.Put(key2, value);
478     EXPECT_TRUE(ret2);
479 }
480 
481 /**
482  * @tc.name: JsonUtilTest018
483  * @tc.desc: Check json util function Put(const char* key, int32_t value) for nullptr key
484  * @tc.type: FUNC
485  */
486 HWTEST_F(JsonUtilTest, JsonUtilTest018, TestSize.Level1)
487 {
488     /**
489      * @tc.steps: step1. construct the nullptr key.
490      */
491     const char* key = nullptr;
492     int32_t value = 8;
493     JsonValue jsonValue;
494     /**
495      * @tc.steps: step2. get  results
496      * @tc.expected: step2.  the results are correct.
497      */
498     bool ret = jsonValue.Put(key, value);
499     EXPECT_FALSE(ret);
500 }
501 
502 /**
503  * @tc.name: JsonUtilTest019
504  * @tc.desc: Check json util function Put(const char* key, double value) for nullptr key
505  * @tc.type: FUNC
506  */
507 HWTEST_F(JsonUtilTest, JsonUtilTest019, TestSize.Level1)
508 {
509     /**
510      * @tc.steps: step1. construct the nullptr key.
511      */
512     const char* key = nullptr;
513     double value = 8;
514     JsonValue jsonValue;
515     /**
516      * @tc.steps: step2. get  results
517      * @tc.expected: step2.  the results are correct.
518      */
519     bool ret = jsonValue.Put(key, value);
520     EXPECT_FALSE(ret);
521 }
522 
523 /**
524  * @tc.name: JsonUtilTest020
525  * @tc.desc: Check json util function Replace(const char* key, double value) for nullptr key
526  * @tc.type: FUNC
527  */
528 HWTEST_F(JsonUtilTest, JsonUtilTest020, TestSize.Level1)
529 {
530     /**
531      * @tc.steps: step1. construct the nullptr key.
532      */
533     const char* key = nullptr;
534     double value = 8.0;
535     std::unique_ptr<JsonValue> jsonValue = JsonUtil::Create(false);
536 
537     /**
538      * @tc.steps: step2. get  results
539      * @tc.expected: step2.  the results are correct.
540      */
541     bool ret = jsonValue->Replace(key, value);
542     EXPECT_FALSE(ret);
543 
544     /**
545      * @tc.steps: step3. construct key(not exist) and value
546      * @tc.expected: step3. true
547      */
548     key = "aaa";
549     bool ret3 = jsonValue->Replace(key, value);
550     EXPECT_FALSE(ret3);
551 
552     /**
553      * @tc.steps: step4. construct key(exist) and value
554      * @tc.expected: step3. true
555      */
556     double valueTmp = 8.0;
557     key = "aaa";
558     bool putRet = jsonValue->Put(key, valueTmp);
559     EXPECT_TRUE(putRet);
560     bool ret4 = jsonValue->Replace(key, value);
561     EXPECT_TRUE(ret4);
562 }
563 
564 /**
565  * @tc.name: JsonUtilTest021
566  * @tc.desc: Check json util function Replace(const char* key, bool value) for nullptr key
567  * @tc.type: FUNC
568  */
569 HWTEST_F(JsonUtilTest, JsonUtilTest021, TestSize.Level1)
570 {
571     /**
572      * @tc.steps: step1. construct the nullptr key.
573      */
574     const char* key = nullptr;
575     bool value = true;
576     std::unique_ptr<JsonValue> jsonValue = JsonUtil::Create(false);
577     /**
578      * @tc.steps: step2. get  results
579      * @tc.expected: step2.  the results are correct.
580      */
581     bool ret = jsonValue->Replace(key, value);
582     EXPECT_FALSE(ret);
583 
584     /**
585      * @tc.steps: step3. construct key(not exist) and value
586      * @tc.expected: step3. true
587      */
588     key = "aaa";
589     bool ret3 = jsonValue->Replace(key, value);
590     EXPECT_FALSE(ret3);
591 
592     /**
593      * @tc.steps: step4. construct key(exist) and value
594      * @tc.expected: step3. true
595      */
596     jsonValue->Put(key, false);
597     bool ret4 = jsonValue->Replace(key, value);
598     EXPECT_TRUE(ret4);
599 }
600 
601 /**
602  * @tc.name: JsonUtilTest022
603  * @tc.desc: Check json util function Replace(const char* key, const char* value) for nullptr key
604  * @tc.type: FUNC
605  */
606 HWTEST_F(JsonUtilTest, JsonUtilTest022, TestSize.Level1)
607 {
608     /**
609      * @tc.steps: step1. construct the nullptr key.
610      */
611     const char* key = nullptr;
612     const char* value = nullptr;
613     std::unique_ptr<JsonValue> jsonValue = JsonUtil::Create(false);
614     /**
615      * @tc.steps: step2. get  results
616      * @tc.expected: step2.  the results are correct.
617      */
618     bool ret = jsonValue->Replace(key, value);
619     EXPECT_FALSE(ret);
620 
621     /**
622      * @tc.steps: step3. construct the nullptr value.
623      */
624     char c = '5';
625     const char* value2 = &c;
626     const char* key2 = nullptr;
627     /**
628      * @tc.steps: step4. get  results
629      * @tc.expected: step4.  the results are correct.
630      */
631     bool ret2 = jsonValue->Replace(key2, value2);
632     EXPECT_FALSE(ret2);
633 
634     /**
635      * @tc.steps: step5. repalce key(not exist) and value
636      * @tc.expected: step5. repalce fail
637      */
638     const char* key3 = "aaa";
639     bool ret3 = jsonValue->Replace(key3, value2);
640     EXPECT_FALSE(ret3);
641     bool putRet = jsonValue->Put(key3, value2);
642     EXPECT_TRUE(putRet);
643     bool ret4 = jsonValue->Replace(key3, value2);
644     EXPECT_TRUE(ret4);
645 }
646 
647 /**
648  * @tc.name: JsonUtilTest023
649  * @tc.desc: Check json util function Replace(const char* key, int32_t value) for nullptr key
650  * @tc.type: FUNC
651  */
652 HWTEST_F(JsonUtilTest, JsonUtilTest023, TestSize.Level1)
653 {
654     /**
655      * @tc.steps: step1. construct the nullptr key.
656      */
657     const char* key = nullptr;
658     int32_t value = 5;
659     std::unique_ptr<JsonValue> jsonValue = JsonUtil::Create(false);
660     /**
661      * @tc.steps: step2. get  results
662      * @tc.expected: step2.  the results are correct.
663      */
664     bool ret = jsonValue->Replace(key, value);
665     EXPECT_FALSE(ret);
666 
667     /**
668      * @tc.steps: step3. repalce key(not exist) and value
669      * @tc.expected: step3. repalce fail
670      */
671     const char* key3 = "aaa";
672     bool ret3 = jsonValue->Replace(key3, value);
673     EXPECT_FALSE(ret3);
674     bool putRet = jsonValue->Put(key3, value);
675     EXPECT_TRUE(putRet);
676     std::string objStr = jsonValue->ToString();
677     EXPECT_TRUE(objStr.find("\"aaa\":5") != std::string::npos);
678     bool ret4 = jsonValue->Replace(key3, value);
679     EXPECT_TRUE(ret4);
680 }
681 
682 /**
683  * @tc.name: JsonUtilTest024
684  * @tc.desc: Check json util Replace(const char* key, const std::unique_ptr<JsonValue>& value) for nullptr key
685  * @tc.type: FUNC
686  */
687 HWTEST_F(JsonUtilTest, JsonUtilTest024, TestSize.Level1)
688 {
689     /**
690      * @tc.steps: step1. construct the nullptr key.
691      */
692     const char* key = nullptr;
693     const std::unique_ptr<JsonValue>& value = nullptr;
694     std::unique_ptr<JsonValue> jsonValue = JsonUtil::Create(false);
695     /**
696      * @tc.steps: step2. get  results
697      * @tc.expected: step2.  the results are correct.
698      */
699     bool ret = jsonValue->Replace(key, value);
700     EXPECT_FALSE(ret);
701     std::unique_ptr<JsonValue> valueTmp = JsonUtil::Create(false);
702     bool ret2 = jsonValue->Replace(key, valueTmp);
703     EXPECT_FALSE(ret2);
704 
705     /**
706      * @tc.steps: step3. construct key(not exist) and value
707      * @tc.expected: step3. true
708      */
709     key = "aaa";
710     bool ret3 = jsonValue->Replace(key, valueTmp);
711     EXPECT_FALSE(ret3);
712 
713     /**
714      * @tc.steps: step4. construct key(exist) and value
715      * @tc.expected: step3. true
716      */
717     jsonValue->Put(key, valueTmp);
718     bool ret4 = jsonValue->Replace(key, valueTmp);
719     EXPECT_TRUE(ret4);
720 }
721 
722 /**
723  * @tc.name: JsonUtilTest025
724  * @tc.desc: Check json util bool Delete(const char* key) for nullptr key
725  * @tc.type: FUNC
726  */
727 HWTEST_F(JsonUtilTest, JsonUtilTest025, TestSize.Level1)
728 {
729     /**
730      * @tc.steps: step1. construct the nullptr key.
731      */
732     const char* key = nullptr;
733     JsonValue jsonValue;
734     /**
735      * @tc.steps: step2. get  results
736      * @tc.expected: step2.  the results are correct.
737      */
738     bool ret = jsonValue.Delete(key);
739     EXPECT_FALSE(ret);
740 }
741 
742 /**
743  * @tc.name: JsonUtilTest026
744  * @tc.desc: Check json util int64_t GetInt64()
745  * @tc.type: FUNC
746  */
747 HWTEST_F(JsonUtilTest, JsonUtilTest026, TestSize.Level1)
748 {
749     /**
750      * @tc.steps: step1. construct the nullptr object_.
751      */
752     std::unique_ptr<JsonValue> jsonValue = JsonUtil::Create(false);
753     /**
754      * @tc.steps: step2. get  results
755      * @tc.expected: step2.  the results are correct.
756      */
757     int64_t ret = jsonValue->GetInt64();
758     ASSERT_EQ(ret, 0);
759 
760     /**
761      * @tc.steps: step3. get key(not exist)
762      * @tc.expected: step3. reture defalut value 0
763      */
764     const std::string key = "key-aaa";
765     int64_t ret3 = jsonValue->GetInt64(key, 0);
766     ASSERT_EQ(ret3, 0);
767 
768     /**
769      * @tc.steps: step4. get key(exist) but value not a number
770      * @tc.expected: step4. reture defalut value 0
771      */
772     const char* keyPut = "key-aaa";
773     const char* value = "value-bbb";
774     jsonValue->Put(keyPut, value);
775     int64_t ret4 = jsonValue->GetInt64(key, 0);
776     ASSERT_EQ(ret4, 0);
777 
778     /**
779      * @tc.steps: step5. get key(exist) and value is a number
780      * @tc.expected: step5. reture value
781      */
782     keyPut = "key-number";
783     jsonValue->Put(keyPut, 100);
784     int64_t ret5 = jsonValue->GetInt64(keyPut, 0);
785     ASSERT_EQ(ret5, 100);
786 }
787 
788 /**
789  * @tc.name: JsonUtilTest027
790  * @tc.desc: Check json util std::unique_ptr<JsonValue> GetNext() for nullptr object_
791  * @tc.type: FUNC
792  */
793 HWTEST_F(JsonUtilTest, JsonUtilTest027, TestSize.Level1)
794 {
795     /**
796      * @tc.steps: step1. construct the nullptr object_.
797      */
798     JsonValue jsonValue(nullptr);
799     /**
800      * @tc.steps: step2. get  results
801      * @tc.expected: step2.  the results are correct.
802      */
803     std::unique_ptr<JsonValue> ret = jsonValue.GetNext();
804     EXPECT_TRUE(ret->IsNull());
805 }
806 
807 /**
808  * @tc.name: JsonUtilTest028
809  * @tc.desc: Check json util std::unique_ptr<JsonValue> GetChild() for nullptr object_
810  * @tc.type: FUNC
811  */
812 HWTEST_F(JsonUtilTest, JsonUtilTest028, TestSize.Level1)
813 {
814     /**
815      * @tc.steps: step1. construct the nullptr object_.
816      */
817     JsonValue jsonValue(nullptr);
818     /**
819      * @tc.steps: step2. get  results
820      * @tc.expected: step2.  the results are correct.
821      */
822     std::unique_ptr<JsonValue> ret = jsonValue.GetChild();
823     EXPECT_TRUE(ret->IsNull());
824 }
825 
826 /**
827  * @tc.name: JsonUtilTest029
828  * @tc.desc: Check json util bool Replace(const char* key, double value) for nullptr key
829  * @tc.type: FUNC
830  */
831 HWTEST_F(JsonUtilTest, JsonUtilTest029, TestSize.Level1)
832 {
833     /**
834      * @tc.steps: step1. construct the nullptr key.
835      */
836     const char* key = nullptr;
837     double value = 5;
838     JsonValue jsonValue;
839     /**
840      * @tc.steps: step2. get  results
841      * @tc.expected: step2.  the results are correct.
842      */
843     bool ret = jsonValue.Replace(key, value);
844     EXPECT_FALSE(ret);
845 }
846 
847 /**
848  * @tc.name: JsonUtilTest030
849  * @tc.desc: Check json util bool Replace(const char* key, bool value) for nullptr key
850  * @tc.type: FUNC
851  */
852 HWTEST_F(JsonUtilTest, JsonUtilTest030, TestSize.Level1)
853 {
854     /**
855      * @tc.steps: step1. construct the nullptr key.
856      */
857     const char* key = nullptr;
858     bool value = true;
859     JsonValue jsonValue;
860     /**
861      * @tc.steps: step2. get  results
862      * @tc.expected: step2.  the results are correct.
863      */
864     bool ret = jsonValue.Replace(key, value);
865     EXPECT_FALSE(ret);
866 }
867 
868 /**
869  * @tc.name: JsonUtilTest031
870  * @tc.desc: Check json util bool Replace(const char* key, const char* value) for nullptr key or nullptr value
871  * @tc.type: FUNC
872  */
873 HWTEST_F(JsonUtilTest, JsonUtilTest031, TestSize.Level1)
874 {
875     /**
876      * @tc.steps: step1. construct the nullptr value.
877      */
878     const char* key = nullptr;
879     const char* value = nullptr;
880     JsonValue jsonValue;
881     /**
882      * @tc.steps: step2. get  results
883      * @tc.expected: step2.  the results are correct.
884      */
885     bool ret = jsonValue.Replace(key, value);
886     EXPECT_FALSE(ret);
887 
888     /**
889      * @tc.steps: step3. construct the nullptr key.
890      */
891     const char* key2 = nullptr;
892     char c = '5';
893     const char* value2 = &c;
894     /**
895      * @tc.steps: step4. get  results
896      * @tc.expected: step4.  the results are correct.
897      */
898     bool ret2 = jsonValue.Replace(key2, value2);
899     EXPECT_FALSE(ret2);
900 }
901 
902 /**
903  * @tc.name: JsonUtilTest032
904  * @tc.desc: Check json util bool Replace(const char* key, int32_t value) for nullptr key
905  * @tc.type: FUNC
906  */
907 HWTEST_F(JsonUtilTest, JsonUtilTest032, TestSize.Level1)
908 {
909     /**
910      * @tc.steps: step1. construct the nullptr key.
911      */
912     const char* key = nullptr;
913     int32_t value = 5;
914     JsonValue jsonValue;
915     /**
916      * @tc.steps: step2. get  results
917      * @tc.expected: step2.  the results are correct.
918      */
919     bool ret = jsonValue.Replace(key, value);
920     EXPECT_FALSE(ret);
921 }
922 
923 /**
924  * @tc.name: JsonUtilTest033
925  * @tc.desc: Check json util func bool PutFixedAttr  with const char* value
926  * @tc.type: FUNC
927  */
928 HWTEST_F(JsonUtilTest, JsonUtilTest033, TestSize.Level1)
929 {
930     /**
931      * @tc.steps: step1. construct the filter object, add filter attr, construct the jsonValue object.
932      */
933     NG::InspectorFilter filter;
934     JsonValue jsonValue;
935     const std::string attr = "color";
936     filter.AddFilterAttr(attr);
937     /**
938      * @tc.steps: step2. get  results
939      * @tc.expected: step2.  the results are correct.
940      */
941     bool ret = jsonValue.PutFixedAttr("editable", "EditMode.None", filter, NG::FIXED_ATTR_EDITABLE);
942     EXPECT_FALSE(ret);
943 }
944 
945 /**
946  * @tc.name: JsonUtilTest034
947  * @tc.desc: Check json util bool PutExtAttr
948  * @tc.type: FUNC
949  */
950 HWTEST_F(JsonUtilTest, JsonUtilTest034, TestSize.Level1)
951 {
952     /**
953      * @tc.steps: step1. construct the filter object, add filter attr, construct the jsonValue object.
954      */
955     NG::InspectorFilter filter;
956     JsonValue jsonValue;
957     const std::string attr = "color";
958     filter.AddFilterAttr(attr);
959     /**
960      * @tc.steps: step2. get  results
961      * @tc.expected: step2.  the results are correct.
962      */
963     bool ret = jsonValue.PutExtAttr("editable", "EditMode.None", filter);
964     EXPECT_FALSE(ret);
965 }
966 
967 /**
968  * @tc.name: JsonUtilTest035
969  * @tc.desc: Check json util func bool PutFixedAttr with const std::unique_ptr<JsonValue>& value
970  * @tc.type: FUNC
971  */
972 HWTEST_F(JsonUtilTest, JsonUtilTest035, TestSize.Level1)
973 {
974     /**
975      * @tc.steps: step1. construct the filter object, add filter attr, construct the empty jsonValue object
976      */
977     NG::InspectorFilter filter;
978     JsonValue jsonValue;
979     JsonValue jsonValueTemp;
980     const std::unique_ptr<JsonValue> value = std::make_unique<JsonValue>(jsonValueTemp);
981     /**
982      * @tc.steps: step2. get  results
983      * @tc.expected: step2.  the results are correct.
984      */
985     bool ret = jsonValue.PutFixedAttr("editable", value, filter, NG::FIXED_ATTR_EDITABLE);
986     EXPECT_FALSE(ret);
987 
988     /**
989      * @tc.steps: step3. set the value to jsonValueTemp, construct the jsonValue object.
990      * @tc.expected: step3.  the results are correct.
991      */
992     std::string testJson = "true";
993     std::unique_ptr<JsonValue> boolValue = JsonUtil::ParseJsonString(testJson);
994     bool ret2 = jsonValue.PutFixedAttr("editable", boolValue, filter, NG::FIXED_ATTR_EDITABLE);
995     EXPECT_TRUE(ret2);
996 
997     /**
998      * @tc.steps: step4. construct the filter object, add filter attr, construct the jsonValue object.
999      */
1000     const std::string attr = "color";
1001     filter.AddFilterAttr(attr);
1002     /**
1003      * @tc.steps: step5. get  results
1004      * @tc.expected: step5.  the results are correct.
1005      */
1006     bool ret3 = jsonValue.PutFixedAttr("editable", value, filter, NG::FIXED_ATTR_EDITABLE);
1007     EXPECT_FALSE(ret3);
1008 }
1009 
1010 /**
1011  * @tc.name: JsonUtilTest036
1012  * @tc.desc: Check json util func bool PutExtAttr with size_t value/int32_t value/double value/bool value/int64_t
1013  * @tc.type: FUNC
1014  */
1015 HWTEST_F(JsonUtilTest, JsonUtilTest036, TestSize.Level1)
1016 {
1017     /**
1018      * @tc.steps: step1. construct the filter object, add filter attr, construct the jsonValue object.
1019      */
1020     NG::InspectorFilter filter;
1021     JsonValue jsonValue;
1022     size_t value = 5;
1023     int32_t value2 = 5;
1024     double value3 = 5.0;
1025     int64_t value4 = 5;
1026     bool value5 = true;
1027     bool ret = jsonValue.PutExtAttr("editable", value, filter);
1028     bool ret2 = jsonValue.PutExtAttr("editable", value2, filter);
1029     bool ret3 = jsonValue.PutExtAttr("editable", value3, filter);
1030     bool ret4 = jsonValue.PutExtAttr("editable", value4, filter);
1031     bool ret5 = jsonValue.PutExtAttr("editable", value5, filter);
1032     EXPECT_TRUE(ret);
1033     EXPECT_TRUE(ret2);
1034     EXPECT_TRUE(ret3);
1035     EXPECT_TRUE(ret4);
1036     EXPECT_TRUE(ret5);
1037     /**
1038      * @tc.steps: step2. make filterExt not empty
1039      */
1040     const std::string attr = "color";
1041     filter.AddFilterAttr(attr);
1042     /**
1043      * @tc.steps: step2. get  results
1044      * @tc.expected: step2.  the results are correct.
1045      */
1046     bool ret6 = jsonValue.PutExtAttr("editable", value, filter);
1047     bool ret7 = jsonValue.PutExtAttr("editable", value2, filter);
1048     bool ret8 = jsonValue.PutExtAttr("editable", value3, filter);
1049     bool ret9 = jsonValue.PutExtAttr("editable", value4, filter);
1050     bool ret10 = jsonValue.PutExtAttr("editable", value5, filter);
1051     EXPECT_FALSE(ret6);
1052     EXPECT_FALSE(ret7);
1053     EXPECT_FALSE(ret8);
1054     EXPECT_FALSE(ret9);
1055     EXPECT_FALSE(ret10);
1056 }
1057 
1058 /**
1059  * @tc.name: JsonUtilTest037
1060  * @tc.desc: Check json util func bool PutFixedAttr with size_t value/int32_t value/double value/bool value/int64_t
1061  * value
1062  * @tc.type: FUNC
1063  */
1064 HWTEST_F(JsonUtilTest, JsonUtilTest037, TestSize.Level1)
1065 {
1066     /**
1067      * @tc.steps: step1. construct the filter object, add filter attr, construct the empty jsonValue object
1068      */
1069     NG::InspectorFilter filter;
1070     JsonValue jsonValue;
1071     size_t value = 5;
1072     int32_t value2 = 5;
1073     double value3 = 5.0;
1074     int64_t value4 = 5;
1075     bool value5 = true;
1076     /**
1077      * @tc.steps: step2. get  results
1078      * @tc.expected: step2.  the results are correct.
1079      */
1080     bool ret = jsonValue.PutFixedAttr("editable", value, filter, NG::FIXED_ATTR_EDITABLE);
1081     bool ret2 = jsonValue.PutFixedAttr("editable", value2, filter, NG::FIXED_ATTR_EDITABLE);
1082     bool ret3 = jsonValue.PutFixedAttr("editable", value3, filter, NG::FIXED_ATTR_EDITABLE);
1083     bool ret4 = jsonValue.PutFixedAttr("editable", value4, filter, NG::FIXED_ATTR_EDITABLE);
1084     bool ret5 = jsonValue.PutFixedAttr("editable", value5, filter, NG::FIXED_ATTR_EDITABLE);
1085     EXPECT_TRUE(ret);
1086     EXPECT_TRUE(ret2);
1087     EXPECT_TRUE(ret3);
1088     EXPECT_TRUE(ret4);
1089     EXPECT_TRUE(ret5);
1090 
1091     /**
1092      * @tc.steps: step3. construct the filter object, add filter attr
1093      */
1094     const std::string attr = "color";
1095     filter.AddFilterAttr(attr);
1096     /**
1097      * @tc.steps: step4. get  results
1098      * @tc.expected: step4.  the results are correct.
1099      */
1100     bool ret6 = jsonValue.PutFixedAttr("editable", value, filter, NG::FIXED_ATTR_EDITABLE);
1101     bool ret7 = jsonValue.PutFixedAttr("editable", value2, filter, NG::FIXED_ATTR_EDITABLE);
1102     bool ret8 = jsonValue.PutFixedAttr("editable", value3, filter, NG::FIXED_ATTR_EDITABLE);
1103     bool ret9 = jsonValue.PutFixedAttr("editable", value4, filter, NG::FIXED_ATTR_EDITABLE);
1104     bool ret10 = jsonValue.PutFixedAttr("editable", value5, filter, NG::FIXED_ATTR_EDITABLE);
1105     EXPECT_FALSE(ret6);
1106     EXPECT_FALSE(ret7);
1107     EXPECT_FALSE(ret8);
1108     EXPECT_FALSE(ret9);
1109     EXPECT_FALSE(ret10);
1110 }
1111 
1112 /**
1113  * @tc.name: JsonUtilTest038
1114  * @tc.desc: Check json util func bool PutExtAttr with const std::unique_ptr<JsonValue>& value
1115  * @tc.type: FUNC
1116  */
1117 HWTEST_F(JsonUtilTest, JsonUtilTest038, TestSize.Level1)
1118 {
1119     /**
1120      * @tc.steps: step1. construct the filter object, add filter attr, construct the empty jsonValue object
1121      */
1122     NG::InspectorFilter filter;
1123     JsonValue jsonValue;
1124     JsonValue jsonValueTemp;
1125     const std::unique_ptr<JsonValue> value = std::make_unique<JsonValue>(jsonValueTemp);
1126     /**
1127      * @tc.steps: step2. get  results
1128      * @tc.expected: step2.  the results are correct.
1129      */
1130     bool ret = jsonValue.PutExtAttr("editable", value, filter);
1131     EXPECT_FALSE(ret);
1132 
1133     /**
1134      * @tc.steps: step3. set the value to jsonValueTemp, construct the jsonValue object.
1135      * @tc.expected: step3.  the results are correct.
1136      */
1137     std::string testJson = "true";
1138     std::unique_ptr<JsonValue> boolValue = JsonUtil::ParseJsonString(testJson);
1139     bool ret2 = jsonValue.PutExtAttr("editable", boolValue, filter);
1140     EXPECT_TRUE(ret2);
1141 
1142     /**
1143      * @tc.steps: step4. construct the filter object, add filter attr, construct the jsonValue object.
1144      */
1145     const std::string attr = "color";
1146     filter.AddFilterAttr(attr);
1147     /**
1148      * @tc.steps: step5. get  results
1149      * @tc.expected: step5.  the results are correct.
1150      */
1151     bool ret3 = jsonValue.PutExtAttr("editable", value, filter);
1152     EXPECT_FALSE(ret3);
1153 }
1154 
1155 /**
1156  * @tc.name: JsonUtilTest039
1157  * @tc.desc: Check json util bool bool PutRef(const char* key, std::unique_ptr<JsonValue>&& value)
1158  * @tc.type: FUNC
1159  */
1160 HWTEST_F(JsonUtilTest, JsonUtilTest039, TestSize.Level1)
1161 {
1162     /**
1163      * @tc.steps: step1. construct the nullptr key
1164      */
1165     JsonValue jsonValue;
1166     const char* key = nullptr;
1167     std::unique_ptr<JsonValue> value = std::make_unique<JsonValue>();
1168     /**
1169      * @tc.steps: step2. get  results
1170      * @tc.expected: step2.  the results are correct.
1171      */
1172     bool ret = jsonValue.PutRef(key, std::move(value));
1173     EXPECT_FALSE(ret);
1174 
1175     /**
1176      * @tc.steps: step3. construct the nullptr value
1177      */
1178     char a = 'a';
1179     const char* key2 = &a;
1180     std::unique_ptr<JsonValue> value2;
1181     /**
1182      * @tc.steps: step4. get  results
1183      * @tc.expected: step4.  the results are correct.
1184      */
1185     bool ret2 = jsonValue.PutRef(key2, std::move(value2));
1186     bool ret3 = jsonValue.PutRef(std::move(value2));
1187     EXPECT_FALSE(ret2);
1188     EXPECT_FALSE(ret3);
1189 }
1190 
1191 /**
1192  * @tc.name: JsonUtilTest040
1193  * @tc.desc: Check json util int64_t GetUInt/GetInt/GetString
1194  * @tc.type: FUNC
1195  */
1196 HWTEST_F(JsonUtilTest, JsonUtilTest040, TestSize.Level1)
1197 {
1198     /**
1199      * @tc.steps: step1. construct jsonValue
1200      */
1201     std::unique_ptr<JsonValue> jsonValue = JsonUtil::Create(false);
1202 
1203     /**
1204      * @tc.steps: step2. get key(not exist)
1205      * @tc.expected: step2. reture defalut value 0
1206      */
1207     const std::string key = "key-aaa";
1208     int64_t ret3 = jsonValue->GetUInt(key, 0);
1209     ASSERT_EQ(ret3, 0);
1210 
1211     /**
1212      * @tc.steps: step3. get key(exist) but value not a number
1213      * @tc.expected: step3. reture defalut value 0
1214      */
1215     const char* keyPut = "key-aaa";
1216     const char* value = "value-bbb";
1217     jsonValue->Put(keyPut, value);
1218     int64_t ret4 = jsonValue->GetUInt(key, 0);
1219     int64_t ret42 = jsonValue->GetInt(key, 0);
1220     ASSERT_EQ(ret4, 0);
1221     ASSERT_EQ(ret42, 0);
1222 
1223     /**
1224      * @tc.steps: step5. get key(exist) and value is a number
1225      * @tc.expected: step5. reture value
1226      */
1227     keyPut = "key-number";
1228     jsonValue->Put(keyPut, 100);
1229     int64_t ret5 = jsonValue->GetUInt(keyPut, 0);
1230     ASSERT_EQ(ret5, 100);
1231     std::string ret52 = jsonValue->GetString(keyPut, "default");
1232     ASSERT_EQ(ret52, "default");
1233 }
1234 
1235 /**
1236  * @tc.name: JsonUtilTest041
1237  * @tc.desc: Check json util Put(const std::unique_ptr<JsonValue>& value)/ReleaseJsonObject
1238  * @tc.type: FUNC
1239  */
1240 HWTEST_F(JsonUtilTest, JsonUtilTest041, TestSize.Level1)
1241 {
1242     std::unique_ptr<JsonValue> value = nullptr;
1243     JsonValue jsonValue;
1244     ASSERT_FALSE(jsonValue.Put(value));
1245 
1246     // ReleaseJsonObject() isRoot_ false
1247     JsonObject* ret = jsonValue.ReleaseJsonObject();
1248     ASSERT_TRUE(ret == nullptr);
1249     // PutRef() isRoot_ true
1250     char keyChar = 'k';
1251     char* keyPtr = &keyChar;
1252     std::unique_ptr<JsonValue> value2 = JsonUtil::Create(true);
1253     bool ret2 = jsonValue.PutRef(keyPtr, std::move(value2));
1254     ASSERT_TRUE(ret2);
1255     bool ret3 = jsonValue.PutRef(std::move(value2));
1256     ASSERT_TRUE(ret3);
1257 }
1258 } // namespace OHOS::Ace
1259