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 "i_locator.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 #include "locator_skeleton.h"
55 #ifdef FEATURE_GNSS_SUPPORT
56 #include "nmea_message_callback_napi.h"
57 #endif
58 #include "permission_manager.h"
59 #include "geofence_request.h"
60 #include "accesstoken_kit.h"
61 #include "bundle_mgr_interface.h"
62 #include "bundle_mgr_proxy.h"
63 #include "if_system_ability_manager.h"
64 #include "ipc_skeleton.h"
65 #include "iservice_registry.h"
66 #include "nativetoken_kit.h"
67 #include "system_ability_definition.h"
68 #include "token_setproc.h"
69 #include "request_manager.h"
70 #include "app_identity.h"
71 
72 #define private public
73 #include "locator_ability.h"
74 #undef private
75 
76 
77 using namespace testing::ext;
78 namespace OHOS {
79 namespace Location {
80 const uint32_t EVENT_SEND_SWITCHSTATE_TO_HIFENCE = 0x0006;
81 const int32_t LOCATION_PERM_NUM = 5;
82 const std::string ARGS_HELP = "-h";
SetUp()83 void LocatorAbilityTest::SetUp()
84 {
85     LoadSystemAbility();
86     MockNativePermission();
87 }
88 
TearDown()89 void LocatorAbilityTest::TearDown()
90 {
91 }
92 
LoadSystemAbility()93 void LocatorAbilityTest::LoadSystemAbility()
94 {
95     LocationSaLoadManager::GetInstance()->LoadLocationSa(LOCATION_LOCATOR_SA_ID);
96 #ifdef FEATURE_GNSS_SUPPORT
97     LocationSaLoadManager::GetInstance()->LoadLocationSa(LOCATION_GNSS_SA_ID);
98 #endif
99 #ifdef FEATURE_PASSIVE_SUPPORT
100     LocationSaLoadManager::GetInstance()->LoadLocationSa(LOCATION_NOPOWER_LOCATING_SA_ID);
101 #endif
102 #ifdef FEATURE_NETWORK_SUPPORT
103     LocationSaLoadManager::GetInstance()->LoadLocationSa(LOCATION_NETWORK_LOCATING_SA_ID);
104 #endif
105 #ifdef FEATURE_GEOCODE_SUPPORT
106     LocationSaLoadManager::GetInstance()->LoadLocationSa(LOCATION_GEO_CONVERT_SA_ID);
107 #endif
108 }
109 
MockNativePermission()110 void LocatorAbilityTest::MockNativePermission()
111 {
112     const char *perms[] = {
113         ACCESS_LOCATION.c_str(), ACCESS_APPROXIMATELY_LOCATION.c_str(),
114         ACCESS_BACKGROUND_LOCATION.c_str(), MANAGE_SECURE_SETTINGS.c_str(),
115         ACCESS_CONTROL_LOCATION_SWITCH.c_str(),
116     };
117     NativeTokenInfoParams infoInstance = {
118         .dcapsNum = 0,
119         .permsNum = LOCATION_PERM_NUM,
120         .aclsNum = 0,
121         .dcaps = nullptr,
122         .perms = perms,
123         .acls = nullptr,
124         .processName = "LocatorAbilityTest",
125         .aplStr = "system_basic",
126     };
127     tokenId_ = GetAccessTokenId(&infoInstance);
128     SetSelfTokenID(tokenId_);
129     Security::AccessToken::AccessTokenKit::ReloadNativeTokenInfo();
130 }
131 
132 HWTEST_F(LocatorAbilityTest, LocatorAbilityApplyRequestsTest001, TestSize.Level1)
133 {
134     GTEST_LOG_(INFO)
135         << "LocatorAbilityTest, LocatorAbilityApplyRequestsTest001, TestSize.Level1";
136     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityApplyRequestsTest001 begin");
137     auto locatorAbility = sptr<LocatorAbility>(new (std::nothrow) LocatorAbility());
138     int delay = 1;
139     locatorAbility->ApplyRequests(delay);
140     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityApplyRequestsTest001 end");
141 }
142 
143 HWTEST_F(LocatorAbilityTest, LocatorAbilityUpdateSaAbilityTest001, TestSize.Level1)
144 {
145     GTEST_LOG_(INFO)
146         << "LocatorAbilityTest, LocatorAbilityUpdateSaAbilityTest001, TestSize.Level1";
147     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityUpdateSaAbilityTest001 begin");
148     auto locatorAbility = sptr<LocatorAbility>(new (std::nothrow) LocatorAbility());
149     locatorAbility->UpdateSaAbility();
150     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityUpdateSaAbilityTest001 end");
151 }
152 
153 HWTEST_F(LocatorAbilityTest, LocatorAbilityRemoveUnloadTaskTest001, TestSize.Level1)
154 {
155     GTEST_LOG_(INFO)
156         << "LocatorAbilityTest, LocatorAbilityRemoveUnloadTaskTest001, TestSize.Level1";
157     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityRemoveUnloadTask001 begin");
158     auto locatorAbility = sptr<LocatorAbility>(new (std::nothrow) LocatorAbility());
159     int code = 1;
160     locatorAbility->RemoveUnloadTask(code);
161     locatorAbility->RemoveUnloadTask(code);
162     code = static_cast<uint16_t>(LocatorInterfaceCode::PROXY_PID_FOR_FREEZE);
163     locatorAbility->RemoveUnloadTask(code);
164     code = static_cast<uint16_t>(LocatorInterfaceCode::RESET_ALL_PROXY);
165     locatorAbility->RemoveUnloadTask(code);
166     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityRemoveUnloadTaskTest001 end");
167 }
168 
169 #ifdef FEATURE_GNSS_SUPPORT
170 HWTEST_F(LocatorAbilityTest, LocatorAbilityAddGnssGeofence001, TestSize.Level1)
171 {
172     GTEST_LOG_(INFO)
173         << "LocatorAbilityTest, LocatorAbilityAddGnssGeofence001, TestSize.Level1";
174     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityAddGnssGeofence001 begin");
175     auto locatorAbility = sptr<LocatorAbility>(new (std::nothrow) LocatorAbility());
176     std::shared_ptr<GeofenceRequest> request = std::make_shared<GeofenceRequest>();
177     locatorAbility->AddGnssGeofence(request);
178     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityAddGnssGeofence001 end");
179 }
180 
181 HWTEST_F(LocatorAbilityTest, LocatorAbilityAddGnssGeofence002, TestSize.Level1)
182 {
183     GTEST_LOG_(INFO)
184         << "LocatorAbilityTest, LocatorAbilityAddGnssGeofence002, TestSize.Level1";
185     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityAddGnssGeofence002 begin");
186     auto locatorAbility = sptr<LocatorAbility>(new (std::nothrow) LocatorAbility());
187     std::shared_ptr<GeofenceRequest> request = std::make_shared<GeofenceRequest>();
188     locatorAbility->AddGnssGeofence(request);
189     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityAddGnssGeofence002 end");
190 }
191 
192 HWTEST_F(LocatorAbilityTest, LocatorAbilityRemoveGnssGeofence001, TestSize.Level1)
193 {
194     GTEST_LOG_(INFO)
195         << "LocatorAbilityTest, LocatorAbilityRemoveGnssGeofence001, TestSize.Level1";
196     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityRemoveGnssGeofence001 begin");
197     auto locatorAbility = sptr<LocatorAbility>(new (std::nothrow) LocatorAbility());
198     std::shared_ptr<GeofenceRequest> request = std::make_shared<GeofenceRequest>();
199     locatorAbility->RemoveGnssGeofence(request);
200     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityRemoveGnssGeofence001 end");
201 }
202 
203 HWTEST_F(LocatorAbilityTest, LocatorAbilityRemoveGnssGeofence002, TestSize.Level1)
204 {
205     GTEST_LOG_(INFO)
206         << "LocatorAbilityTest, LocatorAbilityRemoveGnssGeofence002, TestSize.Level1";
207     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityRemoveGnssGeofence002 begin");
208     auto locatorAbility = sptr<LocatorAbility>(new (std::nothrow) LocatorAbility());
209     std::shared_ptr<GeofenceRequest> request = std::make_shared<GeofenceRequest>();
210     locatorAbility->AddGnssGeofence(request);
211     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityRemoveGnssGeofence002 end");
212 }
213 #endif
214 
215 HWTEST_F(LocatorAbilityTest, LocatorAbilityStartLocating001, TestSize.Level1)
216 {
217     GTEST_LOG_(INFO)
218         << "LocatorAbilityTest, LocatorAbilityStartLocating001, TestSize.Level1";
219     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityStartLocating001 begin");
220     auto locatorAbility =
221         sptr<LocatorAbility>(new (std::nothrow) LocatorAbility());
222     locatorAbility->proxyMap_ = std::make_shared<std::map<std::string, sptr<IRemoteObject>>>();
223     std::unique_ptr<RequestConfig> requestConfig = std::make_unique<RequestConfig>();
224     sptr<ILocatorCallback> callbackStub = new (std::nothrow) LocatorCallbackStub();
225     AppIdentity identity;
226     locatorAbility->StartLocating(requestConfig, callbackStub, identity);
227     sptr<IRemoteObject> objectGnss = CommonUtils::GetRemoteObject(LOCATION_GNSS_SA_ID, CommonUtils::InitDeviceId());
228     locatorAbility->proxyMap_->insert(make_pair(GNSS_ABILITY, objectGnss));
229     locatorAbility->reportManager_ = ReportManager::GetInstance();
230     locatorAbility->requestManager_ = RequestManager::GetInstance();
231     locatorAbility->StartLocating(requestConfig, callbackStub, identity);
232     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityStartLocating001 end");
233 }
234 
235 HWTEST_F(LocatorAbilityTest, LocatorAbilityIsCacheVaildScenario001, TestSize.Level1)
236 {
237     GTEST_LOG_(INFO)
238         << "LocatorAbilityTest, LocatorAbilityIsCacheVaildScenario001, TestSize.Level1";
239     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityIsCacheVaildScenario001 begin");
240     auto locatorAbility =
241         sptr<LocatorAbility>(new (std::nothrow) LocatorAbility());
242     std::unique_ptr<RequestConfig> requestConfig = std::make_unique<RequestConfig>();
243     AppIdentity identity;
244     std::shared_ptr<Request> request = std::make_shared<Request>();
245     request->requestConfig_->scenario_ = SCENE_UNSET;
246     request->requestConfig_->priority_ = PRIORITY_LOW_POWER;
247     bool res = locatorAbility->IsCacheVaildScenario(request->GetRequestConfig());
248     EXPECT_EQ(true, res);
249     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityIsCacheVaildScenario001 end");
250 }
251 
252 HWTEST_F(LocatorAbilityTest, LocatorAbilityIsCacheVaildScenario002, TestSize.Level1)
253 {
254     GTEST_LOG_(INFO)
255         << "LocatorAbilityTest, LocatorAbilityIsCacheVaildScenario002, TestSize.Level1";
256     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityIsCacheVaildScenario002 begin");
257     auto locatorAbility =
258         sptr<LocatorAbility>(new (std::nothrow) LocatorAbility());
259     std::unique_ptr<RequestConfig> requestConfig = std::make_unique<RequestConfig>();
260     AppIdentity identity;
261     std::shared_ptr<Request> request = std::make_shared<Request>();
262     request->requestConfig_->scenario_ = SCENE_UNSET;
263     request->requestConfig_->priority_ = LOCATION_PRIORITY_ACCURACY;
264     bool res = locatorAbility->IsCacheVaildScenario(request->GetRequestConfig());
265     EXPECT_EQ(false, res);
266     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityIsCacheVaildScenario002 end");
267 }
268 
269 HWTEST_F(LocatorAbilityTest, LocatorAbilityIsSingleRequest001, TestSize.Level1)
270 {
271     GTEST_LOG_(INFO)
272         << "LocatorAbilityTest, LocatorAbilityIsSingleRequest001, TestSize.Level1";
273     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityIsSingleRequest001 begin");
274     auto locatorAbility =
275         sptr<LocatorAbility>(new (std::nothrow) LocatorAbility());
276     std::unique_ptr<RequestConfig> requestConfig = std::make_unique<RequestConfig>();
277     AppIdentity identity;
278     std::shared_ptr<Request> request = std::make_shared<Request>();
279     request->requestConfig_->fixNumber_ = 1;
280     bool res = locatorAbility->IsSingleRequest(request->GetRequestConfig());
281     EXPECT_EQ(true, res);
282     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityIsSingleRequest001 end");
283 }
284 
285 HWTEST_F(LocatorAbilityTest, LocatorAbilityNeedReportCacheLocation001, TestSize.Level1)
286 {
287     GTEST_LOG_(INFO)
288         << "LocatorAbilityTest, LocatorAbilityNeedReportCacheLocation001, TestSize.Level1";
289     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityNeedReportCacheLocation001 begin");
290     auto locatorAbility =
291         sptr<LocatorAbility>(new (std::nothrow) LocatorAbility());
292     sptr<ILocatorCallback> callback;
293     std::shared_ptr<Request> request = nullptr;
294     locatorAbility->reportManager_ = nullptr;
295     locatorAbility->NeedReportCacheLocation(request, callback);
296     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityNeedReportCacheLocation001 end");
297 }
298 
299 HWTEST_F(LocatorAbilityTest, LocatorAbilityNeedReportCacheLocation002, TestSize.Level1)
300 {
301     GTEST_LOG_(INFO)
302         << "LocatorAbilityTest, LocatorAbilityNeedReportCacheLocation002, TestSize.Level1";
303     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityNeedReportCacheLocation002 begin");
304     auto locatorAbility =
305         sptr<LocatorAbility>(new (std::nothrow) LocatorAbility());
306     sptr<ILocatorCallback> callback;
307     std::shared_ptr<Request> request = std::make_shared<Request>();
308     locatorAbility->reportManager_ = ReportManager::GetInstance();
309     request->requestConfig_->fixNumber_ = 1;
310     request->requestConfig_->scenario_ = SCENE_DAILY_LIFE_SERVICE;
311     locatorAbility->NeedReportCacheLocation(request, callback);
312     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityNeedReportCacheLocation002 end");
313 }
314 
315 HWTEST_F(LocatorAbilityTest, LocatorAbilityNeedReportCacheLocation003, TestSize.Level1)
316 {
317     GTEST_LOG_(INFO)
318         << "LocatorAbilityTest, LocatorAbilityNeedReportCacheLocation003, TestSize.Level1";
319     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityNeedReportCacheLocation003 begin");
320     auto locatorAbility =
321         sptr<LocatorAbility>(new (std::nothrow) LocatorAbility());
322     sptr<ILocatorCallback> callback;
323     std::shared_ptr<Request> request = std::make_shared<Request>();
324     locatorAbility->reportManager_ = ReportManager::GetInstance();
325     request->requestConfig_->fixNumber_ = 0;
326     request->requestConfig_->scenario_ = SCENE_DAILY_LIFE_SERVICE;
327     locatorAbility->NeedReportCacheLocation(request, callback);
328     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityNeedReportCacheLocation003 end");
329 }
330 
331 HWTEST_F(LocatorAbilityTest, LocatorAbilityNeedReportCacheLocation004, TestSize.Level1)
332 {
333     GTEST_LOG_(INFO)
334         << "LocatorAbilityTest, LocatorAbilityNeedReportCacheLocation004, TestSize.Level1";
335     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityNeedReportCacheLocation004 begin");
336     auto locatorAbility =
337         sptr<LocatorAbility>(new (std::nothrow) LocatorAbility());
338     sptr<ILocatorCallback> callback;
339     std::shared_ptr<Request> request = std::make_shared<Request>();
340     locatorAbility->reportManager_ = ReportManager::GetInstance();
341     request->requestConfig_->fixNumber_ = 0;
342     request->requestConfig_->scenario_ = LOCATION_PRIORITY_ACCURACY;
343     locatorAbility->NeedReportCacheLocation(request, callback);
344     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityNeedReportCacheLocation004 end");
345 }
346 
347 HWTEST_F(LocatorAbilityTest, LocatorAbilityNeedReportCacheLocation005, TestSize.Level1)
348 {
349     GTEST_LOG_(INFO)
350         << "LocatorAbilityTest, LocatorAbilityNeedReportCacheLocation005, TestSize.Level1";
351     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityNeedReportCacheLocation005 begin");
352     auto locatorAbility =
353         sptr<LocatorAbility>(new (std::nothrow) LocatorAbility());
354     sptr<ILocatorCallback> callback;
355     std::shared_ptr<Request> request = std::make_shared<Request>();
356     locatorAbility->reportManager_ = ReportManager::GetInstance();
357     request->requestConfig_->fixNumber_ = 1;
358     request->requestConfig_->scenario_ = LOCATION_PRIORITY_ACCURACY;
359     locatorAbility->NeedReportCacheLocation(request, callback);
360     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityNeedReportCacheLocation005 end");
361 }
362 
363 HWTEST_F(LocatorAbilityTest, LocatorAbilityHandleStartLocating001, TestSize.Level1)
364 {
365     GTEST_LOG_(INFO)
366         << "LocatorAbilityTest, LocatorAbilityHandleStartLocating001, TestSize.Level1";
367     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityHandleStartLocating001 begin");
368     auto locatorAbility =
369         sptr<LocatorAbility>(new (std::nothrow) LocatorAbility());
370     std::shared_ptr<Request> request = std::make_shared<Request>();
371     sptr<LocatorCallbackHost> locatorCallbackHost =
372         sptr<LocatorCallbackHost>(new (std::nothrow)LocatorCallbackHost());
373     sptr<ILocatorCallback> callback = sptr<ILocatorCallback>(locatorCallbackHost);
374     request->SetLocatorCallBack(callback);
375     locatorAbility->HandleStartLocating(request, callback);
376     locatorAbility->HandleStartLocating(request, callback);
377     locatorAbility->locatorHandler_->TaskCancelAndWait();
378     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityHandleStartLocating001 end");
379 }
380 
381 HWTEST_F(LocatorAbilityTest, LocatorAbilityStopLocating001, TestSize.Level1)
382 {
383     GTEST_LOG_(INFO)
384         << "LocatorAbilityTest, LocatorAbilityStopLocating001, TestSize.Level1";
385     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityStopLocating001 begin");
386     auto locatorAbility =
387         sptr<LocatorAbility>(new (std::nothrow) LocatorAbility());
388     sptr<ILocatorCallback> callback;
389     locatorAbility->requestManager_ = nullptr;
390     locatorAbility->StopLocating(callback);
391     locatorAbility->requestManager_ = RequestManager::GetInstance();
392     locatorAbility->StopLocating(callback);
393     locatorAbility->StopLocating(callback);
394     locatorAbility->locatorHandler_->TaskCancelAndWait();
395     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityStopLocating001 end");
396 }
397 
398 HWTEST_F(LocatorAbilityTest, LocatorAbilityGetCacheLocation001, TestSize.Level1)
399 {
400     GTEST_LOG_(INFO)
401         << "LocatorAbilityTest, LocatorAbilityGetCacheLocation001, TestSize.Level1";
402     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityGetCacheLocation001 begin");
403     auto locatorAbility =
404         sptr<LocatorAbility>(new (std::nothrow) LocatorAbility());
405     std::unique_ptr<Location> loc;
406     AppIdentity identity;
407     locatorAbility->GetCacheLocation(loc, identity);
408     locatorAbility->GetCacheLocation(loc, identity);
409     locatorAbility->locatorHandler_->TaskCancelAndWait();
410     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityGetCacheLocation001 end");
411 }
412 
413 HWTEST_F(LocatorAbilityTest, LocatorAbilityEnableReverseGeocodingMock001, TestSize.Level1)
414 {
415     GTEST_LOG_(INFO)
416         << "LocatorAbilityTest, LocatorAbilityEnableReverseGeocodingMock001, TestSize.Level1";
417     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityEnableReverseGeocodingMock001 begin");
418     auto locatorAbility =
419         sptr<LocatorAbility>(new (std::nothrow) LocatorAbility());
420     locatorAbility->EnableReverseGeocodingMock();
421     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityEnableReverseGeocodingMock001 end");
422 }
423 
424 #ifdef FEATURE_GEOCODE_SUPPORT
425 HWTEST_F(LocatorAbilityTest, LocatorAbilityEnableReverseGeocodingMock002, TestSize.Level1)
426 {
427     GTEST_LOG_(INFO)
428         << "LocatorAbilityTest, LocatorAbilityEnableReverseGeocodingMock002, TestSize.Level1";
429     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityEnableReverseGeocodingMock002 begin");
430     auto locatorAbility =
431         sptr<LocatorAbility>(new (std::nothrow) LocatorAbility());
432     locatorAbility->EnableReverseGeocodingMock();
433     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityEnableReverseGeocodingMock002 end");
434 }
435 #endif
436 
437 HWTEST_F(LocatorAbilityTest, LocatorAbilityDisableReverseGeocodingMock001, TestSize.Level1)
438 {
439     GTEST_LOG_(INFO)
440         << "LocatorAbilityTest, LocatorAbilityDisableReverseGeocodingMock001, TestSize.Level1";
441     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityDisableReverseGeocodingMock001 begin");
442     auto locatorAbility =
443         sptr<LocatorAbility>(new (std::nothrow) LocatorAbility());
444     locatorAbility->DisableReverseGeocodingMock();
445     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityDisableReverseGeocodingMock001 end");
446 }
447 
448 #ifdef FEATURE_GEOCODE_SUPPORT
449 HWTEST_F(LocatorAbilityTest, LocatorAbilityDisableReverseGeocodingMock002, TestSize.Level1)
450 {
451     GTEST_LOG_(INFO)
452         << "LocatorAbilityTest, LocatorAbilityDisableReverseGeocodingMock002, TestSize.Level1";
453     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityDisableReverseGeocodingMock002 begin");
454     auto locatorAbility =
455         sptr<LocatorAbility>(new (std::nothrow) LocatorAbility());
456     locatorAbility->DisableReverseGeocodingMock();
457     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityDisableReverseGeocodingMock002 end");
458 }
459 #endif
460 
461 HWTEST_F(LocatorAbilityTest, LocatorAbilitySetReverseGeocodingMockInfo001, TestSize.Level1)
462 {
463     GTEST_LOG_(INFO)
464         << "LocatorAbilityTest, LocatorAbilitySetReverseGeocodingMockInfo001, TestSize.Level1";
465     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilitySetReverseGeocodingMockInfo001 begin");
466     auto locatorAbility =
467         sptr<LocatorAbility>(new (std::nothrow) LocatorAbility());
468     std::vector<std::shared_ptr<GeocodingMockInfo>> mockInfo;
469     locatorAbility->SetReverseGeocodingMockInfo(mockInfo);
470     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilitySetReverseGeocodingMockInfo001 end");
471 }
472 
473 #ifdef FEATURE_GEOCODE_SUPPORT
474 HWTEST_F(LocatorAbilityTest, LocatorAbilitySetReverseGeocodingMockInfo002, TestSize.Level1)
475 {
476     GTEST_LOG_(INFO)
477         << "LocatorAbilityTest, LocatorAbilitySetReverseGeocodingMockInfo002, TestSize.Level1";
478     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilitySetReverseGeocodingMockInfo002 begin");
479     auto locatorAbility =
480         sptr<LocatorAbility>(new (std::nothrow) LocatorAbility());
481     std::vector<std::shared_ptr<GeocodingMockInfo>> mockInfo;
482     locatorAbility->SetReverseGeocodingMockInfo(mockInfo);
483     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilitySetReverseGeocodingMockInfo002 end");
484 }
485 #endif
486 
487 HWTEST_F(LocatorAbilityTest, LocatorAbilityRegisterPermissionCallback001, TestSize.Level1)
488 {
489     GTEST_LOG_(INFO)
490         << "LocatorAbilityTest, LocatorAbilityRegisterPermissionCallback001, TestSize.Level1";
491     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityRegisterPermissionCallback001 begin");
492     auto locatorAbility =
493         sptr<LocatorAbility>(new (std::nothrow) LocatorAbility());
494     auto permissionMap =
495         std::make_shared<std::map<uint32_t, std::shared_ptr<PermissionStatusChangeCb>>>();
496     locatorAbility->permissionMap_ = permissionMap;
497     uint32_t callingTokenId = 10;
498     std::vector<std::string> permissionNameList;
499     locatorAbility->RegisterPermissionCallback(callingTokenId, permissionNameList);
500     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityRegisterPermissionCallback001 end");
501 }
502 
503 HWTEST_F(LocatorAbilityTest, LocatorAbilityUnRegisterPermissionCallback001, TestSize.Level1)
504 {
505     GTEST_LOG_(INFO)
506         << "LocatorAbilityTest, LocatorAbilityUnRegisterPermissionCallback001, TestSize.Level1";
507     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityUnRegisterPermissionCallback001 begin");
508     auto locatorAbility =
509         sptr<LocatorAbility>(new (std::nothrow) LocatorAbility());
510     auto permissionMap =
511         std::make_shared<std::map<uint32_t, std::shared_ptr<PermissionStatusChangeCb>>>();
512     locatorAbility->permissionMap_ = permissionMap;
513     uint32_t callingTokenId = 10;
514     std::vector<std::string> permissionNameList;
515     locatorAbility->UnregisterPermissionCallback(callingTokenId);
516     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityUnRegisterPermissionCallback001 end");
517 }
518 
519 HWTEST_F(LocatorAbilityTest, LocatorAbilityReportDataToResSched001, TestSize.Level1)
520 {
521     GTEST_LOG_(INFO)
522         << "LocatorAbilityTest, LocatorAbilityReportDataToResSched001, TestSize.Level1";
523     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityReportDataToResSched001 begin");
524     auto locatorAbility =
525         sptr<LocatorAbility>(new (std::nothrow) LocatorAbility());
526     std::string state("state");
527     locatorAbility->ReportDataToResSched(state);
528     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityReportDataToResSched001 end");
529 }
530 
531 HWTEST_F(LocatorAbilityTest, LocatorAbilityUpdateLastLocationRequestNum001, TestSize.Level1)
532 {
533     GTEST_LOG_(INFO)
534         << "LocatorAbilityTest, LocatorAbilityUpdateLastLocationRequestNum001, TestSize.Level1";
535     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityUpdateLastLocationRequestNum001 begin");
536     auto locatorAbility =
537         sptr<LocatorAbility>(new (std::nothrow) LocatorAbility());
538     locatorAbility->locatorHandler_->TaskCancelAndWait();
539     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityUpdateLastLocationRequestNum001 end");
540 }
541 
542 #ifdef FEATURE_GNSS_SUPPORT
543 HWTEST_F(LocatorAbilityTest, LocatorAbilitySendNetworkLocation001, TestSize.Level1)
544 {
545     GTEST_LOG_(INFO)
546         << "LocatorAbilityTest, LocatorAbilitySendNetworkLocation001, TestSize.Level1";
547     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilitySendNetworkLocation001 begin");
548     auto locatorAbility =
549         sptr<LocatorAbility>(new (std::nothrow) LocatorAbility());
550     std::unique_ptr<Location> location = std::make_unique<Location>();
551     locatorAbility->SendNetworkLocation(location);
552     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilitySendNetworkLocation001 end");
553 }
554 #endif
555 
556 HWTEST_F(LocatorAbilityTest, LocatorAbilityRegisterLocationError001, TestSize.Level1)
557 {
558     GTEST_LOG_(INFO)
559         << "LocatorAbilityTest, LocatorAbilityRegisterLocationError001, TestSize.Level1";
560     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityRegisterLocationError001 begin");
561     auto locatorAbility =
562         sptr<LocatorAbility>(new (std::nothrow) LocatorAbility());
563     sptr<ILocatorCallback> callback;
564     AppIdentity identity;
565     locatorAbility->RegisterLocationError(callback, identity);
566     locatorAbility->UnregisterLocationError(callback, identity);
567     locatorAbility->RegisterLocationError(callback, identity);
568     locatorAbility->UnregisterLocationError(callback, identity);
569     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityRegisterLocationError001 end");
570 }
571 
572 HWTEST_F(LocatorAbilityTest, LocatorAbilityReportLocationError001, TestSize.Level1)
573 {
574     GTEST_LOG_(INFO)
575         << "LocatorAbilityTest, LocatorAbilityReportLocationError001, TestSize.Level1";
576     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityReportLocationError001 begin");
577     auto locatorAbility =
578         sptr<LocatorAbility>(new (std::nothrow) LocatorAbility());
579     std::string uuid;
580     int32_t errCode = 10;
581     locatorAbility->ReportLocationError(uuid, errCode);
582     locatorAbility->ReportLocationError(uuid, errCode);
583     locatorAbility->locatorHandler_->TaskCancelAndWait();
584     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilityUnRegisterLocationError001 end");
585 }
586 
587 HWTEST_F(LocatorAbilityTest, LocatorAbilitySyncIdleState001, TestSize.Level1)
588 {
589     GTEST_LOG_(INFO)
590         << "LocatorAbilityTest, LocatorAbilitySyncIdleState001, TestSize.Level1";
591     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilitySyncIdleState001 begin");
592     auto locatorAbility =
593         sptr<LocatorAbility>(new (std::nothrow) LocatorAbility());
594     bool state = true;
595     locatorAbility->SyncIdleState(state);
596     state = false;
597     locatorAbility->SyncIdleState(state);
598     locatorAbility->locatorHandler_->TaskCancelAndWait();
599     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorAbilitySyncIdleState001 end");
600 }
601 
602 HWTEST_F(LocatorAbilityTest, LocationMessageGetAbilityName001, TestSize.Level1)
603 {
604     GTEST_LOG_(INFO)
605         << "LocatorAbilityTest, LocationMessageGetAbilityName001, TestSize.Level1";
606     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocationMessageGetAbilityName001 begin");
607     auto locationMessage =
608         new (std::nothrow) LocationMessage();
609     locationMessage->GetAbilityName();
610     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocationMessageGetAbilityName001 end");
611 }
612 
613 HWTEST_F(LocatorAbilityTest, LocationMessageSetLocation001, TestSize.Level1)
614 {
615     GTEST_LOG_(INFO)
616         << "LocatorAbilityTest, LocationMessageSetLocation001, TestSize.Level1";
617     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocationMessageSetLocation001 begin");
618     auto locationMessage =
619         new (std::nothrow) LocationMessage();
620     locationMessage->location_ = nullptr;
621     std::unique_ptr<Location> location;
622     locationMessage->SetLocation(location);
623     location = std::make_unique<Location>();
624     locationMessage->SetLocation(location);
625     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocationMessageSetLocation001 end");
626 }
627 
628 HWTEST_F(LocatorAbilityTest, LocationMessageGetLocation001, TestSize.Level1)
629 {
630     GTEST_LOG_(INFO)
631         << "LocatorAbilityTest, LocationMessageGetLocation001, TestSize.Level1";
632     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocationMessageGetLocation001 begin");
633     auto locationMessage =
634         new (std::nothrow) LocationMessage();
635     locationMessage->location_ = nullptr;
636     locationMessage->GetLocation();
637     locationMessage->location_ = std::make_unique<Location>();
638     locationMessage->GetLocation();
639     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocationMessageGetLocation001 end");
640 }
641 
642 HWTEST_F(LocatorAbilityTest, LocatorHandlerInitLocatorHandlerEventMap001, TestSize.Level1)
643 {
644     GTEST_LOG_(INFO)
645         << "LocatorAbilityTest, LocatorHandlerInitLocatorHandlerEventMap001, TestSize.Level1";
646     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorHandlerInitLocatorHandlerEventMap001 begin");
647     std::shared_ptr<AppExecFwk::EventRunner> runner;
648     auto locatorHandler =
649         new (std::nothrow) LocatorHandler(runner);
650     locatorHandler->InitLocatorHandlerEventMap();
651     locatorHandler->InitLocatorHandlerEventMap();
652     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorHandlerInitLocatorHandlerEventMap001 end");
653 }
654 
655 HWTEST_F(LocatorAbilityTest, LocatorHandlerGetCachedLocationSuccess001, TestSize.Level1)
656 {
657     GTEST_LOG_(INFO)
658         << "LocatorAbilityTest, LocatorHandlerGetCachedLocationSuccess001, TestSize.Level1";
659     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorHandlerGetCachedLocationSuccess001 begin");
660     AppIdentity identity;
661     identity.SetPid(1);
662     identity.SetUid(1);
663     identity.SetTokenId(1);
664     identity.SetTokenIdEx(1);
665     identity.SetFirstTokenId(1);
666     identity.SetBundleName("com.example.lbs.test");
667     std::shared_ptr<AppIdentity> identityInfo = std::make_shared<AppIdentity>(identity);
668     AppExecFwk::InnerEvent::Pointer event  =
669         AppExecFwk::InnerEvent::Get(EVENT_SEND_SWITCHSTATE_TO_HIFENCE, identityInfo);
670     std::shared_ptr<AppExecFwk::EventRunner> runner;
671     auto locatorHandler = new (std::nothrow) LocatorHandler(runner);
672     locatorHandler->GetCachedLocationSuccess(event);
673     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorHandlerGetCachedLocationSuccess001 end");
674 }
675 
676 HWTEST_F(LocatorAbilityTest, LocatorHandlerGetCachedLocationFailed001, TestSize.Level1)
677 {
678     GTEST_LOG_(INFO)
679         << "LocatorAbilityTest, LocatorHandlerGetCachedLocationFailed001, TestSize.Level1";
680     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorHandlerGetCachedLocationFailed001 begin");
681     AppIdentity identity;
682     identity.SetPid(1);
683     identity.SetUid(1);
684     identity.SetTokenId(1);
685     identity.SetTokenIdEx(1);
686     identity.SetFirstTokenId(1);
687     identity.SetBundleName("com.example.lbs.test");
688     std::shared_ptr<AppIdentity> identityInfo = std::make_shared<AppIdentity>(identity);
689     AppExecFwk::InnerEvent::Pointer event  =
690         AppExecFwk::InnerEvent::Get(EVENT_SEND_SWITCHSTATE_TO_HIFENCE, identityInfo);
691     std::shared_ptr<AppExecFwk::EventRunner> runner;
692     auto locatorHandler = new (std::nothrow) LocatorHandler(runner);
693     locatorHandler->GetCachedLocationFailed(event);
694     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorHandlerGetCachedLocationFailed001 end");
695 }
696 
697 HWTEST_F(LocatorAbilityTest, LocatorHandlerUpdateSaEvent001, TestSize.Level1)
698 {
699     GTEST_LOG_(INFO)
700         << "LocatorAbilityTest, LocatorHandlerUpdateSaEvent001, TestSize.Level1";
701     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorHandlerUpdateSaEvent001 begin");
702     std::shared_ptr<AppExecFwk::EventRunner> runner;
703     auto locatorHandler =
704         new (std::nothrow) LocatorHandler(runner);
705     int state = 1;
706     AppExecFwk::InnerEvent::Pointer event  =
707         AppExecFwk::InnerEvent::Get(EVENT_SEND_SWITCHSTATE_TO_HIFENCE, state);
708     locatorHandler->UpdateSaEvent(event);
709     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorHandlerUpdateSaEvent001 end");
710 }
711 
712 HWTEST_F(LocatorAbilityTest, LocatorHandlerApplyRequirementsEvent001, TestSize.Level1)
713 {
714     GTEST_LOG_(INFO)
715         << "LocatorAbilityTest, LocatorHandlerApplyRequirementsEvent001, TestSize.Level1";
716     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorHandlerApplyRequirementsEvent001 begin");
717     std::shared_ptr<AppExecFwk::EventRunner> runner;
718     auto locatorHandler =
719         new (std::nothrow) LocatorHandler(runner);
720     int state = 1;
721     AppExecFwk::InnerEvent::Pointer event  =
722         AppExecFwk::InnerEvent::Get(EVENT_SEND_SWITCHSTATE_TO_HIFENCE, state);
723     locatorHandler->ApplyRequirementsEvent(event);
724     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorHandlerApplyRequirementsEvent001 end");
725 }
726 
727 HWTEST_F(LocatorAbilityTest, LocatorHandlerRetryRegisterActionEvent001, TestSize.Level1)
728 {
729     GTEST_LOG_(INFO)
730         << "LocatorAbilityTest, LocatorHandlerRetryRegisterActionEvent001, TestSize.Level1";
731     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorHandlerRetryRegisterActionEvent001 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->RetryRegisterActionEvent(event);
739     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorHandlerRetryRegisterActionEvent001 end");
740 }
741 
742 HWTEST_F(LocatorAbilityTest, LocatorHandlerReportLocationMessageEvent001, TestSize.Level1)
743 {
744     GTEST_LOG_(INFO)
745         << "LocatorAbilityTest, LocatorHandlerReportLocationMessageEvent001, TestSize.Level1";
746     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorHandlerReportLocationMessageEvent001 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->ReportLocationMessageEvent(event);
754     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorHandlerReportLocationMessageEvent001 end");
755 }
756 
757 HWTEST_F(LocatorAbilityTest, LocatorHandlerStartAndStopLocatingEvent001, TestSize.Level1)
758 {
759     GTEST_LOG_(INFO)
760         << "LocatorAbilityTest, LocatorHandlerStartLocatingEvent001, TestSize.Level1";
761     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorHandlerStartLocatingEvent001 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->StartLocatingEvent(event);
769     locatorHandler->StopLocatingEvent(event);
770     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorHandlerStartLocatingEvent001 end");
771 }
772 
773 HWTEST_F(LocatorAbilityTest, LocatorHandlerUpdateLastLocationRequestNum001, TestSize.Level1)
774 {
775     GTEST_LOG_(INFO)
776         << "LocatorAbilityTest, LocatorHandlerUpdateLastLocationRequestNum001, TestSize.Level1";
777     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorHandlerUpdateLastLocationRequestNum001 begin");
778     std::shared_ptr<AppExecFwk::EventRunner> runner;
779     auto locatorHandler =
780         new (std::nothrow) LocatorHandler(runner);
781     int state = 1;
782     AppExecFwk::InnerEvent::Pointer event  =
783         AppExecFwk::InnerEvent::Get(EVENT_SEND_SWITCHSTATE_TO_HIFENCE, state);
784     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorHandlerUpdateLastLocationRequestNum001 end");
785 }
786 
787 HWTEST_F(LocatorAbilityTest, LocatorHandlerUnloadSaEvent001, TestSize.Level1)
788 {
789     GTEST_LOG_(INFO)
790         << "LocatorAbilityTest, LocatorHandlerUnloadSaEvent001, TestSize.Level1";
791     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorHandlerUnloadSaEvent001 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->UnloadSaEvent(event);
799     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorHandlerUnloadSaEvent001 end");
800 }
801 
802 HWTEST_F(LocatorAbilityTest, LocatorHandler001, TestSize.Level1)
803 {
804     GTEST_LOG_(INFO)
805         << "LocatorAbilityTest, LocatorHandler001, TestSize.Level1";
806     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorHandler001 begin");
807     std::shared_ptr<AppExecFwk::EventRunner> runner;
808     auto locatorHandler =
809         new (std::nothrow) LocatorHandler(runner);
810     int state = 1;
811     AppExecFwk::InnerEvent::Pointer event  =
812         AppExecFwk::InnerEvent::Get(EVENT_SEND_SWITCHSTATE_TO_HIFENCE, state);
813     locatorHandler->RegLocationErrorEvent(event);
814     locatorHandler->UnRegLocationErrorEvent(event);
815     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorHandler001 end");
816 }
817 
818 HWTEST_F(LocatorAbilityTest, LocatorHandler002, TestSize.Level1)
819 {
820     GTEST_LOG_(INFO)
821         << "LocatorAbilityTest, LocatorHandler002, TestSize.Level1";
822     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorHandler002 begin");
823     std::shared_ptr<AppExecFwk::EventRunner> runner;
824     auto locatorHandler =
825         new (std::nothrow) LocatorHandler(runner);
826     int state = 1;
827     AppExecFwk::InnerEvent::Pointer event  =
828         AppExecFwk::InnerEvent::Get(EVENT_SEND_SWITCHSTATE_TO_HIFENCE, state);
829     locatorHandler->SyncIdleState(event);
830     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorHandler002 end");
831 }
832 
833 HWTEST_F(LocatorAbilityTest, LocatorCallbackDeathRecipient001, TestSize.Level1)
834 {
835     GTEST_LOG_(INFO)
836         << "LocatorAbilityTest, LocatorCallbackDeathRecipient001, TestSize.Level1";
837     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorCallbackDeathRecipient001 begin");
838     int32_t tokenId = 1;
839     auto recipient =
840         sptr<LocatorCallbackDeathRecipient>(new (std::nothrow) LocatorCallbackDeathRecipient(tokenId));
841     wptr<IRemoteObject> remote;
842     recipient->OnRemoteDied(remote);
843     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorCallbackDeathRecipient001 end");
844 }
845 
846 HWTEST_F(LocatorAbilityTest, LocatorHandler003, TestSize.Level1)
847 {
848     GTEST_LOG_(INFO)
849         << "LocatorAbilityTest, LocatorHandler003, TestSize.Level1";
850     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorHandler003 begin");
851     std::shared_ptr<AppExecFwk::EventRunner> runner;
852     auto locatorHandler =
853         new (std::nothrow) LocatorHandler(runner);
854     int state = 1;
855     AppExecFwk::InnerEvent::Pointer event  =
856         AppExecFwk::InnerEvent::Get(EVENT_SEND_SWITCHSTATE_TO_HIFENCE, state);
857     locatorHandler->RequestCheckEvent(event);
858     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorHandler003 end");
859 }
860 
861 HWTEST_F(LocatorAbilityTest, LocatorHandler004, TestSize.Level1)
862 {
863     GTEST_LOG_(INFO)
864         << "LocatorAbilityTest, LocatorHandler004, TestSize.Level1";
865     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorHandler004 begin");
866     std::shared_ptr<AppExecFwk::EventRunner> runner;
867     auto locatorHandler =
868         new (std::nothrow) LocatorHandler(runner);
869     int state = 1;
870     AppExecFwk::InnerEvent::Pointer event  =
871         AppExecFwk::InnerEvent::Get(EVENT_SEND_SWITCHSTATE_TO_HIFENCE, state);
872     locatorHandler->SyncStillMovementState(event);
873     LBSLOGI(LOCATOR, "[LocatorAbilityTest] LocatorHandler004 end");
874 }
875 }  // namespace Location
876 }  // namespace OHOS