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