• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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_ability_test.h"
17 #include <cstdlib>
18 
19 #define private public
20 #include "request.h"
21 #include "request_config.h"
22 #undef private
23 
24 #include "event_handler.h"
25 #include "event_runner.h"
26 #include "common_utils.h"
27 #include "constant_definition.h"
28 #include "country_code.h"
29 #include "country_code_callback_host.h"
30 #include "accesstoken_kit.h"
31 #include "nativetoken_kit.h"
32 #include "token_setproc.h"
33 #include "locator.h"
34 #include "permission_manager.h"
35 #include "report_manager.h"
36 
37 #ifdef FEATURE_GNSS_SUPPORT
38 #include "cached_locations_callback_napi.h"
39 #endif
40 #ifdef FEATURE_GEOCODE_SUPPORT
41 #include "geo_address.h"
42 #endif
43 #ifdef FEATURE_GNSS_SUPPORT
44 #include "gnss_status_callback_napi.h"
45 #endif
46 #include "ilocator_service.h"
47 #include "location.h"
48 #include "location_log.h"
49 #include "location_sa_load_manager.h"
50 #include "location_switch_callback_host.h"
51 #include "locator.h"
52 #include "locator_callback_host.h"
53 #include "locator_callback_proxy.h"
54 #ifdef FEATURE_GNSS_SUPPORT
55 #include "nmea_message_callback_napi.h"
56 #endif
57 #include "permission_manager.h"
58 #include "geofence_request.h"
59 #include "accesstoken_kit.h"
60 #include "bundle_mgr_interface.h"
61 #include "bundle_mgr_proxy.h"
62 #include "if_system_ability_manager.h"
63 #include "ipc_skeleton.h"
64 #include "iservice_registry.h"
65 #include "nativetoken_kit.h"
66 #include "system_ability_definition.h"
67 #include "token_setproc.h"
68 #include "request_manager.h"
69 #include "app_identity.h"
70 
71 #define private public
72 #include "locator_ability.h"
73 #undef private
74 
75 #include "mock_i_remote_object.h"
76 #include "bluetooth_scan_result_callback_napi.h"
77 #include "locating_required_data_callback_napi.h"
78 using namespace testing::ext;
79 namespace OHOS {
80 namespace Location {
81 const uint32_t EVENT_SEND_SWITCHSTATE_TO_HIFENCE = 0x0006;
82 const int32_t LOCATION_PERM_NUM = 5;
83 const std::string ARGS_HELP = "-h";
84 const int REQUEST_MAX_NUM = 3;
85 const int UNKNOWN_SERVICE_ID = -1;
86 const int GET_SWITCH_STATE = 1;
SetUp()87 void LocatorAbilityTest::SetUp()
88 {
89     LoadSystemAbility();
90     MockNativePermission();
91     locatorAbility = sptr<LocatorAbility>(new (std::nothrow) LocatorAbility());
92 }
93 
TearDown()94 void LocatorAbilityTest::TearDown()
95 {
96     locatorAbility = nullptr;
97 }
98 
LoadSystemAbility()99 void LocatorAbilityTest::LoadSystemAbility()
100 {
101     LocationSaLoadManager::GetInstance()->LoadLocationSa(LOCATION_LOCATOR_SA_ID);
102 #ifdef FEATURE_GNSS_SUPPORT
103     LocationSaLoadManager::GetInstance()->LoadLocationSa(LOCATION_GNSS_SA_ID);
104 #endif
105 #ifdef FEATURE_PASSIVE_SUPPORT
106     LocationSaLoadManager::GetInstance()->LoadLocationSa(LOCATION_NOPOWER_LOCATING_SA_ID);
107 #endif
108 #ifdef FEATURE_NETWORK_SUPPORT
109     LocationSaLoadManager::GetInstance()->LoadLocationSa(LOCATION_NETWORK_LOCATING_SA_ID);
110 #endif
111 #ifdef FEATURE_GEOCODE_SUPPORT
112     LocationSaLoadManager::GetInstance()->LoadLocationSa(LOCATION_GEO_CONVERT_SA_ID);
113 #endif
114 }
115 
MockNativePermission()116 void LocatorAbilityTest::MockNativePermission()
117 {
118     const char *perms[] = {
119         ACCESS_LOCATION.c_str(), ACCESS_APPROXIMATELY_LOCATION.c_str(),
120         ACCESS_BACKGROUND_LOCATION.c_str(), MANAGE_SECURE_SETTINGS.c_str(),
121         ACCESS_CONTROL_LOCATION_SWITCH.c_str(),
122     };
123     NativeTokenInfoParams infoInstance = {
124         .dcapsNum = 0,
125         .permsNum = LOCATION_PERM_NUM,
126         .aclsNum = 0,
127         .dcaps = nullptr,
128         .perms = perms,
129         .acls = nullptr,
130         .processName = "LocatorAbilityTest",
131         .aplStr = "system_basic",
132     };
133     tokenId_ = GetAccessTokenId(&infoInstance);
134     SetSelfTokenID(tokenId_);
135     Security::AccessToken::AccessTokenKit::ReloadNativeTokenInfo();
136 }
137 
138 #ifdef FEATURE_GNSS_SUPPORT
139 HWTEST_F(LocatorAbilityTest, locatorServiceGnssStatusCallback001, TestSize.Level1)
140 {
141     GTEST_LOG_(INFO)
142         << "LocatorAbilityTest, locatorServiceGnssStatusCallback001, TestSize.Level1";
143     LBSLOGI(LOCATOR, "[LocatorAbilityTest] locatorServiceGnssStatusCallback001 begin");
144     sptr<MockIRemoteObject> callback = sptr<MockIRemoteObject>(new (std::nothrow) MockIRemoteObject());
145     // uid pid not match locationhub process
146     if (!locatorAbility->CheckLocationSwitchState()) {
147         EXPECT_EQ(ERRCODE_SWITCH_OFF, locatorAbility->RegisterGnssStatusCallback(callback));
148         EXPECT_EQ(LOCATION_ERRCODE_PERMISSION_DENIED, locatorAbility->UnregisterGnssStatusCallback(callback));
149         locatorAbility->SetSwitchState(true);
150         EXPECT_EQ(LOCATION_ERRCODE_PERMISSION_DENIED, locatorAbility->RegisterGnssStatusCallback(callback));
151         EXPECT_EQ(LOCATION_ERRCODE_PERMISSION_DENIED, locatorAbility->UnregisterGnssStatusCallback(callback));
152         locatorAbility->SetSwitchState(false);
153     } else {
154         EXPECT_EQ(LOCATION_ERRCODE_PERMISSION_DENIED, locatorAbility->RegisterGnssStatusCallback(callback));
155         EXPECT_EQ(LOCATION_ERRCODE_PERMISSION_DENIED, locatorAbility->UnregisterGnssStatusCallback(callback));
156         locatorAbility->SetSwitchState(false);
157         EXPECT_EQ(ERRCODE_SWITCH_OFF, locatorAbility->RegisterGnssStatusCallback(callback));
158         EXPECT_EQ(LOCATION_ERRCODE_PERMISSION_DENIED, locatorAbility->UnregisterGnssStatusCallback(callback));
159         locatorAbility->SetSwitchState(true);
160     }
161     LBSLOGI(LOCATOR, "[LocatorAbilityTest] locatorServiceGnssStatusCallback001 end");
162 }
163 #endif
164 
165 #ifdef FEATURE_GNSS_SUPPORT
166 HWTEST_F(LocatorAbilityTest, locatorServiceNmeaMessageCallback001, TestSize.Level1)
167 {
168     GTEST_LOG_(INFO)
169         << "LocatorAbilityTest, locatorServiceNmeaMessageCallback001, TestSize.Level1";
170     LBSLOGI(LOCATOR, "[LocatorAbilityTest] locatorServiceNmeaMessageCallback001 begin");
171     sptr<MockIRemoteObject> callback = sptr<MockIRemoteObject>(new (std::nothrow) MockIRemoteObject());
172     if (!locatorAbility->CheckLocationSwitchState()) {
173         EXPECT_EQ(ERRCODE_SWITCH_OFF, locatorAbility->RegisterNmeaMessageCallback(callback));
174         EXPECT_EQ(LOCATION_ERRCODE_PERMISSION_DENIED, locatorAbility->UnregisterNmeaMessageCallback(callback));
175         locatorAbility->SetSwitchState(true);
176         EXPECT_EQ(LOCATION_ERRCODE_PERMISSION_DENIED, locatorAbility->RegisterNmeaMessageCallback(callback));
177         EXPECT_EQ(LOCATION_ERRCODE_PERMISSION_DENIED, locatorAbility->UnregisterNmeaMessageCallback(callback));
178         locatorAbility->SetSwitchState(false);
179     } else {
180         EXPECT_EQ(LOCATION_ERRCODE_PERMISSION_DENIED, locatorAbility->RegisterNmeaMessageCallback(callback));
181         EXPECT_EQ(LOCATION_ERRCODE_PERMISSION_DENIED, locatorAbility->UnregisterNmeaMessageCallback(callback));
182         locatorAbility->SetSwitchState(false);
183         EXPECT_EQ(ERRCODE_SWITCH_OFF, locatorAbility->RegisterNmeaMessageCallback(callback));
184         EXPECT_EQ(LOCATION_ERRCODE_PERMISSION_DENIED, locatorAbility->UnregisterNmeaMessageCallback(callback));
185         locatorAbility->SetSwitchState(true);
186     }
187     LBSLOGI(LOCATOR, "[LocatorAbilityTest] locatorServiceNmeaMessageCallback001 end");
188 }
189 #endif
190 
191 HWTEST_F(LocatorAbilityTest, locatorServiceStartAndStop001, TestSize.Level1)
192 {
193     locatorAbility->OnStart();
194     locatorAbility->OnStop();
195 }
196 
197 HWTEST_F(LocatorAbilityTest, locatorServiceStartAndStopSA001, TestSize.Level1)
198 {
199     GTEST_LOG_(INFO)
200         << "LocatorAbilityTest, locatorServiceStartAndStopSA001, TestSize.Level1";
201     LBSLOGI(LOCATOR, "[LocatorAbilityTest] locatorServiceStartAndStopSA001 begin");
202     locatorAbility->OnAddSystemAbility(UNKNOWN_SERVICE_ID, "device-id");
203     locatorAbility->OnRemoveSystemAbility(UNKNOWN_SERVICE_ID, "device-id");
204     LBSLOGI(LOCATOR, "[LocatorAbilityTest] locatorServiceStartAndStopSA001 end");
205 }
206 
207 HWTEST_F(LocatorAbilityTest, locatorServiceInitSaAbility001, TestSize.Level1)
208 {
209     GTEST_LOG_(INFO)
210         << "LocatorAbilityTest, locatorServiceInitSaAbility001, TestSize.Level1";
211     LBSLOGI(LOCATOR, "[LocatorAbilityTest] locatorServiceInitSaAbility001 begin");
212     ASSERT_TRUE(locatorAbility != nullptr);
213     locatorAbility->InitSaAbility();
214     LBSLOGI(LOCATOR, "[LocatorAbilityTest] locatorServiceInitSaAbility001 end");
215 }
216 
217 HWTEST_F(LocatorAbilityTest, locatorServiceInitRequestManager001, TestSize.Level1)
218 {
219     GTEST_LOG_(INFO)
220         << "LocatorAbilityTest, locatorServiceInitRequestManager001, TestSize.Level1";
221     LBSLOGI(LOCATOR, "[LocatorAbilityTest] locatorServiceInitRequestManager001 begin");
222     locatorAbility->InitRequestManagerMap();
223     EXPECT_EQ(REQUEST_MAX_NUM, locatorAbility->GetRequests()->size());
224     LBSLOGI(LOCATOR, "[LocatorAbilityTest] locatorServiceInitRequestManager001 end");
225 }
226 
227 HWTEST_F(LocatorAbilityTest, locatorServiceUpdateSaAbility001, TestSize.Level1)
228 {
229     GTEST_LOG_(INFO)
230         << "LocatorAbilityTest, locatorServiceUpdateSaAbility001, TestSize.Level1";
231     LBSLOGI(LOCATOR, "[LocatorAbilityTest] locatorServiceUpdateSaAbility001 begin");
232     EXPECT_EQ(ERRCODE_SUCCESS, locatorAbility->UpdateSaAbility());
233     LBSLOGI(LOCATOR, "[LocatorAbilityTest] locatorServiceUpdateSaAbility001 end");
234 }
235 
236 HWTEST_F(LocatorAbilityTest, LocatorAbilityApplyRequestsTest001, TestSize.Level1)
237 {
238     GTEST_LOG_(INFO)
239         << "LocatorAbilityTest, LocatorAbilityApplyRequestsTest001, TestSize.Level1";
240     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityApplyRequestsTest001 begin");
241     int delay = 1;
242     locatorAbility->ApplyRequests(delay);
243     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityApplyRequestsTest001 end");
244 }
245 
246 HWTEST_F(LocatorAbilityTest, LocatorAbilityUpdateSaAbilityTest001, TestSize.Level1)
247 {
248     GTEST_LOG_(INFO)
249         << "LocatorAbilityTest, LocatorAbilityUpdateSaAbilityTest001, TestSize.Level1";
250     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityUpdateSaAbilityTest001 begin");
251     locatorAbility->UpdateSaAbility();
252     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityUpdateSaAbilityTest001 end");
253 }
254 
255 HWTEST_F(LocatorAbilityTest, LocatorAbilityRemoveUnloadTaskTest001, TestSize.Level1)
256 {
257     GTEST_LOG_(INFO)
258         << "LocatorAbilityTest, LocatorAbilityRemoveUnloadTaskTest001, TestSize.Level1";
259     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityRemoveUnloadTask001 begin");
260     int code = 1;
261     locatorAbility->RemoveUnloadTask(code);
262     locatorAbility->RemoveUnloadTask(code);
263     code = static_cast<uint16_t>(LocatorInterfaceCode::PROXY_PID_FOR_FREEZE);
264     locatorAbility->RemoveUnloadTask(code);
265     code = static_cast<uint16_t>(LocatorInterfaceCode::RESET_ALL_PROXY);
266     locatorAbility->RemoveUnloadTask(code);
267     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityRemoveUnloadTaskTest001 end");
268 }
269 
270 #ifdef FEATURE_GNSS_SUPPORT
271 HWTEST_F(LocatorAbilityTest, LocatorAbilityAddFence001, TestSize.Level1)
272 {
273     GTEST_LOG_(INFO)
274         << "LocatorAbilityTest, LocatorAbilityAddFence001, TestSize.Level1";
275     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityAddFence001 begin");
276     std::shared_ptr<GeofenceRequest> request = std::make_shared<GeofenceRequest>();
277     locatorAbility->AddFence(*request);
278     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityAddFence001 end");
279 }
280 
281 HWTEST_F(LocatorAbilityTest, LocatorAbilityRemoveFence001, TestSize.Level1)
282 {
283     GTEST_LOG_(INFO)
284         << "LocatorAbilityTest, LocatorAbilityRemoveFence001, TestSize.Level1";
285     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityRemoveFence001 begin");
286     std::shared_ptr<GeofenceRequest> request = std::make_shared<GeofenceRequest>();
287     locatorAbility->RemoveFence(*request);
288     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityRemoveFence001 end");
289 }
290 
291 HWTEST_F(LocatorAbilityTest, LocatorAbilityAddGnssGeofence001, TestSize.Level1)
292 {
293     GTEST_LOG_(INFO)
294         << "LocatorAbilityTest, LocatorAbilityAddGnssGeofence001, TestSize.Level1";
295     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityAddGnssGeofence001 begin");
296     std::shared_ptr<GeofenceRequest> request = std::make_shared<GeofenceRequest>();
297     locatorAbility->AddGnssGeofence(*request);
298     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityAddGnssGeofence001 end");
299 }
300 
301 HWTEST_F(LocatorAbilityTest, LocatorAbilityRemoveGnssGeofence001, TestSize.Level1)
302 {
303     GTEST_LOG_(INFO)
304         << "LocatorAbilityTest, LocatorAbilityRemoveGnssGeofence001, TestSize.Level1";
305     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityRemoveGnssGeofence001 begin");
306     int32_t fenceId = 1;
307     locatorAbility->RemoveGnssGeofence(fenceId);
308     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityRemoveGnssGeofence001 end");
309 }
310 #endif
311 
312 HWTEST_F(LocatorAbilityTest, LocatorAbilityStartLocating001, TestSize.Level1)
313 {
314     GTEST_LOG_(INFO)
315         << "LocatorAbilityTest, LocatorAbilityStartLocating001, TestSize.Level1";
316     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityStartLocating001 begin");
317     locatorAbility->proxyMap_ = std::make_shared<std::map<std::string, sptr<IRemoteObject>>>();
318     std::unique_ptr<RequestConfig> requestConfig = std::make_unique<RequestConfig>();
319     sptr<ILocatorCallback> callbackStub = new (std::nothrow) LocatorCallbackStub();
320     locatorAbility->StartLocating(*requestConfig, callbackStub);
321     sptr<IRemoteObject> objectGnss = CommonUtils::GetRemoteObject(LOCATION_GNSS_SA_ID, CommonUtils::InitDeviceId());
322     locatorAbility->proxyMap_->insert(make_pair(GNSS_ABILITY, objectGnss));
323     locatorAbility->reportManager_ = ReportManager::GetInstance();
324     locatorAbility->requestManager_ = RequestManager::GetInstance();
325     locatorAbility->StartLocating(*requestConfig, callbackStub);
326     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityStartLocating001 end");
327 }
328 
329 HWTEST_F(LocatorAbilityTest, LocatorAbilityIsCacheVaildScenario001, TestSize.Level1)
330 {
331     GTEST_LOG_(INFO)
332         << "LocatorAbilityTest, LocatorAbilityIsCacheVaildScenario001, TestSize.Level1";
333     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityIsCacheVaildScenario001 begin");
334     std::unique_ptr<RequestConfig> requestConfig = std::make_unique<RequestConfig>();
335     AppIdentity identity;
336     std::shared_ptr<Request> request = std::make_shared<Request>();
337     request->requestConfig_->scenario_ = SCENE_UNSET;
338     request->requestConfig_->priority_ = PRIORITY_LOW_POWER;
339     bool res = locatorAbility->IsCacheVaildScenario(request->GetRequestConfig());
340     EXPECT_EQ(true, res);
341     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityIsCacheVaildScenario001 end");
342 }
343 
344 HWTEST_F(LocatorAbilityTest, LocatorAbilityIsCacheVaildScenario002, TestSize.Level1)
345 {
346     GTEST_LOG_(INFO)
347         << "LocatorAbilityTest, LocatorAbilityIsCacheVaildScenario002, TestSize.Level1";
348     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityIsCacheVaildScenario002 begin");
349     std::unique_ptr<RequestConfig> requestConfig = std::make_unique<RequestConfig>();
350     AppIdentity identity;
351     std::shared_ptr<Request> request = std::make_shared<Request>();
352     request->requestConfig_->scenario_ = SCENE_UNSET;
353     request->requestConfig_->priority_ = LOCATION_PRIORITY_ACCURACY;
354     bool res = locatorAbility->IsCacheVaildScenario(request->GetRequestConfig());
355     EXPECT_EQ(false, res);
356     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityIsCacheVaildScenario002 end");
357 }
358 
359 HWTEST_F(LocatorAbilityTest, LocatorAbilityIsSingleRequest001, TestSize.Level1)
360 {
361     GTEST_LOG_(INFO)
362         << "LocatorAbilityTest, LocatorAbilityIsSingleRequest001, TestSize.Level1";
363     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityIsSingleRequest001 begin");
364     std::unique_ptr<RequestConfig> requestConfig = std::make_unique<RequestConfig>();
365     AppIdentity identity;
366     std::shared_ptr<Request> request = std::make_shared<Request>();
367     request->requestConfig_->fixNumber_ = 1;
368     bool res = locatorAbility->IsSingleRequest(request->GetRequestConfig());
369     EXPECT_EQ(true, res);
370     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityIsSingleRequest001 end");
371 }
372 
373 HWTEST_F(LocatorAbilityTest, LocatorAbilityNeedReportCacheLocation001, TestSize.Level1)
374 {
375     GTEST_LOG_(INFO)
376         << "LocatorAbilityTest, LocatorAbilityNeedReportCacheLocation001, TestSize.Level1";
377     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityNeedReportCacheLocation001 begin");
378     sptr<ILocatorCallback> callback;
379     std::shared_ptr<Request> request = nullptr;
380     locatorAbility->reportManager_ = nullptr;
381     locatorAbility->NeedReportCacheLocation(request, callback);
382     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityNeedReportCacheLocation001 end");
383 }
384 
385 HWTEST_F(LocatorAbilityTest, LocatorAbilityNeedReportCacheLocation002, TestSize.Level1)
386 {
387     GTEST_LOG_(INFO)
388         << "LocatorAbilityTest, LocatorAbilityNeedReportCacheLocation002, TestSize.Level1";
389     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityNeedReportCacheLocation002 begin");
390     sptr<ILocatorCallback> callback;
391     std::shared_ptr<Request> request = std::make_shared<Request>();
392     locatorAbility->reportManager_ = ReportManager::GetInstance();
393     request->requestConfig_->fixNumber_ = 1;
394     request->requestConfig_->scenario_ = SCENE_DAILY_LIFE_SERVICE;
395     locatorAbility->NeedReportCacheLocation(request, callback);
396     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityNeedReportCacheLocation002 end");
397 }
398 
399 HWTEST_F(LocatorAbilityTest, LocatorAbilityNeedReportCacheLocation003, TestSize.Level1)
400 {
401     GTEST_LOG_(INFO)
402         << "LocatorAbilityTest, LocatorAbilityNeedReportCacheLocation003, TestSize.Level1";
403     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityNeedReportCacheLocation003 begin");
404     sptr<ILocatorCallback> callback;
405     std::shared_ptr<Request> request = std::make_shared<Request>();
406     locatorAbility->reportManager_ = ReportManager::GetInstance();
407     request->requestConfig_->fixNumber_ = 0;
408     request->requestConfig_->scenario_ = SCENE_DAILY_LIFE_SERVICE;
409     locatorAbility->NeedReportCacheLocation(request, callback);
410     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityNeedReportCacheLocation003 end");
411 }
412 
413 HWTEST_F(LocatorAbilityTest, LocatorAbilityNeedReportCacheLocation004, TestSize.Level1)
414 {
415     GTEST_LOG_(INFO)
416         << "LocatorAbilityTest, LocatorAbilityNeedReportCacheLocation004, TestSize.Level1";
417     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityNeedReportCacheLocation004 begin");
418     sptr<ILocatorCallback> callback;
419     std::shared_ptr<Request> request = std::make_shared<Request>();
420     locatorAbility->reportManager_ = ReportManager::GetInstance();
421     request->requestConfig_->fixNumber_ = 0;
422     request->requestConfig_->scenario_ = LOCATION_PRIORITY_ACCURACY;
423     locatorAbility->NeedReportCacheLocation(request, callback);
424     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityNeedReportCacheLocation004 end");
425 }
426 
427 HWTEST_F(LocatorAbilityTest, LocatorAbilityNeedReportCacheLocation005, TestSize.Level1)
428 {
429     GTEST_LOG_(INFO)
430         << "LocatorAbilityTest, LocatorAbilityNeedReportCacheLocation005, TestSize.Level1";
431     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityNeedReportCacheLocation005 begin");
432     sptr<ILocatorCallback> callback;
433     std::shared_ptr<Request> request = std::make_shared<Request>();
434     locatorAbility->reportManager_ = ReportManager::GetInstance();
435     request->requestConfig_->fixNumber_ = 1;
436     request->requestConfig_->scenario_ = LOCATION_PRIORITY_ACCURACY;
437     locatorAbility->NeedReportCacheLocation(request, callback);
438     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityNeedReportCacheLocation005 end");
439 }
440 
441 HWTEST_F(LocatorAbilityTest, LocatorAbilityHandleStartLocating001, TestSize.Level1)
442 {
443     GTEST_LOG_(INFO)
444         << "LocatorAbilityTest, LocatorAbilityHandleStartLocating001, TestSize.Level1";
445     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityHandleStartLocating001 begin");
446     std::shared_ptr<Request> request = std::make_shared<Request>();
447     sptr<LocatorCallbackHost> locatorCallbackHost =
448         sptr<LocatorCallbackHost>(new (std::nothrow)LocatorCallbackHost());
449     sptr<ILocatorCallback> callback = sptr<ILocatorCallback>(locatorCallbackHost);
450     request->SetLocatorCallBack(callback);
451     locatorAbility->HandleStartLocating(request, callback);
452     locatorAbility->HandleStartLocating(request, callback);
453     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityHandleStartLocating001 end");
454 }
455 
456 HWTEST_F(LocatorAbilityTest, LocatorAbilityStopLocating001, TestSize.Level1)
457 {
458     GTEST_LOG_(INFO)
459         << "LocatorAbilityTest, LocatorAbilityStopLocating001, TestSize.Level1";
460     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityStopLocating001 begin");
461     sptr<ILocatorCallback> callback;
462     locatorAbility->requestManager_ = nullptr;
463     locatorAbility->StopLocating(callback);
464     locatorAbility->requestManager_ = RequestManager::GetInstance();
465     locatorAbility->StopLocating(callback);
466     locatorAbility->StopLocating(callback);
467     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityStopLocating001 end");
468 }
469 
470 HWTEST_F(LocatorAbilityTest, LocatorAbilityGetCacheLocation001, TestSize.Level1)
471 {
472     GTEST_LOG_(INFO)
473         << "LocatorAbilityTest, LocatorAbilityGetCacheLocation001, TestSize.Level1";
474     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityGetCacheLocation001 begin");
475     std::unique_ptr<Location> loc = std::make_unique<Location>();;
476     locatorAbility->GetCacheLocation(*loc);
477     locatorAbility->GetCacheLocation(*loc);
478     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityGetCacheLocation001 end");
479 }
480 
481 HWTEST_F(LocatorAbilityTest, LocatorAbilityEnableReverseGeocodingMock001, TestSize.Level1)
482 {
483     GTEST_LOG_(INFO)
484         << "LocatorAbilityTest, LocatorAbilityEnableReverseGeocodingMock001, TestSize.Level1";
485     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityEnableReverseGeocodingMock001 begin");
486     locatorAbility->EnableReverseGeocodingMock();
487     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityEnableReverseGeocodingMock001 end");
488 }
489 
490 #ifdef FEATURE_GEOCODE_SUPPORT
491 HWTEST_F(LocatorAbilityTest, LocatorAbilityEnableReverseGeocodingMock002, TestSize.Level1)
492 {
493     GTEST_LOG_(INFO)
494         << "LocatorAbilityTest, LocatorAbilityEnableReverseGeocodingMock002, TestSize.Level1";
495     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityEnableReverseGeocodingMock002 begin");
496     locatorAbility->EnableReverseGeocodingMock();
497     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityEnableReverseGeocodingMock002 end");
498 }
499 #endif
500 
501 HWTEST_F(LocatorAbilityTest, LocatorAbilityDisableReverseGeocodingMock001, TestSize.Level1)
502 {
503     GTEST_LOG_(INFO)
504         << "LocatorAbilityTest, LocatorAbilityDisableReverseGeocodingMock001, TestSize.Level1";
505     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityDisableReverseGeocodingMock001 begin");
506     locatorAbility->DisableReverseGeocodingMock();
507     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityDisableReverseGeocodingMock001 end");
508 }
509 
510 #ifdef FEATURE_GEOCODE_SUPPORT
511 HWTEST_F(LocatorAbilityTest, LocatorAbilityDisableReverseGeocodingMock002, TestSize.Level1)
512 {
513     GTEST_LOG_(INFO)
514         << "LocatorAbilityTest, LocatorAbilityDisableReverseGeocodingMock002, TestSize.Level1";
515     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityDisableReverseGeocodingMock002 begin");
516     locatorAbility->DisableReverseGeocodingMock();
517     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityDisableReverseGeocodingMock002 end");
518 }
519 #endif
520 
521 HWTEST_F(LocatorAbilityTest, LocatorAbilitySetReverseGeocodingMockInfo001, TestSize.Level1)
522 {
523     GTEST_LOG_(INFO)
524         << "LocatorAbilityTest, LocatorAbilitySetReverseGeocodingMockInfo001, TestSize.Level1";
525     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilitySetReverseGeocodingMockInfo001 begin");
526     std::vector<GeocodingMockInfo> mockInfo;
527     locatorAbility->SetReverseGeocodingMockInfo(mockInfo);
528     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilitySetReverseGeocodingMockInfo001 end");
529 }
530 
531 #ifdef FEATURE_GEOCODE_SUPPORT
532 HWTEST_F(LocatorAbilityTest, LocatorAbilitySetReverseGeocodingMockInfo002, TestSize.Level1)
533 {
534     GTEST_LOG_(INFO)
535         << "LocatorAbilityTest, LocatorAbilitySetReverseGeocodingMockInfo002, TestSize.Level1";
536     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilitySetReverseGeocodingMockInfo002 begin");
537     std::vector<GeocodingMockInfo> mockInfo;
538     locatorAbility->SetReverseGeocodingMockInfo(mockInfo);
539     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilitySetReverseGeocodingMockInfo002 end");
540 }
541 #endif
542 
543 HWTEST_F(LocatorAbilityTest, LocatorAbilityRegisterPermissionCallback001, TestSize.Level1)
544 {
545     GTEST_LOG_(INFO)
546         << "LocatorAbilityTest, LocatorAbilityRegisterPermissionCallback001, TestSize.Level1";
547     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityRegisterPermissionCallback001 begin");
548     auto permissionMap =
549         std::make_shared<std::map<uint32_t, std::shared_ptr<PermissionStatusChangeCb>>>();
550     locatorAbility->permissionMap_ = permissionMap;
551     uint32_t callingTokenId = 10;
552     std::vector<std::string> permissionNameList;
553     locatorAbility->RegisterPermissionCallback(callingTokenId, permissionNameList);
554     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityRegisterPermissionCallback001 end");
555 }
556 
557 HWTEST_F(LocatorAbilityTest, LocatorAbilityUnRegisterPermissionCallback001, TestSize.Level1)
558 {
559     GTEST_LOG_(INFO)
560         << "LocatorAbilityTest, LocatorAbilityUnRegisterPermissionCallback001, TestSize.Level1";
561     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityUnRegisterPermissionCallback001 begin");
562     auto permissionMap =
563         std::make_shared<std::map<uint32_t, std::shared_ptr<PermissionStatusChangeCb>>>();
564     locatorAbility->permissionMap_ = permissionMap;
565     uint32_t callingTokenId = 10;
566     std::vector<std::string> permissionNameList;
567     locatorAbility->UnregisterPermissionCallback(callingTokenId);
568     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityUnRegisterPermissionCallback001 end");
569 }
570 
571 HWTEST_F(LocatorAbilityTest, LocatorAbilityReportDataToResSched001, TestSize.Level1)
572 {
573     GTEST_LOG_(INFO)
574         << "LocatorAbilityTest, LocatorAbilityReportDataToResSched001, TestSize.Level1";
575     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityReportDataToResSched001 begin");
576     std::string state("state");
577     locatorAbility->ReportDataToResSched(state);
578     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityReportDataToResSched001 end");
579 }
580 
581 #ifdef FEATURE_GNSS_SUPPORT
582 HWTEST_F(LocatorAbilityTest, LocatorAbilitySendNetworkLocation001, TestSize.Level1)
583 {
584     GTEST_LOG_(INFO)
585         << "LocatorAbilityTest, LocatorAbilitySendNetworkLocation001, TestSize.Level1";
586     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilitySendNetworkLocation001 begin");
587     std::unique_ptr<Location> location = std::make_unique<Location>();
588     locatorAbility->SendNetworkLocation(location);
589     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilitySendNetworkLocation001 end");
590 }
591 #endif
592 
593 HWTEST_F(LocatorAbilityTest, LocatorAbilityRegisterLocationError001, TestSize.Level1)
594 {
595     GTEST_LOG_(INFO)
596         << "LocatorAbilityTest, LocatorAbilityRegisterLocationError001, TestSize.Level1";
597     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityRegisterLocationError001 begin");
598     sptr<ILocatorCallback> callback;
599     AppIdentity identity;
600     locatorAbility->RegisterLocationError(callback, identity);
601     locatorAbility->UnregisterLocationError(callback, identity);
602     locatorAbility->RegisterLocationError(callback, identity);
603     locatorAbility->UnregisterLocationError(callback, identity);
604     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityRegisterLocationError001 end");
605 }
606 
607 HWTEST_F(LocatorAbilityTest, LocatorAbilityReportLocationError001, TestSize.Level1)
608 {
609     GTEST_LOG_(INFO)
610         << "LocatorAbilityTest, LocatorAbilityReportLocationError001, TestSize.Level1";
611     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityReportLocationError001 begin");
612     std::string uuid;
613     std::string errMsg;
614     int32_t errCode = 10;
615     locatorAbility->ReportLocationError(errCode, errMsg, uuid);
616     locatorAbility->ReportLocationError(errCode, errMsg, uuid);
617     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityUnRegisterLocationError001 end");
618 }
619 
620 HWTEST_F(LocatorAbilityTest, LocatorAbilitySyncIdleState001, TestSize.Level1)
621 {
622     GTEST_LOG_(INFO)
623         << "LocatorAbilityTest, LocatorAbilitySyncIdleState001, TestSize.Level1";
624     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilitySyncIdleState001 begin");
625     bool state = true;
626     locatorAbility->SyncIdleState(state);
627     state = false;
628     locatorAbility->SyncIdleState(state);
629     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilitySyncIdleState001 end");
630 }
631 
632 HWTEST_F(LocatorAbilityTest, LocationMessageGetAbilityName001, TestSize.Level1)
633 {
634     GTEST_LOG_(INFO)
635         << "LocatorAbilityTest, LocationMessageGetAbilityName001, TestSize.Level1";
636     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocationMessageGetAbilityName001 begin");
637     auto locationMessage =
638         new (std::nothrow) LocationMessage();
639     locationMessage->GetAbilityName();
640     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocationMessageGetAbilityName001 end");
641 }
642 
643 HWTEST_F(LocatorAbilityTest, LocationMessageSetLocation001, TestSize.Level1)
644 {
645     GTEST_LOG_(INFO)
646         << "LocatorAbilityTest, LocationMessageSetLocation001, TestSize.Level1";
647     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocationMessageSetLocation001 begin");
648     auto locationMessage =
649         new (std::nothrow) LocationMessage();
650     locationMessage->location_ = nullptr;
651     std::unique_ptr<Location> location;
652     locationMessage->SetLocation(location);
653     location = std::make_unique<Location>();
654     locationMessage->SetLocation(location);
655     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocationMessageSetLocation001 end");
656 }
657 
658 HWTEST_F(LocatorAbilityTest, LocationMessageGetLocation001, TestSize.Level1)
659 {
660     GTEST_LOG_(INFO)
661         << "LocatorAbilityTest, LocationMessageGetLocation001, TestSize.Level1";
662     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocationMessageGetLocation001 begin");
663     auto locationMessage =
664         new (std::nothrow) LocationMessage();
665     locationMessage->location_ = nullptr;
666     locationMessage->GetLocation();
667     locationMessage->location_ = std::make_unique<Location>();
668     locationMessage->GetLocation();
669     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocationMessageGetLocation001 end");
670 }
671 
672 HWTEST_F(LocatorAbilityTest, LocatorHandlerInitLocatorHandlerEventMap001, TestSize.Level1)
673 {
674     GTEST_LOG_(INFO)
675         << "LocatorAbilityTest, LocatorHandlerInitLocatorHandlerEventMap001, TestSize.Level1";
676     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorHandlerInitLocatorHandlerEventMap001 begin");
677     std::shared_ptr<AppExecFwk::EventRunner> runner;
678     auto locatorHandler =
679         new (std::nothrow) LocatorHandler(runner);
680     locatorHandler->InitLocatorHandlerEventMap();
681     locatorHandler->InitLocatorHandlerEventMap();
682     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorHandlerInitLocatorHandlerEventMap001 end");
683 }
684 
685 HWTEST_F(LocatorAbilityTest, LocatorHandlerGetCachedLocationSuccess001, TestSize.Level1)
686 {
687     GTEST_LOG_(INFO)
688         << "LocatorAbilityTest, LocatorHandlerGetCachedLocationSuccess001, TestSize.Level1";
689     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorHandlerGetCachedLocationSuccess001 begin");
690     AppIdentity identity;
691     identity.SetPid(1);
692     identity.SetUid(1);
693     identity.SetTokenId(1);
694     identity.SetTokenIdEx(1);
695     identity.SetFirstTokenId(1);
696     identity.SetBundleName("com.example.lbs.test");
697     std::shared_ptr<AppIdentity> identityInfo = std::make_shared<AppIdentity>(identity);
698     AppExecFwk::InnerEvent::Pointer event  =
699         AppExecFwk::InnerEvent::Get(EVENT_SEND_SWITCHSTATE_TO_HIFENCE, identityInfo);
700     std::shared_ptr<AppExecFwk::EventRunner> runner;
701     auto locatorHandler = new (std::nothrow) LocatorHandler(runner);
702     locatorHandler->GetCachedLocationSuccess(event);
703     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorHandlerGetCachedLocationSuccess001 end");
704 }
705 
706 HWTEST_F(LocatorAbilityTest, LocatorHandlerGetCachedLocationFailed001, TestSize.Level1)
707 {
708     GTEST_LOG_(INFO)
709         << "LocatorAbilityTest, LocatorHandlerGetCachedLocationFailed001, TestSize.Level1";
710     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorHandlerGetCachedLocationFailed001 begin");
711     AppIdentity identity;
712     identity.SetPid(1);
713     identity.SetUid(1);
714     identity.SetTokenId(1);
715     identity.SetTokenIdEx(1);
716     identity.SetFirstTokenId(1);
717     identity.SetBundleName("com.example.lbs.test");
718     std::shared_ptr<AppIdentity> identityInfo = std::make_shared<AppIdentity>(identity);
719     AppExecFwk::InnerEvent::Pointer event  =
720         AppExecFwk::InnerEvent::Get(EVENT_SEND_SWITCHSTATE_TO_HIFENCE, identityInfo);
721     std::shared_ptr<AppExecFwk::EventRunner> runner;
722     auto locatorHandler = new (std::nothrow) LocatorHandler(runner);
723     locatorHandler->GetCachedLocationFailed(event);
724     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorHandlerGetCachedLocationFailed001 end");
725 }
726 
727 HWTEST_F(LocatorAbilityTest, LocatorHandlerUpdateSaEvent001, TestSize.Level1)
728 {
729     GTEST_LOG_(INFO)
730         << "LocatorAbilityTest, LocatorHandlerUpdateSaEvent001, TestSize.Level1";
731     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorHandlerUpdateSaEvent001 begin");
732     std::shared_ptr<AppExecFwk::EventRunner> runner;
733     auto locatorHandler =
734         new (std::nothrow) LocatorHandler(runner);
735     int state = 1;
736     AppExecFwk::InnerEvent::Pointer event  =
737         AppExecFwk::InnerEvent::Get(EVENT_SEND_SWITCHSTATE_TO_HIFENCE, state);
738     locatorHandler->UpdateSaEvent(event);
739     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorHandlerUpdateSaEvent001 end");
740 }
741 
742 HWTEST_F(LocatorAbilityTest, LocatorHandlerApplyRequirementsEvent001, TestSize.Level1)
743 {
744     GTEST_LOG_(INFO)
745         << "LocatorAbilityTest, LocatorHandlerApplyRequirementsEvent001, TestSize.Level1";
746     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorHandlerApplyRequirementsEvent001 begin");
747     std::shared_ptr<AppExecFwk::EventRunner> runner;
748     auto locatorHandler =
749         new (std::nothrow) LocatorHandler(runner);
750     int state = 1;
751     AppExecFwk::InnerEvent::Pointer event  =
752         AppExecFwk::InnerEvent::Get(EVENT_SEND_SWITCHSTATE_TO_HIFENCE, state);
753     locatorHandler->ApplyRequirementsEvent(event);
754     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorHandlerApplyRequirementsEvent001 end");
755 }
756 
757 HWTEST_F(LocatorAbilityTest, LocatorHandlerRetryRegisterActionEvent001, TestSize.Level1)
758 {
759     GTEST_LOG_(INFO)
760         << "LocatorAbilityTest, LocatorHandlerRetryRegisterActionEvent001, TestSize.Level1";
761     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorHandlerRetryRegisterActionEvent001 begin");
762     std::shared_ptr<AppExecFwk::EventRunner> runner;
763     auto locatorHandler =
764         new (std::nothrow) LocatorHandler(runner);
765     int state = 1;
766     AppExecFwk::InnerEvent::Pointer event  =
767         AppExecFwk::InnerEvent::Get(EVENT_SEND_SWITCHSTATE_TO_HIFENCE, state);
768     locatorHandler->RetryRegisterActionEvent(event);
769     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorHandlerRetryRegisterActionEvent001 end");
770 }
771 
772 HWTEST_F(LocatorAbilityTest, LocatorHandlerReportLocationMessageEvent001, TestSize.Level1)
773 {
774     GTEST_LOG_(INFO)
775         << "LocatorAbilityTest, LocatorHandlerReportLocationMessageEvent001, TestSize.Level1";
776     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorHandlerReportLocationMessageEvent001 begin");
777     std::shared_ptr<AppExecFwk::EventRunner> runner;
778     auto locatorHandler =
779         new (std::nothrow) LocatorHandler(runner);
780     int state = 1;
781     AppExecFwk::InnerEvent::Pointer event  =
782         AppExecFwk::InnerEvent::Get(EVENT_SEND_SWITCHSTATE_TO_HIFENCE, state);
783     locatorHandler->ReportLocationMessageEvent(event);
784     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorHandlerReportLocationMessageEvent001 end");
785 }
786 
787 HWTEST_F(LocatorAbilityTest, LocatorHandlerStartAndStopLocatingEvent001, TestSize.Level1)
788 {
789     GTEST_LOG_(INFO)
790         << "LocatorAbilityTest, LocatorHandlerStartLocatingEvent001, TestSize.Level1";
791     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorHandlerStartLocatingEvent001 begin");
792     std::shared_ptr<AppExecFwk::EventRunner> runner;
793     auto locatorHandler =
794         new (std::nothrow) LocatorHandler(runner);
795     int state = 1;
796     AppExecFwk::InnerEvent::Pointer event  =
797         AppExecFwk::InnerEvent::Get(EVENT_SEND_SWITCHSTATE_TO_HIFENCE, state);
798     locatorHandler->StartLocatingEvent(event);
799     locatorHandler->StopLocatingEvent(event);
800     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorHandlerStartLocatingEvent001 end");
801 }
802 
803 HWTEST_F(LocatorAbilityTest, LocatorHandlerUpdateLastLocationRequestNum001, TestSize.Level1)
804 {
805     GTEST_LOG_(INFO)
806         << "LocatorAbilityTest, LocatorHandlerUpdateLastLocationRequestNum001, TestSize.Level1";
807     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorHandlerUpdateLastLocationRequestNum001 begin");
808     std::shared_ptr<AppExecFwk::EventRunner> runner;
809     auto locatorHandler =
810         new (std::nothrow) LocatorHandler(runner);
811     int state = 1;
812     AppExecFwk::InnerEvent::Pointer event  =
813         AppExecFwk::InnerEvent::Get(EVENT_SEND_SWITCHSTATE_TO_HIFENCE, state);
814     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorHandlerUpdateLastLocationRequestNum001 end");
815 }
816 
817 HWTEST_F(LocatorAbilityTest, LocatorHandlerUnloadSaEvent001, TestSize.Level1)
818 {
819     GTEST_LOG_(INFO)
820         << "LocatorAbilityTest, LocatorHandlerUnloadSaEvent001, TestSize.Level1";
821     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorHandlerUnloadSaEvent001 begin");
822     std::shared_ptr<AppExecFwk::EventRunner> runner;
823     auto locatorHandler =
824         new (std::nothrow) LocatorHandler(runner);
825     int state = 1;
826     AppExecFwk::InnerEvent::Pointer event  =
827         AppExecFwk::InnerEvent::Get(EVENT_SEND_SWITCHSTATE_TO_HIFENCE, state);
828     locatorHandler->UnloadSaEvent(event);
829     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorHandlerUnloadSaEvent001 end");
830 }
831 
832 HWTEST_F(LocatorAbilityTest, LocatorHandler001, TestSize.Level1)
833 {
834     GTEST_LOG_(INFO)
835         << "LocatorAbilityTest, LocatorHandler001, TestSize.Level1";
836     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorHandler001 begin");
837     std::shared_ptr<AppExecFwk::EventRunner> runner;
838     auto locatorHandler =
839         new (std::nothrow) LocatorHandler(runner);
840     int state = 1;
841     AppExecFwk::InnerEvent::Pointer event  =
842         AppExecFwk::InnerEvent::Get(EVENT_SEND_SWITCHSTATE_TO_HIFENCE, state);
843     locatorHandler->RegLocationErrorEvent(event);
844     locatorHandler->UnRegLocationErrorEvent(event);
845     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorHandler001 end");
846 }
847 
848 HWTEST_F(LocatorAbilityTest, LocatorHandler002, TestSize.Level1)
849 {
850     GTEST_LOG_(INFO)
851         << "LocatorAbilityTest, LocatorHandler002, TestSize.Level1";
852     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorHandler002 begin");
853     std::shared_ptr<AppExecFwk::EventRunner> runner;
854     auto locatorHandler =
855         new (std::nothrow) LocatorHandler(runner);
856     int state = 1;
857     AppExecFwk::InnerEvent::Pointer event  =
858         AppExecFwk::InnerEvent::Get(EVENT_SEND_SWITCHSTATE_TO_HIFENCE, state);
859     locatorHandler->SyncIdleState(event);
860     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorHandler002 end");
861 }
862 
863 HWTEST_F(LocatorAbilityTest, LocatorCallbackDeathRecipient001, TestSize.Level1)
864 {
865     GTEST_LOG_(INFO)
866         << "LocatorAbilityTest, LocatorCallbackDeathRecipient001, TestSize.Level1";
867     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorCallbackDeathRecipient001 begin");
868     int32_t tokenId = 1;
869     auto recipient =
870         sptr<LocatorCallbackDeathRecipient>(new (std::nothrow) LocatorCallbackDeathRecipient(tokenId));
871     wptr<IRemoteObject> remote;
872     recipient->OnRemoteDied(remote);
873     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorCallbackDeathRecipient001 end");
874 }
875 
876 HWTEST_F(LocatorAbilityTest, LocatorHandler003, TestSize.Level1)
877 {
878     GTEST_LOG_(INFO)
879         << "LocatorAbilityTest, LocatorHandler003, TestSize.Level1";
880     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorHandler003 begin");
881     std::shared_ptr<AppExecFwk::EventRunner> runner;
882     auto locatorHandler =
883         new (std::nothrow) LocatorHandler(runner);
884     int state = 1;
885     AppExecFwk::InnerEvent::Pointer event  =
886         AppExecFwk::InnerEvent::Get(EVENT_SEND_SWITCHSTATE_TO_HIFENCE, state);
887     locatorHandler->RequestCheckEvent(event);
888     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorHandler003 end");
889 }
890 
891 HWTEST_F(LocatorAbilityTest, LocatorHandler004, TestSize.Level1)
892 {
893     GTEST_LOG_(INFO)
894         << "LocatorAbilityTest, LocatorHandler004, TestSize.Level1";
895     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorHandler004 begin");
896     std::shared_ptr<AppExecFwk::EventRunner> runner;
897     auto locatorHandler =
898         new (std::nothrow) LocatorHandler(runner);
899     int state = 1;
900     AppExecFwk::InnerEvent::Pointer event  =
901         AppExecFwk::InnerEvent::Get(EVENT_SEND_SWITCHSTATE_TO_HIFENCE, state);
902     locatorHandler->SyncStillMovementState(event);
903     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorHandler004 end");
904 }
905 
906 HWTEST_F(LocatorAbilityTest, TestLocalPermission, TestSize.Level1)
907 {
908     LBSLOGI(LOCATOR, "[LocatorAbilityTest] TestLocalPermission start");
909     // test local permisson
910     AppIdentity identity;
911     locatorAbility->GetAppIdentityInfo(identity);
912     LBSLOGI(LOCATOR, "identity: %{public}s", identity.ToString().c_str());
913 
914     if (!PermissionManager::CheckSystemPermission(identity.GetTokenId(), identity.GetTokenIdEx())) {
915         LBSLOGE(LOCATOR, "CheckSystemPermission return false, [%{public}s]", identity.ToString().c_str());
916     }
917     LBSLOGI(LOCATOR, "[LocatorAbilityTest] TestLocalPermission end");
918 }
919 
920 HWTEST_F(LocatorAbilityTest, EnableAbilityForUser_Test_001, TestSize.Level1)
921 {
922     LBSLOGI(LOCATOR, "[LocatorAbilityTest] EnableAbilityForUser_Test_001 start");
923     // Arrange
924     int32_t userId = 100;
925 
926     // Act
927     ErrCode result = locatorAbility->EnableAbilityForUser(false, userId);
928     result = locatorAbility->EnableAbilityForUser(true, userId);
929 
930     // Assert
931     EXPECT_EQ(result, ERRCODE_SUCCESS);
932     LBSLOGI(LOCATOR, "[LocatorAbilityTest] EnableAbilityForUser_Test_001 end");
933 }
934 
935 HWTEST_F(LocatorAbilityTest, GetCachedGnssLocationsSize_Test_001, TestSize.Level1)
936 {
937     LBSLOGI(LOCATOR, "[LocatorAbilityTest] GetCachedGnssLocationsSize_Test_001 start");
938     // Arrange
939     auto locatorAbility = sptr<LocatorAbility>(new (std::nothrow) LocatorAbility());
940     int32_t size = -1;
941 
942     // Act
943     ErrCode result = locatorAbility->GetCachedGnssLocationsSize(size);
944     // Assert
945     EXPECT_EQ(true, size >= -1);
946     LBSLOGI(LOCATOR, "[LocatorAbilityTest] GetCachedGnssLocationsSize_Test_001 end");
947 }
948 
949 HWTEST_F(LocatorAbilityTest, FlushCachedGnssLocations_Test_001, TestSize.Level1)
950 {
951     LBSLOGI(LOCATOR, "[LocatorAbilityTest] FlushCachedGnssLocations_Test_001 start");
952     // Arrange
953     auto locatorAbility = sptr<LocatorAbility>(new (std::nothrow) LocatorAbility());
954     ASSERT_TRUE(locatorAbility != nullptr);
955     // Act
956     ErrCode result = locatorAbility->FlushCachedGnssLocations();
957     // Assert
958     LBSLOGI(LOCATOR, "[LocatorAbilityTest] FlushCachedGnssLocations_Test_001 end");
959 }
960 
961 HWTEST_F(LocatorAbilityTest, Add_RemoveFence_Test_001, TestSize.Level1)
962 {
963     LBSLOGI(LOCATOR, "[LocatorAbilityTest] RemoveFence_Test_001 start");
964     // Arrange
965     auto locatorAbility = sptr<LocatorAbility>(new (std::nothrow) LocatorAbility());
966     ASSERT_TRUE(locatorAbility != nullptr);
967     std::shared_ptr<GeofenceRequest> request = std::make_shared<GeofenceRequest>();
968 
969     // Act
970     ErrCode result = locatorAbility->AddFence(*request);
971     result = locatorAbility->RemoveFence(*request);
972 
973     // Assert
974     LBSLOGI(LOCATOR, "[LocatorAbilityTest] RemoveFence_Test_001 end");
975 }
976 
977 HWTEST_F(LocatorAbilityTest, Add_RemoveGnssFence_Test_001, TestSize.Level1)
978 {
979     LBSLOGI(LOCATOR, "[LocatorAbilityTest] Add_RemoveGnssFence_Test_001 start");
980     // Arrange
981     auto locatorAbility = sptr<LocatorAbility>(new (std::nothrow) LocatorAbility());
982     ASSERT_TRUE(locatorAbility != nullptr);
983     int32_t fenceId = 100;
984     std::shared_ptr<GeofenceRequest> request = std::make_shared<GeofenceRequest>();
985     request->SetFenceId(fenceId);
986 
987     // Act
988     ErrCode result = locatorAbility->AddGnssGeofence(*request);
989     result = locatorAbility->RemoveGnssGeofence(fenceId);
990 
991     // Assert
992     LBSLOGI(LOCATOR, "[LocatorAbilityTest] Add_RemoveGnssFence_Test_001 end");
993 }
994 
995 HWTEST_F(LocatorAbilityTest, StartLocating_Test_001, TestSize.Level1)
996 {
997     LBSLOGI(LOCATOR, "[LocatorAbilityTest] StartLocating_Test_001 start");
998     // Arrange
999     auto locatorAbility = sptr<LocatorAbility>(new (std::nothrow) LocatorAbility());
1000     ASSERT_TRUE(locatorAbility != nullptr);
1001     locatorAbility->proxyMap_ = std::make_shared<std::map<std::string, sptr<IRemoteObject>>>();
1002     std::unique_ptr<RequestConfig> requestConfig = std::make_unique<RequestConfig>();
1003     sptr<ILocatorCallback> callbackStub = new (std::nothrow) LocatorCallbackStub();
1004     // Act
1005     ErrCode result = locatorAbility->StartLocating(*requestConfig, callbackStub);
1006     result = locatorAbility->StopLocating(callbackStub);
1007     // Assert
1008     LBSLOGI(LOCATOR, "[LocatorAbilityTest] StartLocating_Test_001 end");
1009 }
1010 
1011 HWTEST_F(LocatorAbilityTest, NeedReportCacheLocation_Test_001, TestSize.Level1)
1012 {
1013     LBSLOGI(LOCATOR, "[LocatorAbilityTest] NeedReportCacheLocation_Test_001 start");
1014     // Arrange
1015     auto locatorAbility = sptr<LocatorAbility>(new (std::nothrow) LocatorAbility());
1016     ASSERT_TRUE(locatorAbility != nullptr);
1017     locatorAbility->proxyMap_ = std::make_shared<std::map<std::string, sptr<IRemoteObject>>>();
1018     std::shared_ptr<Request> request = std::make_shared<Request>();
1019     request->requestConfig_->scenario_ = SCENE_UNSET;
1020     request->requestConfig_->priority_ = PRIORITY_LOW_POWER;
1021 
1022     sptr<ILocatorCallback> callbackStub = new (std::nothrow) LocatorCallbackStub();
1023     // Act
1024     ErrCode result = locatorAbility->NeedReportCacheLocation(request, callbackStub);
1025 
1026     // Assert
1027     LBSLOGI(LOCATOR, "[LocatorAbilityTest] NeedReportCacheLocation_Test_001 end");
1028 }
1029 
1030 HWTEST_F(LocatorAbilityTest, ReportSingleCacheLocation_Test_001, TestSize.Level1)
1031 {
1032     LBSLOGI(LOCATOR, "[LocatorAbilityTest] ReportSingleCacheLocation_Test_001 start");
1033     // Arrange
1034     auto locatorAbility = sptr<LocatorAbility>(new (std::nothrow) LocatorAbility());
1035     ASSERT_TRUE(locatorAbility != nullptr);
1036     locatorAbility->proxyMap_ = std::make_shared<std::map<std::string, sptr<IRemoteObject>>>();
1037     std::shared_ptr<Request> request = std::make_shared<Request>();
1038     request->requestConfig_->scenario_ = SCENE_UNSET;
1039     request->requestConfig_->priority_ = PRIORITY_LOW_POWER;
1040     sptr<ILocatorCallback> callbackStub = new (std::nothrow) LocatorCallbackStub();
1041 
1042     auto cacheLocation = locatorAbility->reportManager_->GetCacheLocation(request);
1043     // Act
1044     ErrCode result = locatorAbility->ReportSingleCacheLocation(request, callbackStub, cacheLocation);
1045 
1046     // Assert
1047     LBSLOGI(LOCATOR, "[LocatorAbilityTest] ReportSingleCacheLocation_Test_001 end");
1048 }
1049 
1050 HWTEST_F(LocatorAbilityTest, GetCacheLocation_Test_001, TestSize.Level1)
1051 {
1052     LBSLOGI(LOCATOR, "[LocatorAbilityTest] GetCacheLocation_Test_001 start");
1053     // Arrange
1054     auto locatorAbility = sptr<LocatorAbility>(new (std::nothrow) LocatorAbility());
1055     ASSERT_TRUE(locatorAbility != nullptr);
1056     std::unique_ptr<Location> location = std::make_unique<Location>();
1057     sptr<ILocatorCallback> callbackStub = new (std::nothrow) LocatorCallbackStub();
1058 
1059     // Act
1060     ErrCode result = locatorAbility->GetCacheLocation(*location);
1061     result = locatorAbility->ReportLocation(NETWORK_ABILITY, *location);
1062     result = locatorAbility->ReportLocationStatus(callbackStub, result);
1063     result = locatorAbility->ReportErrorStatus(callbackStub, result);
1064     // Assert
1065     LBSLOGI(LOCATOR, "[LocatorAbilityTest] GetCacheLocation_Test_001 end");
1066 }
1067 
1068 HWTEST_F(LocatorAbilityTest, GeoConvert_Test_001, TestSize.Level1)
1069 {
1070     LBSLOGI(LOCATOR, "[LocatorAbilityTest] GeoConvert_Test_001 start");
1071     // Arrange
1072     auto locatorAbility = sptr<LocatorAbility>(new (std::nothrow) LocatorAbility());
1073     ASSERT_TRUE(locatorAbility != nullptr);
1074     bool isAvailable = false;
1075     // Act
1076     ErrCode result = locatorAbility->IsGeoConvertAvailable(isAvailable);
1077     // Assert
1078     LBSLOGI(LOCATOR, "[LocatorAbilityTest] GeoConvert_Test_001 end");
1079 }
1080 
1081 HWTEST_F(LocatorAbilityTest, GetAddressByLocationName_Test_001, TestSize.Level1)
1082 {
1083     LBSLOGI(LOCATOR, "[LocatorAbilityTest] GetAddressByLocationName_Test_001 start");
1084     // Arrange
1085     auto locatorAbility = sptr<LocatorAbility>(new (std::nothrow) LocatorAbility());
1086     ASSERT_TRUE(locatorAbility != nullptr);
1087     auto geoConvertRequest = std::make_unique<GeocodeConvertAddressRequest>();
1088     sptr<MockIRemoteObject> callback = sptr<MockIRemoteObject>(new (std::nothrow) MockIRemoteObject());
1089     // Act
1090     ErrCode result = locatorAbility->GetAddressByLocationName(callback, *geoConvertRequest);
1091     // Assert
1092     LBSLOGI(LOCATOR, "[LocatorAbilityTest] GetAddressByLocationName_Test_001 end");
1093 }
1094 
1095 HWTEST_F(LocatorAbilityTest, BluetoothScan_Test_001, TestSize.Level1)
1096 {
1097     LBSLOGI(LOCATOR, "[LocatorAbilityTest] BluetoothScan_Test_001 start");
1098     // Arrange
1099     auto locatorAbility = sptr<LocatorAbility>(new (std::nothrow) LocatorAbility());
1100     ASSERT_TRUE(locatorAbility != nullptr);
1101     std::vector<CoordinateType> coordinateTypes;
1102     auto bluetoothScanResultCallbackHost =
1103         sptr<BluetoothScanResultCallbackNapi>(new (std::nothrow) BluetoothScanResultCallbackNapi());
1104     auto bluetoothScanResultCallback = sptr<IBluetoothScanResultCallback>(bluetoothScanResultCallbackHost);
1105     // Act
1106     ErrCode result = locatorAbility->QuerySupportCoordinateSystemType(coordinateTypes);
1107     result = locatorAbility->SubscribeBluetoothScanResultChange(nullptr);
1108     result = locatorAbility->SubscribeBluetoothScanResultChange(bluetoothScanResultCallback);
1109     result = locatorAbility->UnSubscribeBluetoothScanResultChange(bluetoothScanResultCallback);
1110     // Assert
1111     LBSLOGI(LOCATOR, "[LocatorAbilityTest] BluetoothScan_Test_001 end");
1112 }
1113 
1114 HWTEST_F(LocatorAbilityTest, RemoveInvalidRequests_Test_001, TestSize.Level1)
1115 {
1116     LBSLOGI(LOCATOR, "[LocatorAbilityTest] RemoveInvalidRequests_Test_001 start");
1117     // Arrange
1118     auto locatorAbility = sptr<LocatorAbility>(new (std::nothrow) LocatorAbility());
1119     ASSERT_TRUE(locatorAbility != nullptr);
1120     AppIdentity identity;
1121     auto requestManager_ = RequestManager::GetInstance();
1122     std::unique_ptr<RequestConfig> requestConfig = std::make_unique<RequestConfig>();
1123     requestConfig->SetTimeStamp(0);
1124     requestConfig->SetFixNumber(1);
1125     requestConfig->SetScenario(SCENE_NAVIGATION);
1126     requestConfig->SetPriority(PRIORITY_ACCURACY);
1127     sptr<ILocatorCallback> callbackStub = new (std::nothrow) LocatorCallbackStub();
1128     std::shared_ptr<Request> request = std::make_shared<Request>(requestConfig, callbackStub, identity);
1129 
1130     // Act
1131     ErrCode result = locatorAbility->IsInvalidRequest(request);
1132     locatorAbility->StartLocating(*requestConfig, callbackStub);
1133     result = locatorAbility->RemoveInvalidRequests();
1134     locatorAbility->StopLocating(callbackStub);
1135     // Assert
1136     LBSLOGI(LOCATOR, "[LocatorAbilityTest] RemoveInvalidRequests_Test_001 end");
1137 }
1138 
1139 HWTEST_F(LocatorAbilityTest, SyncStillMovementState_Test_001, TestSize.Level1)
1140 {
1141     LBSLOGI(LOCATOR, "[LocatorAbilityTest] SyncStillMovementState_Test_001 start");
1142     // Arrange
1143     auto locatorAbility = sptr<LocatorAbility>(new (std::nothrow) LocatorAbility());
1144     ASSERT_TRUE(locatorAbility != nullptr);
1145 
1146     // Act
1147     locatorAbility->SyncStillMovementState(true);
1148 
1149     // Assert
1150     LBSLOGI(LOCATOR, "[LocatorAbilityTest] SyncStillMovementState_Test_001 end");
1151 }
1152 
1153 HWTEST_F(LocatorAbilityTest, SetLocationSwitchIgnored_Test_001, TestSize.Level1)
1154 {
1155     LBSLOGI(LOCATOR, "[LocatorAbilityTest] SetLocationSwitchIgnored_Test_001 start");
1156     // Arrange
1157     auto locatorAbility = sptr<LocatorAbility>(new (std::nothrow) LocatorAbility());
1158     ASSERT_TRUE(locatorAbility != nullptr);
1159     ErrCode result = ERRCODE_SUCCESS;
1160     AppIdentity identity;
1161     locatorAbility->GetAppIdentityInfo(identity);
1162 
1163     // Act
1164     bool switchFlag = locatorAbility->GetLocationSwitchIgnoredFlag(identity.GetTokenId());
1165     result = locatorAbility->SetLocationSwitchIgnored(true);
1166     sleep(1);
1167     result = locatorAbility->SetLocationSwitchIgnored(false);
1168     sleep(1);
1169     locatorAbility->SetLocationSwitchIgnoredFlag(identity.GetTokenId(), true);
1170     sleep(1);
1171     locatorAbility->SetLocationSwitchIgnoredFlag(identity.GetTokenId(), false);
1172 
1173     // Assert
1174     LBSLOGI(LOCATOR, "[LocatorAbilityTest] SetLocationSwitchIgnored_Test_001 end");
1175 }
1176 
1177 HWTEST_F(LocatorAbilityTest, SetLocationWorkingStateEvent_Test_001, TestSize.Level1)
1178 {
1179     LBSLOGI(LOCATOR, "[LocatorAbilityTest] SetLocationWorkingStateEvent_Test_001 start");
1180     // Arrange
1181     auto locatorAbility = sptr<LocatorAbility>(new (std::nothrow) LocatorAbility());
1182     ASSERT_TRUE(locatorAbility != nullptr);
1183     // Act
1184     ErrCode result = ERRCODE_SUCCESS;
1185     result = locatorAbility->SetSwitchState(true);
1186     sleep(1);
1187     result = locatorAbility->SetSwitchState(false);
1188     sleep(1);
1189     result = locatorAbility->SetSwitchState(true);
1190     sleep(1);
1191 
1192     result = locatorAbility->SetSwitchStateForUser(true, 100);
1193     sleep(1);
1194     result = locatorAbility->SetSwitchStateForUser(false, 100);
1195     sleep(1);
1196     result = locatorAbility->SetSwitchStateForUser(true, 100);
1197 
1198     // Assert
1199     LBSLOGI(LOCATOR, "[LocatorAbilityTest] SetLocationWorkingStateEvent_Test_001 end");
1200 }
1201 
1202 HWTEST_F(LocatorAbilityTest, RegisterLocatingRequiredDataCallback_Test_001, TestSize.Level1)
1203 {
1204     LBSLOGI(LOCATOR, "[LocatorAbilityTest] RegisterLocatingRequiredDataCallback_Test_001 start");
1205     // Arrange
1206     auto locatorAbility = sptr<LocatorAbility>(new (std::nothrow) LocatorAbility());
1207     ASSERT_TRUE(locatorAbility != nullptr);
1208     std::unique_ptr<LocatingRequiredDataConfig> requestConfig = std::make_unique<LocatingRequiredDataConfig>();
1209     requestConfig->SetFixNumber(1);
1210     auto callbackHost =
1211         sptr<LocatingRequiredDataCallbackNapi>(new (std::nothrow) LocatingRequiredDataCallbackNapi());
1212     callbackHost->SetFixNumber(1);
1213     auto callbackPtr = sptr<ILocatingRequiredDataCallback>(callbackHost);
1214     // Act
1215     ErrCode result = ERRCODE_SUCCESS;
1216     result = locatorAbility->RegisterLocatingRequiredDataCallback(*requestConfig, nullptr);
1217     result = locatorAbility->RegisterLocatingRequiredDataCallback(*requestConfig, callbackPtr);
1218 
1219     result = locatorAbility->UnRegisterLocatingRequiredDataCallback(callbackPtr);
1220     // Assert
1221     LBSLOGI(LOCATOR, "[LocatorAbilityTest] RegisterLocatingRequiredDataCallback_Test_001 end");
1222 }
1223 
1224 HWTEST_F(LocatorAbilityTest, SubscribeLocationError_Test_001, TestSize.Level1)
1225 {
1226     LBSLOGI(LOCATOR, "[LocatorAbilityTest] SubscribeLocationError_Test_001 start");
1227     // Arrange
1228     auto locatorAbility = sptr<LocatorAbility>(new (std::nothrow) LocatorAbility());
1229     ASSERT_TRUE(locatorAbility != nullptr);
1230 
1231     sptr<ILocatorCallback> callbackStub = new (std::nothrow) LocatorCallbackStub();
1232 
1233     // Act
1234     ErrCode result = ERRCODE_SUCCESS;
1235     result = locatorAbility->SubscribeLocationError(nullptr);
1236     result = locatorAbility->UnSubscribeLocationError(nullptr);
1237 
1238     result = locatorAbility->SubscribeLocationError(callbackStub);
1239     result = locatorAbility->UnSubscribeLocationError(callbackStub);
1240     LBSLOGI(LOCATOR, "[LocatorAbilityTest] SubscribeLocationError_Test_001 end");
1241 }
1242 
1243 HWTEST_F(LocatorAbilityTest, GetCurrentWifiBssidForLocating_Test_001, TestSize.Level1)
1244 {
1245     LBSLOGI(LOCATOR, "[LocatorAbilityTest] GetCurrentWifiBssidForLocating_Test_001 start");
1246     // Arrange
1247     auto locatorAbility = sptr<LocatorAbility>(new (std::nothrow) LocatorAbility());
1248     ASSERT_TRUE(locatorAbility != nullptr);
1249     std::string bssid = "0112:110:123";
1250     sptr<ILocatorCallback> callbackStub = new (std::nothrow) LocatorCallbackStub();
1251 
1252     // Act
1253     ErrCode result = ERRCODE_SUCCESS;
1254     result = locatorAbility->GetCurrentWifiBssidForLocating(bssid);
1255     result = locatorAbility->GetCurrentWifiBssidForLocating(bssid);
1256     LBSLOGI(LOCATOR, "[LocatorAbilityTest] GetCurrentWifiBssidForLocating_Test_001 end");
1257 }
1258 
1259 HWTEST_F(LocatorAbilityTest, COMMON_Test_001, TestSize.Level1)
1260 {
1261     LBSLOGI(LOCATOR, "[LocatorAbilityTest] GetCurrentWifiBssidForLocating_Test_001 start");
1262     // Arrange
1263     auto locatorAbility = sptr<LocatorAbility>(new (std::nothrow) LocatorAbility());
1264     ASSERT_TRUE(locatorAbility != nullptr);
1265     std::string bssid = "0112:110:123";
1266     sptr<ILocatorCallback> callbackStub = new (std::nothrow) LocatorCallbackStub();
1267 
1268     // Act
1269     ErrCode result = ERRCODE_SUCCESS;
1270     result = locatorAbility->CheckPreciseLocationPermissions(123123, 123123); // INVALID token-id test
1271 
1272     LBSLOGI(LOCATOR, "[LocatorAbilityTest] GetCurrentWifiBssidForLocating_Test_001 end");
1273 }
1274 }  // namespace Location
1275 }  // namespace OHOS