1 /*
2 * Copyright (c) 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 "report_manager_test.h"
17
18 #include "accesstoken_kit.h"
19 #include "message_parcel.h"
20 #include "nativetoken_kit.h"
21 #include "token_setproc.h"
22
23 #include "i_locator_callback.h"
24 #include "location.h"
25 #include "locator.h"
26 #define private public
27 #include "locator_ability.h"
28 #include "request.h"
29 #undef private
30 #include "locator_callback_napi.h"
31 #include "locator_callback_proxy.h"
32 #include "request_manager.h"
33 #include "permission_manager.h"
34
35 using namespace testing::ext;
36 namespace OHOS {
37 namespace Location {
38 const int32_t LOCATION_PERM_NUM = 4;
39 const std::string UNKNOWN_ABILITY = "unknown_ability";
SetUp()40 void ReportManagerTest::SetUp()
41 {
42 MockNativePermission();
43 reportManager_ = ReportManager::GetInstance();
44 EXPECT_NE(nullptr, reportManager_);
45 }
46
TearDown()47 void ReportManagerTest::TearDown()
48 {
49 reportManager_ = nullptr;
50 }
51
MockNativePermission()52 void ReportManagerTest::MockNativePermission()
53 {
54 const char *perms[] = {
55 ACCESS_LOCATION.c_str(), ACCESS_APPROXIMATELY_LOCATION.c_str(),
56 ACCESS_BACKGROUND_LOCATION.c_str(), MANAGE_SECURE_SETTINGS.c_str(),
57 };
58 NativeTokenInfoParams infoInstance = {
59 .dcapsNum = 0,
60 .permsNum = LOCATION_PERM_NUM,
61 .aclsNum = 0,
62 .dcaps = nullptr,
63 .perms = perms,
64 .acls = nullptr,
65 .processName = "ReportManagerTest",
66 .aplStr = "system_basic",
67 };
68 tokenId_ = GetAccessTokenId(&infoInstance);
69 SetSelfTokenID(tokenId_);
70 Security::AccessToken::AccessTokenKit::ReloadNativeTokenInfo();
71 }
72
MockLocation()73 std::unique_ptr<Location> ReportManagerTest::MockLocation()
74 {
75 std::unique_ptr<Location> location = std::make_unique<Location>();
76 MessageParcel parcel;
77 parcel.WriteDouble(12.0); // latitude
78 parcel.WriteDouble(13.0); // longitude
79 parcel.WriteDouble(14.0); // altitude
80 parcel.WriteDouble(1000.0); // accuracy
81 parcel.WriteDouble(10.0); // speed
82 parcel.WriteDouble(90.0); // direction
83 parcel.WriteInt64(1000000000); // timeStamp
84 parcel.WriteInt64(1000000100); // timeSinceBoot
85 parcel.WriteString16(u"additions"); // additions
86 parcel.WriteInt64(1); // additionSize
87 parcel.WriteInt32(1); // isFromMock
88 location->ReadFromParcel(parcel);
89 return location;
90 }
91
92 HWTEST_F(ReportManagerTest, ReportRemoteCallbackTest001, TestSize.Level1)
93 {
94 GTEST_LOG_(INFO)
95 << "ReportManagerTest, ReportRemoteCallbackTest001, TestSize.Level1";
96 LBSLOGI(REPORT_MANAGER, "[ReportManagerTest] ReportRemoteCallbackTest001 begin");
97 std::unique_ptr<Location> location = std::make_unique<Location>();
98 auto locatorCallbackHostForTest =
99 sptr<LocatorCallbackNapi>(new (std::nothrow) LocatorCallbackNapi());
100 sptr<ILocatorCallback> locatorCallback =
101 sptr<ILocatorCallback>(locatorCallbackHostForTest);
102 EXPECT_EQ(true, reportManager_->
103 ReportRemoteCallback(locatorCallback, ILocatorCallback::RECEIVE_LOCATION_STATUS_EVENT, 1));
104 EXPECT_EQ(true, reportManager_->
105 ReportRemoteCallback(locatorCallback, ILocatorCallback::RECEIVE_ERROR_INFO_EVENT, 1));
106 EXPECT_EQ(false, reportManager_->
107 ReportRemoteCallback(locatorCallback, ILocatorCallback::RECEIVE_LOCATION_INFO_EVENT, 1));
108 LBSLOGI(REPORT_MANAGER, "[ReportManagerTest] ReportRemoteCallbackTest001 end");
109 }
110
111 HWTEST_F(ReportManagerTest, ResultCheckTest001, TestSize.Level1)
112 {
113 GTEST_LOG_(INFO)
114 << "ReportManagerTest, ResultCheckTest001, TestSize.Level1";
115 LBSLOGI(REPORT_MANAGER, "[ReportManagerTest] ResultCheckTest001 begin");
116 std::shared_ptr<Request> request = std::make_shared<Request>();
117 request->SetUid(1000);
118 request->SetPid(0);
119 request->SetTokenId(tokenId_);
120 request->SetFirstTokenId(0);
121 request->SetPackageName("ReportManagerTest");
122 auto location = MockLocation();
123
124 EXPECT_EQ(true, reportManager_->ResultCheck(location, request));
125 EXPECT_EQ(false, reportManager_->ResultCheck(nullptr, request)); // no location
126 EXPECT_EQ(false, reportManager_->ResultCheck(location, nullptr)); // no request
127 EXPECT_EQ(false, reportManager_->ResultCheck(nullptr, nullptr)); // no location & no request
128
129 auto requestConfig = std::make_unique<RequestConfig>();
130 EXPECT_NE(nullptr, requestConfig);
131 requestConfig->SetPriority(PRIORITY_FAST_FIRST_FIX);
132 requestConfig->SetMaxAccuracy(1000.0);
133 requestConfig->SetFixNumber(1);
134 request->SetRequestConfig(*requestConfig);
135 EXPECT_EQ(true, reportManager_->ResultCheck(location, request)); // no last location
136
137 std::unique_ptr<Location> lastLocation1 = std::make_unique<Location>(*location);
138 lastLocation1->SetLatitude(-91.0);
139 request->SetLastLocation(lastLocation1);
140 EXPECT_EQ(true, reportManager_->ResultCheck(location, request)); // no need to check
141
142 std::unique_ptr<Location> lastLocation2 = std::make_unique<Location>(*location);
143 request->SetLastLocation(lastLocation2);
144 reportManager_->ResultCheck(location, request); // time interval check failed
145
146 std::unique_ptr<Location> lastLocation3 = std::make_unique<Location>(*location);
147 lastLocation3->SetTimeSinceBoot(1000000000);
148 requestConfig->SetDistanceInterval(1.0);
149 request->SetRequestConfig(*requestConfig);
150 request->SetLastLocation(lastLocation3);
151 reportManager_->ResultCheck(location, request); // distance interval check failed
152
153 std::unique_ptr<Location> lastLocation4 = std::make_unique<Location>(*location);
154 lastLocation4->SetTimeSinceBoot(1000000000);
155 requestConfig->SetDistanceInterval(0.0);
156 requestConfig->SetMaxAccuracy(10.0);
157 request->SetRequestConfig(*requestConfig);
158 request->SetLastLocation(lastLocation4);
159 EXPECT_EQ(false, reportManager_->ResultCheck(location, request)); // acc check failed
160 LBSLOGI(REPORT_MANAGER, "[ReportManagerTest] ResultCheckTest001 end");
161 }
162
163 HWTEST_F(ReportManagerTest, ResultCheckTest002, TestSize.Level1)
164 {
165 GTEST_LOG_(INFO)
166 << "ReportManagerTest, ResultCheckTest002, TestSize.Level1";
167 LBSLOGI(REPORT_MANAGER, "[ReportManagerTest] ResultCheckTest002 begin");
168 std::shared_ptr<Request> request = std::make_shared<Request>();
169 request->SetUid(1000);
170 request->SetPid(0);
171 request->SetTokenId(tokenId_);
172 request->SetFirstTokenId(0);
173 request->SetPackageName("ReportManagerTest");
174 auto requestConfig = std::make_unique<RequestConfig>();
175 EXPECT_NE(nullptr, requestConfig);
176 requestConfig->SetPriority(PRIORITY_FAST_FIRST_FIX);
177 requestConfig->SetMaxAccuracy(1000.0);
178 requestConfig->SetFixNumber(1);
179 request->SetRequestConfig(*requestConfig);
180 auto location = MockLocation();
181
182 std::unique_ptr<Location> lastLocation5 = std::make_unique<Location>(*location);
183 lastLocation5->SetTimeSinceBoot(1000000000);
184 requestConfig->SetDistanceInterval(0.0);
185 requestConfig->SetMaxAccuracy(0.0);
186 request->SetRequestConfig(*requestConfig);
187 request->SetLastLocation(lastLocation5);
188 reportManager_->ResultCheck(location, request); // check pass
189 LBSLOGI(REPORT_MANAGER, "[ReportManagerTest] ResultCheckTest002 end");
190 }
191
192 HWTEST_F(ReportManagerTest, SetLastLocationTest001, TestSize.Level1)
193 {
194 GTEST_LOG_(INFO)
195 << "ReportManagerTest, SetLastLocationTest001, TestSize.Level1";
196 LBSLOGI(REPORT_MANAGER, "[ReportManagerTest] SetLastLocationTest001 begin");
197 reportManager_->GetLastLocation();
198 int64_t curTime = CommonUtils::GetCurrentTimeStamp();
199 MessageParcel parcel;
200 parcel.WriteDouble(12.0); // latitude
201 parcel.WriteDouble(13.0); // longitude
202 parcel.WriteDouble(14.0); // altitude
203 parcel.WriteDouble(1000.0); // accuracy
204 parcel.WriteDouble(10.0); // speed
205 parcel.WriteDouble(90.0); // direction
206 parcel.WriteInt64(curTime * MILLI_PER_SEC); // timeStamp
207 parcel.WriteInt64(1000000000); // timeSinceBoot
208 parcel.WriteString16(u"additions"); // additions
209 parcel.WriteInt64(1); // additionSize
210 parcel.WriteInt32(1); // isFromMock
211 std::unique_ptr<Location> location = std::make_unique<Location>();
212 location->ReadFromParcel(parcel);
213 reportManager_->UpdateCacheLocation(location, GNSS_ABILITY);
214 std::shared_ptr<Request> request = std::make_shared<Request>();
215 request->SetUid(1000);
216 request->SetPid(0);
217 request->SetTokenId(tokenId_);
218 request->SetFirstTokenId(0);
219 request->SetPackageName("ReportManagerTest");
220 EXPECT_NE(nullptr, reportManager_->GetLastLocation());
221 reportManager_->GetCacheLocation(request);
222 reportManager_->UpdateCacheLocation(location, NETWORK_ABILITY);
223 reportManager_->GetCacheLocation(request);
224 LBSLOGI(REPORT_MANAGER, "[ReportManagerTest] SetLastLocationTest001 end");
225 }
226
227 HWTEST_F(ReportManagerTest, GetPermittedLocationTest001, TestSize.Level1)
228 {
229 GTEST_LOG_(INFO)
230 << "ReportManagerTest, GetPermittedLocationTest001, TestSize.Level1";
231 LBSLOGI(REPORT_MANAGER, "[ReportManagerTest] GetPermittedLocationTest001 begin");
232 std::shared_ptr<Request> request = std::make_shared<Request>();
233 request->SetTokenId(tokenId_);
234 EXPECT_EQ(nullptr, reportManager_->GetPermittedLocation(request, nullptr));
235 MessageParcel parcel;
236 parcel.WriteDouble(12.0); // latitude
237 parcel.WriteDouble(13.0); // longitude
238 parcel.WriteDouble(14.0); // altitude
239 parcel.WriteDouble(1000.0); // accuracy
240 parcel.WriteDouble(10.0); // speed
241 parcel.WriteDouble(90.0); // direction
242 parcel.WriteInt64(1000000000); // timeStamp
243 parcel.WriteInt64(1000000000); // timeSinceBoot
244 parcel.WriteString16(u"additions"); // additions
245 parcel.WriteInt64(1); // additionSize
246 parcel.WriteInt32(1); // isFromMock
247 std::unique_ptr<Location> location = std::make_unique<Location>();
248 location->ReadFromParcel(parcel);
249 auto newLocation = reportManager_->GetPermittedLocation(request, location);
250 EXPECT_NE(nullptr, newLocation);
251 if (newLocation != nullptr) {
252 EXPECT_EQ(12.0, newLocation->GetLatitude());
253 EXPECT_EQ(13.0, newLocation->GetLongitude());
254 EXPECT_EQ(1000.0, newLocation->GetAccuracy());
255 LBSLOGI(REPORT_MANAGER, "[ReportManagerTest] GetPermittedLocationTest001 end");
256 }
257 }
258
259 HWTEST_F(ReportManagerTest, OnReportLocationTest001, TestSize.Level1)
260 {
261 GTEST_LOG_(INFO)
262 << "ReportManagerTest, OnReportLocationTest001, TestSize.Level1";
263 LBSLOGI(REPORT_MANAGER, "[ReportManagerTest] OnReportLocationTest001 begin");
264 MessageParcel parcel;
265 parcel.WriteDouble(12.0); // latitude
266 parcel.WriteDouble(13.0); // longitude
267 parcel.WriteDouble(14.0); // altitude
268 parcel.WriteDouble(1000.0); // accuracy
269 parcel.WriteDouble(10.0); // speed
270 parcel.WriteDouble(90.0); // direction
271 parcel.WriteInt64(1000000000); // timeStamp
272 parcel.WriteInt64(1000000000); // timeSinceBoot
273 parcel.WriteString16(u"additions"); // additions
274 parcel.WriteInt64(1); // additionSize
275 parcel.WriteInt32(0); // isFromMock
276 std::unique_ptr<Location> location = std::make_unique<Location>();
277 location->ReadFromParcel(parcel);
278 location->SetUuid("35279");
279 std::list<std::shared_ptr<Request>> networkList;
280 int num = 2;
281 for (int i = 0; i < num; i++) {
282 std::shared_ptr<Request> request = std::make_shared<Request>();
283 std::unique_ptr<RequestConfig> requestConfig = std::make_unique<RequestConfig>();
284 requestConfig->SetTimeInterval(i);
285 request->SetUid(i + 1);
286 request->SetPid(i + 2);
287 request->SetPackageName("nameForTest");
288 request->SetRequestConfig(*requestConfig);
289 request->SetUuid(std::to_string(i + 35279));
290 request->SetNlpRequestType(0);
291 networkList.push_back(request);
292 }
293 auto locatorAbility = LocatorAbility::GetInstance();
294 locatorAbility->requests_->insert(make_pair(NETWORK_ABILITY, networkList));
295
296 EXPECT_EQ(true, reportManager_->OnReportLocation(location, NETWORK_ABILITY));
297 LBSLOGI(REPORT_MANAGER, "[ReportManagerTest] OnReportLocationTest001 end");
298 }
299
300 HWTEST_F(ReportManagerTest, OnReportLocationTest002, TestSize.Level1)
301 {
302 GTEST_LOG_(INFO)
303 << "ReportManagerTest, OnReportLocationTest002, TestSize.Level1";
304 LBSLOGI(REPORT_MANAGER, "[ReportManagerTest] OnReportLocationTest002 begin");
305 MessageParcel parcel;
306 parcel.WriteDouble(12.0); // latitude
307 parcel.WriteDouble(13.0); // longitude
308 parcel.WriteDouble(14.0); // altitude
309 parcel.WriteDouble(1000.0); // accuracy
310 parcel.WriteDouble(10.0); // speed
311 parcel.WriteDouble(90.0); // direction
312 parcel.WriteInt64(1000000000); // timeStamp
313 parcel.WriteInt64(1000000000); // timeSinceBoot
314 parcel.WriteString16(u"additions"); // additions
315 parcel.WriteInt64(1); // additionSize
316 parcel.WriteInt32(0); // isFromMock
317 std::unique_ptr<Location> location = std::make_unique<Location>();
318 location->ReadFromParcel(parcel);
319 EXPECT_EQ(true, reportManager_->OnReportLocation(location, GNSS_ABILITY)); // is not requesting
320 LBSLOGI(REPORT_MANAGER, "[ReportManagerTest] OnReportLocationTest002 end");
321 }
322
323 HWTEST_F(ReportManagerTest, OnReportLocationTest003, TestSize.Level1)
324 {
325 GTEST_LOG_(INFO)
326 << "ReportManagerTest, OnReportLocationTest003, TestSize.Level1";
327 LBSLOGI(REPORT_MANAGER, "[ReportManagerTest] OnReportLocationTest003 begin");
328 MessageParcel parcel;
329 parcel.WriteDouble(12.0); // latitude
330 parcel.WriteDouble(13.0); // longitude
331 parcel.WriteDouble(14.0); // altitude
332 parcel.WriteDouble(1000.0); // accuracy
333 parcel.WriteDouble(10.0); // speed
334 parcel.WriteDouble(90.0); // direction
335 parcel.WriteInt64(1000000000); // timeStamp
336 parcel.WriteInt64(1000000000); // timeSinceBoot
337 parcel.WriteString16(u"additions"); // additions
338 parcel.WriteInt64(1); // additionSize
339 parcel.WriteInt32(0); // isFromMock
340 std::unique_ptr<Location> location = std::make_unique<Location>();
341 location->ReadFromParcel(parcel);
342
343 std::unique_ptr<RequestConfig> requestConfig = std::make_unique<RequestConfig>();
344 requestConfig->SetPriority(PRIORITY_ACCURACY);
345 requestConfig->SetFixNumber(0);
346 requestConfig->SetTimeInterval(1);
347 requestConfig->SetScenario(SCENE_DAILY_LIFE_SERVICE);
348 auto locatorImpl = Locator::GetInstance();
349 sptr<ILocatorCallback> callbackStub = new (std::nothrow) LocatorCallbackStub();
350 locatorImpl->EnableAbility(true);
351 locatorImpl->StartLocating(requestConfig, callbackStub); // start locating
352 sleep(1);
353 EXPECT_EQ(true, reportManager_->OnReportLocation(location, GNSS_ABILITY)); // report location successfully
354 EXPECT_EQ(true,
355 reportManager_->OnReportLocation(location, GNSS_ABILITY)); // report the same location, result check is false
356 locatorImpl->StopLocating(callbackStub);
357 LBSLOGI(REPORT_MANAGER, "[ReportManagerTest] OnReportLocationTest003 end");
358 }
359
360 HWTEST_F(ReportManagerTest, OnReportLocationTest004, TestSize.Level1)
361 {
362 GTEST_LOG_(INFO)
363 << "ReportManagerTest, OnReportLocationTest004, TestSize.Level1";
364 LBSLOGI(REPORT_MANAGER, "[ReportManagerTest] OnReportLocationTest004 begin");
365 MessageParcel parcel;
366 parcel.WriteDouble(12.0); // latitude
367 parcel.WriteDouble(13.0); // longitude
368 parcel.WriteDouble(14.0); // altitude
369 parcel.WriteDouble(1000.0); // accuracy
370 parcel.WriteDouble(10.0); // speed
371 parcel.WriteDouble(90.0); // direction
372 parcel.WriteInt64(1000000000); // timeStamp
373 parcel.WriteInt64(1000000000); // timeSinceBoot
374 parcel.WriteString16(u"additions"); // additions
375 parcel.WriteInt64(1); // additionSize
376 parcel.WriteInt32(0); // isFromMock
377 std::unique_ptr<Location> location = std::make_unique<Location>();
378 location->ReadFromParcel(parcel);
379
380 std::unique_ptr<RequestConfig> requestConfig = std::make_unique<RequestConfig>();
381 requestConfig->SetPriority(PRIORITY_ACCURACY);
382 requestConfig->SetFixNumber(1); // locating once
383 requestConfig->SetTimeOut(120000);
384 requestConfig->SetScenario(SCENE_DAILY_LIFE_SERVICE);
385 auto locatorImpl = Locator::GetInstance();
386 sptr<ILocatorCallback> callbackStub = new (std::nothrow) LocatorCallbackStub();
387 locatorImpl->EnableAbility(true);
388 locatorImpl->StartLocating(requestConfig, callbackStub); // start locating
389 sleep(1);
390 EXPECT_EQ(true, reportManager_->OnReportLocation(location, GNSS_ABILITY)); // will resolve deadRequests
391 locatorImpl->StopLocating(callbackStub);
392 LBSLOGI(REPORT_MANAGER, "[ReportManagerTest] OnReportLocationTest004 end");
393 }
394
395 HWTEST_F(ReportManagerTest, UpdateRandomTest004, TestSize.Level1)
396 {
397 GTEST_LOG_(INFO)
398 << "ReportManagerTest, UpdateRandomTest004, TestSize.Level1";
399 LBSLOGI(REPORT_MANAGER, "[ReportManagerTest] UpdateRandomTest004 begin");
400 std::list<std::shared_ptr<Request>> gnssList;
401 auto locatorAbility = sptr<LocatorAbility>(new (std::nothrow) LocatorAbility());
402 locatorAbility->requests_->insert(make_pair(GNSS_ABILITY, gnssList));
403 reportManager_->UpdateRandom();
404
405 struct timespec now;
406 clock_gettime(CLOCK_REALTIME, &now);
407 reportManager_->lastUpdateTime_.tv_sec = now.tv_sec + LONG_TIME_INTERVAL +1;
408 locatorAbility->requests_->clear();
409 reportManager_->UpdateRandom();
410 LBSLOGI(REPORT_MANAGER, "[ReportManagerTest] UpdateRandomTest004 end");
411 }
412
413 HWTEST_F(ReportManagerTest, IsRequestFuseTest001, TestSize.Level1)
414 {
415 GTEST_LOG_(INFO)
416 << "ReportManagerTest, IsRequestFuseTest001, TestSize.Level1";
417 LBSLOGI(REPORT_MANAGER, "[ReportManagerTest] IsRequestFuseTest001 begin");
418 EXPECT_EQ(false, reportManager_->IsRequestFuse(nullptr));
419
420 std::shared_ptr<Request> request = std::make_shared<Request>();
421 std::unique_ptr<RequestConfig> requestConfig = std::make_unique<RequestConfig>();
422 requestConfig->SetPriority(PRIORITY_FAST_FIRST_FIX);
423 requestConfig->SetScenario(SCENE_UNSET);
424 request->SetRequestConfig(*requestConfig);
425 EXPECT_EQ(true, reportManager_->IsRequestFuse(request));
426
427 LBSLOGI(REPORT_MANAGER, "[ReportManagerTest] IsRequestFuseTest001 end");
428 }
429
430 HWTEST_F(ReportManagerTest, IsRequestFuseTest002, TestSize.Level1)
431 {
432 GTEST_LOG_(INFO)
433 << "ReportManagerTest, IsRequestFuseTest002, TestSize.Level1";
434 LBSLOGI(REPORT_MANAGER, "[ReportManagerTest] IsRequestFuseTest002 begin");
435 EXPECT_EQ(false, reportManager_->IsRequestFuse(nullptr));
436
437 std::shared_ptr<Request> request = std::make_shared<Request>();
438 std::unique_ptr<RequestConfig> requestConfig = std::make_unique<RequestConfig>();
439 requestConfig->SetPriority(PRIORITY_UNSET);
440 requestConfig->SetScenario(SCENE_UNSET);
441 request->SetRequestConfig(*requestConfig);
442 reportManager_->IsRequestFuse(request);
443
444 LBSLOGI(REPORT_MANAGER, "[ReportManagerTest] IsRequestFuseTest002 end");
445 }
446
447 HWTEST_F(ReportManagerTest, UpdateLocationByRequestTest001, TestSize.Level1)
448 {
449 GTEST_LOG_(INFO)
450 << "ReportManagerTest, UpdateLocationByRequestTest001, TestSize.Level1";
451 LBSLOGI(REPORT_MANAGER, "[ReportManagerTest] UpdateLocationByRequestTest001 begin");
452 auto location = MockLocation();
453 reportManager_->UpdateLocationByRequest(tokenId_, tokenId_, location);
454 LBSLOGI(REPORT_MANAGER, "[ReportManagerTest] UpdateLocationByRequestTest001 end");
455 }
456
457 HWTEST_F(ReportManagerTest, UpdateLocationByRequestTest002, TestSize.Level1)
458 {
459 GTEST_LOG_(INFO)
460 << "ReportManagerTest, UpdateLocationByRequestTest002, TestSize.Level1";
461 LBSLOGI(REPORT_MANAGER, "[ReportManagerTest] UpdateLocationByRequestTest002 begin");
462 std::unique_ptr<Location> location = nullptr;
463 reportManager_->UpdateLocationByRequest(tokenId_, tokenId_, location);
464 LBSLOGI(REPORT_MANAGER, "[ReportManagerTest] UpdateLocationByRequestTest002 end");
465 }
466
467 HWTEST_F(ReportManagerTest, ProcessRequestForReport001, TestSize.Level1)
468 {
469 GTEST_LOG_(INFO)
470 << "ReportManagerTest, ProcessRequestForReport001, TestSize.Level1";
471 LBSLOGI(REPORT_MANAGER, "[ReportManagerTest] ProcessRequestForReport001 begin");
472 std::shared_ptr<Request> request = std::make_shared<Request>();
473 std::unique_ptr<RequestConfig> requestConfig = std::make_unique<RequestConfig>();
474 requestConfig->SetTimeInterval(1);
475 request->SetUid(111);
476 request->SetPid(222);
477 request->SetPackageName("nameForTest");
478 request->SetRequestConfig(*requestConfig);
479 request->SetRequesting(true);
480 request->SetUuid(std::to_string(35279));
481 request->SetNlpRequestType(0);
482 auto deadRequests = std::make_unique<std::list<std::shared_ptr<Request>>>();
483 std::unique_ptr<Location> location = std::make_unique<Location>();
484 location->SetUuid("35279");
485 reportManager_->ProcessRequestForReport(request, deadRequests, location, NETWORK_ABILITY);
486 LBSLOGI(REPORT_MANAGER, "[ReportManagerTest] ProcessRequestForReport001 end");
487 }
488
489 HWTEST_F(ReportManagerTest, ProcessRequestForReport002, TestSize.Level1)
490 {
491 GTEST_LOG_(INFO)
492 << "ReportManagerTest, ProcessRequestForReport002, TestSize.Level1";
493 LBSLOGI(REPORT_MANAGER, "[ReportManagerTest] ProcessRequestForReport002 begin");
494 std::shared_ptr<Request> request = std::make_shared<Request>();
495 std::unique_ptr<RequestConfig> requestConfig = std::make_unique<RequestConfig>();
496 requestConfig->SetTimeInterval(1);
497 request->SetUid(111);
498 request->SetPid(222);
499 request->SetPackageName("nameForTest");
500
501 request->SetRequesting(true);
502 request->SetUuid(std::to_string(35279));
503 request->SetNlpRequestType(0);
504 auto deadRequests = std::make_unique<std::list<std::shared_ptr<Request>>>();
505 std::unique_ptr<Location> location = std::make_unique<Location>();
506 location->SetUuid("35279");
507 reportManager_->ProcessRequestForReport(request, deadRequests, location, NETWORK_ABILITY);
508 LBSLOGI(REPORT_MANAGER, "[ReportManagerTest] ProcessRequestForReport002 end");
509 }
510
511 HWTEST_F(ReportManagerTest, WriteNetWorkReportEvent, TestSize.Level1)
512 {
513 GTEST_LOG_(INFO)
514 << "ReportManagerTest, WriteNetWorkReportEvent, TestSize.Level1";
515 LBSLOGI(REPORT_MANAGER, "[ReportManagerTest] WriteNetWorkReportEvent begin");
516 std::shared_ptr<Request> request = std::make_shared<Request>();
517 std::unique_ptr<RequestConfig> requestConfig = std::make_unique<RequestConfig>();
518 requestConfig->SetTimeInterval(1);
519 request->SetUid(111);
520 request->SetPid(222);
521 request->SetPackageName("nameForTest");
522 request->SetRequestConfig(*requestConfig);
523 request->SetRequesting(true);
524 request->SetUuid(std::to_string(35279));
525 request->SetNlpRequestType(0);
526 std::unique_ptr<Location> location = std::make_unique<Location>();
527 location->SetUuid("35279");
528 reportManager_->WriteNetWorkReportEvent(NETWORK_ABILITY, request, location);
529 LBSLOGI(REPORT_MANAGER, "[ReportManagerTest] WriteNetWorkReportEvent end");
530 }
531 } // namespace Location
532 } // namespace OHOS