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 "locator_skeleton_test.h"
17
18 #include <cstdlib>
19
20 #include "accesstoken_kit.h"
21 #include "bundle_mgr_interface.h"
22 #include "bundle_mgr_proxy.h"
23 #include "if_system_ability_manager.h"
24 #include "ipc_skeleton.h"
25 #include "iservice_registry.h"
26 #include "nativetoken_kit.h"
27 #include "system_ability_definition.h"
28 #include "token_setproc.h"
29
30 #include "app_identity.h"
31
32 #include "common_utils.h"
33 #include "constant_definition.h"
34 #include "i_locator.h"
35 #include "location.h"
36 #include "location_log.h"
37 #include "location_sa_load_manager.h"
38 #include "locator.h"
39 #define private public
40 #include "locator_skeleton.h"
41 #undef private
42 #ifdef FEATURE_GNSS_SUPPORT
43 #include "nmea_message_callback_napi.h"
44 #endif
45 #include "permission_manager.h"
46 #include "location_data_rdb_manager.h"
47 #include "locator_callback_napi.h"
48
49 using namespace testing::ext;
50
51 namespace OHOS {
52 namespace Location {
53 const int32_t LOCATION_WITHOUT_PERM = 1;
54 const int32_t LOCATION_WITHOUT_MOCK_PERM_NUM = 6;
55 const int32_t LOCATION_NATIVE_PERM_NUM = 7;
56 const std::string RUNNING_STATE_OBSERVER = "ohos.permission.RUNNING_STATE_OBSERVER";
SetUp()57 void LocatorSkeletonTest::SetUp()
58 {
59 /*
60 * @tc.setup: Get system ability's pointer and get sa proxy object.
61 */
62 LoadSystemAbility();
63 MockNativePermission();
64 MockNativeWithoutMockPermission();
65 MockNativeWithoutSecurePermission();
66 MockNativeWithoutLocationPermission();
67 }
68
TearDown()69 void LocatorSkeletonTest::TearDown()
70 {
71 }
72
LoadSystemAbility()73 void LocatorSkeletonTest::LoadSystemAbility()
74 {
75 LocationSaLoadManager::GetInstance()->LoadLocationSa(LOCATION_LOCATOR_SA_ID);
76 #ifdef FEATURE_GNSS_SUPPORT
77 LocationSaLoadManager::GetInstance()->LoadLocationSa(LOCATION_GNSS_SA_ID);
78 #endif
79 #ifdef FEATURE_PASSIVE_SUPPORT
80 LocationSaLoadManager::GetInstance()->LoadLocationSa(LOCATION_NOPOWER_LOCATING_SA_ID);
81 #endif
82 #ifdef FEATURE_NETWORK_SUPPORT
83 LocationSaLoadManager::GetInstance()->LoadLocationSa(LOCATION_NETWORK_LOCATING_SA_ID);
84 #endif
85 #ifdef FEATURE_GEOCODE_SUPPORT
86 LocationSaLoadManager::GetInstance()->LoadLocationSa(LOCATION_GEO_CONVERT_SA_ID);
87 #endif
88 }
89
MockNativePermission()90 void LocatorSkeletonTest::MockNativePermission()
91 {
92 const char *perms[] = {
93 ACCESS_LOCATION.c_str(), ACCESS_APPROXIMATELY_LOCATION.c_str(),
94 ACCESS_BACKGROUND_LOCATION.c_str(), MANAGE_SECURE_SETTINGS.c_str(),
95 RUNNING_STATE_OBSERVER.c_str(), ACCESS_MOCK_LOCATION.c_str(),
96 ACCESS_CONTROL_LOCATION_SWITCH.c_str(),
97 };
98 NativeTokenInfoParams infoInstance = {
99 .dcapsNum = 0,
100 .permsNum = LOCATION_NATIVE_PERM_NUM,
101 .aclsNum = 0,
102 .dcaps = nullptr,
103 .perms = perms,
104 .acls = nullptr,
105 .processName = "tddTestApkname01",
106 .aplStr = "system_basic",
107 };
108 tokenId_ = GetAccessTokenId(&infoInstance);
109 SetSelfTokenID(tokenId_);
110 Security::AccessToken::AccessTokenKit::ReloadNativeTokenInfo();
111 }
112
MockNativeWithoutMockPermission()113 void LocatorSkeletonTest::MockNativeWithoutMockPermission()
114 {
115 const char *perms[] = {
116 ACCESS_LOCATION.c_str(), ACCESS_APPROXIMATELY_LOCATION.c_str(),
117 ACCESS_BACKGROUND_LOCATION.c_str(), MANAGE_SECURE_SETTINGS.c_str(),
118 RUNNING_STATE_OBSERVER.c_str(), ACCESS_CONTROL_LOCATION_SWITCH.c_str(),
119 };
120 NativeTokenInfoParams infoInstance = {
121 .dcapsNum = 0,
122 .permsNum = LOCATION_WITHOUT_MOCK_PERM_NUM,
123 .aclsNum = 0,
124 .dcaps = nullptr,
125 .perms = perms,
126 .acls = nullptr,
127 .processName = "tddTestApkname02",
128 .aplStr = "system_basic",
129 };
130 tokenId2_ = GetAccessTokenId(&infoInstance);
131 SetSelfTokenID(tokenId2_);
132 Security::AccessToken::AccessTokenKit::ReloadNativeTokenInfo();
133 }
134
MockNativeWithoutSecurePermission()135 void LocatorSkeletonTest::MockNativeWithoutSecurePermission()
136 {
137 const char *perms[] = {
138 ACCESS_LOCATION.c_str(), ACCESS_APPROXIMATELY_LOCATION.c_str(),
139 ACCESS_BACKGROUND_LOCATION.c_str(), RUNNING_STATE_OBSERVER.c_str(),
140 ACCESS_MOCK_LOCATION.c_str(), ACCESS_CONTROL_LOCATION_SWITCH.c_str(),
141 };
142 NativeTokenInfoParams infoInstance = {
143 .dcapsNum = 0,
144 .permsNum = LOCATION_WITHOUT_MOCK_PERM_NUM,
145 .aclsNum = 0,
146 .dcaps = nullptr,
147 .perms = perms,
148 .acls = nullptr,
149 .processName = "tddTestApkname03",
150 .aplStr = "system_basic",
151 };
152 tokenId3_ = GetAccessTokenId(&infoInstance);
153 SetSelfTokenID(tokenId3_);
154 Security::AccessToken::AccessTokenKit::ReloadNativeTokenInfo();
155 }
156
MockNativeWithoutLocationPermission()157 void LocatorSkeletonTest::MockNativeWithoutLocationPermission()
158 {
159 const char *perms[] = {
160 ACCESS_BACKGROUND_LOCATION.c_str(),
161 };
162 NativeTokenInfoParams infoInstance = {
163 .dcapsNum = 0,
164 .permsNum = LOCATION_WITHOUT_PERM,
165 .aclsNum = 0,
166 .dcaps = nullptr,
167 .perms = perms,
168 .acls = nullptr,
169 .processName = "tddTestApkname04",
170 .aplStr = "system_basic",
171 };
172 tokenId4_ = GetAccessTokenId(&infoInstance);
173 SetSelfTokenID(tokenId4_);
174 Security::AccessToken::AccessTokenKit::ReloadNativeTokenInfo();
175 }
176
177 HWTEST_F(LocatorSkeletonTest, LocatorInterfaceTest, TestSize.Level1)
178 {
179 GTEST_LOG_(INFO)
180 << "LocatorSkeletonTest, LocatorInterfaceTest, TestSize.Level1";
181 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] LocatorInterfaceTest begin");
182 auto locatorAbilityStub = sptr<MockLocatorAbilityStub>(new (std::nothrow) MockLocatorAbilityStub());
183 auto locatorHandleMap = locatorAbilityStub->locatorHandleMap_;
184 for (auto it = locatorHandleMap.begin(); it != locatorHandleMap.end(); ++it) {
185 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] LocatorInterfaceTest code %{public}d", it->first);
186 MessageParcel data;
187 MessageParcel reply;
188 AppIdentity identity;
189 it->second(data, reply, identity);
190 }
191 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] LocatorInterfaceTest end");
192 }
193
194 HWTEST_F(LocatorSkeletonTest, PreGetSwitchState, TestSize.Level1)
195 {
196 GTEST_LOG_(INFO)
197 << "LocatorSkeletonTest, PreGetSwitchState, TestSize.Level1";
198 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreGetSwitchState begin");
199 auto locatorAbilityStub = sptr<MockLocatorAbilityStub>(new (std::nothrow) MockLocatorAbilityStub());
200 MessageParcel data;
201 MessageParcel reply;
202 AppIdentity identity;
203 identity.SetPid(1);
204 identity.SetUid(2);
205 uint32_t tokenId = static_cast<uint32_t>(tokenId_);
206 identity.SetTokenId(tokenId);
207 identity.SetFirstTokenId(0);
208 identity.SetBundleName("bundleName");
209 auto result = locatorAbilityStub->PreGetSwitchState(data, reply, identity);
210 EXPECT_EQ(ERRCODE_SUCCESS, result);
211 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreGetSwitchState end");
212 }
213
214 HWTEST_F(LocatorSkeletonTest, PreRegisterSwitchCallback, TestSize.Level1)
215 {
216 GTEST_LOG_(INFO)
217 << "LocatorSkeletonTest, PreRegisterSwitchCallback, TestSize.Level1";
218 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreRegisterSwitchCallback begin");
219 auto locatorAbilityStub = sptr<MockLocatorAbilityStub>(new (std::nothrow) MockLocatorAbilityStub());
220 MessageParcel data;
221 MessageParcel reply;
222 AppIdentity identity;
223 identity.SetPid(1);
224 identity.SetUid(2);
225 uint32_t tokenId = static_cast<uint32_t>(tokenId_);
226 identity.SetTokenId(tokenId);
227 identity.SetFirstTokenId(0);
228 identity.SetBundleName("bundleName");
229 auto result = locatorAbilityStub->PreRegisterSwitchCallback(data, reply, identity);
230 EXPECT_EQ(ERRCODE_SUCCESS, result);
231 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreRegisterSwitchCallback end");
232 }
233
234 HWTEST_F(LocatorSkeletonTest, PreStartLocating, TestSize.Level1)
235 {
236 GTEST_LOG_(INFO)
237 << "LocatorSkeletonTest, PreStartLocating, TestSize.Level1";
238 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreStartLocating begin");
239 auto locatorAbilityStub = sptr<MockLocatorAbilityStub>(new (std::nothrow) MockLocatorAbilityStub());
240 MessageParcel data;
241 auto callback = sptr<LocatorCallbackNapi>(new (std::nothrow) LocatorCallbackNapi());
242 data.WriteInt32(1);
243 data.WriteInt32(1);
244 data.WriteInt32(1);
245 data.WriteDouble(1.0);
246 data.WriteFloat(1.0);
247 data.WriteInt32(1);
248 data.WriteInt32(1);
249 data.WriteRemoteObject(callback->AsObject());
250 MessageParcel reply;
251 AppIdentity identity;
252 locatorAbilityStub->PreStartLocating(data, reply, identity);
253 identity.SetPid(1);
254 identity.SetUid(2);
255 uint32_t tokenId = static_cast<uint32_t>(tokenId_);
256 identity.SetTokenId(tokenId);
257 identity.SetFirstTokenId(0);
258 identity.SetBundleName("bundleName");
259 bool isSwitchEnable = LocationDataRdbManager::QuerySwitchState() == ENABLED ? true : false;
260 if (isSwitchEnable) {
261 locatorAbilityStub->PreStartLocating(data, reply, identity);
262 LocationDataRdbManager::SetSwitchStateToSysparaForCurrentUser(DISABLED);
263 locatorAbilityStub->PreStartLocating(data, reply, identity);
264 LocationDataRdbManager::SetSwitchStateToSysparaForCurrentUser(ENABLED);
265 } else {
266 locatorAbilityStub->PreStartLocating(data, reply, identity);
267 }
268 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreStartLocating end");
269 }
270
271 HWTEST_F(LocatorSkeletonTest, PreStopLocating001, TestSize.Level1)
272 {
273 GTEST_LOG_(INFO)
274 << "LocatorSkeletonTest, PreStopLocating001, TestSize.Level1";
275 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreStopLocating001 begin");
276 auto locatorAbilityStub = sptr<MockLocatorAbilityStub>(new (std::nothrow) MockLocatorAbilityStub());
277 MessageParcel data;
278 auto callback = sptr<LocatorCallbackNapi>(new (std::nothrow) LocatorCallbackNapi());
279 data.WriteRemoteObject(callback->AsObject());
280 MessageParcel reply;
281 AppIdentity identity;
282 identity.SetPid(1);
283 identity.SetUid(2);
284 uint32_t tokenId = static_cast<uint32_t>(tokenId_);
285 identity.SetTokenId(tokenId);
286 identity.SetFirstTokenId(0);
287 identity.SetBundleName("bundleName");
288 locatorAbilityStub->PreStopLocating(data, reply, identity);
289 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreStopLocating001 end");
290 }
291
292 HWTEST_F(LocatorSkeletonTest, PreStopLocating002, TestSize.Level1)
293 {
294 GTEST_LOG_(INFO)
295 << "LocatorSkeletonTest, PreStopLocating002, TestSize.Level1";
296 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreStopLocating002 begin");
297 auto locatorAbilityStub = sptr<MockLocatorAbilityStub>(new (std::nothrow) MockLocatorAbilityStub());
298 MessageParcel data;
299 auto callback = sptr<LocatorCallbackNapi>(new (std::nothrow) LocatorCallbackNapi());
300 data.WriteRemoteObject(callback->AsObject());
301 MessageParcel reply;
302 AppIdentity identity;
303 identity.SetPid(1);
304 identity.SetUid(2);
305 uint32_t tokenId = static_cast<uint32_t>(tokenId4_);
306 identity.SetTokenId(tokenId);
307 identity.SetFirstTokenId(0);
308 identity.SetBundleName("bundleName");
309 locatorAbilityStub->PreStopLocating(data, reply, identity);
310 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreStopLocating002 end");
311 }
312
313 HWTEST_F(LocatorSkeletonTest, PreGetCacheLocation001, TestSize.Level1)
314 {
315 GTEST_LOG_(INFO)
316 << "LocatorSkeletonTest, PreGetCacheLocation001, TestSize.Level1";
317 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreGetCacheLocation001 begin");
318 auto locatorAbilityStub = sptr<MockLocatorAbilityStub>(new (std::nothrow) MockLocatorAbilityStub());
319 auto callback = sptr<LocatorCallbackNapi>(new (std::nothrow) LocatorCallbackNapi());
320 MessageParcel reply;
321 MessageParcel data;
322 data.WriteInt32(1);
323 data.WriteBool(true);
324 data.WriteRemoteObject(callback->AsObject());
325 AppIdentity identity;
326 identity.SetPid(1);
327 identity.SetUid(2);
328 uint32_t tokenId = static_cast<uint32_t>(tokenId_);
329 identity.SetTokenId(tokenId);
330 identity.SetFirstTokenId(0);
331 identity.SetBundleName("bundleName");
332 bool isSwitchEnable = LocationDataRdbManager::QuerySwitchState() == ENABLED ? true : false;
333 if (isSwitchEnable) {
334 auto result = locatorAbilityStub->PreGetCacheLocation(data, reply, identity);
335 EXPECT_EQ(ERRCODE_SUCCESS, result);
336 LocationDataRdbManager::SetSwitchStateToSysparaForCurrentUser(DISABLED);
337 locatorAbilityStub->PreGetCacheLocation(data, reply, identity);
338 LocationDataRdbManager::SetSwitchStateToSysparaForCurrentUser(ENABLED);
339 } else {
340 locatorAbilityStub->PreGetCacheLocation(data, reply, identity);
341 }
342 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreGetCacheLocation001 end");
343 }
344
345 HWTEST_F(LocatorSkeletonTest, PreGetCacheLocation002, TestSize.Level1)
346 {
347 GTEST_LOG_(INFO)
348 << "LocatorSkeletonTest, PreGetCacheLocation002, TestSize.Level1";
349 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreGetCacheLocation002 begin");
350 auto locatorAbilityStub = sptr<MockLocatorAbilityStub>(new (std::nothrow) MockLocatorAbilityStub());
351 auto callback = sptr<LocatorCallbackNapi>(new (std::nothrow) LocatorCallbackNapi());
352 MessageParcel reply;
353 MessageParcel data;
354 data.WriteInt32(1);
355 data.WriteBool(true);
356 data.WriteRemoteObject(callback->AsObject());
357 AppIdentity identity;
358 identity.SetPid(1);
359 identity.SetUid(2);
360 uint32_t tokenId = static_cast<uint32_t>(tokenId4_);
361 identity.SetTokenId(tokenId);
362 identity.SetFirstTokenId(0);
363 identity.SetBundleName("bundleName");
364 bool isSwitchEnable = LocationDataRdbManager::QuerySwitchState() == ENABLED ? true : false;
365 if (isSwitchEnable) {
366 auto result = locatorAbilityStub->PreGetCacheLocation(data, reply, identity);
367 EXPECT_NE(ERRCODE_SUCCESS, result);
368 LocationDataRdbManager::SetSwitchStateToSysparaForCurrentUser(DISABLED);
369 locatorAbilityStub->PreGetCacheLocation(data, reply, identity);
370 LocationDataRdbManager::SetSwitchStateToSysparaForCurrentUser(ENABLED);
371 } else {
372 locatorAbilityStub->PreGetCacheLocation(data, reply, identity);
373 }
374 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreGetCacheLocation002 end");
375 }
376
377 HWTEST_F(LocatorSkeletonTest, PreEnableAbility001, TestSize.Level1)
378 {
379 GTEST_LOG_(INFO)
380 << "LocatorSkeletonTest, PreEnableAbility001, TestSize.Level1";
381 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreEnableAbility001 begin");
382 auto locatorAbilityStub = sptr<MockLocatorAbilityStub>(new (std::nothrow) MockLocatorAbilityStub());
383 MessageParcel data;
384 MessageParcel reply;
385 AppIdentity identity;
386 locatorAbilityStub->PreEnableAbility(data, reply, identity);
387 auto callback = sptr<LocatorCallbackNapi>(new (std::nothrow) LocatorCallbackNapi());
388 data.WriteBool(true);
389 identity.SetPid(1);
390 identity.SetUid(2);
391 uint32_t tokenId = static_cast<uint32_t>(tokenId_);
392 identity.SetTokenId(tokenId);
393 identity.SetFirstTokenId(0);
394 identity.SetBundleName("bundleName");
395 auto result = locatorAbilityStub->PreEnableAbility(data, reply, identity);
396 EXPECT_EQ(ERRCODE_SUCCESS, result);
397 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreEnableAbility001 end");
398 }
399
400 HWTEST_F(LocatorSkeletonTest, PreEnableAbility002, TestSize.Level1)
401 {
402 GTEST_LOG_(INFO)
403 << "LocatorSkeletonTest, PreEnableAbility002, TestSize.Level1";
404 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreEnableAbility002 begin");
405 auto locatorAbilityStub = sptr<MockLocatorAbilityStub>(new (std::nothrow) MockLocatorAbilityStub());
406 MessageParcel data;
407 MessageParcel reply;
408 AppIdentity identity;
409 locatorAbilityStub->PreEnableAbility(data, reply, identity);
410 auto callback = sptr<LocatorCallbackNapi>(new (std::nothrow) LocatorCallbackNapi());
411 data.WriteBool(true);
412 identity.SetPid(1);
413 identity.SetUid(2);
414 uint32_t tokenId = static_cast<uint32_t>(tokenId3_);
415 identity.SetTokenId(tokenId);
416 identity.SetFirstTokenId(0);
417 identity.SetBundleName("bundleName");
418 auto result = locatorAbilityStub->PreEnableAbility(data, reply, identity);
419 EXPECT_NE(ERRCODE_SUCCESS, result);
420 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreEnableAbility002 end");
421 }
422
423 HWTEST_F(LocatorSkeletonTest, PreUpdateSaAbility, TestSize.Level1)
424 {
425 GTEST_LOG_(INFO)
426 << "LocatorSkeletonTest, PreUpdateSaAbility, TestSize.Level1";
427 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreUpdateSaAbility begin");
428 auto locatorAbilityStub = sptr<MockLocatorAbilityStub>(new (std::nothrow) MockLocatorAbilityStub());
429 MessageParcel data;
430 MessageParcel reply;
431 AppIdentity identity;
432 locatorAbilityStub->PreUpdateSaAbility(data, reply, identity);
433 identity.SetPid(1);
434 identity.SetUid(2);
435 uint32_t tokenId = static_cast<uint32_t>(tokenId_);
436 identity.SetTokenId(tokenId);
437 identity.SetFirstTokenId(0);
438 identity.SetBundleName("bundleName");
439 auto result = locatorAbilityStub->PreUpdateSaAbility(data, reply, identity);
440 EXPECT_EQ(ERRCODE_SUCCESS, result);
441 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreUpdateSaAbility end");
442 }
443
444 #ifdef FEATURE_GEOCODE_SUPPORT
445 HWTEST_F(LocatorSkeletonTest, PreIsGeoConvertAvailable, TestSize.Level1)
446 {
447 GTEST_LOG_(INFO)
448 << "LocatorSkeletonTest, PreIsGeoConvertAvailable, TestSize.Level1";
449 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreIsGeoConvertAvailable begin");
450 auto locatorAbilityStub = sptr<MockLocatorAbilityStub>(new (std::nothrow) MockLocatorAbilityStub());
451 MessageParcel data;
452 MessageParcel reply;
453 AppIdentity identity;
454 locatorAbilityStub->PreIsGeoConvertAvailable(data, reply, identity);
455 identity.SetPid(1);
456 identity.SetUid(2);
457 uint32_t tokenId = static_cast<uint32_t>(tokenId_);
458 identity.SetTokenId(tokenId);
459 identity.SetFirstTokenId(0);
460 identity.SetBundleName("bundleName");
461 auto result = locatorAbilityStub->PreIsGeoConvertAvailable(data, reply, identity);
462 EXPECT_EQ(ERRCODE_SUCCESS, result);
463 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreIsGeoConvertAvailable end");
464 }
465 #endif
466
467 #ifdef FEATURE_GEOCODE_SUPPORT
468 HWTEST_F(LocatorSkeletonTest, PreGetAddressByCoordinate, TestSize.Level1)
469 {
470 GTEST_LOG_(INFO)
471 << "LocatorSkeletonTest, PreGetAddressByCoordinate, TestSize.Level1";
472 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreGetAddressByCoordinate begin");
473 auto locatorAbilityStub = sptr<MockLocatorAbilityStub>(new (std::nothrow) MockLocatorAbilityStub());
474 MessageParcel data;
475 MessageParcel reply;
476 AppIdentity identity;
477 identity.SetPid(1);
478 identity.SetUid(2);
479 uint32_t tokenId = static_cast<uint32_t>(tokenId_);
480 identity.SetTokenId(tokenId);
481 identity.SetFirstTokenId(0);
482 identity.SetBundleName("bundleName");
483 auto result = locatorAbilityStub->PreGetAddressByCoordinate(data, reply, identity);
484 EXPECT_EQ(ERRCODE_SUCCESS, result);
485 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreGetAddressByCoordinate end");
486 }
487 #endif
488
489 #ifdef FEATURE_GEOCODE_SUPPORT
490 HWTEST_F(LocatorSkeletonTest, PreGetAddressByLocationName, TestSize.Level1)
491 {
492 GTEST_LOG_(INFO)
493 << "LocatorSkeletonTest, PreGetAddressByLocationName, TestSize.Level1";
494 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreGetAddressByLocationName begin");
495 auto locatorAbilityStub = sptr<MockLocatorAbilityStub>(new (std::nothrow) MockLocatorAbilityStub());
496 MessageParcel data;
497 MessageParcel reply;
498 AppIdentity identity;
499 identity.SetPid(1);
500 identity.SetUid(2);
501 uint32_t tokenId = static_cast<uint32_t>(tokenId_);
502 identity.SetTokenId(tokenId);
503 identity.SetFirstTokenId(0);
504 identity.SetBundleName("bundleName");
505 auto result = locatorAbilityStub->PreGetAddressByLocationName(data, reply, identity);
506 EXPECT_EQ(ERRCODE_SUCCESS, result);
507 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreGetAddressByLocationName end");
508 }
509 #endif
510
511 #ifdef FEATURE_GEOCODE_SUPPORT
512 HWTEST_F(LocatorSkeletonTest, PreUnregisterSwitchCallback, TestSize.Level1)
513 {
514 GTEST_LOG_(INFO)
515 << "LocatorSkeletonTest, PreUnregisterSwitchCallback, TestSize.Level1";
516 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreUnregisterSwitchCallback begin");
517 auto locatorAbilityStub = sptr<MockLocatorAbilityStub>(new (std::nothrow) MockLocatorAbilityStub());
518 MessageParcel data;
519 MessageParcel reply;
520 AppIdentity identity;
521 identity.SetPid(1);
522 identity.SetUid(2);
523 uint32_t tokenId = static_cast<uint32_t>(tokenId_);
524 identity.SetTokenId(tokenId);
525 identity.SetFirstTokenId(0);
526 identity.SetBundleName("bundleName");
527 auto result = locatorAbilityStub->PreUnregisterSwitchCallback(data, reply, identity);
528 EXPECT_EQ(ERRCODE_SUCCESS, result);
529 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreUnregisterSwitchCallback end");
530 }
531 #endif
532
533 #ifdef FEATURE_GNSS_SUPPORT
534 HWTEST_F(LocatorSkeletonTest, PreRegisterGnssStatusCallback, TestSize.Level1)
535 {
536 GTEST_LOG_(INFO)
537 << "LocatorSkeletonTest, PreRegisterGnssStatusCallback, TestSize.Level1";
538 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreRegisterGnssStatusCallback begin");
539 auto locatorAbilityStub = sptr<MockLocatorAbilityStub>(new (std::nothrow) MockLocatorAbilityStub());
540 MessageParcel data;
541 MessageParcel reply;
542 AppIdentity identity;
543 locatorAbilityStub->PreRegisterGnssStatusCallback(data, reply, identity);
544 identity.SetPid(1);
545 identity.SetUid(2);
546 uint32_t tokenId = static_cast<uint32_t>(tokenId_);
547 identity.SetTokenId(tokenId);
548 identity.SetFirstTokenId(0);
549 identity.SetBundleName("bundleName");
550 bool isSwitchEnable = LocationDataRdbManager::QuerySwitchState() == ENABLED ? true : false;
551 if (isSwitchEnable) {
552 auto result = locatorAbilityStub->PreRegisterGnssStatusCallback(data, reply, identity);
553 EXPECT_EQ(ERRCODE_SUCCESS, result);
554 LocationDataRdbManager::SetSwitchStateToSysparaForCurrentUser(DISABLED);
555 locatorAbilityStub->PreRegisterGnssStatusCallback(data, reply, identity);
556 LocationDataRdbManager::SetSwitchStateToSysparaForCurrentUser(ENABLED);
557 } else {
558 locatorAbilityStub->PreRegisterGnssStatusCallback(data, reply, identity);
559 }
560 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreRegisterGnssStatusCallback end");
561 }
562 #endif
563
564 #ifdef FEATURE_GNSS_SUPPORT
565 HWTEST_F(LocatorSkeletonTest, PreUnregisterGnssStatusCallback001, TestSize.Level1)
566 {
567 GTEST_LOG_(INFO)
568 << "LocatorSkeletonTest, PreUnregisterGnssStatusCallback001, TestSize.Level1";
569 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreUnregisterGnssStatusCallback001 begin");
570 auto locatorAbilityStub = sptr<MockLocatorAbilityStub>(new (std::nothrow) MockLocatorAbilityStub());
571 MessageParcel data;
572 MessageParcel reply;
573 AppIdentity identity;
574 locatorAbilityStub->PreRegisterGnssStatusCallback(data, reply, identity);
575 identity.SetPid(1);
576 identity.SetUid(2);
577 uint32_t tokenId = static_cast<uint32_t>(tokenId_);
578 identity.SetTokenId(tokenId);
579 identity.SetFirstTokenId(0);
580 identity.SetBundleName("bundleName");
581 auto result = locatorAbilityStub->PreUnregisterGnssStatusCallback(data, reply, identity);
582 EXPECT_EQ(ERRCODE_SUCCESS, result);
583 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreUnregisterGnssStatusCallback001 end");
584 }
585 #endif
586
587 #ifdef FEATURE_GNSS_SUPPORT
588 HWTEST_F(LocatorSkeletonTest, PreUnregisterGnssStatusCallback002, TestSize.Level1)
589 {
590 GTEST_LOG_(INFO)
591 << "LocatorSkeletonTest, PreUnregisterGnssStatusCallback002, TestSize.Level1";
592 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreUnregisterGnssStatusCallback002 begin");
593 auto locatorAbilityStub = sptr<MockLocatorAbilityStub>(new (std::nothrow) MockLocatorAbilityStub());
594 MessageParcel data;
595 MessageParcel reply;
596 AppIdentity identity;
597 locatorAbilityStub->PreRegisterGnssStatusCallback(data, reply, identity);
598 identity.SetPid(1);
599 identity.SetUid(2);
600 uint32_t tokenId = static_cast<uint32_t>(tokenId4_);
601 identity.SetTokenId(tokenId);
602 identity.SetFirstTokenId(0);
603 identity.SetBundleName("bundleName");
604 auto result = locatorAbilityStub->PreUnregisterGnssStatusCallback(data, reply, identity);
605 EXPECT_NE(ERRCODE_SUCCESS, result);
606 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreUnregisterGnssStatusCallback002 end");
607 }
608 #endif
609
610 #ifdef FEATURE_GNSS_SUPPORT
611 HWTEST_F(LocatorSkeletonTest, PreRegisterNmeaMessageCallback001, TestSize.Level1)
612 {
613 GTEST_LOG_(INFO)
614 << "LocatorSkeletonTest, PreRegisterNmeaMessageCallback001, TestSize.Level1";
615 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreRegisterNmeaMessageCallback001 begin");
616 auto locatorAbilityStub = sptr<MockLocatorAbilityStub>(new (std::nothrow) MockLocatorAbilityStub());
617 MessageParcel data;
618 MessageParcel reply;
619 AppIdentity identity;
620 locatorAbilityStub->PreRegisterGnssStatusCallback(data, reply, identity);
621 identity.SetPid(1);
622 identity.SetUid(2);
623 uint32_t tokenId = static_cast<uint32_t>(tokenId_);
624 identity.SetTokenId(tokenId);
625 identity.SetFirstTokenId(0);
626 identity.SetBundleName("bundleName");
627 bool isSwitchEnable = LocationDataRdbManager::QuerySwitchState() == ENABLED ? true : false;
628 if (isSwitchEnable) {
629 auto result = locatorAbilityStub->PreRegisterNmeaMessageCallback(data, reply, identity);
630 EXPECT_EQ(ERRCODE_SUCCESS, result);
631 LocationDataRdbManager::SetSwitchStateToSysparaForCurrentUser(DISABLED);
632 locatorAbilityStub->PreRegisterNmeaMessageCallback(data, reply, identity);
633 LocationDataRdbManager::SetSwitchStateToSysparaForCurrentUser(ENABLED);
634 } else {
635 locatorAbilityStub->PreRegisterNmeaMessageCallback(data, reply, identity);
636 }
637 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreRegisterNmeaMessageCallback001 end");
638 }
639 #endif
640
641 #ifdef FEATURE_GNSS_SUPPORT
642 HWTEST_F(LocatorSkeletonTest, PreRegisterNmeaMessageCallback002, TestSize.Level1)
643 {
644 GTEST_LOG_(INFO)
645 << "LocatorSkeletonTest, PreRegisterNmeaMessageCallback002, TestSize.Level1";
646 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreRegisterNmeaMessageCallback002 begin");
647 auto locatorAbilityStub = sptr<MockLocatorAbilityStub>(new (std::nothrow) MockLocatorAbilityStub());
648 MessageParcel data;
649 MessageParcel reply;
650 AppIdentity identity;
651 locatorAbilityStub->PreRegisterGnssStatusCallback(data, reply, identity);
652 identity.SetPid(1);
653 identity.SetUid(2);
654 uint32_t tokenId = static_cast<uint32_t>(tokenId4_);
655 identity.SetTokenId(tokenId);
656 identity.SetFirstTokenId(0);
657 identity.SetBundleName("bundleName");
658 bool isSwitchEnable = LocationDataRdbManager::QuerySwitchState() == ENABLED ? true : false;
659 if (isSwitchEnable) {
660 auto result = locatorAbilityStub->PreRegisterNmeaMessageCallback(data, reply, identity);
661 EXPECT_NE(ERRCODE_SUCCESS, result);
662 LocationDataRdbManager::SetSwitchStateToSysparaForCurrentUser(DISABLED);
663 locatorAbilityStub->PreRegisterNmeaMessageCallback(data, reply, identity);
664 LocationDataRdbManager::SetSwitchStateToSysparaForCurrentUser(ENABLED);
665 } else {
666 locatorAbilityStub->PreRegisterNmeaMessageCallback(data, reply, identity);
667 }
668 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreRegisterNmeaMessageCallback002 end");
669 }
670 #endif
671
672 #ifdef FEATURE_GNSS_SUPPORT
673 HWTEST_F(LocatorSkeletonTest, PreUnregisterNmeaMessageCallback001, TestSize.Level1)
674 {
675 GTEST_LOG_(INFO)
676 << "LocatorSkeletonTest, PreUnregisterNmeaMessageCallback001, TestSize.Level1";
677 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreUnregisterNmeaMessageCallback001 begin");
678 auto locatorAbilityStub = sptr<MockLocatorAbilityStub>(new (std::nothrow) MockLocatorAbilityStub());
679 MessageParcel data;
680 MessageParcel reply;
681 AppIdentity identity;
682 identity.SetPid(1);
683 identity.SetUid(2);
684 uint32_t tokenId = static_cast<uint32_t>(tokenId_);
685 identity.SetTokenId(tokenId);
686 identity.SetFirstTokenId(0);
687 identity.SetBundleName("bundleName");
688 auto result = locatorAbilityStub->PreUnregisterNmeaMessageCallback(data, reply, identity);
689 EXPECT_EQ(ERRCODE_SUCCESS, result);
690 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreUnregisterNmeaMessageCallback001 end");
691 }
692 #endif
693
694 #ifdef FEATURE_GNSS_SUPPORT
695 HWTEST_F(LocatorSkeletonTest, PreUnregisterNmeaMessageCallback002, TestSize.Level1)
696 {
697 GTEST_LOG_(INFO)
698 << "LocatorSkeletonTest, PreUnregisterNmeaMessageCallback002, TestSize.Level1";
699 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreUnregisterNmeaMessageCallback002 begin");
700 auto locatorAbilityStub = sptr<MockLocatorAbilityStub>(new (std::nothrow) MockLocatorAbilityStub());
701 MessageParcel data;
702 MessageParcel reply;
703 AppIdentity identity;
704 identity.SetPid(1);
705 identity.SetUid(2);
706 uint32_t tokenId = static_cast<uint32_t>(tokenId4_);
707 identity.SetTokenId(tokenId);
708 identity.SetFirstTokenId(0);
709 identity.SetBundleName("bundleName");
710 auto result = locatorAbilityStub->PreUnregisterNmeaMessageCallback(data, reply, identity);
711 EXPECT_NE(ERRCODE_SUCCESS, result);
712 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreUnregisterNmeaMessageCallback002 end");
713 }
714 #endif
715
716 #ifdef FEATURE_GNSS_SUPPORT
717 HWTEST_F(LocatorSkeletonTest, PreRegisterNmeaMessageCallbackV9, TestSize.Level1)
718 {
719 GTEST_LOG_(INFO)
720 << "LocatorSkeletonTest, PreRegisterNmeaMessageCallbackV9, TestSize.Level1";
721 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreRegisterNmeaMessageCallbackV9 begin");
722 auto locatorAbilityStub = sptr<MockLocatorAbilityStub>(new (std::nothrow) MockLocatorAbilityStub());
723 MessageParcel data;
724 MessageParcel reply;
725 AppIdentity identity;
726 locatorAbilityStub->PreRegisterNmeaMessageCallbackV9(data, reply, identity);
727 identity.SetPid(1);
728 identity.SetUid(2);
729 uint32_t tokenId = static_cast<uint32_t>(tokenId_);
730 identity.SetTokenId(tokenId);
731 identity.SetFirstTokenId(0);
732 identity.SetBundleName("bundleName");
733 bool isSwitchEnable = LocationDataRdbManager::QuerySwitchState() == ENABLED ? true : false;
734 if (isSwitchEnable) {
735 auto result = locatorAbilityStub->PreRegisterNmeaMessageCallbackV9(data, reply, identity);
736 EXPECT_EQ(ERRCODE_SUCCESS, result);
737 LocationDataRdbManager::SetSwitchStateToSysparaForCurrentUser(DISABLED);
738 locatorAbilityStub->PreRegisterNmeaMessageCallbackV9(data, reply, identity);
739 LocationDataRdbManager::SetSwitchStateToSysparaForCurrentUser(ENABLED);
740 } else {
741 locatorAbilityStub->PreRegisterNmeaMessageCallbackV9(data, reply, identity);
742 }
743 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreRegisterNmeaMessageCallbackV9 end");
744 }
745 #endif
746
747 #ifdef FEATURE_GNSS_SUPPORT
748 HWTEST_F(LocatorSkeletonTest, PreUnregisterNmeaMessageCallbackV9, TestSize.Level1)
749 {
750 GTEST_LOG_(INFO)
751 << "LocatorSkeletonTest, PreUnregisterNmeaMessageCallbackV9, TestSize.Level1";
752 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreUnregisterNmeaMessageCallbackV9 begin");
753 auto locatorAbilityStub = sptr<MockLocatorAbilityStub>(new (std::nothrow) MockLocatorAbilityStub());
754 MessageParcel data;
755 MessageParcel reply;
756 AppIdentity identity;
757 locatorAbilityStub->PreUnregisterNmeaMessageCallbackV9(data, reply, identity);
758 identity.SetPid(1);
759 identity.SetUid(2);
760 uint32_t tokenId = static_cast<uint32_t>(tokenId_);
761 identity.SetTokenId(tokenId);
762 identity.SetFirstTokenId(0);
763 identity.SetBundleName("bundleName");
764 auto result = locatorAbilityStub->PreUnregisterNmeaMessageCallbackV9(data, reply, identity);
765 EXPECT_EQ(ERRCODE_SUCCESS, result);
766 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreUnregisterNmeaMessageCallbackV9 end");
767 }
768 #endif
769
770 HWTEST_F(LocatorSkeletonTest, PreIsLocationPrivacyConfirmed, TestSize.Level1)
771 {
772 GTEST_LOG_(INFO)
773 << "LocatorSkeletonTest, PreIsLocationPrivacyConfirmed, TestSize.Level1";
774 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreIsLocationPrivacyConfirmed begin");
775 auto locatorAbilityStub = sptr<MockLocatorAbilityStub>(new (std::nothrow) MockLocatorAbilityStub());
776 MessageParcel data;
777 MessageParcel reply;
778 AppIdentity identity;
779 locatorAbilityStub->PreIsLocationPrivacyConfirmed(data, reply, identity);
780 identity.SetPid(1);
781 identity.SetUid(2);
782 uint32_t tokenId = static_cast<uint32_t>(tokenId_);
783 identity.SetTokenId(tokenId);
784 identity.SetFirstTokenId(0);
785 identity.SetBundleName("bundleName");
786 auto result = locatorAbilityStub->PreIsLocationPrivacyConfirmed(data, reply, identity);
787 EXPECT_EQ(ERRCODE_SUCCESS, result);
788 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreIsLocationPrivacyConfirmed end");
789 }
790
791 HWTEST_F(LocatorSkeletonTest, PreSetLocationPrivacyConfirmStatus001, TestSize.Level1)
792 {
793 GTEST_LOG_(INFO)
794 << "LocatorSkeletonTest, PreSetLocationPrivacyConfirmStatus001, TestSize.Level1";
795 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreSetLocationPrivacyConfirmStatus001 begin");
796 auto locatorAbilityStub = sptr<MockLocatorAbilityStub>(new (std::nothrow) MockLocatorAbilityStub());
797 MessageParcel data;
798 MessageParcel reply;
799 AppIdentity identity;
800 locatorAbilityStub->PreSetLocationPrivacyConfirmStatus(data, reply, identity);
801 identity.SetPid(1);
802 identity.SetUid(2);
803 uint32_t tokenId = static_cast<uint32_t>(tokenId_);
804 identity.SetTokenId(tokenId);
805 identity.SetFirstTokenId(0);
806 identity.SetBundleName("bundleName");
807 auto result = locatorAbilityStub->PreSetLocationPrivacyConfirmStatus(data, reply, identity);
808 EXPECT_EQ(ERRCODE_SUCCESS, result);
809 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreSetLocationPrivacyConfirmStatus001 end");
810 }
811
812 HWTEST_F(LocatorSkeletonTest, PreSetLocationPrivacyConfirmStatus002, TestSize.Level1)
813 {
814 GTEST_LOG_(INFO)
815 << "LocatorSkeletonTest, PreSetLocationPrivacyConfirmStatus002, TestSize.Level1";
816 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreSetLocationPrivacyConfirmStatus002 begin");
817 auto locatorAbilityStub = sptr<MockLocatorAbilityStub>(new (std::nothrow) MockLocatorAbilityStub());
818 MessageParcel data;
819 MessageParcel reply;
820 AppIdentity identity;
821 locatorAbilityStub->PreSetLocationPrivacyConfirmStatus(data, reply, identity);
822 identity.SetPid(1);
823 identity.SetUid(2);
824 uint32_t tokenId = static_cast<uint32_t>(tokenId3_);
825 identity.SetTokenId(tokenId);
826 identity.SetFirstTokenId(0);
827 identity.SetBundleName("bundleName");
828 auto result = locatorAbilityStub->PreSetLocationPrivacyConfirmStatus(data, reply, identity);
829 EXPECT_NE(ERRCODE_SUCCESS, result);
830 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreSetLocationPrivacyConfirmStatus002 end");
831 }
832
833 #ifdef FEATURE_GNSS_SUPPORT
834 HWTEST_F(LocatorSkeletonTest, PreStartCacheLocating001, TestSize.Level1)
835 {
836 GTEST_LOG_(INFO)
837 << "LocatorSkeletonTest, PreStartCacheLocating001, TestSize.Level1";
838 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreStartCacheLocating001 begin");
839 auto locatorAbilityStub = sptr<MockLocatorAbilityStub>(new (std::nothrow) MockLocatorAbilityStub());
840 MessageParcel data;
841 MessageParcel reply;
842 AppIdentity identity;
843 auto callback = sptr<LocatorCallbackNapi>(new (std::nothrow) LocatorCallbackNapi());
844 identity.SetPid(1);
845 identity.SetUid(2);
846 uint32_t tokenId = static_cast<uint32_t>(tokenId_);
847 identity.SetTokenId(tokenId);
848 identity.SetFirstTokenId(0);
849 identity.SetBundleName("bundleName");
850 data.WriteInt32(1);
851 data.WriteBool(true);
852 data.WriteRemoteObject(callback->AsObject());
853 bool isSwitchEnable = LocationDataRdbManager::QuerySwitchState() == ENABLED ? true : false;
854 if (isSwitchEnable) {
855 locatorAbilityStub->PreStartCacheLocating(data, reply, identity);
856 LocationDataRdbManager::SetSwitchStateToSysparaForCurrentUser(DISABLED);
857 locatorAbilityStub->PreStartCacheLocating(data, reply, identity);
858 LocationDataRdbManager::SetSwitchStateToSysparaForCurrentUser(ENABLED);
859 } else {
860 locatorAbilityStub->PreStartCacheLocating(data, reply, identity);
861 }
862 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreStartCacheLocating001 end");
863 }
864
865 HWTEST_F(LocatorSkeletonTest, PreStartCacheLocating002, TestSize.Level1)
866 {
867 GTEST_LOG_(INFO)
868 << "LocatorSkeletonTest, PreStartCacheLocating002, TestSize.Level1";
869 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreStartCacheLocating002 begin");
870 auto locatorAbilityStub = sptr<MockLocatorAbilityStub>(new (std::nothrow) MockLocatorAbilityStub());
871 MessageParcel data;
872 MessageParcel reply;
873 AppIdentity identity;
874 auto callback = sptr<LocatorCallbackNapi>(new (std::nothrow) LocatorCallbackNapi());
875 identity.SetPid(1);
876 identity.SetUid(2);
877 uint32_t tokenId = static_cast<uint32_t>(tokenId4_);
878 identity.SetTokenId(tokenId);
879 identity.SetFirstTokenId(0);
880 identity.SetBundleName("bundleName");
881 data.WriteInt32(1);
882 data.WriteBool(true);
883 data.WriteRemoteObject(callback->AsObject());
884 bool isSwitchEnable = LocationDataRdbManager::QuerySwitchState() == ENABLED ? true : false;
885 if (isSwitchEnable) {
886 locatorAbilityStub->PreStartCacheLocating(data, reply, identity);
887 LocationDataRdbManager::SetSwitchStateToSysparaForCurrentUser(DISABLED);
888 locatorAbilityStub->PreStartCacheLocating(data, reply, identity);
889 LocationDataRdbManager::SetSwitchStateToSysparaForCurrentUser(ENABLED);
890 } else {
891 locatorAbilityStub->PreStartCacheLocating(data, reply, identity);
892 }
893 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreStartCacheLocating002 end");
894 }
895
896 HWTEST_F(LocatorSkeletonTest, PreStopCacheLocating001, TestSize.Level1)
897 {
898 GTEST_LOG_(INFO)
899 << "LocatorSkeletonTest, PreStopCacheLocating001, TestSize.Level1";
900 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreStopCacheLocating001 begin");
901 auto locatorAbilityStub = sptr<MockLocatorAbilityStub>(new (std::nothrow) MockLocatorAbilityStub());
902 MessageParcel data;
903 MessageParcel reply;
904 AppIdentity identity;
905 identity.SetPid(1);
906 identity.SetUid(2);
907 uint32_t tokenId = static_cast<uint32_t>(tokenId_);
908 identity.SetTokenId(tokenId);
909 identity.SetFirstTokenId(0);
910 identity.SetBundleName("bundleName");
911 auto callback = sptr<LocatorCallbackNapi>(new (std::nothrow) LocatorCallbackNapi());
912 data.WriteInt32(1);
913 data.WriteBool(true);
914 data.WriteRemoteObject(callback->AsObject());
915 locatorAbilityStub->PreStopCacheLocating(data, reply, identity);
916 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreStopCacheLocating001 end");
917 }
918
919 HWTEST_F(LocatorSkeletonTest, PreStopCacheLocating002, TestSize.Level1)
920 {
921 GTEST_LOG_(INFO)
922 << "LocatorSkeletonTest, PreStopCacheLocating002, TestSize.Level1";
923 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreStopCacheLocating002 begin");
924 auto locatorAbilityStub = sptr<MockLocatorAbilityStub>(new (std::nothrow) MockLocatorAbilityStub());
925 MessageParcel data;
926 MessageParcel reply;
927 AppIdentity identity;
928 identity.SetPid(1);
929 identity.SetUid(2);
930 uint32_t tokenId = static_cast<uint32_t>(tokenId4_);
931 identity.SetTokenId(tokenId);
932 identity.SetFirstTokenId(0);
933 identity.SetBundleName("bundleName");
934 auto callback = sptr<LocatorCallbackNapi>(new (std::nothrow) LocatorCallbackNapi());
935 data.WriteInt32(1);
936 data.WriteBool(true);
937 data.WriteRemoteObject(callback->AsObject());
938 locatorAbilityStub->PreStopCacheLocating(data, reply, identity);
939 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreStopCacheLocating002 end");
940 }
941
942 HWTEST_F(LocatorSkeletonTest, PreGetCachedGnssLocationsSize, TestSize.Level1)
943 {
944 GTEST_LOG_(INFO)
945 << "LocatorSkeletonTest, PreGetCachedGnssLocationsSize, TestSize.Level1";
946 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreGetCachedGnssLocationsSize begin");
947 auto locatorAbilityStub = sptr<MockLocatorAbilityStub>(new (std::nothrow) MockLocatorAbilityStub());
948 MessageParcel data;
949 MessageParcel reply;
950 AppIdentity identity;
951 locatorAbilityStub->PreGetCachedGnssLocationsSize(data, reply, identity);
952 identity.SetPid(1);
953 identity.SetUid(2);
954 uint32_t tokenId = static_cast<uint32_t>(tokenId_);
955 identity.SetTokenId(tokenId);
956 identity.SetFirstTokenId(0);
957 identity.SetBundleName("bundleName");
958 bool isSwitchEnable = LocationDataRdbManager::QuerySwitchState() == ENABLED ? true : false;
959 if (isSwitchEnable) {
960 auto result = locatorAbilityStub->PreGetCachedGnssLocationsSize(data, reply, identity);
961 EXPECT_EQ(ERRCODE_SUCCESS, result);
962 LocationDataRdbManager::SetSwitchStateToSysparaForCurrentUser(DISABLED);
963 locatorAbilityStub->PreGetCachedGnssLocationsSize(data, reply, identity);
964 LocationDataRdbManager::SetSwitchStateToSysparaForCurrentUser(ENABLED);
965 }
966 locatorAbilityStub->PreGetCachedGnssLocationsSize(data, reply, identity);
967 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreGetCachedGnssLocationsSize end");
968 }
969
970 HWTEST_F(LocatorSkeletonTest, PreFlushCachedGnssLocations, TestSize.Level1)
971 {
972 GTEST_LOG_(INFO)
973 << "LocatorSkeletonTest, PreFlushCachedGnssLocations, TestSize.Level1";
974 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreFlushCachedGnssLocations begin");
975 auto locatorAbilityStub = sptr<MockLocatorAbilityStub>(new (std::nothrow) MockLocatorAbilityStub());
976 MessageParcel data;
977 MessageParcel reply;
978 AppIdentity identity;
979 locatorAbilityStub->PreFlushCachedGnssLocations(data, reply, identity);
980 identity.SetPid(1);
981 identity.SetUid(2);
982 uint32_t tokenId = static_cast<uint32_t>(tokenId_);
983 identity.SetTokenId(tokenId);
984 identity.SetFirstTokenId(0);
985 identity.SetBundleName("bundleName");
986 bool isSwitchEnable = LocationDataRdbManager::QuerySwitchState() == ENABLED ? true : false;
987 if (isSwitchEnable) {
988 auto result = locatorAbilityStub->PreFlushCachedGnssLocations(data, reply, identity);
989 EXPECT_EQ(ERRCODE_SUCCESS, result);
990 LocationDataRdbManager::SetSwitchStateToSysparaForCurrentUser(DISABLED);
991 locatorAbilityStub->PreFlushCachedGnssLocations(data, reply, identity);
992 LocationDataRdbManager::SetSwitchStateToSysparaForCurrentUser(ENABLED);
993 } else {
994 locatorAbilityStub->PreFlushCachedGnssLocations(data, reply, identity);
995 }
996 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreFlushCachedGnssLocations end");
997 }
998
999 HWTEST_F(LocatorSkeletonTest, PreSendCommand, TestSize.Level1)
1000 {
1001 GTEST_LOG_(INFO)
1002 << "LocatorSkeletonTest, PreSendCommand, TestSize.Level1";
1003 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreSendCommand begin");
1004 auto locatorAbilityStub = sptr<MockLocatorAbilityStub>(new (std::nothrow) MockLocatorAbilityStub());
1005 MessageParcel data;
1006 MessageParcel reply;
1007 AppIdentity identity;
1008 locatorAbilityStub->PreSendCommand(data, reply, identity);
1009 identity.SetPid(1);
1010 identity.SetUid(2);
1011 uint32_t tokenId = static_cast<uint32_t>(tokenId_);
1012 identity.SetTokenId(tokenId);
1013 identity.SetFirstTokenId(0);
1014 identity.SetBundleName("bundleName");
1015 auto result = locatorAbilityStub->PreSendCommand(data, reply, identity);
1016 EXPECT_EQ(ERRCODE_SUCCESS, result);
1017 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreSendCommand end");
1018 }
1019
1020 HWTEST_F(LocatorSkeletonTest, PreAddFence, TestSize.Level1)
1021 {
1022 GTEST_LOG_(INFO)
1023 << "LocatorSkeletonTest, PreAddFence, TestSize.Level1";
1024 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreAddFence begin");
1025 auto locatorAbilityStub = sptr<MockLocatorAbilityStub>(new (std::nothrow) MockLocatorAbilityStub());
1026 MessageParcel data;
1027 MessageParcel reply;
1028 AppIdentity identity;
1029 locatorAbilityStub->PreAddFence(data, reply, identity);
1030 identity.SetPid(1);
1031 identity.SetUid(2);
1032 uint32_t tokenId = static_cast<uint32_t>(tokenId_);
1033 identity.SetTokenId(tokenId);
1034 identity.SetFirstTokenId(0);
1035 identity.SetBundleName("bundleName");
1036 auto result = locatorAbilityStub->PreAddFence(data, reply, identity);
1037 EXPECT_EQ(ERRCODE_SUCCESS, result);
1038 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreAddFence end");
1039 }
1040
1041
1042 HWTEST_F(LocatorSkeletonTest, PreRemoveFence, TestSize.Level1)
1043 {
1044 GTEST_LOG_(INFO)
1045 << "LocatorSkeletonTest, PreRemoveFence, TestSize.Level1";
1046 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreRemoveFence begin");
1047 auto locatorAbilityStub = sptr<MockLocatorAbilityStub>(new (std::nothrow) MockLocatorAbilityStub());
1048 MessageParcel data;
1049 MessageParcel reply;
1050 AppIdentity identity;
1051 identity.SetPid(1);
1052 identity.SetUid(2);
1053 uint32_t tokenId = static_cast<uint32_t>(tokenId_);
1054 identity.SetTokenId(tokenId);
1055 identity.SetFirstTokenId(0);
1056 identity.SetBundleName("bundleName");
1057 auto result = locatorAbilityStub->PreRemoveFence(data, reply, identity);
1058 EXPECT_EQ(ERRCODE_SUCCESS, result);
1059 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreRemoveFence end");
1060 }
1061
1062 HWTEST_F(LocatorSkeletonTest, DoProcessFenceRequest, TestSize.Level1)
1063 {
1064 GTEST_LOG_(INFO)
1065 << "LocatorSkeletonTest, DoProcessFenceRequest, TestSize.Level1";
1066 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] DoProcessFenceRequest begin");
1067 auto locatorAbilityStub = sptr<MockLocatorAbilityStub>(new (std::nothrow) MockLocatorAbilityStub());
1068 MessageParcel data;
1069 MessageParcel reply;
1070 AppIdentity identity;
1071 identity.SetPid(1);
1072 identity.SetUid(2);
1073 uint32_t tokenId = static_cast<uint32_t>(tokenId_);
1074 identity.SetTokenId(tokenId);
1075 identity.SetFirstTokenId(0);
1076 identity.SetBundleName("bundleName");
1077 bool isSwitchEnable = LocationDataRdbManager::QuerySwitchState() == ENABLED ? true : false;
1078 if (isSwitchEnable) {
1079 locatorAbilityStub->DoProcessFenceRequest(LocatorInterfaceCode::ADD_FENCE, data, reply, identity);
1080 LocationDataRdbManager::SetSwitchStateToSysparaForCurrentUser(DISABLED);
1081 locatorAbilityStub->DoProcessFenceRequest(LocatorInterfaceCode::ADD_FENCE, data, reply, identity);
1082 LocationDataRdbManager::SetSwitchStateToSysparaForCurrentUser(ENABLED);
1083 } else {
1084 locatorAbilityStub->DoProcessFenceRequest(LocatorInterfaceCode::ADD_FENCE, data, reply, identity);
1085 }
1086 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] DoProcessFenceRequest end");
1087 }
1088
1089 HWTEST_F(LocatorSkeletonTest, PreAddGnssGeofence, TestSize.Level1)
1090 {
1091 GTEST_LOG_(INFO)
1092 << "LocatorSkeletonTest, PreAddGnssGeofence, TestSize.Level1";
1093 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreAddGnssGeofence begin");
1094 auto locatorAbilityStub = sptr<MockLocatorAbilityStub>(new (std::nothrow) MockLocatorAbilityStub());
1095 MessageParcel data;
1096 MessageParcel reply;
1097 AppIdentity identity;
1098 identity.SetPid(1);
1099 identity.SetUid(2);
1100 uint32_t tokenId = static_cast<uint32_t>(tokenId_);
1101 identity.SetTokenId(tokenId);
1102 identity.SetFirstTokenId(0);
1103 identity.SetBundleName("bundleName");
1104 bool isSwitchEnable = LocationDataRdbManager::QuerySwitchState() == ENABLED ? true : false;
1105 if (isSwitchEnable) {
1106 auto result = locatorAbilityStub->PreAddGnssGeofence(data, reply, identity);
1107 EXPECT_EQ(ERRCODE_SUCCESS, result);
1108 LocationDataRdbManager::SetSwitchStateToSysparaForCurrentUser(DISABLED);
1109 locatorAbilityStub->PreAddGnssGeofence(data, reply, identity);
1110 LocationDataRdbManager::SetSwitchStateToSysparaForCurrentUser(ENABLED);
1111 }
1112 locatorAbilityStub->PreAddGnssGeofence(data, reply, identity);
1113 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreAddGnssGeofence end");
1114 }
1115
1116 HWTEST_F(LocatorSkeletonTest, PreRemoveGnssGeofence, TestSize.Level1)
1117 {
1118 GTEST_LOG_(INFO)
1119 << "LocatorSkeletonTest, PreRemoveGnssGeofence, TestSize.Level1";
1120 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreRemoveGnssGeofence begin");
1121 auto locatorAbilityStub = sptr<MockLocatorAbilityStub>(new (std::nothrow) MockLocatorAbilityStub());
1122 MessageParcel data;
1123 MessageParcel reply;
1124 AppIdentity identity;
1125 identity.SetPid(1);
1126 identity.SetUid(2);
1127 uint32_t tokenId = static_cast<uint32_t>(tokenId_);
1128 identity.SetTokenId(tokenId);
1129 identity.SetFirstTokenId(0);
1130 identity.SetBundleName("bundleName");
1131 bool isSwitchEnable = LocationDataRdbManager::QuerySwitchState() == ENABLED ? true : false;
1132 if (isSwitchEnable) {
1133 auto result = locatorAbilityStub->PreRemoveGnssGeofence(data, reply, identity);
1134 EXPECT_EQ(ERRCODE_SUCCESS, result);
1135 LocationDataRdbManager::SetSwitchStateToSysparaForCurrentUser(DISABLED);
1136 locatorAbilityStub->PreRemoveGnssGeofence(data, reply, identity);
1137 LocationDataRdbManager::SetSwitchStateToSysparaForCurrentUser(ENABLED);
1138 } else {
1139 locatorAbilityStub->PreRemoveGnssGeofence(data, reply, identity);
1140 }
1141 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreRemoveGnssGeofence end");
1142 }
1143 #endif
1144
1145 HWTEST_F(LocatorSkeletonTest, PreEnableLocationMock001, TestSize.Level1)
1146 {
1147 GTEST_LOG_(INFO)
1148 << "LocatorSkeletonTest, PreEnableLocationMock001, TestSize.Level1";
1149 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreEnableLocationMock001 begin");
1150 auto locatorAbilityStub = sptr<MockLocatorAbilityStub>(new (std::nothrow) MockLocatorAbilityStub());
1151 MessageParcel data;
1152 MessageParcel reply;
1153 AppIdentity identity;
1154 identity.SetPid(1);
1155 identity.SetUid(2);
1156 uint32_t tokenId = static_cast<uint32_t>(tokenId_);
1157 identity.SetTokenId(tokenId);
1158 identity.SetFirstTokenId(0);
1159 identity.SetBundleName("bundleName");
1160 locatorAbilityStub->PreEnableLocationMock(data, reply, identity);
1161 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreEnableLocationMock001 end");
1162 }
1163
1164 HWTEST_F(LocatorSkeletonTest, PreEnableLocationMock002, TestSize.Level1)
1165 {
1166 GTEST_LOG_(INFO)
1167 << "LocatorSkeletonTest, PreEnableLocationMock002, TestSize.Level1";
1168 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreEnableLocationMock002 begin");
1169 auto locatorAbilityStub = sptr<MockLocatorAbilityStub>(new (std::nothrow) MockLocatorAbilityStub());
1170 MessageParcel data;
1171 MessageParcel reply;
1172 AppIdentity identity;
1173 identity.SetPid(1);
1174 identity.SetUid(2);
1175 uint32_t tokenId = static_cast<uint32_t>(tokenId2_);
1176 identity.SetTokenId(tokenId);
1177 identity.SetFirstTokenId(0);
1178 identity.SetBundleName("bundleName");
1179 locatorAbilityStub->PreEnableLocationMock(data, reply, identity);
1180 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreEnableLocationMock002 end");
1181 }
1182
1183 HWTEST_F(LocatorSkeletonTest, PreDisableLocationMock001, TestSize.Level1)
1184 {
1185 GTEST_LOG_(INFO)
1186 << "LocatorSkeletonTest, PreDisableLocationMock001, TestSize.Level1";
1187 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreDisableLocationMock001 begin");
1188 auto locatorAbilityStub = sptr<MockLocatorAbilityStub>(new (std::nothrow) MockLocatorAbilityStub());
1189 MessageParcel data;
1190 MessageParcel reply;
1191 AppIdentity identity;
1192 identity.SetPid(1);
1193 identity.SetUid(2);
1194 uint32_t tokenId = static_cast<uint32_t>(tokenId_);
1195 identity.SetTokenId(tokenId);
1196 identity.SetFirstTokenId(0);
1197 identity.SetBundleName("bundleName");
1198 locatorAbilityStub->PreDisableLocationMock(data, reply, identity);
1199 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreDisableLocationMock001 end");
1200 }
1201
1202 HWTEST_F(LocatorSkeletonTest, PreDisableLocationMock002, TestSize.Level1)
1203 {
1204 GTEST_LOG_(INFO)
1205 << "LocatorSkeletonTest, PreDisableLocationMock002, TestSize.Level1";
1206 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreDisableLocationMock002 begin");
1207 auto locatorAbilityStub = sptr<MockLocatorAbilityStub>(new (std::nothrow) MockLocatorAbilityStub());
1208 MessageParcel data;
1209 MessageParcel reply;
1210 AppIdentity identity;
1211 identity.SetPid(1);
1212 identity.SetUid(2);
1213 uint32_t tokenId = static_cast<uint32_t>(tokenId2_);
1214 identity.SetTokenId(tokenId);
1215 identity.SetFirstTokenId(0);
1216 identity.SetBundleName("bundleName");
1217 locatorAbilityStub->PreDisableLocationMock(data, reply, identity);
1218 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreDisableLocationMock002 end");
1219 }
1220
1221 HWTEST_F(LocatorSkeletonTest, PreSetMockedLocations001, TestSize.Level1)
1222 {
1223 GTEST_LOG_(INFO)
1224 << "LocatorSkeletonTest, PreSetMockedLocations001, TestSize.Level1";
1225 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreSetMockedLocations001 begin");
1226 auto locatorAbilityStub = sptr<MockLocatorAbilityStub>(new (std::nothrow) MockLocatorAbilityStub());
1227 MessageParcel data;
1228 MessageParcel reply;
1229 AppIdentity identity;
1230 identity.SetPid(1);
1231 identity.SetUid(2);
1232 uint32_t tokenId = static_cast<uint32_t>(tokenId_);
1233 identity.SetTokenId(tokenId);
1234 identity.SetFirstTokenId(0);
1235 identity.SetBundleName("bundleName");
1236 locatorAbilityStub->PreSetMockedLocations(data, reply, identity);
1237 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreSetMockedLocations001 end");
1238 }
1239
1240 HWTEST_F(LocatorSkeletonTest, PreSetMockedLocations002, TestSize.Level1)
1241 {
1242 GTEST_LOG_(INFO)
1243 << "LocatorSkeletonTest, PreSetMockedLocations002, TestSize.Level1";
1244 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreSetMockedLocations002 begin");
1245 auto locatorAbilityStub = sptr<MockLocatorAbilityStub>(new (std::nothrow) MockLocatorAbilityStub());
1246 MessageParcel data;
1247 MessageParcel reply;
1248 AppIdentity identity;
1249 identity.SetPid(1);
1250 identity.SetUid(2);
1251 uint32_t tokenId = static_cast<uint32_t>(tokenId2_);
1252 identity.SetTokenId(tokenId);
1253 identity.SetFirstTokenId(0);
1254 identity.SetBundleName("bundleName");
1255 locatorAbilityStub->PreSetMockedLocations(data, reply, identity);
1256 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreSetMockedLocations002 end");
1257 }
1258
1259 HWTEST_F(LocatorSkeletonTest, PreEnableReverseGeocodingMock001, TestSize.Level1)
1260 {
1261 GTEST_LOG_(INFO)
1262 << "LocatorSkeletonTest, PreEnableReverseGeocodingMock001, TestSize.Level1";
1263 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreEnableReverseGeocodingMock001 begin");
1264 auto locatorAbilityStub = sptr<MockLocatorAbilityStub>(new (std::nothrow) MockLocatorAbilityStub());
1265 MessageParcel data;
1266 MessageParcel reply;
1267 AppIdentity identity;
1268 identity.SetPid(1);
1269 identity.SetUid(2);
1270 uint32_t tokenId = static_cast<uint32_t>(tokenId_);
1271 identity.SetTokenId(tokenId);
1272 identity.SetFirstTokenId(0);
1273 identity.SetBundleName("bundleName");
1274 locatorAbilityStub->PreEnableReverseGeocodingMock(data, reply, identity);
1275 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreEnableReverseGeocodingMock001 end");
1276 }
1277
1278 HWTEST_F(LocatorSkeletonTest, PreEnableReverseGeocodingMock002, TestSize.Level1)
1279 {
1280 GTEST_LOG_(INFO)
1281 << "LocatorSkeletonTest, PreEnableReverseGeocodingMock002, TestSize.Level1";
1282 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreEnableReverseGeocodingMock002 begin");
1283 auto locatorAbilityStub = sptr<MockLocatorAbilityStub>(new (std::nothrow) MockLocatorAbilityStub());
1284 MessageParcel data;
1285 MessageParcel reply;
1286 AppIdentity identity;
1287 identity.SetPid(1);
1288 identity.SetUid(2);
1289 uint32_t tokenId = static_cast<uint32_t>(tokenId2_);
1290 identity.SetTokenId(tokenId);
1291 identity.SetFirstTokenId(0);
1292 identity.SetBundleName("bundleName");
1293 locatorAbilityStub->PreEnableReverseGeocodingMock(data, reply, identity);
1294 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreEnableReverseGeocodingMock002 end");
1295 }
1296
1297 HWTEST_F(LocatorSkeletonTest, PreDisableReverseGeocodingMock001, TestSize.Level1)
1298 {
1299 GTEST_LOG_(INFO)
1300 << "LocatorSkeletonTest, PreDisableReverseGeocodingMock001, TestSize.Level1";
1301 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreDisableReverseGeocodingMock001 begin");
1302 auto locatorAbilityStub = sptr<MockLocatorAbilityStub>(new (std::nothrow) MockLocatorAbilityStub());
1303 MessageParcel data;
1304 MessageParcel reply;
1305 AppIdentity identity;
1306 identity.SetPid(1);
1307 identity.SetUid(2);
1308 uint32_t tokenId = static_cast<uint32_t>(tokenId_);
1309 identity.SetTokenId(tokenId);
1310 identity.SetFirstTokenId(0);
1311 identity.SetBundleName("bundleName");
1312 locatorAbilityStub->PreDisableReverseGeocodingMock(data, reply, identity);
1313 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreDisableReverseGeocodingMock001 end");
1314 }
1315
1316 HWTEST_F(LocatorSkeletonTest, PreDisableReverseGeocodingMock002, TestSize.Level1)
1317 {
1318 GTEST_LOG_(INFO)
1319 << "LocatorSkeletonTest, PreDisableReverseGeocodingMock002, TestSize.Level1";
1320 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreDisableReverseGeocodingMock002 begin");
1321 auto locatorAbilityStub = sptr<MockLocatorAbilityStub>(new (std::nothrow) MockLocatorAbilityStub());
1322 MessageParcel data;
1323 MessageParcel reply;
1324 AppIdentity identity;
1325 identity.SetPid(1);
1326 identity.SetUid(2);
1327 uint32_t tokenId = static_cast<uint32_t>(tokenId2_);
1328 identity.SetTokenId(tokenId);
1329 identity.SetFirstTokenId(0);
1330 identity.SetBundleName("bundleName");
1331 locatorAbilityStub->PreDisableReverseGeocodingMock(data, reply, identity);
1332 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreDisableReverseGeocodingMock002 end");
1333 }
1334
1335 HWTEST_F(LocatorSkeletonTest, PreSetReverseGeocodingMockInfo001, TestSize.Level1)
1336 {
1337 GTEST_LOG_(INFO)
1338 << "LocatorSkeletonTest, PreSetReverseGeocodingMockInfo001, TestSize.Level1";
1339 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreSetReverseGeocodingMockInfo001 begin");
1340 auto locatorAbilityStub = sptr<MockLocatorAbilityStub>(new (std::nothrow) MockLocatorAbilityStub());
1341 MessageParcel data;
1342 MessageParcel reply;
1343 AppIdentity identity;
1344 identity.SetPid(1);
1345 identity.SetUid(2);
1346 uint32_t tokenId = static_cast<uint32_t>(tokenId_);
1347 identity.SetTokenId(tokenId);
1348 identity.SetFirstTokenId(0);
1349 identity.SetBundleName("bundleName");
1350 locatorAbilityStub->PreSetReverseGeocodingMockInfo(data, reply, identity);
1351 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreSetReverseGeocodingMockInfo001 end");
1352 }
1353
1354 HWTEST_F(LocatorSkeletonTest, PreSetReverseGeocodingMockInfo002, TestSize.Level1)
1355 {
1356 GTEST_LOG_(INFO)
1357 << "LocatorSkeletonTest, PreSetReverseGeocodingMockInfo002, TestSize.Level1";
1358 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreSetReverseGeocodingMockInfo002 begin");
1359 auto locatorAbilityStub = sptr<MockLocatorAbilityStub>(new (std::nothrow) MockLocatorAbilityStub());
1360 MessageParcel data;
1361 MessageParcel reply;
1362 AppIdentity identity;
1363 identity.SetPid(1);
1364 identity.SetUid(2);
1365 uint32_t tokenId = static_cast<uint32_t>(tokenId2_);
1366 identity.SetTokenId(tokenId);
1367 identity.SetFirstTokenId(0);
1368 identity.SetBundleName("bundleName");
1369 locatorAbilityStub->PreSetReverseGeocodingMockInfo(data, reply, identity);
1370 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreSetReverseGeocodingMockInfo002 end");
1371 }
1372
1373 HWTEST_F(LocatorSkeletonTest, PreProxyForFreeze, TestSize.Level1)
1374 {
1375 GTEST_LOG_(INFO)
1376 << "LocatorSkeletonTest, PreProxyForFreeze, TestSize.Level1";
1377 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreProxyForFreeze begin");
1378 auto locatorAbilityStub = sptr<MockLocatorAbilityStub>(new (std::nothrow) MockLocatorAbilityStub());
1379 MessageParcel data;
1380 MessageParcel reply;
1381 AppIdentity identity;
1382 identity.SetPid(1);
1383 identity.SetUid(2);
1384 uint32_t tokenId = static_cast<uint32_t>(tokenId_);
1385 identity.SetTokenId(tokenId);
1386 identity.SetFirstTokenId(0);
1387 identity.SetBundleName("bundleName");
1388 locatorAbilityStub->PreProxyForFreeze(data, reply, identity);
1389 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreProxyForFreeze end");
1390 }
1391
1392 HWTEST_F(LocatorSkeletonTest, PreResetAllProxy, TestSize.Level1)
1393 {
1394 GTEST_LOG_(INFO)
1395 << "LocatorSkeletonTest, PreResetAllProxy, TestSize.Level1";
1396 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreResetAllProxy begin");
1397 auto locatorAbilityStub = sptr<MockLocatorAbilityStub>(new (std::nothrow) MockLocatorAbilityStub());
1398 MessageParcel data;
1399 MessageParcel reply;
1400 AppIdentity identity;
1401 identity.SetPid(1);
1402 identity.SetUid(2);
1403 uint32_t tokenId = static_cast<uint32_t>(tokenId_);
1404 identity.SetTokenId(tokenId);
1405 identity.SetFirstTokenId(0);
1406 identity.SetBundleName("bundleName");
1407 locatorAbilityStub->PreResetAllProxy(data, reply, identity);
1408 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreResetAllProxy end");
1409 }
1410
1411 HWTEST_F(LocatorSkeletonTest, PreReportLocation, TestSize.Level1)
1412 {
1413 GTEST_LOG_(INFO)
1414 << "LocatorSkeletonTest, PreReportLocation, TestSize.Level1";
1415 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreReportLocation begin");
1416 auto locatorAbilityStub = sptr<MockLocatorAbilityStub>(new (std::nothrow) MockLocatorAbilityStub());
1417 MessageParcel data;
1418 MessageParcel reply;
1419 AppIdentity identity;
1420 identity.SetPid(1);
1421 identity.SetUid(2);
1422 uint32_t tokenId = static_cast<uint32_t>(tokenId_);
1423 identity.SetTokenId(tokenId);
1424 identity.SetFirstTokenId(0);
1425 identity.SetBundleName("bundleName");
1426 auto result = locatorAbilityStub->PreReportLocation(data, reply, identity);
1427 EXPECT_EQ(ERRCODE_SUCCESS, result);
1428 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreReportLocation end");
1429 }
1430
1431 HWTEST_F(LocatorSkeletonTest, PreRegisterLocatingRequiredDataCallback, TestSize.Level1)
1432 {
1433 GTEST_LOG_(INFO)
1434 << "LocatorSkeletonTest, PreRegisterLocatingRequiredDataCallback, TestSize.Level1";
1435 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreRegisterLocatingRequiredDataCallback begin");
1436 auto locatorAbilityStub = sptr<MockLocatorAbilityStub>(new (std::nothrow) MockLocatorAbilityStub());
1437 MessageParcel data;
1438 MessageParcel reply;
1439 AppIdentity identity;
1440 identity.SetPid(1);
1441 identity.SetUid(2);
1442 uint32_t tokenId = static_cast<uint32_t>(tokenId_);
1443 identity.SetTokenId(tokenId);
1444 identity.SetFirstTokenId(0);
1445 identity.SetBundleName("bundleName");
1446 locatorAbilityStub->PreRegisterLocatingRequiredDataCallback(data, reply, identity);
1447 locatorAbilityStub->PreUnregisterLocatingRequiredDataCallback(data, reply, identity);
1448 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreRegisterLocatingRequiredDataCallback end");
1449 }
1450
1451 HWTEST_F(LocatorSkeletonTest, PreUnregisterLocatingRequiredDataCallback, TestSize.Level1)
1452 {
1453 GTEST_LOG_(INFO)
1454 << "LocatorSkeletonTest, PreUnregisterLocatingRequiredDataCallback, TestSize.Level1";
1455 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreUnregisterLocatingRequiredDataCallback begin");
1456 auto locatorAbilityStub = sptr<MockLocatorAbilityStub>(new (std::nothrow) MockLocatorAbilityStub());
1457 MessageParcel data;
1458 MessageParcel reply;
1459 AppIdentity identity;
1460 identity.SetPid(1);
1461 identity.SetUid(2);
1462 uint32_t tokenId = static_cast<uint32_t>(tokenId_);
1463 identity.SetTokenId(tokenId);
1464 identity.SetFirstTokenId(0);
1465 identity.SetBundleName("bundleName");
1466 locatorAbilityStub->PreUnregisterLocatingRequiredDataCallback(data, reply, identity);
1467 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreUnregisterLocatingRequiredDataCallback end");
1468 }
1469
1470 #ifdef FEATURE_GNSS_SUPPORT
1471 HWTEST_F(LocatorSkeletonTest, PreQuerySupportCoordinateSystemType, TestSize.Level1)
1472 {
1473 GTEST_LOG_(INFO)
1474 << "LocatorSkeletonTest, PreQuerySupportCoordinateSystemType, TestSize.Level1";
1475 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreQuerySupportCoordinateSystemType begin");
1476 auto locatorAbilityStub = sptr<MockLocatorAbilityStub>(new (std::nothrow) MockLocatorAbilityStub());
1477 MessageParcel data;
1478 MessageParcel reply;
1479 AppIdentity identity;
1480 identity.SetPid(1);
1481 identity.SetUid(2);
1482 uint32_t tokenId = static_cast<uint32_t>(tokenId_);
1483 identity.SetTokenId(tokenId);
1484 identity.SetFirstTokenId(0);
1485 identity.SetBundleName("bundleName");
1486 locatorAbilityStub->PreQuerySupportCoordinateSystemType(data, reply, identity);
1487 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreQuerySupportCoordinateSystemType end");
1488 }
1489 #endif
1490
1491 HWTEST_F(LocatorSkeletonTest, PreRegisterLocationError001, TestSize.Level1)
1492 {
1493 GTEST_LOG_(INFO)
1494 << "LocatorSkeletonTest, PreRegisterLocationError001, TestSize.Level1";
1495 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreRegisterLocationError001 begin");
1496 auto locatorAbilityStub = sptr<MockLocatorAbilityStub>(new (std::nothrow) MockLocatorAbilityStub());
1497 MessageParcel data;
1498 MessageParcel reply;
1499 AppIdentity identity;
1500 identity.SetPid(1);
1501 identity.SetUid(2);
1502 uint32_t tokenId = static_cast<uint32_t>(tokenId_);
1503 identity.SetTokenId(tokenId);
1504 identity.SetFirstTokenId(0);
1505 identity.SetBundleName("bundleName");
1506 bool isSwitchEnable = LocationDataRdbManager::QuerySwitchState() == ENABLED ? true : false;
1507 if (isSwitchEnable) {
1508 locatorAbilityStub->PreRegisterLocationError(data, reply, identity);
1509 LocationDataRdbManager::SetSwitchStateToSysparaForCurrentUser(DISABLED);
1510 locatorAbilityStub->PreRegisterLocationError(data, reply, identity);
1511 LocationDataRdbManager::SetSwitchStateToSysparaForCurrentUser(ENABLED);
1512 } else {
1513 locatorAbilityStub->PreRegisterLocationError(data, reply, identity);
1514 }
1515 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreRegisterLocationError001 end");
1516 }
1517
1518 HWTEST_F(LocatorSkeletonTest, PreRegisterLocationError002, TestSize.Level1)
1519 {
1520 GTEST_LOG_(INFO)
1521 << "LocatorSkeletonTest, PreRegisterLocationError002, TestSize.Level1";
1522 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreRegisterLocationError002 begin");
1523 auto locatorAbilityStub = sptr<MockLocatorAbilityStub>(new (std::nothrow) MockLocatorAbilityStub());
1524 MessageParcel data;
1525 MessageParcel reply;
1526 AppIdentity identity;
1527 identity.SetPid(1);
1528 identity.SetUid(2);
1529 uint32_t tokenId = static_cast<uint32_t>(tokenId4_);
1530 identity.SetTokenId(tokenId);
1531 identity.SetFirstTokenId(0);
1532 identity.SetBundleName("bundleName");
1533 bool isSwitchEnable = LocationDataRdbManager::QuerySwitchState() == ENABLED ? true : false;
1534 if (isSwitchEnable) {
1535 locatorAbilityStub->PreRegisterLocationError(data, reply, identity);
1536 LocationDataRdbManager::SetSwitchStateToSysparaForCurrentUser(DISABLED);
1537 locatorAbilityStub->PreRegisterLocationError(data, reply, identity);
1538 LocationDataRdbManager::SetSwitchStateToSysparaForCurrentUser(ENABLED);
1539 } else {
1540 locatorAbilityStub->PreRegisterLocationError(data, reply, identity);
1541 }
1542 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreRegisterLocationError002 end");
1543 }
1544
1545 HWTEST_F(LocatorSkeletonTest, PreUnregisterLocationError001, TestSize.Level1)
1546 {
1547 GTEST_LOG_(INFO)
1548 << "LocatorSkeletonTest, PreUnregisterLocationError001, TestSize.Level1";
1549 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreUnregisterLocationError001 begin");
1550
1551 auto locatorAbilityStub = sptr<MockLocatorAbilityStub>(new (std::nothrow) MockLocatorAbilityStub());
1552 MessageParcel data;
1553 MessageParcel reply;
1554 AppIdentity identity;
1555 identity.SetPid(1);
1556 identity.SetUid(2);
1557 uint32_t tokenId = static_cast<uint32_t>(tokenId_);
1558 identity.SetTokenId(tokenId);
1559 identity.SetFirstTokenId(0);
1560 identity.SetBundleName("bundleName");
1561 locatorAbilityStub->PreUnregisterLocationError(data, reply, identity);
1562 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreUnregisterLocationError001 end");
1563 }
1564
1565 HWTEST_F(LocatorSkeletonTest, PreUnregisterLocationError002, TestSize.Level1)
1566 {
1567 GTEST_LOG_(INFO)
1568 << "LocatorSkeletonTest, PreUnregisterLocationError002, TestSize.Level1";
1569 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreUnregisterLocationError002 begin");
1570
1571 auto locatorAbilityStub = sptr<MockLocatorAbilityStub>(new (std::nothrow) MockLocatorAbilityStub());
1572 MessageParcel data;
1573 MessageParcel reply;
1574 AppIdentity identity;
1575 identity.SetPid(1);
1576 identity.SetUid(2);
1577 uint32_t tokenId = static_cast<uint32_t>(tokenId4_);
1578 identity.SetTokenId(tokenId);
1579 identity.SetFirstTokenId(0);
1580 identity.SetBundleName("bundleName");
1581 locatorAbilityStub->PreUnregisterLocationError(data, reply, identity);
1582 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreUnregisterLocationError002 end");
1583 }
1584
1585 HWTEST_F(LocatorSkeletonTest, PreReportLocationError, TestSize.Level1)
1586 {
1587 GTEST_LOG_(INFO)
1588 << "LocatorSkeletonTest, PreReportLocationError, TestSize.Level1";
1589 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreReportLocationError begin");
1590 auto locatorAbilityStub = sptr<MockLocatorAbilityStub>(new (std::nothrow) MockLocatorAbilityStub());
1591 MessageParcel data;
1592
1593 MessageParcel reply;
1594 AppIdentity identity;
1595 identity.SetPid(1);
1596 identity.SetUid(2);
1597 uint32_t tokenId = static_cast<uint32_t>(tokenId_);
1598 identity.SetTokenId(tokenId);
1599 identity.SetFirstTokenId(0);
1600 identity.SetBundleName("bundleName");
1601 auto result = locatorAbilityStub->PreReportLocationError(data, reply, identity);
1602 EXPECT_EQ(ERRCODE_SUCCESS, result);
1603 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreReportLocationError end");
1604 }
1605
1606 HWTEST_F(LocatorSkeletonTest, OnRemoteRequest, TestSize.Level1)
1607 {
1608 GTEST_LOG_(INFO)
1609 << "LocatorSkeletonTest, OnRemoteRequest, TestSize.Level1";
1610 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] OnRemoteRequest begin");
1611 auto locatorAbilityStub = sptr<MockLocatorAbilityStub>(new (std::nothrow) MockLocatorAbilityStub());
1612 MessageParcel data;
1613 data.WriteInterfaceToken(LocatorProxy::GetDescriptor());
1614 MessageParcel reply;
1615 MessageOption option;
1616 locatorAbilityStub->OnRemoteRequest(3, data, reply, option);
1617 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] OnRemoteRequest end");
1618 }
1619
1620 HWTEST_F(LocatorSkeletonTest, RemoveUnloadTask, TestSize.Level1)
1621 {
1622 GTEST_LOG_(INFO)
1623 << "LocatorSkeletonTest, RemoveUnloadTask TestSize.Level1";
1624 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] RemoveUnloadTask begin");
1625 auto locatorAbilityStub = sptr<MockLocatorAbilityStub>(new (std::nothrow) MockLocatorAbilityStub());
1626 locatorAbilityStub->RemoveUnloadTask(3);
1627 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] RemoveUnloadTask end");
1628 }
1629
1630 HWTEST_F(LocatorSkeletonTest, PostUnloadTask, TestSize.Level1)
1631 {
1632 GTEST_LOG_(INFO)
1633 << "LocatorSkeletonTest, PostUnloadTask, TestSize.Level1";
1634 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PostUnloadTask begin");
1635 auto locatorAbilityStub = sptr<MockLocatorAbilityStub>(new (std::nothrow) MockLocatorAbilityStub());
1636 locatorAbilityStub->PostUnloadTask(3);
1637 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PostUnloadTask end");
1638 }
1639
1640 HWTEST_F(LocatorSkeletonTest, WriteLocationDenyReportEvent, TestSize.Level1)
1641 {
1642 GTEST_LOG_(INFO)
1643 << "LocatorSkeletonTest, WriteLocationDenyReportEvent TestSize.Level1";
1644 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] WriteLocationDenyReportEvent begin");
1645 MessageParcel data;
1646 data.WriteInterfaceToken(LocatorProxy::GetDescriptor());
1647 AppIdentity identity;
1648 auto locatorAbilityStub = sptr<MockLocatorAbilityStub>(new (std::nothrow) MockLocatorAbilityStub());
1649 locatorAbilityStub->WriteLocationDenyReportEvent(0, 0, data, identity);
1650 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] WriteLocationDenyReportEvent end");
1651 }
1652
1653 HWTEST_F(LocatorSkeletonTest, OnRemoteDied, TestSize.Level1)
1654 {
1655 GTEST_LOG_(INFO)
1656 << "LocatorSkeletonTest, OnRemoteDied TestSize.Level1";
1657 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] OnRemoteDied begin");
1658 const wptr<IRemoteObject> remote;
1659 auto switchCallbackDeathRecipient =
1660 sptr<SwitchCallbackDeathRecipient>(new (std::nothrow) SwitchCallbackDeathRecipient());
1661 switchCallbackDeathRecipient->OnRemoteDied(remote);
1662 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] OnRemoteDied end");
1663 }
1664
1665 HWTEST_F(LocatorSkeletonTest, ScanCallbackOnRemoteDied, TestSize.Level1)
1666 {
1667 GTEST_LOG_(INFO)
1668 << "LocatorSkeletonTest, ScanCallbackOnRemoteDied TestSize.Level1";
1669 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] ScanCallbackOnRemoteDied begin");
1670 const wptr<IRemoteObject> remote;
1671 auto scanCallbackDeathRecipient =
1672 sptr<ScanCallbackDeathRecipient>(new (std::nothrow) ScanCallbackDeathRecipient());
1673 scanCallbackDeathRecipient->OnRemoteDied(remote);
1674 LBSLOGI(LOCATOR, "[LocatorSkeletonTest] ScanCallbackOnRemoteDied end");
1675 }
1676 } // namespace Location
1677 } // namespace OHOS
1678