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 "tooling/base/pt_types.h"
17 #include "tooling/base/pt_returns.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 using ObjectType = RemoteObject::TypeName;
33 using ObjectSubType = RemoteObject::SubTypeName;
34 using ObjectClassName = RemoteObject::ClassName;
35 
36 class DebuggerReturnsTest : public testing::Test {
37 public:
SetUpTestCase()38     static void SetUpTestCase()
39     {
40         GTEST_LOG_(INFO) << "SetUpTestCase";
41     }
42 
TearDownTestCase()43     static void TearDownTestCase()
44     {
45         GTEST_LOG_(INFO) << "TearDownCase";
46     }
47 
48     void SetUp() override
49     {
50         TestHelper::CreateEcmaVMWithScope(ecmaVm, thread, scope);
51     }
52 
53     void TearDown() override
54     {
55         TestHelper::DestroyEcmaVMWithScope(ecmaVm, scope);
56     }
57 
58 protected:
59     EcmaVM *ecmaVm {nullptr};
60     EcmaHandleScope *scope {nullptr};
61     JSThread *thread {nullptr};
62 };
63 
HWTEST_F_L0(DebuggerReturnsTest, DebuggerEnableReturnsToJsonTest)64 HWTEST_F_L0(DebuggerReturnsTest, DebuggerEnableReturnsToJsonTest)
65 {
66     std::vector<std::string> list {};
67     std::unique_ptr<DebuggerEnableReturns> enableReturns = std::make_unique<DebuggerEnableReturns>(100U, list);
68     ASSERT_NE(enableReturns, nullptr);
69 
70     std::string debuggerId;
71     ASSERT_EQ(enableReturns->ToJson()->GetString("debuggerId", &debuggerId), Result::SUCCESS);
72     EXPECT_EQ(debuggerId, "100");
73 }
74 
HWTEST_F_L0(DebuggerReturnsTest, SetBreakpointByUrlReturnsToJsonTest)75 HWTEST_F_L0(DebuggerReturnsTest, SetBreakpointByUrlReturnsToJsonTest)
76 {
77     auto locations = std::vector<std::unique_ptr<Location>>();
78     std::unique_ptr<Location> location = std::make_unique<Location>();
79     location->SetScriptId(1).SetLine(99);
80     locations.emplace_back(std::move(location));
81     std::unique_ptr<SetBreakpointByUrlReturns> setBreakpointByUrlReturns
82                      = std::make_unique<SetBreakpointByUrlReturns>("11", std::move(locations));
83     ASSERT_NE(setBreakpointByUrlReturns, nullptr);
84     std::string id;
85     ASSERT_EQ(setBreakpointByUrlReturns->ToJson()->GetString("breakpointId", &id), Result::SUCCESS);
86     EXPECT_EQ(id, "11");
87 
88     std::unique_ptr<PtJson> locationsJson;
89     ASSERT_EQ(setBreakpointByUrlReturns->ToJson()->GetArray("locations", &locationsJson), Result::SUCCESS);
90     ASSERT_NE(locationsJson, nullptr);
91     EXPECT_EQ(locationsJson->GetSize(), 1);
92 }
93 
HWTEST_F_L0(DebuggerReturnsTest, EvaluateOnCallFrameReturnsToJsonTest)94 HWTEST_F_L0(DebuggerReturnsTest, EvaluateOnCallFrameReturnsToJsonTest)
95 {
96     std::unique_ptr<RemoteObject> result = std::make_unique<RemoteObject>();
97     result->SetType("idle");
98     std::unique_ptr<ExceptionDetails> exceptionDetails = std::make_unique<ExceptionDetails>();
99     exceptionDetails->SetExceptionId(12);
100     std::unique_ptr<EvaluateOnCallFrameReturns> evaluateOnCallFrameReturns
101                      = std::make_unique<EvaluateOnCallFrameReturns>(std::move(result), std::move(exceptionDetails));
102     ASSERT_NE(evaluateOnCallFrameReturns, nullptr);
103     std::unique_ptr<PtJson> json;
104     ASSERT_EQ(evaluateOnCallFrameReturns->ToJson()->GetObject("result", &json), Result::SUCCESS);
105     std::string type;
106     ASSERT_EQ(json->GetString("type", &type), Result::SUCCESS);
107     EXPECT_EQ(type, "idle");
108 
109     std::unique_ptr<PtJson> tmpJson;
110     ASSERT_EQ(evaluateOnCallFrameReturns->ToJson()->GetObject("exceptionDetails", &tmpJson), Result::SUCCESS);
111     int32_t exceptionId;
112     ASSERT_EQ(tmpJson->GetInt("exceptionId", &exceptionId), Result::SUCCESS);
113     EXPECT_EQ(exceptionId, 12);
114 }
115 
HWTEST_F_L0(DebuggerReturnsTest, GetPossibleBreakpointsReturnsToJsonTest)116 HWTEST_F_L0(DebuggerReturnsTest, GetPossibleBreakpointsReturnsToJsonTest)
117 {
118     auto locations = std::vector<std::unique_ptr<BreakLocation>>();
119     std::unique_ptr<BreakLocation> breakLocation = std::make_unique<BreakLocation>();
120     breakLocation->SetScriptId(11).SetLine(1).SetColumn(44).SetType("idel5");
121     locations.emplace_back(std::move(breakLocation));
122     std::unique_ptr<GetPossibleBreakpointsReturns> getPossibleBreakpointsReturns = std::make_unique
123                                                     <GetPossibleBreakpointsReturns>(std::move(locations));
124 
125     std::unique_ptr<PtJson> locationsJson;
126     ASSERT_EQ(getPossibleBreakpointsReturns->ToJson()->GetArray("locations", &locationsJson), Result::SUCCESS);
127     ASSERT_NE(locationsJson, nullptr);
128     EXPECT_EQ(locationsJson->GetSize(), 1);
129 }
130 
HWTEST_F_L0(DebuggerReturnsTest, GetScriptSourceReturnsToJsonTest)131 HWTEST_F_L0(DebuggerReturnsTest, GetScriptSourceReturnsToJsonTest)
132 {
133     std::unique_ptr<GetScriptSourceReturns> getScriptSourceReturns = std::make_unique
134                                                                     <GetScriptSourceReturns>("source_1", "bytecode_1");
135     ASSERT_NE(getScriptSourceReturns, nullptr);
136 
137     std::string scriptSource;
138     ASSERT_EQ(getScriptSourceReturns->ToJson()->GetString("scriptSource", &scriptSource), Result::SUCCESS);
139     EXPECT_EQ(scriptSource, "source_1");
140 
141     std::string bytecode;
142     ASSERT_EQ(getScriptSourceReturns->ToJson()->GetString("bytecode", &bytecode), Result::SUCCESS);
143     EXPECT_EQ(bytecode, "bytecode_1");
144 }
145 
HWTEST_F_L0(DebuggerReturnsTest, RestartFrameReturnsToJsonTest)146 HWTEST_F_L0(DebuggerReturnsTest, RestartFrameReturnsToJsonTest)
147 {
148     auto callFrames = std::vector<std::unique_ptr<CallFrame>>();
149     std::unique_ptr<CallFrame> callFrame = std::make_unique<CallFrame>();
150     std::unique_ptr<Location> location = std::make_unique<Location>();
151     location->SetScriptId(13).SetLine(16);
152 
153     std::unique_ptr<RemoteObject> res = std::make_unique<RemoteObject>();
154     res->SetType("idle2");
155 
156     callFrame->SetCallFrameId(55);
157     callFrame->SetLocation(std::move(location));
158     callFrame->SetThis(std::move(res));
159     callFrames.emplace_back(std::move(callFrame));
160     std::unique_ptr<RestartFrameReturns> restartFrameReturns = std::make_unique
161                                                                  <RestartFrameReturns>(std::move(callFrames));
162 
163     std::unique_ptr<PtJson> json;
164     ASSERT_EQ(restartFrameReturns->ToJson()->GetArray("callFrames", &json), Result::SUCCESS);
165     ASSERT_NE(json, nullptr);
166     EXPECT_EQ(json->GetSize(), 1);
167 }
168 
HWTEST_F_L0(DebuggerReturnsTest, SetBreakpointReturnsToJsonTest)169 HWTEST_F_L0(DebuggerReturnsTest, SetBreakpointReturnsToJsonTest)
170 {
171     std::unique_ptr<Location> location = std::make_unique<Location>();
172     std::unique_ptr<SetBreakpointReturns> setBreakpointReturns
173                      = std::make_unique<SetBreakpointReturns>("breakpointId_1", std::move(location));
174     ASSERT_NE(setBreakpointReturns, nullptr);
175 
176     std::string breakpointId;
177     ASSERT_EQ(setBreakpointReturns->ToJson()->GetString("breakpointId", &breakpointId), Result::SUCCESS);
178     EXPECT_EQ(breakpointId, "breakpointId_1");
179 
180     std::unique_ptr<PtJson> tmpJson;
181     ASSERT_EQ(setBreakpointReturns->ToJson()->GetObject("actualLocation", &tmpJson), Result::SUCCESS);
182 }
183 
HWTEST_F_L0(DebuggerReturnsTest, SetInstrumentationBreakpointReturnsToJsonTest)184 HWTEST_F_L0(DebuggerReturnsTest, SetInstrumentationBreakpointReturnsToJsonTest)
185 {
186     std::unique_ptr<SetInstrumentationBreakpointReturns> setInstrumentationBreakpointReturns
187                      = std::make_unique<SetInstrumentationBreakpointReturns>("111");
188     ASSERT_NE(setInstrumentationBreakpointReturns, nullptr);
189 
190     std::string breakpointId;
191     ASSERT_EQ(setInstrumentationBreakpointReturns->ToJson()->GetString("breakpointId", &breakpointId),
192               Result::SUCCESS);
193     EXPECT_EQ(breakpointId, "111");
194 }
195 
HWTEST_F_L0(DebuggerReturnsTest, SetScriptSourceReturnsToJsonTest)196 HWTEST_F_L0(DebuggerReturnsTest, SetScriptSourceReturnsToJsonTest)
197 {
198     auto callFrames = std::vector<std::unique_ptr<CallFrame>>();
199     std::unique_ptr<CallFrame> callFrame = std::make_unique<CallFrame>();
200     std::unique_ptr<Location> location = std::make_unique<Location>();
201     location->SetScriptId(3).SetLine(36);
202 
203     std::unique_ptr<RemoteObject> res = std::make_unique<RemoteObject>();
204     res->SetType("idle5");
205 
206     callFrame->SetCallFrameId(33);
207     callFrame->SetLocation(std::move(location));
208     callFrame->SetThis(std::move(res));
209     callFrames.emplace_back(std::move(callFrame));
210     std::unique_ptr<SetScriptSourceReturns> setScriptSourceReturns = std::make_unique
211                                                                 <SetScriptSourceReturns>(std::move(callFrames));
212 
213     std::unique_ptr<PtJson> json;
214     ASSERT_EQ(setScriptSourceReturns->ToJson()->GetArray("callFrames", &json), Result::SUCCESS);
215     ASSERT_NE(json, nullptr);
216     EXPECT_EQ(json->GetSize(), 1);
217 }
218 
HWTEST_F_L0(DebuggerReturnsTest, GetPropertiesReturnsToJsonTest)219 HWTEST_F_L0(DebuggerReturnsTest, GetPropertiesReturnsToJsonTest)
220 {
221     auto descriptor = std::vector<std::unique_ptr<PropertyDescriptor>>();
222     std::unique_ptr<PropertyDescriptor> propertyDescriptor = std::make_unique<PropertyDescriptor>();
223     propertyDescriptor->SetName("filename1").SetConfigurable(true).SetEnumerable(true);
224     descriptor.emplace_back(std::move(propertyDescriptor));
225     std::unique_ptr<GetPropertiesReturns> getPropertiesReturns = std::make_unique
226                                                         <GetPropertiesReturns>(std::move(descriptor));
227     ASSERT_NE(getPropertiesReturns, nullptr);
228 
229     std::unique_ptr<PtJson> json;
230     ASSERT_EQ(getPropertiesReturns->ToJson()->GetArray("result", &json), Result::SUCCESS);
231     ASSERT_NE(json, nullptr);
232     EXPECT_EQ(json->GetSize(), 1);
233 }
234 
HWTEST_F_L0(DebuggerReturnsTest, CallFunctionOnReturnsToJsonTest)235 HWTEST_F_L0(DebuggerReturnsTest, CallFunctionOnReturnsToJsonTest)
236 {
237     std::unique_ptr<RemoteObject> result = std::make_unique<RemoteObject>();
238     result->SetType("idle2");
239     std::unique_ptr<ExceptionDetails> exceptionDetails = std::make_unique<ExceptionDetails>();
240     std::unique_ptr<CallFunctionOnReturns> callFunctionOnReturns
241                      = std::make_unique<CallFunctionOnReturns>(std::move(result), std::move(exceptionDetails));
242     ASSERT_NE(callFunctionOnReturns, nullptr);
243     std::unique_ptr<PtJson> json;
244     ASSERT_EQ(callFunctionOnReturns->ToJson()->GetObject("result", &json), Result::SUCCESS);
245     std::string type;
246     ASSERT_EQ(json->GetString("type", &type), Result::SUCCESS);
247     EXPECT_EQ(type, "idle2");
248 
249     std::unique_ptr<PtJson> tmpJson;
250     ASSERT_EQ(callFunctionOnReturns->ToJson()->GetObject("exceptionDetails", &tmpJson), Result::SUCCESS);
251 }
252 
HWTEST_F_L0(DebuggerReturnsTest, StopSamplingReturnsToJsonTest)253 HWTEST_F_L0(DebuggerReturnsTest, StopSamplingReturnsToJsonTest)
254 {
255     auto res = std::vector<std::unique_ptr<SamplingHeapProfileSample>>();
256     std::unique_ptr<RuntimeCallFrame> runtime = std::make_unique<RuntimeCallFrame>();
257     std::unique_ptr<SamplingHeapProfileNode> node = std::make_unique<SamplingHeapProfileNode>();
258     node->SetCallFrame(std::move(runtime));
259     std::unique_ptr<SamplingHeapProfile> profile = std::make_unique<SamplingHeapProfile>();
260     profile->SetHead(std::move(node));
261     profile->SetSamples(std::move(res));
262     std::unique_ptr<StopSamplingReturns> stopSamplingReturns =
263                                          std::make_unique<StopSamplingReturns>(std::move(profile));
264     ASSERT_NE(stopSamplingReturns, nullptr);
265 
266     std::unique_ptr<PtJson> json;
267     ASSERT_EQ(stopSamplingReturns->ToJson()->GetObject("profile", &json), Result::SUCCESS);
268 }
269 
HWTEST_F_L0(DebuggerReturnsTest, GetHeapObjectIdReturnsToJsonTest)270 HWTEST_F_L0(DebuggerReturnsTest, GetHeapObjectIdReturnsToJsonTest)
271 {
272     std::unique_ptr<GetHeapObjectIdReturns> getHeapObjectIdReturns = std::make_unique<GetHeapObjectIdReturns>(10);
273     ASSERT_NE(getHeapObjectIdReturns, nullptr);
274 
275     std::string heapSnapshotObjectId;
276     ASSERT_EQ(getHeapObjectIdReturns->ToJson()->GetString("heapSnapshotObjectId", &heapSnapshotObjectId),
277               Result::SUCCESS);
278     EXPECT_EQ(heapSnapshotObjectId, "10");
279 }
280 
HWTEST_F_L0(DebuggerReturnsTest, GetObjectByHeapObjectIdReturnsToJsonTest)281 HWTEST_F_L0(DebuggerReturnsTest, GetObjectByHeapObjectIdReturnsToJsonTest)
282 {
283     std::unique_ptr<RemoteObject> remoteObjectResult = std::make_unique<RemoteObject>();
284     remoteObjectResult->SetType("idle5");
285     std::unique_ptr<GetObjectByHeapObjectIdReturns> getObjectByHeapObjectIdReturns =
286                                     std::make_unique<GetObjectByHeapObjectIdReturns>(std::move(remoteObjectResult));
287     ASSERT_NE(getObjectByHeapObjectIdReturns, nullptr);
288 
289     std::unique_ptr<PtJson> json;
290     ASSERT_EQ(getObjectByHeapObjectIdReturns->ToJson()->GetObject("result", &json), Result::SUCCESS);
291     std::string type;
292     ASSERT_EQ(json->GetString("type", &type), Result::SUCCESS);
293     EXPECT_EQ(type, "idle5");
294 }
295 
HWTEST_F_L0(DebuggerReturnsTest, StopReturnsToJsonTest)296 HWTEST_F_L0(DebuggerReturnsTest, StopReturnsToJsonTest)
297 {
298     std::unique_ptr<Profile> profile = std::make_unique<Profile>();
299     std::unique_ptr<StopReturns> stopReturns= std::make_unique<StopReturns>(std::move(profile));
300     ASSERT_NE(stopReturns, nullptr);
301 
302     std::unique_ptr<PtJson> json;
303     ASSERT_EQ(stopReturns->ToJson()->GetObject("profile", &json), Result::SUCCESS);
304 }
305 
HWTEST_F_L0(DebuggerReturnsTest, GetHeapUsageReturnsToJsonTest)306 HWTEST_F_L0(DebuggerReturnsTest, GetHeapUsageReturnsToJsonTest)
307 {
308     double usedSize = 1;
309     double totalSize = 1;
310     std::unique_ptr<GetHeapUsageReturns> getHeapUsageReturns =
311         std::make_unique<GetHeapUsageReturns>(usedSize, totalSize);
312     ASSERT_NE(getHeapUsageReturns, nullptr);
313 
314     double pUsedSize;
315     ASSERT_EQ(getHeapUsageReturns->ToJson()->GetDouble("usedSize", &pUsedSize), Result::SUCCESS);
316     EXPECT_EQ(pUsedSize, 1);
317 
318     double pTotalSize;
319     ASSERT_EQ(getHeapUsageReturns->ToJson()->GetDouble("totalSize", &pTotalSize), Result::SUCCESS);
320     EXPECT_EQ(pTotalSize, 1);
321 }
322 
HWTEST_F_L0(DebuggerReturnsTest, GetBestEffortCoverageReturnsToJsonTest)323 HWTEST_F_L0(DebuggerReturnsTest, GetBestEffortCoverageReturnsToJsonTest)
324 {
325     auto result = std::vector<std::unique_ptr<ScriptCoverage>>();
326     std::unique_ptr<ScriptCoverage> scriptCoverage = std::make_unique<ScriptCoverage>();
327     std::unique_ptr<GetBestEffortCoverageReturns> getBestEffortCoverageReturns =
328                                                 std::make_unique<GetBestEffortCoverageReturns>(std::move(result));
329 
330     std::unique_ptr<PtJson> json;
331     ASSERT_EQ(getBestEffortCoverageReturns->ToJson()->GetArray("result", &json), Result::SUCCESS);
332     ASSERT_NE(json, nullptr);
333     EXPECT_EQ(json->GetSize(), 0);
334 }
335 
HWTEST_F_L0(DebuggerReturnsTest, StartPreciseCoverageReturnsToJsonTest)336 HWTEST_F_L0(DebuggerReturnsTest, StartPreciseCoverageReturnsToJsonTest)
337 {
338     std::unique_ptr<StartPreciseCoverageReturns> startPreciseCoverageReturns
339                      = std::make_unique<StartPreciseCoverageReturns>(1001);
340     ASSERT_NE(startPreciseCoverageReturns, nullptr);
341 
342     int32_t timestamp;
343     ASSERT_EQ(startPreciseCoverageReturns->ToJson()->GetInt("timestamp", &timestamp), Result::SUCCESS);
344     EXPECT_EQ(timestamp, 1001);
345 }
346 
HWTEST_F_L0(DebuggerReturnsTest, TakePreciseCoverageReturnsToJsonTest)347 HWTEST_F_L0(DebuggerReturnsTest, TakePreciseCoverageReturnsToJsonTest)
348 {
349     auto coverage = std::vector<std::unique_ptr<ScriptCoverage>>();
350     std::unique_ptr<TakePreciseCoverageReturns> takePreciseCoverageReturns =
351                                                 std::make_unique<TakePreciseCoverageReturns>(std::move(coverage), 1001);
352     ASSERT_NE(takePreciseCoverageReturns, nullptr);
353 
354     std::unique_ptr<PtJson> json;
355     ASSERT_EQ(takePreciseCoverageReturns->ToJson()->GetArray("result", &json), Result::SUCCESS);
356     ASSERT_NE(json, nullptr);
357     EXPECT_EQ(json->GetSize(), 0);
358 
359     int32_t timestamp;
360     ASSERT_EQ(takePreciseCoverageReturns->ToJson()->GetInt("timestamp", &timestamp), Result::SUCCESS);
361     EXPECT_EQ(timestamp, 1001);
362 }
363 
HWTEST_F_L0(DebuggerReturnsTest, TakeTypeProfileturnsToJsonTest)364 HWTEST_F_L0(DebuggerReturnsTest, TakeTypeProfileturnsToJsonTest)
365 {
366     auto result = std::vector<std::unique_ptr<ScriptTypeProfile>>();
367     std::unique_ptr<ScriptTypeProfile> scriptTypeProfile = std::make_unique<ScriptTypeProfile>();
368     std::unique_ptr<TakeTypeProfileReturns> takeTypeProfileturns = std::make_unique
369                                                     <TakeTypeProfileReturns>(std::move(result));
370 
371     std::unique_ptr<PtJson> json;
372     ASSERT_EQ(takeTypeProfileturns->ToJson()->GetArray("result", &json), Result::SUCCESS);
373     ASSERT_NE(json, nullptr);
374     EXPECT_EQ(json->GetSize(), 0);
375 }
376 
HWTEST_F_L0(DebuggerReturnsTest, GetCategoriesReturnsToJsonTest)377 HWTEST_F_L0(DebuggerReturnsTest, GetCategoriesReturnsToJsonTest)
378 {
379     auto result = std::vector<std::string>();
380     std::unique_ptr<GetCategoriesReturns> getCategoriesReturns = std::make_unique
381                                                     <GetCategoriesReturns>(std::move(result));
382 
383     std::unique_ptr<PtJson> json;
384     ASSERT_EQ(getCategoriesReturns->ToJson()->GetArray("categories", &json), Result::SUCCESS);
385     ASSERT_NE(json, nullptr);
386     EXPECT_EQ(json->GetSize(), 0);
387 }
388 
HWTEST_F_L0(DebuggerReturnsTest, RequestMemoryDumpReturnsToJsonTest)389 HWTEST_F_L0(DebuggerReturnsTest, RequestMemoryDumpReturnsToJsonTest)
390 {
391     std::unique_ptr<RequestMemoryDumpReturns> requestMemoryDumpReturns
392                      = std::make_unique<RequestMemoryDumpReturns>("123", true);
393     ASSERT_NE(requestMemoryDumpReturns, nullptr);
394 
395     std::string dumpGuid;
396     ASSERT_EQ(requestMemoryDumpReturns->ToJson()->GetString("dumpGuid", &dumpGuid),
397               Result::SUCCESS);
398     EXPECT_EQ(dumpGuid, "123");
399 
400     bool success;
401     ASSERT_EQ(requestMemoryDumpReturns->ToJson()->GetBool("success", &success), Result::SUCCESS);
402     ASSERT_TRUE(success);
403 }
404 
HWTEST_F_L0(DebuggerReturnsTest, SearchInContentReturnsToJsonTest)405 HWTEST_F_L0(DebuggerReturnsTest, SearchInContentReturnsToJsonTest)
406 {
407     auto result = std::vector<std::unique_ptr<SearchMatch>>();
408     std::unique_ptr<SearchMatch> searchMatch = std::make_unique<SearchMatch>();
409     std::unique_ptr<SearchInContentReturns> searchInContentReturns =
410                                                 std::make_unique<SearchInContentReturns>(std::move(result));
411 
412     std::unique_ptr<PtJson> json;
413     ASSERT_EQ(searchInContentReturns->ToJson()->GetArray("result", &json), Result::SUCCESS);
414     ASSERT_NE(json, nullptr);
415     EXPECT_EQ(json->GetSize(), 0);
416 }
417 
HWTEST_F_L0(DebuggerReturnsTest, GetPossibleAndSetBreakpointByUrlReturnsToJsonTest)418 HWTEST_F_L0(DebuggerReturnsTest, GetPossibleAndSetBreakpointByUrlReturnsToJsonTest)
419 {
420     auto locations = std::vector<std::unique_ptr<BreakpointReturnInfo>>();
421     std::unique_ptr<BreakpointReturnInfo> breakpointReturnInfo = std::make_unique<BreakpointReturnInfo>();
422     breakpointReturnInfo->SetScriptId(11).SetLineNumber(1).SetColumnNumber(44);
423     locations.emplace_back(std::move(breakpointReturnInfo));
424     std::unique_ptr<GetPossibleAndSetBreakpointByUrlReturns> getPossibleAndSetBreakpointByUrlReturns = std::make_unique
425                                                     <GetPossibleAndSetBreakpointByUrlReturns>(std::move(locations));
426     std::unique_ptr<PtJson> locationsJS;
427     ASSERT_EQ(getPossibleAndSetBreakpointByUrlReturns->ToJson()->GetArray("locations", &locationsJS), Result::SUCCESS);
428     ASSERT_NE(locationsJS, nullptr);
429     EXPECT_EQ(locationsJS->GetSize(), 1);
430 }
431 }  // namespace panda::test