• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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 "base/pt_types.h"
17 #include "base/pt_params.h"
18 #include "dispatcher.h"
19 
20 #include "ecmascript/js_array.h"
21 #include "ecmascript/js_object-inl.h"
22 #include "ecmascript/js_tagged_value-inl.h"
23 #include "ecmascript/object_factory.h"
24 #include "ecmascript/tests/test_helper.h"
25 
26 using namespace panda::ecmascript;
27 using namespace panda::ecmascript::tooling;
28 
29 namespace panda::test {
30 // Duplicate name of panda::ecmascript::PropertyDescriptor in js_object-inl.h
31 using panda::ecmascript::tooling::PropertyDescriptor;
32 
33 using ObjectType = RemoteObject::TypeName;
34 using ObjectSubType = RemoteObject::SubTypeName;
35 using ObjectClassName = RemoteObject::ClassName;
36 
37 class DebuggerParamsTest : public testing::Test {
38 public:
SetUpTestCase()39     static void SetUpTestCase()
40     {
41         GTEST_LOG_(INFO) << "SetUpTestCase";
42         Logger::InitializeStdLogging(Logger::Level::FATAL, LoggerComponentMaskAll);
43     }
44 
TearDownTestCase()45     static void TearDownTestCase()
46     {
47         Logger::InitializeStdLogging(Logger::Level::ERROR, LoggerComponentMaskAll);
48         GTEST_LOG_(INFO) << "TearDownCase";
49     }
50 
SetUp()51     void SetUp() override
52     {
53         TestHelper::CreateEcmaVMWithScope(ecmaVm, thread, scope);
54         // Main logic is JSON parser, so not need trigger GC to decrease execute time
55         ecmaVm->SetEnableForceGC(false);
56     }
57 
TearDown()58     void TearDown() override
59     {
60         TestHelper::DestroyEcmaVMWithScope(ecmaVm, scope);
61     }
62 
63 protected:
64     EcmaVM *ecmaVm {nullptr};
65     EcmaHandleScope *scope {nullptr};
66     JSThread *thread {nullptr};
67 };
68 
HWTEST_F_L0(DebuggerParamsTest,EnableParamsCreateTest)69 HWTEST_F_L0(DebuggerParamsTest, EnableParamsCreateTest)
70 {
71     std::string msg;
72     std::unique_ptr<EnableParams> enableParams;
73 
74     // abnormal
75     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{}})";
76     enableParams = EnableParams::Create(DispatchRequest(msg).GetParams());
77     ASSERT_NE(enableParams, nullptr);
78     EXPECT_FALSE(enableParams->HasMaxScriptsCacheSize());
79 
80     // normal
81     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"maxScriptsCacheSize":100}})";
82     enableParams = EnableParams::Create(DispatchRequest(msg).GetParams());
83     ASSERT_NE(enableParams, nullptr);
84     EXPECT_EQ(enableParams->GetMaxScriptsCacheSize(), 100);
85 }
86 
HWTEST_F_L0(DebuggerParamsTest,StartSamplingParamsCreateTest)87 HWTEST_F_L0(DebuggerParamsTest, StartSamplingParamsCreateTest)
88 {
89     std::string msg;
90     std::unique_ptr<StartSamplingParams> startSamplingData;
91 
92     // abnormal params of null params.sub-key
93     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{}})";
94     startSamplingData = StartSamplingParams::Create(DispatchRequest(msg).GetParams());
95     ASSERT_NE(startSamplingData, nullptr);
96     EXPECT_EQ(startSamplingData->GetSamplingInterval(), 32768);
97 
98     // abnormal params of unknown params.sub-key
99     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"unknownKey":100}})";
100     startSamplingData = StartSamplingParams::Create(DispatchRequest(msg).GetParams());
101     ASSERT_NE(startSamplingData, nullptr);
102     EXPECT_EQ(startSamplingData->GetSamplingInterval(), 32768);
103 
104     // abnormal params of params.sub-key=["samplingInterval":true]
105     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"samplingInterval":true}})";
106     startSamplingData = StartSamplingParams::Create(DispatchRequest(msg).GetParams());
107     EXPECT_EQ(startSamplingData, nullptr);
108 
109     // abnormal params of params.sub-key=["samplingInterval":true]
110     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"samplingInterval":"Test"}})";
111     startSamplingData = StartSamplingParams::Create(DispatchRequest(msg).GetParams());
112     EXPECT_EQ(startSamplingData, nullptr);
113 
114     // abnormal params of params.sub-key = [ "size"=100,"nodeId"=1,"ordinal"=10]
115     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"samplingInterval":1000}})";
116     startSamplingData = StartSamplingParams::Create(DispatchRequest(msg).GetParams());
117     ASSERT_NE(startSamplingData, nullptr);
118     EXPECT_EQ(startSamplingData->GetSamplingInterval(), 1000);
119 }
120 
HWTEST_F_L0(DebuggerParamsTest,StartTrackingHeapObjectsParamsCreateTest)121 HWTEST_F_L0(DebuggerParamsTest, StartTrackingHeapObjectsParamsCreateTest)
122 {
123     std::string msg;
124     std::unique_ptr<StartTrackingHeapObjectsParams> objectData;
125 
126     // abnormal params of null params.sub-key
127     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{}})";
128     objectData = StartTrackingHeapObjectsParams::Create(DispatchRequest(msg).GetParams());
129     ASSERT_NE(objectData, nullptr);
130     ASSERT_FALSE(objectData->GetTrackAllocations());
131 
132     // abnormal params of unknown params.sub-key
133     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"unknownKey":100}})";
134     objectData = StartTrackingHeapObjectsParams::Create(DispatchRequest(msg).GetParams());
135     ASSERT_NE(objectData, nullptr);
136     ASSERT_FALSE(objectData->GetTrackAllocations());
137 
138     // abnormal params of params.sub-key=["trackAllocations":10]
139     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"trackAllocations":10}})";
140     objectData = StartTrackingHeapObjectsParams::Create(DispatchRequest(msg).GetParams());
141     EXPECT_EQ(objectData, nullptr);
142 
143     // abnormal params of params.sub-key=["trackAllocations":"Test"]
144     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"trackAllocations":"Test"}})";
145     objectData = StartTrackingHeapObjectsParams::Create(DispatchRequest(msg).GetParams());
146     EXPECT_EQ(objectData, nullptr);
147 
148     // abnormal params of params.sub-key=["trackAllocations":true]
149     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"trackAllocations":true}})";
150     objectData = StartTrackingHeapObjectsParams::Create(DispatchRequest(msg).GetParams());
151     ASSERT_NE(objectData, nullptr);
152     ASSERT_TRUE(objectData->GetTrackAllocations());
153 }
154 
HWTEST_F_L0(DebuggerParamsTest,StopTrackingHeapObjectsParamsCreateTest)155 HWTEST_F_L0(DebuggerParamsTest, StopTrackingHeapObjectsParamsCreateTest)
156 {
157     std::string msg;
158     std::unique_ptr<StopTrackingHeapObjectsParams> objectData;
159 
160     // abnormal params of null params.sub-key
161     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{}})";
162     objectData = StopTrackingHeapObjectsParams::Create(DispatchRequest(msg).GetParams());
163     ASSERT_NE(objectData, nullptr);
164     ASSERT_FALSE(objectData->GetReportProgress());
165     ASSERT_FALSE(objectData->GetTreatGlobalObjectsAsRoots());
166     ASSERT_FALSE(objectData->GetCaptureNumericValue());
167 
168     // abnormal params of unknown params.sub-key
169     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"unknownKey":100}})";
170     objectData = StopTrackingHeapObjectsParams::Create(DispatchRequest(msg).GetParams());
171     ASSERT_NE(objectData, nullptr);
172     ASSERT_FALSE(objectData->GetReportProgress());
173     ASSERT_FALSE(objectData->GetTreatGlobalObjectsAsRoots());
174     ASSERT_FALSE(objectData->GetCaptureNumericValue());
175 
176     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{
177             "reportProgress":10,
178             "treatGlobalObjectsAsRoots":10,
179             "captureNumericValue":10}})";
180     objectData = StopTrackingHeapObjectsParams::Create(DispatchRequest(msg).GetParams());
181     EXPECT_EQ(objectData, nullptr);
182 
183     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{
184             "reportProgress":"Test",
185             "treatGlobalObjectsAsRoots":"Test",
186             "captureNumericValue":"Test"}})";
187     objectData = StopTrackingHeapObjectsParams::Create(DispatchRequest(msg).GetParams());
188     EXPECT_EQ(objectData, nullptr);
189 
190     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{
191             "reportProgress":true,
192             "treatGlobalObjectsAsRoots":true,
193             "captureNumericValue":true}})";
194     objectData = StopTrackingHeapObjectsParams::Create(DispatchRequest(msg).GetParams());
195     ASSERT_NE(objectData, nullptr);
196     ASSERT_TRUE(objectData->GetReportProgress());
197     ASSERT_TRUE(objectData->GetTreatGlobalObjectsAsRoots());
198     ASSERT_TRUE(objectData->GetCaptureNumericValue());
199 }
200 
HWTEST_F_L0(DebuggerParamsTest,AddInspectedHeapObjectParamsCreateTest)201 HWTEST_F_L0(DebuggerParamsTest, AddInspectedHeapObjectParamsCreateTest)
202 {
203     std::string msg;
204     std::unique_ptr<AddInspectedHeapObjectParams> objectData;
205 
206     //  abnormal params of null msg
207     msg = std::string() + R"({})";
208     objectData = AddInspectedHeapObjectParams::Create(DispatchRequest(msg).GetParams());
209     EXPECT_EQ(objectData, nullptr);
210 
211     // abnormal params of unexist key params
212     msg = std::string() + R"({"id":0,"method":"Debugger.Test"})";
213     objectData = AddInspectedHeapObjectParams::Create(DispatchRequest(msg).GetParams());
214     EXPECT_EQ(objectData, nullptr);
215 
216     // abnormal params of null params.sub-key
217     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{}})";
218     objectData = AddInspectedHeapObjectParams::Create(DispatchRequest(msg).GetParams());
219     EXPECT_EQ(objectData, nullptr);
220 
221     // abnormal params of unknown params.sub-key
222     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"unknownKey":100}})";
223     objectData = AddInspectedHeapObjectParams::Create(DispatchRequest(msg).GetParams());
224     EXPECT_EQ(objectData, nullptr);
225 
226     // abnormal params of params.sub-key=["heapObjectId":10]
227     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"heapObjectId":10}})";
228     objectData = AddInspectedHeapObjectParams::Create(DispatchRequest(msg).GetParams());
229     EXPECT_EQ(objectData, nullptr);
230 
231     // abnormal params of params.sub-key=["heapObjectId":true]
232     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"heapObjectId":true}})";
233     objectData = AddInspectedHeapObjectParams::Create(DispatchRequest(msg).GetParams());
234     EXPECT_EQ(objectData, nullptr);
235 
236     // abnormal params of params.sub-key=["heapObjectId":“10”]
237     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"heapObjectId":"10"}})";
238     objectData = AddInspectedHeapObjectParams::Create(DispatchRequest(msg).GetParams());
239     ASSERT_NE(objectData, nullptr);
240     EXPECT_EQ(objectData->GetHeapObjectId(), 10);
241 }
242 
HWTEST_F_L0(DebuggerParamsTest,GetHeapObjectIdParamsCreateTest)243 HWTEST_F_L0(DebuggerParamsTest, GetHeapObjectIdParamsCreateTest)
244 {
245     std::string msg;
246     std::unique_ptr<GetHeapObjectIdParams> objectData;
247 
248     // abnormal params of params.sub-key=["objectId":10]
249     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"objectId":10}})";
250     objectData = GetHeapObjectIdParams::Create(DispatchRequest(msg).GetParams());
251     EXPECT_EQ(objectData, nullptr);
252 
253     // abnormal params of params.sub-key=["objectId":true]
254     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"objectId":true}})";
255     objectData = GetHeapObjectIdParams::Create(DispatchRequest(msg).GetParams());
256     EXPECT_EQ(objectData, nullptr);
257 
258     // abnormal params of params.sub-key=["objectId":“10”]
259     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"objectId":"10"}})";
260     objectData = GetHeapObjectIdParams::Create(DispatchRequest(msg).GetParams());
261     ASSERT_NE(objectData, nullptr);
262     EXPECT_EQ((int)objectData->GetObjectId(), 10);
263 }
264 
HWTEST_F_L0(DebuggerParamsTest,GetObjectByHeapObjectIdParamsCreateTest)265 HWTEST_F_L0(DebuggerParamsTest, GetObjectByHeapObjectIdParamsCreateTest)
266 {
267     std::string msg;
268     std::unique_ptr<GetObjectByHeapObjectIdParams> objectData;
269 
270     // abnormal params of params.sub-key=["objectId":10]
271     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"objectId":10}})";
272     objectData = GetObjectByHeapObjectIdParams::Create(DispatchRequest(msg).GetParams());
273     EXPECT_EQ(objectData, nullptr);
274 
275     // abnormal params of params.sub-key=["objectId":true]
276     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"objectId":"10", "objectGroup":10}})";
277     objectData = GetObjectByHeapObjectIdParams::Create(DispatchRequest(msg).GetParams());
278     EXPECT_EQ(objectData, nullptr);
279 
280     // abnormal params of params.sub-key=["objectId":“10”]
281     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"objectId":"10"}})";
282     objectData = GetObjectByHeapObjectIdParams::Create(DispatchRequest(msg).GetParams());
283     ASSERT_NE(objectData, nullptr);
284     EXPECT_EQ((int)objectData->GetObjectId(), 10);
285     ASSERT_FALSE(objectData->HasObjectGroup());
286 
287     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"objectId":"10", "objectGroup":"groupname"}})";
288     objectData = GetObjectByHeapObjectIdParams::Create(DispatchRequest(msg).GetParams());
289     ASSERT_NE(objectData, nullptr);
290     EXPECT_EQ((int)objectData->GetObjectId(), 10);
291     EXPECT_EQ(objectData->GetObjectGroup(), "groupname");
292 }
293 
HWTEST_F_L0(DebuggerParamsTest,StartPreciseCoverageParamCreateTest)294 HWTEST_F_L0(DebuggerParamsTest, StartPreciseCoverageParamCreateTest)
295 {
296     std::string msg;
297     std::unique_ptr<StartPreciseCoverageParams> objectData;
298 
299     // abnormal params of null params.sub-key
300     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{}})";
301     objectData = StartPreciseCoverageParams::Create(DispatchRequest(msg).GetParams());
302     ASSERT_NE(objectData, nullptr);
303 
304     // abnormal params of unknown params.sub-key
305     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"unknownKey":100}})";
306     objectData = StartPreciseCoverageParams::Create(DispatchRequest(msg).GetParams());
307     ASSERT_NE(objectData, nullptr);
308 
309     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{
310             "callCount":8,
311             "detailed":8,
312             "allowTriggeredUpdates":8}})";
313     objectData = StartPreciseCoverageParams::Create(DispatchRequest(msg).GetParams());
314     EXPECT_EQ(objectData, nullptr);
315 
316     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{
317             "callCount":"Test",
318             "detailed":"Test",
319             "allowTriggeredUpdates":"Test"}})";
320     objectData = StartPreciseCoverageParams::Create(DispatchRequest(msg).GetParams());
321     EXPECT_EQ(objectData, nullptr);
322 
323     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{
324             "callCount":true,
325             "detailed":true,
326             "allowTriggeredUpdates":true}})";
327     objectData = StartPreciseCoverageParams::Create(DispatchRequest(msg).GetParams());
328     ASSERT_NE(objectData, nullptr);
329     ASSERT_TRUE(objectData->GetCallCount());
330     ASSERT_TRUE(objectData->GetDetailed());
331     ASSERT_TRUE(objectData->GetAllowTriggeredUpdates());
332 }
333 
HWTEST_F_L0(DebuggerParamsTest,SetSamplingIntervalParamsCreateTest)334 HWTEST_F_L0(DebuggerParamsTest, SetSamplingIntervalParamsCreateTest)
335 {
336     std::string msg;
337     std::unique_ptr<SetSamplingIntervalParams> objectData;
338 
339     //  abnormal params of null msg
340     msg = std::string() + R"({})";
341     objectData = SetSamplingIntervalParams::Create(DispatchRequest(msg).GetParams());
342     EXPECT_EQ(objectData, nullptr);
343 
344     // abnormal params of unexist key params
345     msg = std::string() + R"({"id":0,"method":"Debugger.Test"})";
346     objectData = SetSamplingIntervalParams::Create(DispatchRequest(msg).GetParams());
347     EXPECT_EQ(objectData, nullptr);
348 
349     // abnormal params of null params.sub-key
350     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{}})";
351     objectData = SetSamplingIntervalParams::Create(DispatchRequest(msg).GetParams());
352     EXPECT_EQ(objectData, nullptr);
353 
354     // abnormal params of unknown params.sub-key
355     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"unknownKey":100}})";
356     objectData = SetSamplingIntervalParams::Create(DispatchRequest(msg).GetParams());
357     EXPECT_EQ(objectData, nullptr);
358 
359     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{
360             "interval":"500"}})";
361     objectData = SetSamplingIntervalParams::Create(DispatchRequest(msg).GetParams());
362     EXPECT_EQ(objectData, nullptr);
363 
364     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"interval":500}})";
365     objectData = SetSamplingIntervalParams::Create(DispatchRequest(msg).GetParams());
366     ASSERT_NE(objectData, nullptr);
367     EXPECT_EQ(objectData->GetInterval(), 500);
368 }
369 
HWTEST_F_L0(DebuggerParamsTest,RecordClockSyncMarkerParamsCreateTest)370 HWTEST_F_L0(DebuggerParamsTest, RecordClockSyncMarkerParamsCreateTest)
371 {
372     std::string msg;
373     std::unique_ptr<RecordClockSyncMarkerParams> objectData;
374 
375     //  abnormal params of null msg
376     msg = std::string() + R"({})";
377     objectData = RecordClockSyncMarkerParams::Create(DispatchRequest(msg).GetParams());
378     EXPECT_EQ(objectData, nullptr);
379 
380     // abnormal params of unexist key params
381     msg = std::string() + R"({"id":0,"method":"Debugger.Test"})";
382     objectData = RecordClockSyncMarkerParams::Create(DispatchRequest(msg).GetParams());
383     EXPECT_EQ(objectData, nullptr);
384 
385     // abnormal params of null params.sub-key
386     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{}})";
387     objectData = RecordClockSyncMarkerParams::Create(DispatchRequest(msg).GetParams());
388     EXPECT_EQ(objectData, nullptr);
389 
390     // abnormal params of unknown params.sub-key
391     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"unknownKey":100}})";
392     objectData = RecordClockSyncMarkerParams::Create(DispatchRequest(msg).GetParams());
393     EXPECT_EQ(objectData, nullptr);
394 
395     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"syncId":"101"}})";
396     objectData = RecordClockSyncMarkerParams::Create(DispatchRequest(msg).GetParams());
397     ASSERT_NE(objectData, nullptr);
398     EXPECT_EQ(objectData->GetSyncId(), "101");
399 }
400 
HWTEST_F_L0(DebuggerParamsTest,RequestMemoryDumpParamsCreateTest)401 HWTEST_F_L0(DebuggerParamsTest, RequestMemoryDumpParamsCreateTest)
402 {
403     std::string msg;
404     std::unique_ptr<RequestMemoryDumpParams> objectData;
405 
406     //  abnormal params of null msg
407     msg = std::string() + R"({})";
408     objectData = RequestMemoryDumpParams::Create(DispatchRequest(msg).GetParams());
409     ASSERT_NE(objectData, nullptr);
410 
411     // abnormal params of unexist key params
412     msg = std::string() + R"({"id":0,"method":"Debugger.Test"})";
413     objectData = RequestMemoryDumpParams::Create(DispatchRequest(msg).GetParams());
414     ASSERT_NE(objectData, nullptr);
415 
416     // abnormal params of null params.sub-key
417     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{}})";
418     objectData = RequestMemoryDumpParams::Create(DispatchRequest(msg).GetParams());
419     ASSERT_NE(objectData, nullptr);
420 
421     // abnormal params of unknown params.sub-key
422     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"unknownKey":100}})";
423     objectData = RequestMemoryDumpParams::Create(DispatchRequest(msg).GetParams());
424     ASSERT_NE(objectData, nullptr);
425 
426     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"deterministic":true,
427             "levelOfDetail":"background"}})";
428     objectData = RequestMemoryDumpParams::Create(DispatchRequest(msg).GetParams());
429     ASSERT_NE(objectData, nullptr);
430     ASSERT_TRUE(objectData->GetDeterministic());
431     EXPECT_EQ(objectData->GetLevelOfDetail(), "background");
432 }
433 
HWTEST_F_L0(DebuggerParamsTest,StartParamsCreateTest)434 HWTEST_F_L0(DebuggerParamsTest, StartParamsCreateTest)
435 {
436     std::string msg;
437     std::unique_ptr<StartParams> objectData;
438 
439     //  abnormal params of null msg
440     msg = std::string() + R"({})";
441     objectData = StartParams::Create(DispatchRequest(msg).GetParams());
442     ASSERT_NE(objectData, nullptr);
443 
444     // abnormal params of unexist key params
445     msg = std::string() + R"({"id":0,"method":"Debugger.Test"})";
446     objectData = StartParams::Create(DispatchRequest(msg).GetParams());
447     ASSERT_NE(objectData, nullptr);
448 
449     // abnormal params of null params.sub-key
450     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{}})";
451     objectData = StartParams::Create(DispatchRequest(msg).GetParams());
452     ASSERT_NE(objectData, nullptr);
453 
454     // abnormal params of unknown params.sub-key
455     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"unknownKey":100}})";
456     objectData = StartParams::Create(DispatchRequest(msg).GetParams());
457     ASSERT_NE(objectData, nullptr);
458 
459     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"categories":"filter1",
460             "options":"1", "bufferUsageReportingInterval":11, "transferMode":"ReportEvents", "streamFormat":"json",
461             "streamCompression":"none", "traceConfig": {"recordMode":"recordUntilFull"}, "perfettoConfig":"categories",
462             "tracingBackend":"auto"}})";
463     objectData = StartParams::Create(DispatchRequest(msg).GetParams());
464     ASSERT_NE(objectData, nullptr);
465     EXPECT_EQ(objectData->GetCategories(), "filter1");
466     EXPECT_EQ(objectData->GetOptions(), "1");
467     EXPECT_EQ(objectData->GetBufferUsageReportingInterval(), 11);
468     EXPECT_EQ(objectData->GetTransferMode(), "ReportEvents");
469     EXPECT_EQ(objectData->GetStreamFormat(), "json");
470     EXPECT_EQ(objectData->GetStreamCompression(), "none");
471     TraceConfig *traceConfig = objectData->GetTraceConfig();
472     ASSERT_NE(traceConfig, nullptr);
473     EXPECT_EQ(traceConfig->GetRecordMode(), "recordUntilFull");
474     EXPECT_EQ(objectData->GetPerfettoConfig(), "categories");
475     EXPECT_EQ(objectData->GetTracingBackend(), "auto");
476 }
477 
HWTEST_F_L0(DebuggerParamsTest,EvaluateOnCallFrameParamsCreateTest)478 HWTEST_F_L0(DebuggerParamsTest, EvaluateOnCallFrameParamsCreateTest)
479 {
480     std::string msg;
481     std::unique_ptr<EvaluateOnCallFrameParams> objectData;
482 
483     // abnormal params of null msg
484     msg = std::string() + R"({})";
485     objectData = EvaluateOnCallFrameParams::Create(DispatchRequest(msg).GetParams());
486     EXPECT_EQ(objectData, nullptr);
487 
488     // abnormal params of unexist key params
489     msg = std::string() + R"({"id":0,"method":"Debugger.Test"})";
490     objectData = EvaluateOnCallFrameParams::Create(DispatchRequest(msg).GetParams());
491     EXPECT_EQ(objectData, nullptr);
492 
493     // abnormal params of null params.sub-key
494     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{}})";
495     objectData = EvaluateOnCallFrameParams::Create(DispatchRequest(msg).GetParams());
496     EXPECT_EQ(objectData, nullptr);
497 
498     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"callFrameId":1, "expression":true,
499         "objectGroup":1, "includeCommandLineAPI":"true", "silent":"true", "returnByValue":"true",
500         "generatePreview":"true", "throwOnSideEffect":"true", "timeout":"10"}})";
501     EXPECT_EQ(objectData, nullptr);
502 
503     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"callFrameId":"1", "expression":"test",
504         "objectGroup":"testGroup", "includeCommandLineAPI":true, "silent":true, "returnByValue":true,
505         "generatePreview":true, "throwOnSideEffect":true, "timeout":10}})";
506     objectData = EvaluateOnCallFrameParams::Create(DispatchRequest(msg).GetParams());
507     ASSERT_NE(objectData, nullptr);
508     EXPECT_EQ(objectData->GetCallFrameId(), 1);
509     EXPECT_EQ(objectData->GetExpression(), "test");
510 }
511 
HWTEST_F_L0(DebuggerParamsTest,GetPossibleBreakpointsParamsCreateTest)512 HWTEST_F_L0(DebuggerParamsTest, GetPossibleBreakpointsParamsCreateTest)
513 {
514     std::string msg;
515     std::unique_ptr<GetPossibleBreakpointsParams> objectData;
516 
517     // abnormal params of null msg
518     msg = std::string() + R"({})";
519     objectData = GetPossibleBreakpointsParams::Create(DispatchRequest(msg).GetParams());
520     EXPECT_EQ(objectData, nullptr);
521 
522     // abnormal params of unexist key params
523     msg = std::string() + R"({"id":0,"method":"Debugger.Test"})";
524     objectData = GetPossibleBreakpointsParams::Create(DispatchRequest(msg).GetParams());
525     EXPECT_EQ(objectData, nullptr);
526 
527     // abnormal params of null params.sub-key
528     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{}})";
529     objectData = GetPossibleBreakpointsParams::Create(DispatchRequest(msg).GetParams());
530     EXPECT_EQ(objectData, nullptr);
531 
532     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"start":10, "end":10,
533         "restrictToFunction":"true"}})";
534     EXPECT_EQ(objectData, nullptr);
535 
536     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"start":{"scriptId":"1", "lineNumber":1,
537         "columnNumber":10}, "end":{"scriptId":"1", "lineNumber":10, "columnNumber":10}, "restrictToFunction":true}})";
538     objectData = GetPossibleBreakpointsParams::Create(DispatchRequest(msg).GetParams());
539     ASSERT_NE(objectData, nullptr);
540     Location *start = objectData->GetStart();
541     Location *end = objectData->GetEnd();
542     EXPECT_EQ(start->GetScriptId(), 1);
543     EXPECT_EQ(start->GetLine(), 1);
544     EXPECT_EQ(start->GetColumn(), 10);
545     EXPECT_EQ(end->GetScriptId(), 1);
546     EXPECT_EQ(end->GetLine(), 10);
547     EXPECT_EQ(end->GetColumn(), 10);
548     ASSERT_TRUE(objectData->GetRestrictToFunction());
549 }
550 
HWTEST_F_L0(DebuggerParamsTest,GetScriptSourceParamsCreateTest)551 HWTEST_F_L0(DebuggerParamsTest, GetScriptSourceParamsCreateTest)
552 {
553     std::string msg;
554     std::unique_ptr<GetScriptSourceParams> objectData;
555 
556     // abnormal params of null msg
557     msg = std::string() + R"({})";
558     objectData = GetScriptSourceParams::Create(DispatchRequest(msg).GetParams());
559     EXPECT_EQ(objectData, nullptr);
560 
561     // abnormal params of unexist key params
562     msg = std::string() + R"({"id":0,"method":"Debugger.Test"})";
563     objectData = GetScriptSourceParams::Create(DispatchRequest(msg).GetParams());
564     EXPECT_EQ(objectData, nullptr);
565 
566     // abnormal params of null params.sub-key
567     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{}})";
568     objectData = GetScriptSourceParams::Create(DispatchRequest(msg).GetParams());
569     EXPECT_EQ(objectData, nullptr);
570 
571     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"scriptId":10}})";
572     objectData = GetScriptSourceParams::Create(DispatchRequest(msg).GetParams());
573     EXPECT_EQ(objectData, nullptr);
574 
575     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"scriptId":"10"}})";
576     objectData = GetScriptSourceParams::Create(DispatchRequest(msg).GetParams());
577     ASSERT_NE(objectData, nullptr);
578     EXPECT_EQ(objectData->GetScriptId(), 10);
579 }
580 
HWTEST_F_L0(DebuggerParamsTest,RemoveBreakpointParamsCreateTest)581 HWTEST_F_L0(DebuggerParamsTest, RemoveBreakpointParamsCreateTest)
582 {
583     std::string msg;
584     std::unique_ptr<RemoveBreakpointParams> objectData;
585 
586     // abnormal params of null msg
587     msg = std::string() + R"({})";
588     objectData = RemoveBreakpointParams::Create(DispatchRequest(msg).GetParams());
589     EXPECT_EQ(objectData, nullptr);
590 
591     // abnormal params of unexist key params
592     msg = std::string() + R"({"id":0,"method":"Debugger.Test"})";
593     objectData = RemoveBreakpointParams::Create(DispatchRequest(msg).GetParams());
594     EXPECT_EQ(objectData, nullptr);
595 
596     // abnormal params of null params.sub-key
597     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{}})";
598     objectData = RemoveBreakpointParams::Create(DispatchRequest(msg).GetParams());
599     EXPECT_EQ(objectData, nullptr);
600 
601     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"breakpointId":10}})";
602     objectData = RemoveBreakpointParams::Create(DispatchRequest(msg).GetParams());
603     EXPECT_EQ(objectData, nullptr);
604 
605     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"breakpointId":"10"}})";
606     objectData = RemoveBreakpointParams::Create(DispatchRequest(msg).GetParams());
607     ASSERT_NE(objectData, nullptr);
608     EXPECT_EQ(objectData->GetBreakpointId(), "10");
609 }
610 
HWTEST_F_L0(DebuggerParamsTest,ResumeParamsCreateTest)611 HWTEST_F_L0(DebuggerParamsTest, ResumeParamsCreateTest)
612 {
613     std::string msg;
614     std::unique_ptr<ResumeParams> objectData;
615 
616     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"terminateOnResume":10}})";
617     objectData = ResumeParams::Create(DispatchRequest(msg).GetParams());
618     EXPECT_EQ(objectData, nullptr);
619 
620     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"terminateOnResume":true}})";
621     objectData = ResumeParams::Create(DispatchRequest(msg).GetParams());
622     ASSERT_NE(objectData, nullptr);
623     ASSERT_TRUE(objectData->GetTerminateOnResume());
624 }
625 
HWTEST_F_L0(DebuggerParamsTest,SetAsyncCallStackDepthParamsCreateTest)626 HWTEST_F_L0(DebuggerParamsTest, SetAsyncCallStackDepthParamsCreateTest)
627 {
628     std::string msg;
629     std::unique_ptr<SetAsyncCallStackDepthParams> objectData;
630 
631     // abnormal params of null msg
632     msg = std::string() + R"({})";
633     objectData = SetAsyncCallStackDepthParams::Create(DispatchRequest(msg).GetParams());
634     EXPECT_EQ(objectData, nullptr);
635 
636     // abnormal params of unexist key params
637     msg = std::string() + R"({"id":0,"method":"Debugger.Test"})";
638     objectData = SetAsyncCallStackDepthParams::Create(DispatchRequest(msg).GetParams());
639     EXPECT_EQ(objectData, nullptr);
640 
641     // abnormal params of null params.sub-key
642     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{}})";
643     objectData = SetAsyncCallStackDepthParams::Create(DispatchRequest(msg).GetParams());
644     EXPECT_EQ(objectData, nullptr);
645 
646     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"maxDepth":true}})";
647     objectData = SetAsyncCallStackDepthParams::Create(DispatchRequest(msg).GetParams());
648     EXPECT_EQ(objectData, nullptr);
649 
650     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"maxDepth":5}})";
651     objectData = SetAsyncCallStackDepthParams::Create(DispatchRequest(msg).GetParams());
652     ASSERT_NE(objectData, nullptr);
653     EXPECT_EQ(objectData->GetMaxDepth(), 5);
654 }
655 
HWTEST_F_L0(DebuggerParamsTest,SetBlackboxPatternsParamsCreateTest)656 HWTEST_F_L0(DebuggerParamsTest, SetBlackboxPatternsParamsCreateTest)
657 {
658     std::string msg;
659     std::unique_ptr<SetBlackboxPatternsParams> objectData;
660 
661     // abnormal params of null msg
662     msg = std::string() + R"({})";
663     objectData = SetBlackboxPatternsParams::Create(DispatchRequest(msg).GetParams());
664     EXPECT_EQ(objectData, nullptr);
665 
666     // abnormal params of unexist key params
667     msg = std::string() + R"({"id":0,"method":"Debugger.Test"})";
668     objectData = SetBlackboxPatternsParams::Create(DispatchRequest(msg).GetParams());
669     EXPECT_EQ(objectData, nullptr);
670 
671     // abnormal params of null params.sub-key
672     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{}})";
673     objectData = SetBlackboxPatternsParams::Create(DispatchRequest(msg).GetParams());
674     EXPECT_EQ(objectData, nullptr);
675 
676     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"patterns":"testpattern"}})";
677     objectData = SetBlackboxPatternsParams::Create(DispatchRequest(msg).GetParams());
678     EXPECT_EQ(objectData, nullptr);
679 
680     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"patterns":["testpattern1", "testpattern2"]}})";
681     objectData = SetBlackboxPatternsParams::Create(DispatchRequest(msg).GetParams());
682     ASSERT_NE(objectData, nullptr);
683     std::list<std::string> patterns = objectData->GetPatterns();
684     EXPECT_EQ(patterns.size(), 2U);
685 }
686 
HWTEST_F_L0(DebuggerParamsTest,SetBreakpointByUrlParamsCreateTest)687 HWTEST_F_L0(DebuggerParamsTest, SetBreakpointByUrlParamsCreateTest)
688 {
689     std::string msg;
690     std::unique_ptr<SetBreakpointByUrlParams> objectData;
691 
692     // abnormal params of null msg
693     msg = std::string() + R"({})";
694     objectData = SetBreakpointByUrlParams::Create(DispatchRequest(msg).GetParams());
695     EXPECT_EQ(objectData, nullptr);
696 
697     // abnormal params of unexist key params
698     msg = std::string() + R"({"id":0,"method":"Debugger.Test"})";
699     objectData = SetBreakpointByUrlParams::Create(DispatchRequest(msg).GetParams());
700     EXPECT_EQ(objectData, nullptr);
701 
702     // abnormal params of null params.sub-key
703     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{}})";
704     objectData = SetBreakpointByUrlParams::Create(DispatchRequest(msg).GetParams());
705     EXPECT_EQ(objectData, nullptr);
706 
707     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"lineNumber":"10", "url":10,
708         "urlRegex":true, "scriptHash":true, "columnNumber":"10", "condition":10}})";
709     objectData = SetBreakpointByUrlParams::Create(DispatchRequest(msg).GetParams());
710     EXPECT_EQ(objectData, nullptr);
711 
712     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"lineNumber":10, "url":"testURL",
713         "urlRegex":"testURLRegex", "scriptHash":"testScriptHash", "columnNumber":10, "condition":"testCondition"}})";
714     objectData = SetBreakpointByUrlParams::Create(DispatchRequest(msg).GetParams());
715     ASSERT_NE(objectData, nullptr);
716     EXPECT_EQ(objectData->GetLine(), 10);
717     EXPECT_EQ(objectData->GetUrl(), "testURL");
718     EXPECT_EQ(objectData->GetUrlRegex(), "testURLRegex");
719     EXPECT_EQ(objectData->GetScriptHash(), "testScriptHash");
720     EXPECT_EQ(objectData->GetColumn(), 10);
721     EXPECT_EQ(objectData->GetCondition(), "testCondition");
722 }
723 
HWTEST_F_L0(DebuggerParamsTest,SetPauseOnExceptionsParamsCreateTest)724 HWTEST_F_L0(DebuggerParamsTest, SetPauseOnExceptionsParamsCreateTest)
725 {
726     std::string msg;
727     std::unique_ptr<SetPauseOnExceptionsParams> objectData;
728 
729     // abnormal params of null msg
730     msg = std::string() + R"({})";
731     objectData = SetPauseOnExceptionsParams::Create(DispatchRequest(msg).GetParams());
732     EXPECT_EQ(objectData, nullptr);
733 
734     // abnormal params of unexist key params
735     msg = std::string() + R"({"id":0,"method":"Debugger.Test"})";
736     objectData = SetPauseOnExceptionsParams::Create(DispatchRequest(msg).GetParams());
737     EXPECT_EQ(objectData, nullptr);
738 
739     // abnormal params of null params.sub-key
740     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{}})";
741     objectData = SetPauseOnExceptionsParams::Create(DispatchRequest(msg).GetParams());
742     EXPECT_EQ(objectData, nullptr);
743 
744     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"state":10}})";
745     objectData = SetPauseOnExceptionsParams::Create(DispatchRequest(msg).GetParams());
746     EXPECT_EQ(objectData, nullptr);
747 
748     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"state":"none"}})";
749     objectData = SetPauseOnExceptionsParams::Create(DispatchRequest(msg).GetParams());
750     ASSERT_NE(objectData, nullptr);
751     EXPECT_EQ(objectData->GetState(), PauseOnExceptionsState::NONE);
752 }
753 
HWTEST_F_L0(DebuggerParamsTest,StepIntoParamsCreateTest)754 HWTEST_F_L0(DebuggerParamsTest, StepIntoParamsCreateTest)
755 {
756     std::string msg;
757     std::unique_ptr<StepIntoParams> objectData;
758 
759     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"breakOnAsyncCall":10, "skipList":true}})";
760     objectData = StepIntoParams::Create(DispatchRequest(msg).GetParams());
761     EXPECT_EQ(objectData, nullptr);
762 
763     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"breakOnAsyncCall":true,
764         "skipList":[{"scriptId":"1", "start":{"lineNumber":1, "columnNumber":10}, "end":{"lineNumber":2,
765         "columnNumber":20}}, {"scriptId":"2", "start":{"lineNumber":3, "columnNumber":30}, "end":{"lineNumber":4,
766         "columnNumber":40}}]}})";
767     objectData = StepIntoParams::Create(DispatchRequest(msg).GetParams());
768     ASSERT_NE(objectData, nullptr);
769     ASSERT_TRUE(objectData->GetBreakOnAsyncCall());
770     const std::list<std::unique_ptr<LocationRange>> *locationRangeList = objectData->GetSkipList();
771     EXPECT_EQ(locationRangeList->size(), 2U);
772 }
773 
774 
HWTEST_F_L0(DebuggerParamsTest,StepOverParamsCreateTest)775 HWTEST_F_L0(DebuggerParamsTest, StepOverParamsCreateTest)
776 {
777     std::string msg;
778     std::unique_ptr<StepOverParams> objectData;
779 
780     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"skipList":true}})";
781     objectData = StepOverParams::Create(DispatchRequest(msg).GetParams());
782     EXPECT_EQ(objectData, nullptr);
783 
784     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"skipList":[{"scriptId":"1",
785         "start":{"lineNumber":1, "columnNumber":10}, "end":{"lineNumber":2, "columnNumber":20}}, {"scriptId":"2",
786         "start":{"lineNumber":3, "columnNumber":30}, "end":{"lineNumber":4, "columnNumber":40}}]}})";
787     objectData = StepOverParams::Create(DispatchRequest(msg).GetParams());
788     ASSERT_NE(objectData, nullptr);
789     const std::list<std::unique_ptr<LocationRange>> *locationRangeList = objectData->GetSkipList();
790     EXPECT_EQ(locationRangeList->size(), 2U);
791 }
792 
HWTEST_F_L0(DebuggerParamsTest,SetMixedDebugParamsCreateTest)793 HWTEST_F_L0(DebuggerParamsTest, SetMixedDebugParamsCreateTest)
794 {
795     std::string msg;
796     std::unique_ptr<SetMixedDebugParams> objectData;
797 
798     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"enabled":"test"}})";
799     objectData = SetMixedDebugParams::Create(DispatchRequest(msg).GetParams());
800     EXPECT_EQ(objectData, nullptr);
801 
802     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"enabled":true}})";
803     objectData = SetMixedDebugParams::Create(DispatchRequest(msg).GetParams());
804     ASSERT_NE(objectData, nullptr);
805     ASSERT_TRUE(objectData->GetEnabled());
806 }
807 
HWTEST_F_L0(DebuggerParamsTest,ReplyNativeCallingParamsCreateTest)808 HWTEST_F_L0(DebuggerParamsTest, ReplyNativeCallingParamsCreateTest)
809 {
810     std::string msg;
811     std::unique_ptr<ReplyNativeCallingParams> objectData;
812 
813     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"userCode":"test"}})";
814     objectData = ReplyNativeCallingParams::Create(DispatchRequest(msg).GetParams());
815     EXPECT_EQ(objectData, nullptr);
816 
817     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"userCode":true}})";
818     objectData = ReplyNativeCallingParams::Create(DispatchRequest(msg).GetParams());
819     ASSERT_NE(objectData, nullptr);
820     ASSERT_TRUE(objectData->GetUserCode());
821 }
822 
HWTEST_F_L0(DebuggerParamsTest,GetPropertiesParamsCreateTest)823 HWTEST_F_L0(DebuggerParamsTest, GetPropertiesParamsCreateTest)
824 {
825     std::string msg;
826     std::unique_ptr<GetPropertiesParams> objectData;
827 
828     // abnormal params of null msg
829     msg = std::string() + R"({})";
830     objectData = GetPropertiesParams::Create(DispatchRequest(msg).GetParams());
831     EXPECT_EQ(objectData, nullptr);
832 
833     // abnormal params of unexist key params
834     msg = std::string() + R"({"id":0,"method":"Debugger.Test"})";
835     objectData = GetPropertiesParams::Create(DispatchRequest(msg).GetParams());
836     EXPECT_EQ(objectData, nullptr);
837 
838     // abnormal params of null params.sub-key
839     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{}})";
840     objectData = GetPropertiesParams::Create(DispatchRequest(msg).GetParams());
841     EXPECT_EQ(objectData, nullptr);
842 
843     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"objectId":10, "ownProperties":1,
844         "accessorPropertiesOnly":2, "generatePreview":3}})";
845     objectData = GetPropertiesParams::Create(DispatchRequest(msg).GetParams());
846     EXPECT_EQ(objectData, nullptr);
847 
848     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"objectId":"10", "ownProperties":true,
849         "accessorPropertiesOnly":true, "generatePreview":true}})";
850     objectData = GetPropertiesParams::Create(DispatchRequest(msg).GetParams());
851     ASSERT_NE(objectData, nullptr);
852     EXPECT_EQ(objectData->GetObjectId(), 10);
853     ASSERT_TRUE(objectData->GetOwnProperties());
854     ASSERT_TRUE(objectData->GetAccessPropertiesOnly());
855     ASSERT_TRUE(objectData->GetGeneratePreview());
856 }
857 
HWTEST_F_L0(DebuggerParamsTest,CallFunctionOnParamsCreateTest)858 HWTEST_F_L0(DebuggerParamsTest, CallFunctionOnParamsCreateTest)
859 {
860     std::string msg;
861     std::unique_ptr<CallFunctionOnParams> objectData;
862 
863     // abnormal params of null msg
864     msg = std::string() + R"({})";
865     objectData = CallFunctionOnParams::Create(DispatchRequest(msg).GetParams());
866     EXPECT_EQ(objectData, nullptr);
867 
868     // abnormal params of unexist key params
869     msg = std::string() + R"({"id":0,"method":"Debugger.Test"})";
870     objectData = CallFunctionOnParams::Create(DispatchRequest(msg).GetParams());
871     EXPECT_EQ(objectData, nullptr);
872 
873     // abnormal params of null params.sub-key
874     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{}})";
875     objectData = CallFunctionOnParams::Create(DispatchRequest(msg).GetParams());
876     EXPECT_EQ(objectData, nullptr);
877 
878     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"functionDeclaration":true, "objectId":1,
879         "arguments":[{"unserializableValue":1, "objectId":10}, {"unserializableValue":2, "objectId":20}],
880         "silent":"true", "returnByValue":"true", "generatePreview":"true", "userGesture":"true", "awaitPromise":"true",
881         "executionContextId":"1", "objectGroup":2, "throwOnSideEffect":"true"}})";
882     objectData = CallFunctionOnParams::Create(DispatchRequest(msg).GetParams());
883     EXPECT_EQ(objectData, nullptr);
884 
885     msg = std::string() + R"({"id":0,"method":"Debugger.Test","params":{"functionDeclaration":"testFunction",
886         "objectId":"1", "arguments":[{"unserializableValue":"testValue1", "objectId":"10"},
887         {"unserializableValue":"testValue2", "objectId":"20"}], "silent":true, "returnByValue":true,
888         "generatePreview":true, "userGesture":true, "awaitPromise":true, "executionContextId":1,
889         "objectGroup":"testGrp", "throwOnSideEffect":true}})";
890     objectData = CallFunctionOnParams::Create(DispatchRequest(msg).GetParams());
891     ASSERT_NE(objectData, nullptr);
892     EXPECT_EQ(objectData->GetFunctionDeclaration(), "testFunction");
893     EXPECT_EQ(objectData->GetObjectId(), 1);
894     const std::vector<std::unique_ptr<CallArgument>> *callArgument = objectData->GetArguments();
895     EXPECT_EQ(callArgument->size(), 2U);
896     ASSERT_TRUE(objectData->GetSilent());
897     ASSERT_TRUE(objectData->GetReturnByValue());
898     ASSERT_TRUE(objectData->GetGeneratePreview());
899     ASSERT_TRUE(objectData->GetUserGesture());
900     ASSERT_TRUE(objectData->GetAwaitPromise());
901     EXPECT_EQ(objectData->GetExecutionContextId(), 1);
902     EXPECT_EQ(objectData->GetObjectGroup(), "testGrp");
903     ASSERT_TRUE(objectData->GetThrowOnSideEffect());
904 }
905 }  // namespace panda::test
906