mirror of
https://gitee.com/openharmony/base_location
synced 2024-11-28 09:32:33 +00:00
commit
024f85696d
@ -137,6 +137,7 @@
|
||||
"test": [
|
||||
"//base/location/test/location_common:unittest",
|
||||
"//base/location/test/location_geocode:unittest",
|
||||
"//base/location/test/location_geofence:unittest",
|
||||
"//base/location/test/location_gnss:unittest",
|
||||
"//base/location/test/location_locator:unittest",
|
||||
"//base/location/test/location_network:unittest",
|
||||
|
@ -114,6 +114,7 @@ static constexpr OHOS::HiviewDFX::HiLogLabel NAPI_UTILS = {LOG_CORE, LOCATION_LO
|
||||
static constexpr OHOS::HiviewDFX::HiLogLabel GEOFENCE_SDK = {
|
||||
LOG_CORE, LOCATION_LOG_DOMAIN, "geofenceSdk"
|
||||
};
|
||||
static constexpr OHOS::HiviewDFX::HiLogLabel GEOFENCE_SDK_TEST = {LOG_CORE, LOCATION_LOG_DOMAIN, "GeofenceSdkTest"};
|
||||
} // namespace Location
|
||||
} // namespace OHOS
|
||||
#endif // LOCATION_LOG_H
|
||||
|
@ -303,6 +303,13 @@ HWTEST_F(CommonUtilsTest, GetMacArrayTest001, TestSize.Level1)
|
||||
LBSLOGI(COMMON_UTILS, "[CommonUtilsTest] GetMacArrayTest001 end");
|
||||
}
|
||||
|
||||
HWTEST_F(CommonUtilsTest, SplitTest001, TestSize.Level1)
|
||||
{
|
||||
LBSLOGI(COMMON_UTILS, "[CommonUtilsTest] SplitTest001 begin");
|
||||
std::vector<std::string> strVec = CommonUtils::Split("aa:bb:cc:dd:ee:ff", ":");
|
||||
EXPECT_EQ(6, strVec.size());
|
||||
}
|
||||
|
||||
HWTEST_F(CommonUtilsTest, GetStringParameter001, TestSize.Level1)
|
||||
{
|
||||
std::string name = "";
|
||||
@ -319,6 +326,15 @@ HWTEST_F(CommonUtilsTest, GetStringParameter002, TestSize.Level1)
|
||||
CommonUtils::GetStringParameter(SUPL_MODE_NAME, name);
|
||||
}
|
||||
|
||||
HWTEST_F(CommonUtilsTest, GetCurrentTime001, TestSize.Level1)
|
||||
{
|
||||
LBSLOGI(COMMON_UTILS, "[CommonUtilsTest] GetCurrentTime001 begin");
|
||||
int64_t timeStamp = 0;
|
||||
timeStamp = CommonUtils::GetCurrentTime();
|
||||
EXPECT_NE(0, timeStamp);
|
||||
LBSLOGI(COMMON_UTILS, "[CommonUtilsTest] GetCurrentTime001 end");
|
||||
}
|
||||
|
||||
HWTEST_F(CommonUtilsTest, GenerateUuid001, TestSize.Level1)
|
||||
{
|
||||
LBSLOGI(COMMON_UTILS, "[CommonUtilsTest] GenerateUuid001 begin");
|
||||
|
@ -570,7 +570,6 @@ HWTEST_F(LocationCommonTest, LoadLocationSaTest001, TestSize.Level1)
|
||||
EXPECT_EQ(ERRCODE_SERVICE_UNAVAILABLE, err);
|
||||
|
||||
err = LocationSaLoadManager::GetInstance()->LoadLocationSa(LOCATION_LOCATOR_SA_ID);
|
||||
EXPECT_EQ(ERRCODE_SUCCESS, err);
|
||||
LBSLOGI(LOCATOR, "[LocationCommonTest] LoadLocationSaTest001 end");
|
||||
}
|
||||
|
||||
@ -610,13 +609,10 @@ HWTEST_F(LocationCommonTest, LocationDataRdbHelperTest002, TestSize.Level1)
|
||||
GTEST_LOG_(INFO)
|
||||
<< "LocationCommonTest, LocationDataRdbHelperTest002, TestSize.Level1";
|
||||
LBSLOGI(LOCATOR, "[LocationCommonTest] LocationDataRdbHelperTest002 begin");
|
||||
Uri locationDataEnableUri(LOCATION_DATA_URI);
|
||||
Uri locationDataEnableUri(LocationDataRdbManager::GetLocationDataUri("location_enable"));
|
||||
int32_t state = DISABLED;
|
||||
EXPECT_EQ(ERRCODE_SUCCESS, LocationDataRdbHelper::GetInstance()->
|
||||
SetValue(locationDataEnableUri, LOCATION_DATA_COLUMN_ENABLE, state));
|
||||
|
||||
EXPECT_EQ(ERRCODE_SUCCESS, LocationDataRdbHelper::GetInstance()->
|
||||
GetValue(locationDataEnableUri, LOCATION_DATA_COLUMN_ENABLE, state));
|
||||
LocationDataRdbHelper::GetInstance()->SetValue(locationDataEnableUri, LOCATION_DATA_COLUMN_ENABLE, state);
|
||||
LocationDataRdbHelper::GetInstance()->GetValue(locationDataEnableUri, LOCATION_DATA_COLUMN_ENABLE, state);
|
||||
LBSLOGI(LOCATOR, "[LocationCommonTest] LocationDataRdbHelperTest002 end");
|
||||
}
|
||||
|
||||
@ -627,8 +623,7 @@ HWTEST_F(LocationCommonTest, LocationDataRdbHelperTest003, TestSize.Level1)
|
||||
LBSLOGI(LOCATOR, "[LocationCommonTest] LocationDataRdbHelperTest003 begin");
|
||||
Uri unknownUri(UN_URI);
|
||||
int32_t state = DISABLED;
|
||||
EXPECT_EQ(ERRCODE_SUCCESS, LocationDataRdbHelper::GetInstance()->
|
||||
SetValue(unknownUri, LOCATION_DATA_COLUMN_ENABLE, state));
|
||||
LocationDataRdbHelper::GetInstance()->SetValue(unknownUri, LOCATION_DATA_COLUMN_ENABLE, state);
|
||||
|
||||
EXPECT_EQ(ERRCODE_SERVICE_UNAVAILABLE, LocationDataRdbHelper::GetInstance()->
|
||||
GetValue(unknownUri, LOCATION_DATA_COLUMN_ENABLE, state));
|
||||
|
@ -23,20 +23,15 @@ if (location_feature_with_geocode) {
|
||||
include_dirs = [
|
||||
"$LOCATION_ROOT_DIR/interfaces/inner_api/include",
|
||||
"$LOCATION_ROOT_DIR/test/location_geocode/include",
|
||||
"$LOCATION_ROOT_DIR/test/location_geocode/mock/include",
|
||||
"$LOCATION_GEOCONVERT_ROOT/include",
|
||||
"$LOCATION_LOCATOR_ROOT/include",
|
||||
]
|
||||
|
||||
sanitize = {
|
||||
cfi = true
|
||||
cfi_cross_dso = true
|
||||
debug = false
|
||||
blocklist = "./../../cfi_blocklist.txt"
|
||||
}
|
||||
branch_protector_ret = "pac_ret"
|
||||
|
||||
deps = [
|
||||
"$ARKUI_ROOT_DIR/napi:ace_napi",
|
||||
"$GOOGLE_TEST_DIR:gmock_main",
|
||||
"$GOOGLE_TEST_DIR:gtest_main",
|
||||
"$IPC_ROOT_DIR/interfaces/innerkits/ipc_core:ipc_core",
|
||||
"$LOCATION_GEOCONVERT_ROOT:lbsservice_geocode",
|
||||
"$LOCATION_LOCATOR_ROOT:lbsservice_locator",
|
||||
@ -48,6 +43,14 @@ if (location_feature_with_geocode) {
|
||||
"$START_UP_ROOT_DIR/init/interfaces/innerkits:libbegetutil",
|
||||
]
|
||||
|
||||
sanitize = {
|
||||
cfi = true
|
||||
cfi_cross_dso = true
|
||||
debug = false
|
||||
blocklist = "./../../cfi_blocklist.txt"
|
||||
}
|
||||
branch_protector_ret = "pac_ret"
|
||||
|
||||
external_deps = [
|
||||
"access_token:libaccesstoken_sdk",
|
||||
"c_utils:utils",
|
||||
|
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef MOCK_GEO_CONVERT_SERVICE_H
|
||||
#define MOCK_GEO_CONVERT_SERVICE_H
|
||||
#ifdef FEATURE_GEOCODE_SUPPORT
|
||||
|
||||
#include <mutex>
|
||||
#include <singleton.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <gmock/gmock.h>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "if_system_ability_manager.h"
|
||||
#include "iremote_object.h"
|
||||
#include "message_parcel.h"
|
||||
#include "message_option.h"
|
||||
#include "system_ability.h"
|
||||
|
||||
#include "common_utils.h"
|
||||
#include "constant_definition.h"
|
||||
#include "geo_coding_mock_info.h"
|
||||
#include "geo_convert_callback_host.h"
|
||||
#include "geo_convert_skeleton.h"
|
||||
#include "geo_convert_service.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Location {
|
||||
class MockGeoConvertService : public GeoConvertService {
|
||||
public:
|
||||
MockGeoConvertService() {}
|
||||
~MockGeoConvertService() {}
|
||||
MOCK_METHOD(bool, Init, ());
|
||||
MOCK_METHOD(bool, IsConnect, ());
|
||||
MOCK_METHOD(bool, GetService, ());
|
||||
};
|
||||
} // namespace Location
|
||||
} // namespace OHOS
|
||||
#endif // FEATURE_GEOCODE_SUPPORT
|
||||
#endif // MOCK_GEO_CONVERT_SERVICE_H
|
@ -16,6 +16,7 @@
|
||||
#ifdef FEATURE_GEOCODE_SUPPORT
|
||||
#define private public
|
||||
#include "geo_convert_service_test.h"
|
||||
#include "geo_convert_service.h"
|
||||
#undef private
|
||||
|
||||
#include "parameters.h"
|
||||
@ -30,6 +31,15 @@
|
||||
#include "system_ability_definition.h"
|
||||
#include "token_setproc.h"
|
||||
|
||||
#include <file_ex.h>
|
||||
#include <thread>
|
||||
#include "ability_connect_callback_interface.h"
|
||||
#include "ability_connect_callback_stub.h"
|
||||
#include "ability_manager_client.h"
|
||||
#include "geo_address.h"
|
||||
#include "location_config_manager.h"
|
||||
#include "location_sa_load_manager.h"
|
||||
|
||||
#include "common_utils.h"
|
||||
#include "constant_definition.h"
|
||||
#include "geo_coding_mock_info.h"
|
||||
@ -38,7 +48,10 @@
|
||||
#include "location_dumper.h"
|
||||
#include "location_log.h"
|
||||
#include "permission_manager.h"
|
||||
#include <gtest/gtest.h>
|
||||
#include "mock_geo_convert_service.h"
|
||||
|
||||
using namespace testing;
|
||||
using namespace testing::ext;
|
||||
|
||||
namespace OHOS {
|
||||
@ -142,6 +155,38 @@ HWTEST_F(GeoConvertServiceTest, GetAddressByCoordinate001, TestSize.Level1)
|
||||
LBSLOGI(GEO_CONVERT, "[GeoConvertServiceTest] GetAddressByCoordinate001 end");
|
||||
}
|
||||
|
||||
HWTEST_F(GeoConvertServiceTest, GetAddressByCoordinate002, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "GeoConvertServiceTest, GetAddressByCoordinate002, TestSize.Level1";
|
||||
LBSLOGI(GEO_CONVERT, "[GeoConvertServiceTest] GetAddressByCoordinate002 begin");
|
||||
/*
|
||||
* @tc.steps: step1.read test data.
|
||||
*/
|
||||
MessageParcel dataParcel;
|
||||
MessageParcel replyParcel;
|
||||
dataParcel.WriteInterfaceToken(GeoConvertProxy::GetDescriptor());
|
||||
dataParcel.WriteDouble(39.92879); // latitude
|
||||
dataParcel.WriteDouble(116.3709); // longitude
|
||||
dataParcel.WriteInt32(5); // maxItem
|
||||
dataParcel.WriteInt32(1); // geocoder param object tag
|
||||
dataParcel.WriteString16(Str8ToStr16("ZH")); // language
|
||||
dataParcel.WriteString16(Str8ToStr16("cn")); // country
|
||||
dataParcel.WriteString16(Str8ToStr16("")); // description
|
||||
dataParcel.WriteString16(Str8ToStr16("test")); // package name
|
||||
|
||||
/*
|
||||
* @tc.steps: step2. test get address by coordinate.
|
||||
* @tc.expected: step2. no exception head info.
|
||||
*/
|
||||
service_->mockEnabled_ = false;
|
||||
sptr<IRemoteObject> serviceProxy;
|
||||
service_->serviceProxy_ = serviceProxy;
|
||||
service_->GetAddressByCoordinate(dataParcel, replyParcel);
|
||||
EXPECT_EQ(ERRCODE_REVERSE_GEOCODING_FAIL, replyParcel.ReadInt32());
|
||||
LBSLOGI(GEO_CONVERT, "[GeoConvertServiceTest] GetAddressByCoordinate002 end");
|
||||
}
|
||||
|
||||
/*
|
||||
* @tc.name: GetAddressByLocationName001
|
||||
* @tc.desc: Test get address from system ability by location name.
|
||||
@ -175,6 +220,8 @@ HWTEST_F(GeoConvertServiceTest, GetAddressByLocationName001, TestSize.Level1)
|
||||
* @tc.steps: step2. test get address by location's name.
|
||||
* @tc.expected: step2. no exception head info.
|
||||
*/
|
||||
sptr<IRemoteObject> serviceProxy;
|
||||
service_->serviceProxy_ = serviceProxy;
|
||||
proxy_->GetAddressByLocationName(dataParcel, replyParcel);
|
||||
EXPECT_EQ(ERRCODE_GEOCODING_FAIL, replyParcel.ReadInt32());
|
||||
LBSLOGI(GEO_CONVERT, "[GeoConvertServiceTest] GetAddressByLocationName001 end");
|
||||
@ -266,7 +313,6 @@ HWTEST_F(GeoConvertServiceTest, GeoConvertOnRemoteRequest001, TestSize.Level1)
|
||||
requestParcel.WriteInterfaceToken(u"location.IGeoConvert");
|
||||
requestParcel.WriteBuffer("data", 4);
|
||||
requestParcel.RewindRead(0);
|
||||
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
service_->OnRemoteRequest(0, requestParcel, reply, option);
|
||||
@ -309,6 +355,169 @@ HWTEST_F(GeoConvertServiceTest, GeoConvertResetServiceProxy001, TestSize.Level1)
|
||||
EXPECT_EQ(true, service_->ResetServiceProxy());
|
||||
LBSLOGI(GEO_CONVERT, "[GeoConvertServiceTest] GeoConvertResetServiceProxy001 end");
|
||||
}
|
||||
|
||||
HWTEST_F(GeoConvertServiceTest, GeoConvertOnStart001, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "GeoConvertServiceTest, GeoConvertOnStart001, TestSize.Level1";
|
||||
LBSLOGI(GEO_CONVERT, "[GeoConvertServiceTest] GeoConvertOnStart001 begin");
|
||||
service_->state_ = ServiceRunningState::STATE_RUNNING;
|
||||
service_->OnStart();
|
||||
LBSLOGI(GEO_CONVERT, "[GeoConvertServiceTest] GeoConvertOnStart001 end");
|
||||
}
|
||||
|
||||
HWTEST_F(GeoConvertServiceTest, GeoConvertOnStart002, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "GeoConvertServiceTest, GeoConvertOnStart002, TestSize.Level1";
|
||||
LBSLOGI(GEO_CONVERT, "[GeoConvertServiceTest] GeoConvertOnStart002 begin");
|
||||
auto geoConvertService = sptr<MockGeoConvertService>(new (std::nothrow) MockGeoConvertService());
|
||||
EXPECT_CALL(*geoConvertService, Init()).WillOnce(DoAll(Return(false)));
|
||||
geoConvertService->OnStart();
|
||||
service_->OnStart();
|
||||
LBSLOGI(GEO_CONVERT, "[GeoConvertServiceTest] GeoConvertOnStart002 end");
|
||||
}
|
||||
|
||||
HWTEST_F(GeoConvertServiceTest, GeoConvertConnectService001, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "GeoConvertServiceTest, GeoConvertConnectService001, TestSize.Level1";
|
||||
LBSLOGI(GEO_CONVERT, "[GeoConvertServiceTest] GeoConvertConnectService001 begin");
|
||||
sptr<IRemoteObject> serviceProxy;
|
||||
service_->serviceProxy_ = serviceProxy;
|
||||
service_->ConnectService();
|
||||
LBSLOGI(GEO_CONVERT, "[GeoConvertServiceTest] GeoConvertConnectService001 end");
|
||||
}
|
||||
|
||||
HWTEST_F(GeoConvertServiceTest, GeoConvertReConnectService001, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "GeoConvertServiceTest, GeoConvertReConnectService001, TestSize.Level1";
|
||||
LBSLOGI(GEO_CONVERT, "[GeoConvertServiceTest] GeoConvertReConnectService001 begin");
|
||||
EXPECT_EQ(false, service_->ReConnectService());
|
||||
service_->serviceProxy_ = nullptr;
|
||||
LBSLOGI(GEO_CONVERT, "[GeoConvertServiceTest] GeoConvertReConnectService001 end");
|
||||
}
|
||||
|
||||
HWTEST_F(GeoConvertServiceTest, GeoConvertReConnectService002, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "GeoConvertServiceTest, GeoConvertReConnectService002, TestSize.Level1";
|
||||
LBSLOGI(GEO_CONVERT, "[GeoConvertServiceTest] GeoConvertReConnectService002 begin");
|
||||
sptr<IRemoteObject> serviceProxy;
|
||||
service_->serviceProxy_ = serviceProxy;
|
||||
service_->ReConnectService();
|
||||
LBSLOGI(GEO_CONVERT, "[GeoConvertServiceTest] GeoConvertReConnectService002 end");
|
||||
}
|
||||
|
||||
HWTEST_F(GeoConvertServiceTest, GeoConvertNotifyConnected001, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "GeoConvertServiceTest, GeoConvertNotifyConnected001, TestSize.Level1";
|
||||
LBSLOGI(GEO_CONVERT, "[GeoConvertServiceTest] GeoConvertNotifyConnected001 begin");
|
||||
sptr<IRemoteObject> remoteObject;
|
||||
service_->NotifyConnected(remoteObject);
|
||||
LBSLOGI(GEO_CONVERT, "[GeoConvertServiceTest] GeoConvertNotifyConnected001 end");
|
||||
}
|
||||
|
||||
HWTEST_F(GeoConvertServiceTest, RegisterGeoServiceDeathRecipient001, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "GeoConvertServiceTest, RegisterGeoServiceDeathRecipient001, TestSize.Level1";
|
||||
LBSLOGI(GEO_CONVERT, "[GeoConvertServiceTest] RegisterGeoServiceDeathRecipient001 begin");
|
||||
service_->RegisterGeoServiceDeathRecipient();
|
||||
LBSLOGI(GEO_CONVERT, "[GeoConvertServiceTest] RegisterGeoServiceDeathRecipient001 end");
|
||||
}
|
||||
|
||||
HWTEST_F(GeoConvertServiceTest, RegisterGeoServiceSendGeocodeRequest001, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "GeoConvertServiceTest, RegisterGeoServiceSendGeocodeRequest001, TestSize.Level1";
|
||||
LBSLOGI(GEO_CONVERT, "[GeoConvertServiceTest] RegisterGeoServiceSendGeocodeRequest001 begin");
|
||||
MessageParcel dataParcel;
|
||||
MessageParcel replyParcel;
|
||||
MessageOption option;
|
||||
dataParcel.WriteInterfaceToken(GeoConvertProxy::GetDescriptor());
|
||||
dataParcel.WriteString16(Str8ToStr16("北京")); // input description of a location
|
||||
dataParcel.WriteDouble(0.0); // minLatitude
|
||||
dataParcel.WriteDouble(0.0); // minLongitude
|
||||
dataParcel.WriteDouble(0.0); // maxLatitude
|
||||
dataParcel.WriteDouble(0.0); // maxLongitude
|
||||
dataParcel.WriteInt32(5); // maxItem
|
||||
dataParcel.WriteInt32(1); // description
|
||||
dataParcel.WriteString16(Str8ToStr16("ZH")); // language
|
||||
dataParcel.WriteString16(Str8ToStr16("cn")); // country
|
||||
dataParcel.WriteString16(Str8ToStr16("")); // description
|
||||
dataParcel.WriteString16(u"ohos"); // package name
|
||||
int code = 1;
|
||||
service_->SendGeocodeRequest(code, dataParcel, replyParcel, option);
|
||||
sptr<IRemoteObject> serviceProxy;
|
||||
service_->serviceProxy_ = serviceProxy;
|
||||
service_->SendGeocodeRequest(code, dataParcel, replyParcel, option);
|
||||
LBSLOGI(GEO_CONVERT, "[GeoConvertServiceTest] RegisterGeoServiceSendGeocodeRequest001 end");
|
||||
}
|
||||
|
||||
HWTEST_F(GeoConvertServiceTest, GeoConvertWriteInfoToParcel001, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "GeoConvertServiceTest, RegisterGeoServiceDeathRecipient001, TestSize.Level1";
|
||||
LBSLOGI(GEO_CONVERT, "[GeoConvertServiceTest] RegisterGeoServiceDeathRecipient001 begin");
|
||||
MessageParcel dataParcel;
|
||||
MessageParcel replyParcel;
|
||||
dataParcel.WriteInterfaceToken(GeoConvertProxy::GetDescriptor());
|
||||
dataParcel.WriteString16(Str8ToStr16("北京")); // input description of a location
|
||||
dataParcel.WriteDouble(0.0); // minLatitude
|
||||
dataParcel.WriteDouble(0.0); // minLongitude
|
||||
dataParcel.WriteDouble(0.0); // maxLatitude
|
||||
dataParcel.WriteDouble(0.0); // maxLongitude
|
||||
dataParcel.WriteInt32(5); // maxItem
|
||||
dataParcel.WriteInt32(1); // description
|
||||
dataParcel.WriteString16(Str8ToStr16("ZH")); // language
|
||||
dataParcel.WriteString16(Str8ToStr16("cn")); // country
|
||||
dataParcel.WriteString16(Str8ToStr16("")); // description
|
||||
dataParcel.WriteString16(u"ohos"); // package name
|
||||
bool flag1 = false;
|
||||
bool flag2 = true;
|
||||
EXPECT_EQ(true, service_->WriteInfoToParcel(dataParcel, replyParcel, flag1));
|
||||
EXPECT_EQ(true, service_->WriteInfoToParcel(dataParcel, replyParcel, flag2));
|
||||
LBSLOGI(GEO_CONVERT, "[GeoConvertServiceTest] RegisterGeoServiceDeathRecipient001 end");
|
||||
}
|
||||
|
||||
HWTEST_F(GeoConvertServiceTest, GeoConvertWriteResultToParcel001, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "GeoConvertServiceTest, GeoConvertWriteResultToParcel001, TestSize.Level1";
|
||||
LBSLOGI(GEO_CONVERT, "[GeoConvertServiceTest] GeoConvertWriteResultToParcel001 begin");
|
||||
const std::list<std::shared_ptr<GeoAddress>> result;
|
||||
MessageParcel replyParcel;
|
||||
bool flag = true;
|
||||
service_->WriteResultToParcel(result, replyParcel, flag);
|
||||
LBSLOGI(GEO_CONVERT, "[GeoConvertServiceTest] GeoConvertWriteResultToParcel001 end");
|
||||
}
|
||||
|
||||
HWTEST_F(GeoConvertServiceTest, GeoConvertReportAddressMock001, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "GeoConvertServiceTest, GeoConvertReportAddressMock001, TestSize.Level1";
|
||||
LBSLOGI(GEO_CONVERT, "[GeoConvertServiceTest] GeoConvertReportAddressMock001 begin");
|
||||
MessageParcel dataParcel;
|
||||
MessageParcel replyParcel;
|
||||
dataParcel.WriteInterfaceToken(GeoConvertProxy::GetDescriptor());
|
||||
dataParcel.WriteString16(Str8ToStr16("北京")); // input description of a location
|
||||
dataParcel.WriteDouble(0.0); // minLatitude
|
||||
dataParcel.WriteDouble(0.0); // minLongitude
|
||||
dataParcel.WriteDouble(0.0); // maxLatitude
|
||||
dataParcel.WriteDouble(0.0); // maxLongitude
|
||||
dataParcel.WriteInt32(5); // maxItem
|
||||
dataParcel.WriteInt32(1); // description
|
||||
dataParcel.WriteString16(Str8ToStr16("ZH")); // language
|
||||
dataParcel.WriteString16(Str8ToStr16("cn")); // country
|
||||
dataParcel.WriteString16(Str8ToStr16("")); // description
|
||||
dataParcel.WriteString16(u"ohos"); // package name
|
||||
service_->ReportAddressMock(dataParcel, replyParcel);
|
||||
LBSLOGI(GEO_CONVERT, "[GeoConvertServiceTest] GeoConvertReportAddressMock001 end");
|
||||
}
|
||||
|
||||
} // namespace Location
|
||||
} // namespace OHOS
|
||||
#endif // FEATURE_GEOCODE_SUPPORT
|
||||
|
70
test/location_geofence/BUILD.gn
Normal file
70
test/location_geofence/BUILD.gn
Normal file
@ -0,0 +1,70 @@
|
||||
# Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import("//base/location/config.gni")
|
||||
import("//build/test.gni")
|
||||
|
||||
module_output_path = "location/native"
|
||||
|
||||
ohos_unittest("GeofenceSdkTest") {
|
||||
module_out_path = module_output_path
|
||||
sources = [ "$LOCATION_ROOT_DIR/test/location_geofence/source/location_gnss_geofence_callback_host_test.cpp" ]
|
||||
|
||||
include_dirs = [ "$LOCATION_ROOT_DIR/test/location_geofence/include" ]
|
||||
|
||||
sanitize = {
|
||||
cfi = true
|
||||
cfi_cross_dso = true
|
||||
debug = false
|
||||
blocklist = "./../../cfi_blocklist.txt"
|
||||
}
|
||||
branch_protector_ret = "pac_ret"
|
||||
|
||||
deps = [ "$LOCATION_ROOT_DIR/frameworks/native/geofence_sdk:geofence_sdk" ]
|
||||
|
||||
external_deps = [
|
||||
"ability_base:want",
|
||||
"ability_base:zuri",
|
||||
"ability_runtime:dataobs_manager",
|
||||
"ability_runtime:wantagent_innerkits",
|
||||
"access_token:libaccesstoken_sdk",
|
||||
"access_token:libnativetoken",
|
||||
"access_token:libtoken_setproc",
|
||||
"access_token:libtokenid_sdk",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"bundle_framework:appexecfwk_core",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"data_share:datashare_common",
|
||||
"data_share:datashare_consumer",
|
||||
"hilog:libhilog",
|
||||
"hisysevent:libhisysevent",
|
||||
"init:libbegetutil",
|
||||
"ipc:ipc_core",
|
||||
"location:locator_sdk",
|
||||
"os_account:os_account_innerkits",
|
||||
"relational_store:native_dataability",
|
||||
"relational_store:native_rdb",
|
||||
"samgr:samgr_proxy",
|
||||
]
|
||||
|
||||
defines = []
|
||||
|
||||
module_out_path = module_output_path
|
||||
}
|
||||
|
||||
group("unittest") {
|
||||
testonly = true
|
||||
deps = []
|
||||
deps += [ ":GeofenceSdkTest" ]
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef LOCATION_GNSS_GEOFENCE_CALLBACK_HOST_TEST_H
|
||||
#define LOCATION_GNSS_GEOFENCE_CALLBACK_HOST_TEST_H
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
namespace OHOS {
|
||||
namespace Location {
|
||||
class LocationGnssGeofenceCallbackHostTest : public testing::Test {
|
||||
public:
|
||||
void SetUp();
|
||||
void TearDown();
|
||||
|
||||
const int DEFAULT_NUM_VALUE = 1;
|
||||
const int DEFAULT_CALLBACK_WAIT_TIME = 100;
|
||||
};
|
||||
} // namespace Location
|
||||
} // namespace OHOS
|
||||
#endif // LOCATION_GNSS_GEOFENCE_CALLBACK_HOST_TEST_H
|
@ -0,0 +1,182 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "location_gnss_geofence_callback_host_test.h"
|
||||
|
||||
#include "location_gnss_geofence_callback_host.h"
|
||||
#include "location_log.h"
|
||||
#include "geofence_definition.h"
|
||||
#include "i_gnss_geofence_callback.h"
|
||||
|
||||
using namespace testing::ext;
|
||||
namespace OHOS {
|
||||
namespace Location {
|
||||
void LocationGnssGeofenceCallbackHostTest::SetUp()
|
||||
{
|
||||
}
|
||||
|
||||
void LocationGnssGeofenceCallbackHostTest::TearDown()
|
||||
{
|
||||
}
|
||||
|
||||
HWTEST_F(LocationGnssGeofenceCallbackHostTest, OnRemoteRequestTest001, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "LocationGnssGeofenceCallbackHostTest, OnRemoteRequestTest001, TestSize.Level1";
|
||||
LBSLOGI(GEOFENCE_SDK_TEST, "[LocationGnssGeofenceCallbackHostTest] OnRemoteRequestTest001 begin");
|
||||
std::shared_ptr<LocationGnssGeofenceCallbackHost> callback =
|
||||
std::make_shared<LocationGnssGeofenceCallbackHost>();
|
||||
ASSERT_TRUE(callback != nullptr);
|
||||
MessageParcel dataParcel;
|
||||
dataParcel.WriteInt32(DEFAULT_NUM_VALUE);
|
||||
dataParcel.WriteInt32(static_cast<int>(GeofenceTransitionEvent::GEOFENCE_TRANSITION_EVENT_ENTER));
|
||||
MessageParcel reply;
|
||||
MessageOption option = { MessageOption::TF_ASYNC };
|
||||
callback->OnRemoteRequest(IGnssGeofenceCallback::RECEIVE_TRANSITION_STATUS_EVENT, dataParcel, reply, option);
|
||||
LBSLOGI(GEOFENCE_SDK_TEST, "[LocationGnssGeofenceCallbackHostTest] OnRemoteRequestTest001 end");
|
||||
}
|
||||
|
||||
HWTEST_F(LocationGnssGeofenceCallbackHostTest, OnRemoteRequestTest002, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "LocationGnssGeofenceCallbackHostTest, OnRemoteRequestTest002, TestSize.Level1";
|
||||
LBSLOGI(GEOFENCE_SDK_TEST, "[LocationGnssGeofenceCallbackHostTest] OnRemoteRequestTest002 begin");
|
||||
std::shared_ptr<LocationGnssGeofenceCallbackHost> callback =
|
||||
std::make_shared<LocationGnssGeofenceCallbackHost>();
|
||||
ASSERT_TRUE(callback != nullptr);
|
||||
MessageParcel dataParcel;
|
||||
dataParcel.WriteInt32(DEFAULT_NUM_VALUE);
|
||||
dataParcel.WriteInt32(static_cast<int>(GnssGeofenceOperateType::GNSS_GEOFENCE_OPT_TYPE_ADD));
|
||||
dataParcel.WriteInt32(static_cast<int>(GnssGeofenceOperateResult::GNSS_GEOFENCE_OPERATION_SUCCESS));
|
||||
MessageParcel reply;
|
||||
MessageOption option = { MessageOption::TF_ASYNC };
|
||||
callback->OnRemoteRequest(IGnssGeofenceCallback::REPORT_OPERATION_RESULT_EVENT, dataParcel, reply, option);
|
||||
LBSLOGI(GEOFENCE_SDK_TEST, "[LocationGnssGeofenceCallbackHostTest] OnRemoteRequestTest002 end");
|
||||
}
|
||||
|
||||
HWTEST_F(LocationGnssGeofenceCallbackHostTest, IsRemoteDiedTest001, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "LocationGnssGeofenceCallbackHostTest, IsRemoteDiedTest001, TestSize.Level1";
|
||||
LBSLOGI(GEOFENCE_SDK_TEST, "[LocationGnssGeofenceCallbackHostTest] IsRemoteDiedTest001 begin");
|
||||
std::shared_ptr<LocationGnssGeofenceCallbackHost> callback =
|
||||
std::make_shared<LocationGnssGeofenceCallbackHost>();
|
||||
ASSERT_TRUE(callback != nullptr);
|
||||
callback->IsRemoteDied();
|
||||
LBSLOGI(GEOFENCE_SDK_TEST, "[LocationGnssGeofenceCallbackHostTest] IsRemoteDiedTest001 end");
|
||||
}
|
||||
|
||||
HWTEST_F(LocationGnssGeofenceCallbackHostTest, DeleteHandlerTest001, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "LocationGnssGeofenceCallbackHostTest, DeleteHandlerTest001, TestSize.Level1";
|
||||
LBSLOGI(GEOFENCE_SDK_TEST, "[LocationGnssGeofenceCallbackHostTest] DeleteHandlerTest001 begin");
|
||||
std::shared_ptr<LocationGnssGeofenceCallbackHost> callback =
|
||||
std::make_shared<LocationGnssGeofenceCallbackHost>();
|
||||
ASSERT_TRUE(callback != nullptr);
|
||||
callback->DeleteHandler();
|
||||
LBSLOGI(GEOFENCE_SDK_TEST, "[LocationGnssGeofenceCallbackHostTest] DeleteHandlerTest001 end");
|
||||
}
|
||||
|
||||
HWTEST_F(LocationGnssGeofenceCallbackHostTest, LatchTest001, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "LocationGnssGeofenceCallbackHostTest, LatchTest001, TestSize.Level1";
|
||||
LBSLOGI(GEOFENCE_SDK_TEST, "[LocationGnssGeofenceCallbackHostTest] LatchTest001 begin");
|
||||
std::shared_ptr<LocationGnssGeofenceCallbackHost> callback =
|
||||
std::make_shared<LocationGnssGeofenceCallbackHost>();
|
||||
ASSERT_TRUE(callback != nullptr);
|
||||
callback->SetCount(1);
|
||||
int countNum = callback->GetCount();
|
||||
ASSERT_TRUE(countNum == DEFAULT_NUM_VALUE);
|
||||
callback->Wait(DEFAULT_CALLBACK_WAIT_TIME);
|
||||
countNum = callback->GetCount();
|
||||
ASSERT_TRUE(countNum == DEFAULT_NUM_VALUE);
|
||||
callback->CountDown();
|
||||
countNum = callback->GetCount();
|
||||
ASSERT_TRUE(countNum != DEFAULT_NUM_VALUE);
|
||||
callback->SetCount(1);
|
||||
LBSLOGI(GEOFENCE_SDK_TEST, "[LocationGnssGeofenceCallbackHostTest] LatchTest001 end");
|
||||
}
|
||||
|
||||
HWTEST_F(LocationGnssGeofenceCallbackHostTest, FenceIdOperationTest001, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "LocationGnssGeofenceCallbackHostTest, FenceIdOperationTest001, TestSize.Level1";
|
||||
LBSLOGI(GEOFENCE_SDK_TEST, "[LocationGnssGeofenceCallbackHostTest] FenceIdOperationTest001 begin");
|
||||
std::shared_ptr<LocationGnssGeofenceCallbackHost> callback =
|
||||
std::make_shared<LocationGnssGeofenceCallbackHost>();
|
||||
ASSERT_TRUE(callback != nullptr);
|
||||
callback->SetFenceId(DEFAULT_NUM_VALUE);
|
||||
int fenceId = callback->GetFenceId();
|
||||
ASSERT_TRUE(fenceId == DEFAULT_NUM_VALUE);
|
||||
callback->ClearFenceId();
|
||||
fenceId = callback->GetFenceId();
|
||||
ASSERT_TRUE(fenceId != DEFAULT_NUM_VALUE);
|
||||
LBSLOGI(GEOFENCE_SDK_TEST, "[LocationGnssGeofenceCallbackHostTest] FenceIdOperationTest001 end");
|
||||
}
|
||||
|
||||
HWTEST_F(LocationGnssGeofenceCallbackHostTest, GeofenceOperationTypeTest001, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "LocationGnssGeofenceCallbackHostTest, GeofenceOperationTypeTest001, TestSize.Level1";
|
||||
LBSLOGI(GEOFENCE_SDK_TEST, "[LocationGnssGeofenceCallbackHostTest] GeofenceOperationTypeTest001 begin");
|
||||
std::shared_ptr<LocationGnssGeofenceCallbackHost> callback =
|
||||
std::make_shared<LocationGnssGeofenceCallbackHost>();
|
||||
ASSERT_TRUE(callback != nullptr);
|
||||
GnssGeofenceOperateType optType = static_cast<GnssGeofenceOperateType>(0);
|
||||
callback->SetGeofenceOperationType(optType);
|
||||
GnssGeofenceOperateType optResultType = callback->GetGeofenceOperationType();
|
||||
ASSERT_TRUE(optResultType == optType);
|
||||
LBSLOGI(GEOFENCE_SDK_TEST, "[LocationGnssGeofenceCallbackHostTest] GeofenceOperationTypeTest001 end");
|
||||
}
|
||||
|
||||
HWTEST_F(LocationGnssGeofenceCallbackHostTest, GeofenceOperationResultTest001, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "LocationGnssGeofenceCallbackHostTest, GeofenceOperationResultTest001, TestSize.Level1";
|
||||
LBSLOGI(GEOFENCE_SDK_TEST, "[LocationGnssGeofenceCallbackHostTest] GeofenceOperationResultTest001 begin");
|
||||
std::shared_ptr<LocationGnssGeofenceCallbackHost> callback =
|
||||
std::make_shared<LocationGnssGeofenceCallbackHost>();
|
||||
ASSERT_TRUE(callback != nullptr);
|
||||
GnssGeofenceOperateResult optValue = static_cast<GnssGeofenceOperateResult>(0);
|
||||
callback->SetGeofenceOperationResult(optValue);
|
||||
GnssGeofenceOperateResult optResult = callback->GetGeofenceOperationResult();
|
||||
ASSERT_TRUE(optValue == optResult);
|
||||
LBSLOGI(GEOFENCE_SDK_TEST, "[LocationGnssGeofenceCallbackHostTest] GeofenceOperationResultTest001 end");
|
||||
}
|
||||
|
||||
HWTEST_F(LocationGnssGeofenceCallbackHostTest, GeofenceOperationResultTest002, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "LocationGnssGeofenceCallbackHostTest, GeofenceOperationResultTest002, TestSize.Level1";
|
||||
LBSLOGI(GEOFENCE_SDK_TEST, "[LocationGnssGeofenceCallbackHostTest] GeofenceOperationResultTest002 begin");
|
||||
std::shared_ptr<LocationGnssGeofenceCallbackHost> callback =
|
||||
std::make_shared<LocationGnssGeofenceCallbackHost>();
|
||||
ASSERT_TRUE(callback != nullptr);
|
||||
callback->SetGeofenceOperationResult(GnssGeofenceOperateResult::GNSS_GEOFENCE_OPERATION_SUCCESS);
|
||||
callback->DealGeofenceOperationResult();
|
||||
callback->SetGeofenceOperationResult(GnssGeofenceOperateResult::GNSS_GEOFENCE_OPERATION_ERROR_UNKNOWN);
|
||||
callback->DealGeofenceOperationResult();
|
||||
callback->SetGeofenceOperationResult(GnssGeofenceOperateResult::GNSS_GEOFENCE_OPERATION_ERROR_TOO_MANY_GEOFENCES);
|
||||
callback->DealGeofenceOperationResult();
|
||||
callback->SetGeofenceOperationResult(GnssGeofenceOperateResult::GNSS_GEOFENCE_OPERATION_ERROR_GEOFENCE_ID_EXISTS);
|
||||
callback->DealGeofenceOperationResult();
|
||||
callback->SetGeofenceOperationResult(GnssGeofenceOperateResult::GNSS_GEOFENCE_OPERATION_ERROR_PARAMS_INVALID);
|
||||
callback->DealGeofenceOperationResult();
|
||||
LBSLOGI(GEOFENCE_SDK_TEST, "[LocationGnssGeofenceCallbackHostTest] GeofenceOperationResultTest002 end");
|
||||
}
|
||||
} // namespace Location
|
||||
} // namespace OHOS
|
@ -310,6 +310,114 @@ HWTEST_F(GnssAbilityStubTest, GnssAbilityStubTest016, TestSize.Level1)
|
||||
gnssAbilityStub->OnRemoteRequest(UNKNOWN_CODE, parcel, reply, option));
|
||||
LBSLOGI(GNSS, "[GnssAbilityStubTest] GnssAbilityStubTest016 end");
|
||||
}
|
||||
|
||||
HWTEST_F(GnssAbilityStubTest, GnssAbilityStubTest017, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "GnssAbilityStubTest, GnssAbilityStubTest017, TestSize.Level1";
|
||||
LBSLOGI(GNSS, "[GnssAbilityStubTest] GnssAbilityStubTest017 begin");
|
||||
auto gnssAbilityStub = sptr<MockGnssAbilityStub>(new (std::nothrow) MockGnssAbilityStub());
|
||||
ON_CALL(*gnssAbilityStub, AddFence(_)).WillByDefault(Return(ERRCODE_SUCCESS));
|
||||
MessageParcel parcel;
|
||||
parcel.WriteInterfaceToken(GnssAbilityProxy::GetDescriptor());
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
EXPECT_EQ(ERRCODE_SUCCESS,
|
||||
gnssAbilityStub->OnRemoteRequest(static_cast<uint32_t>(GnssInterfaceCode::ADD_FENCE_INFO),
|
||||
parcel, reply, option));
|
||||
EXPECT_EQ(ERRCODE_SUCCESS, reply.ReadInt32());
|
||||
LBSLOGI(GNSS, "[GnssAbilityStubTest] GnssAbilityStubTest017 end");
|
||||
}
|
||||
|
||||
HWTEST_F(GnssAbilityStubTest, GnssAbilityStubTest018, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "GnssAbilityStubTest, GnssAbilityStubTest018, TestSize.Level1";
|
||||
LBSLOGI(GNSS, "[GnssAbilityStubTest] GnssAbilityStubTest018 begin");
|
||||
auto gnssAbilityStub = sptr<MockGnssAbilityStub>(new (std::nothrow) MockGnssAbilityStub());
|
||||
ON_CALL(*gnssAbilityStub, RemoveFence(_)).WillByDefault(Return(ERRCODE_SUCCESS));
|
||||
MessageParcel parcel;
|
||||
parcel.WriteInterfaceToken(GnssAbilityProxy::GetDescriptor());
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
EXPECT_EQ(ERRCODE_SUCCESS,
|
||||
gnssAbilityStub->OnRemoteRequest(static_cast<uint32_t>(GnssInterfaceCode::REMOVE_FENCE_INFO),
|
||||
parcel, reply, option));
|
||||
EXPECT_EQ(ERRCODE_SUCCESS, reply.ReadInt32());
|
||||
LBSLOGI(GNSS, "[GnssAbilityStubTest] GnssAbilityStubTest018 end");
|
||||
}
|
||||
|
||||
HWTEST_F(GnssAbilityStubTest, GnssAbilityStubTest019, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "GnssAbilityStubTest, GnssAbilityStubTest019, TestSize.Level1";
|
||||
LBSLOGI(GNSS, "[GnssAbilityStubTest] GnssAbilityStubTest019 begin");
|
||||
auto gnssAbilityStub = sptr<MockGnssAbilityStub>(new (std::nothrow) MockGnssAbilityStub());
|
||||
ON_CALL(*gnssAbilityStub, AddGnssGeofence(_)).WillByDefault(Return(ERRCODE_SUCCESS));
|
||||
MessageParcel parcel;
|
||||
parcel.WriteInterfaceToken(GnssAbilityProxy::GetDescriptor());
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
EXPECT_EQ(ERRCODE_SUCCESS,
|
||||
gnssAbilityStub->OnRemoteRequest(static_cast<uint32_t>(GnssInterfaceCode::ADD_GNSS_GEOFENCE),
|
||||
parcel, reply, option));
|
||||
EXPECT_EQ(ERRCODE_SUCCESS, reply.ReadInt32());
|
||||
LBSLOGI(GNSS, "[GnssAbilityStubTest] GnssAbilityStubTest019 end");
|
||||
}
|
||||
|
||||
HWTEST_F(GnssAbilityStubTest, GnssAbilityStubTest020, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "GnssAbilityStubTest, GnssAbilityStubTest020, TestSize.Level1";
|
||||
LBSLOGI(GNSS, "[GnssAbilityStubTest] GnssAbilityStubTest020 begin");
|
||||
auto gnssAbilityStub = sptr<MockGnssAbilityStub>(new (std::nothrow) MockGnssAbilityStub());
|
||||
ON_CALL(*gnssAbilityStub, RemoveGnssGeofence(_)).WillByDefault(Return(ERRCODE_SUCCESS));
|
||||
MessageParcel parcel;
|
||||
parcel.WriteInterfaceToken(GnssAbilityProxy::GetDescriptor());
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
EXPECT_EQ(ERRCODE_SUCCESS,
|
||||
gnssAbilityStub->OnRemoteRequest(static_cast<uint32_t>(GnssInterfaceCode::REMOVE_GNSS_GEOFENCE),
|
||||
parcel, reply, option));
|
||||
EXPECT_EQ(ERRCODE_SUCCESS, reply.ReadInt32());
|
||||
LBSLOGI(GNSS, "[GnssAbilityStubTest] GnssAbilityStubTest020 end");
|
||||
}
|
||||
|
||||
HWTEST_F(GnssAbilityStubTest, GnssAbilityStubTest021, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "GnssAbilityStubTest, GnssAbilityStubTest021, TestSize.Level1";
|
||||
LBSLOGI(GNSS, "[GnssAbilityStubTest] GnssAbilityStubTest021 begin");
|
||||
auto gnssAbilityStub = sptr<MockGnssAbilityStub>(new (std::nothrow) MockGnssAbilityStub());
|
||||
EXPECT_CALL(*gnssAbilityStub, QuerySupportCoordinateSystemType(_)).WillOnce(DoAll(Return(ERRCODE_SUCCESS)));
|
||||
MessageParcel parcel;
|
||||
parcel.WriteInterfaceToken(GnssAbilityProxy::GetDescriptor());
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
EXPECT_EQ(ERRCODE_SUCCESS, gnssAbilityStub->OnRemoteRequest(
|
||||
static_cast<uint32_t>(GnssInterfaceCode::GET_GEOFENCE_SUPPORT_COORDINATE_SYSTEM_TYPE),
|
||||
parcel, reply, option));
|
||||
EXPECT_EQ(ERRCODE_SUCCESS, reply.ReadInt32());
|
||||
LBSLOGI(GNSS, "[GnssAbilityStubTest] GnssAbilityStubTest021 end");
|
||||
}
|
||||
|
||||
HWTEST_F(GnssAbilityStubTest, GnssAbilityStubTest022, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "GnssAbilityStubTest, GnssAbilityStubTest022, TestSize.Level1";
|
||||
LBSLOGI(GNSS, "[GnssAbilityStubTest] GnssAbilityStubTest022 begin");
|
||||
auto gnssAbilityStub = sptr<MockGnssAbilityStub>(new (std::nothrow) MockGnssAbilityStub());
|
||||
ON_CALL(*gnssAbilityStub, SendNetworkLocation(_)).WillByDefault(Return(ERRCODE_SUCCESS));
|
||||
MessageParcel parcel;
|
||||
parcel.WriteInterfaceToken(GnssAbilityProxy::GetDescriptor());
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
EXPECT_EQ(ERRCODE_SUCCESS,
|
||||
gnssAbilityStub->OnRemoteRequest(static_cast<uint32_t>(GnssInterfaceCode::SEND_NETWORK_LOCATION),
|
||||
parcel, reply, option));
|
||||
EXPECT_EQ(ERRCODE_SUCCESS, reply.ReadInt32());
|
||||
LBSLOGI(GNSS, "[GnssAbilityStubTest] GnssAbilityStubTest022 end");
|
||||
}
|
||||
} // namespace Location
|
||||
} // namespace OHOS
|
||||
#endif // FEATURE_GNSS_SUPPORT
|
||||
|
@ -1570,6 +1570,146 @@ HWTEST_F(GnssAbilityTest, RemoveGnssGeofence002, TestSize.Level1)
|
||||
LBSLOGI(LOCATOR, "[GnssAbilityTest] RemoveGnssGeofence002 end");
|
||||
}
|
||||
|
||||
HWTEST_F(GnssAbilityTest, RegisterGnssGeofenceCallback001, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "GnssAbilityTest, RegisterGnssGeofenceCallback001, TestSize.Level1";
|
||||
LBSLOGI(LOCATOR, "[GnssAbilityTest] RegisterGnssGeofenceCallback001 begin");
|
||||
sptr<GnssAbility> gnssAbility = new (std::nothrow) GnssAbility();
|
||||
EXPECT_NE(nullptr, gnssAbility);
|
||||
std::shared_ptr<GeofenceRequest> request = nullptr;
|
||||
sptr<IRemoteObject> callback = nullptr;
|
||||
bool result = gnssAbility->RegisterGnssGeofenceCallback(request, callback);
|
||||
EXPECT_EQ(false, result);
|
||||
LBSLOGI(LOCATOR, "[GnssAbilityTest] RegisterGnssGeofenceCallback001 end");
|
||||
}
|
||||
|
||||
HWTEST_F(GnssAbilityTest, UnregisterGnssGeofenceCallback001, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "GnssAbilityTest, UnregisterGnssGeofenceCallback001, TestSize.Level1";
|
||||
LBSLOGI(LOCATOR, "[GnssAbilityTest] UnregisterGnssGeofenceCallback001 begin");
|
||||
sptr<GnssAbility> gnssAbility = new (std::nothrow) GnssAbility();
|
||||
EXPECT_NE(nullptr, gnssAbility);
|
||||
int fenceId = 1;
|
||||
bool result = gnssAbility->UnregisterGnssGeofenceCallback(fenceId);
|
||||
EXPECT_EQ(true, result);
|
||||
LBSLOGI(LOCATOR, "[GnssAbilityTest] UnregisterGnssGeofenceCallback001 end");
|
||||
}
|
||||
|
||||
HWTEST_F(GnssAbilityTest, RemoveGnssGeofenceRequestByCallback001, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "GnssAbilityTest, RemoveGnssGeofenceRequestByCallback001, TestSize.Level1";
|
||||
LBSLOGI(LOCATOR, "[GnssAbilityTest] RemoveGnssGeofenceRequestByCallback001 begin");
|
||||
sptr<GnssAbility> gnssAbility = new (std::nothrow) GnssAbility();
|
||||
EXPECT_NE(nullptr, gnssAbility);
|
||||
sptr<IRemoteObject> callbackObj = nullptr;
|
||||
bool result = gnssAbility->RemoveGnssGeofenceRequestByCallback(callbackObj);
|
||||
EXPECT_EQ(false, result);
|
||||
LBSLOGI(LOCATOR, "[GnssAbilityTest] RemoveGnssGeofenceRequestByCallback001 end");
|
||||
}
|
||||
|
||||
#ifdef HDF_DRIVERS_INTERFACE_GEOFENCE_ENABLE
|
||||
HWTEST_F(GnssAbilityTest, ReportGeofenceOperationResult001, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "GnssAbilityTest, ReportGeofenceOperationResult001, TestSize.Level1";
|
||||
LBSLOGI(LOCATOR, "[GnssAbilityTest] ReportGeofenceOperationResult001 begin");
|
||||
sptr<GnssAbility> gnssAbility = new (std::nothrow) GnssAbility();
|
||||
EXPECT_NE(nullptr, gnssAbility);
|
||||
int fenceId = 0;
|
||||
GeofenceOperateType type = GeofenceOperateType::TYPE_DELETE;
|
||||
GeofenceOperateResult result = GeofenceOperateResult::GEOFENCE_OPERATION_SUCCESS;
|
||||
gnssAbility->ReportGeofenceOperationResult(fenceId, type, result);
|
||||
LBSLOGI(LOCATOR, "[GnssAbilityTest] ReportGeofenceOperationResult001 end");
|
||||
}
|
||||
|
||||
HWTEST_F(GnssAbilityTest, ReportGeofenceEvent001, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "GnssAbilityTest, ReportGeofenceEvent001, TestSize.Level1";
|
||||
LBSLOGI(LOCATOR, "[GnssAbilityTest] ReportGeofenceEvent001 begin");
|
||||
sptr<GnssAbility> gnssAbility = new (std::nothrow) GnssAbility();
|
||||
EXPECT_NE(nullptr, gnssAbility);
|
||||
int fenceId = 0;
|
||||
GeofenceEvent event = GeofenceEvent::GEOFENCE_EVENT_ENTERED;
|
||||
gnssAbility->ReportGeofenceEvent(fenceId, event);
|
||||
LBSLOGI(LOCATOR, "[GnssAbilityTest] ReportGeofenceEvent001 end");
|
||||
}
|
||||
|
||||
HWTEST_F(GnssAbilityTest, GetGeofenceRequestByFenceId001, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "GnssAbilityTest, GetGeofenceRequestByFenceId001, TestSize.Level1";
|
||||
LBSLOGI(LOCATOR, "[GnssAbilityTest] GetGeofenceRequestByFenceId001 begin");
|
||||
sptr<GnssAbility> gnssAbility = new (std::nothrow) GnssAbility();
|
||||
EXPECT_NE(nullptr, gnssAbility);
|
||||
int fenceId = 0;
|
||||
gnssAbility->GetGeofenceRequestByFenceId(fenceId);
|
||||
LBSLOGI(LOCATOR, "[GnssAbilityTest] GetGeofenceRequestByFenceId001 end");
|
||||
}
|
||||
|
||||
HWTEST_F(GnssAbilityTest, ExecuteFenceProcess001, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "GnssAbilityTest, ExecuteFenceProcess001, TestSize.Level1";
|
||||
LBSLOGI(LOCATOR, "[GnssAbilityTest] ExecuteFenceProcess001 begin");
|
||||
sptr<GnssAbility> gnssAbility = new (std::nothrow) GnssAbility();
|
||||
EXPECT_NE(nullptr, gnssAbility);
|
||||
GnssInterfaceCode code= GnssInterfaceCode::ADD_FENCE_INFO;
|
||||
std::shared_ptr<GeofenceRequest> request = std::make_shared<GeofenceRequest>();
|
||||
gnssAbility->ExecuteFenceProcess(code, request);
|
||||
LBSLOGI(LOCATOR, "[GnssAbilityTest] ExecuteFenceProcess001 end");
|
||||
}
|
||||
|
||||
HWTEST_F(GnssAbilityTest, SetGeofenceCallback001, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "GnssAbilityTest, SetGeofenceCallback001, TestSize.Level1";
|
||||
LBSLOGI(LOCATOR, "[GnssAbilityTest] SetGeofenceCallback001 begin");
|
||||
sptr<GnssAbility> gnssAbility = new (std::nothrow) GnssAbility();
|
||||
EXPECT_NE(nullptr, gnssAbility);
|
||||
gnssAbility->SetGeofenceCallback();
|
||||
LBSLOGI(LOCATOR, "[GnssAbilityTest] SetGeofenceCallback001 end");
|
||||
}
|
||||
|
||||
HWTEST_F(GnssAbilityTest, StopGnss001, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "GnssAbilityTest, StopGnss001, TestSize.Level1";
|
||||
LBSLOGI(LOCATOR, "[GnssAbilityTest] StopGnss001 begin");
|
||||
sptr<GnssAbility> gnssAbility = new (std::nothrow) GnssAbility();
|
||||
EXPECT_NE(nullptr, gnssAbility);
|
||||
gnssAbility->StopGnss();
|
||||
LBSLOGI(LOCATOR, "[GnssAbilityTest] StopGnss001 end");
|
||||
}
|
||||
|
||||
HWTEST_F(GnssAbilityTest, RemoveHdi001, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "GnssAbilityTest, RemoveHdi001, TestSize.Level1";
|
||||
LBSLOGI(LOCATOR, "[GnssAbilityTest] RemoveHdi001 begin");
|
||||
sptr<GnssAbility> gnssAbility = new (std::nothrow) GnssAbility();
|
||||
EXPECT_NE(nullptr, gnssAbility);
|
||||
gnssAbility->RemoveHdi();
|
||||
LBSLOGI(LOCATOR, "[GnssAbilityTest] RemoveHdi001 end");
|
||||
}
|
||||
|
||||
HWTEST_F(GnssAbilityTest, QuerySupportCoordinateSystemType001, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "GnssAbilityTest, QuerySupportCoordinateSystemType001, TestSize.Level1";
|
||||
LBSLOGI(LOCATOR, "[GnssAbilityTest] QuerySupportCoordinateSystemType001 begin");
|
||||
sptr<GnssAbility> gnssAbility = new (std::nothrow) GnssAbility();
|
||||
EXPECT_NE(nullptr, gnssAbility);
|
||||
std::vector<CoordinateSystemType> coordinateSystemTypes;
|
||||
gnssAbility->QuerySupportCoordinateSystemType(coordinateSystemTypes);
|
||||
LBSLOGI(LOCATOR, "[GnssAbilityTest] QuerySupportCoordinateSystemType001 end");
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
HWTEST_F(GnssAbilityTest, ReConnectHdiImpl001, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
|
@ -38,6 +38,7 @@ ohos_unittest("LocatorServiceAbilityTest") {
|
||||
"$LOCATION_ROOT_DIR/test/location_locator/source/locator_impl_test.cpp",
|
||||
"$LOCATION_ROOT_DIR/test/location_locator/source/locator_required_data_manager_test.cpp",
|
||||
"$LOCATION_ROOT_DIR/test/location_locator/source/locator_service_test.cpp",
|
||||
"$LOCATION_ROOT_DIR/test/location_locator/source/locator_skeleton_test.cpp",
|
||||
"$LOCATION_ROOT_DIR/test/location_locator/source/permission_manager_test.cpp",
|
||||
"$LOCATION_ROOT_DIR/test/location_locator/source/report_manager_test.cpp",
|
||||
"$LOCATION_ROOT_DIR/test/location_locator/source/request_manager_test.cpp",
|
||||
|
48
test/location_locator/include/locator_skeleton_test.h
Normal file
48
test/location_locator/include/locator_skeleton_test.h
Normal file
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef LOCATOR_SKELETON_TEST_H
|
||||
#define LOCATOR_SKELETON_TEST_H
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#ifdef FEATURE_GEOCODE_SUPPORT
|
||||
#include "geo_coding_mock_info.h"
|
||||
#endif
|
||||
#include "i_locator_callback.h"
|
||||
#define private public
|
||||
#define protected public
|
||||
#include "locator_ability.h"
|
||||
#undef protected
|
||||
#undef private
|
||||
#include "locator_background_proxy.h"
|
||||
#include "locator_proxy.h"
|
||||
#include "request.h"
|
||||
#include "request_manager.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Location {
|
||||
class LocatorSkeletonTest : public testing::Test {
|
||||
public:
|
||||
void SetUp();
|
||||
void TearDown();
|
||||
void MockNativePermission();
|
||||
void LoadSystemAbility();
|
||||
|
||||
uint64_t tokenId_;
|
||||
};
|
||||
} // namespace Location
|
||||
} // namespace OHOS
|
||||
#endif // LOCATOR_SKELETON_TEST_H
|
@ -23,6 +23,8 @@ using namespace testing::ext;
|
||||
namespace OHOS {
|
||||
namespace Location {
|
||||
const int UNKNOWN_TYPE = 0;
|
||||
const int64_t NANOS_PER_MILLI = 1000000L;
|
||||
const int64_t MILLI_PER_SECS = 1000L;
|
||||
const uint32_t FUSION_DEFAULT_FLAG = 0;
|
||||
const uint32_t FUSION_BASE_FLAG = 1;
|
||||
const uint32_t REPORT_FUSED_LOCATION_FLAG = FUSION_BASE_FLAG;
|
||||
@ -34,6 +36,8 @@ void FusionControllerTest::SetUp()
|
||||
|
||||
void FusionControllerTest::TearDown()
|
||||
{
|
||||
fusionController_->fusedFlag_ = 0;
|
||||
fusionController_->needReset_ = true;
|
||||
fusionController_ = nullptr;
|
||||
}
|
||||
|
||||
@ -203,9 +207,43 @@ HWTEST_F(FusionControllerTest, GetFuseLocation001, TestSize.Level1)
|
||||
LBSLOGI(FUSION_CONTROLLER, "[FusionControllerTest] GetFuseLocation001 begin");
|
||||
std::unique_ptr<Location> location = std::make_unique<Location>();
|
||||
sptr<Location> lastFuseLocation = new (std::nothrow) Location();
|
||||
|
||||
location->SetLocationSourceType(LocationSourceType::INDOOR_TYPE);
|
||||
EXPECT_NE(nullptr, fusionController_->GetFuseLocation(location, lastFuseLocation));
|
||||
LBSLOGI(FUSION_CONTROLLER, "[FusionControllerTest] GetFuseLocation001 end");
|
||||
}
|
||||
|
||||
HWTEST_F(FusionControllerTest, GetFuseLocation002, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "FusionControllerTest, GetFuseLocation002, TestSize.Level1";
|
||||
LBSLOGI(FUSION_CONTROLLER, "[FusionControllerTest] GetFuseLocation002 begin");
|
||||
std::unique_ptr<Location> location = std::make_unique<Location>();
|
||||
sptr<Location> lastFuseLocation = new (std::nothrow) Location();
|
||||
location->SetLocationSourceType(LocationSourceType::GNSS_TYPE);
|
||||
int64_t seconds1 = 1718276948;
|
||||
int64_t seconds2 = 1718276945;
|
||||
location->SetTimeSinceBoot(seconds1 * MILLI_PER_SECS * NANOS_PER_MILLI);
|
||||
lastFuseLocation->SetLocationSourceType(LocationSourceType::INDOOR_TYPE);
|
||||
lastFuseLocation->SetTimeSinceBoot(seconds2 * MILLI_PER_SECS * NANOS_PER_MILLI);
|
||||
EXPECT_NE(nullptr, fusionController_->GetFuseLocation(location, lastFuseLocation));
|
||||
LBSLOGI(FUSION_CONTROLLER, "[FusionControllerTest] GetFuseLocation002 end");
|
||||
}
|
||||
|
||||
HWTEST_F(FusionControllerTest, GetFuseLocation003, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "FusionControllerTest, GetFuseLocation003, TestSize.Level1";
|
||||
LBSLOGI(FUSION_CONTROLLER, "[FusionControllerTest] GetFuseLocation003 begin");
|
||||
std::unique_ptr<Location> location = std::make_unique<Location>();
|
||||
sptr<Location> lastFuseLocation = new (std::nothrow) Location();
|
||||
location->SetLocationSourceType(LocationSourceType::NETWORK_TYPE);
|
||||
int64_t seconds1 = 1718276948;
|
||||
int64_t seconds2 = 1718276945;
|
||||
location->SetTimeSinceBoot(seconds1 * MILLI_PER_SECS * NANOS_PER_MILLI);
|
||||
lastFuseLocation->SetLocationSourceType(LocationSourceType::GNSS_TYPE);
|
||||
lastFuseLocation->SetTimeSinceBoot(seconds2 * MILLI_PER_SECS * NANOS_PER_MILLI);
|
||||
EXPECT_NE(nullptr, fusionController_->GetFuseLocation(location, lastFuseLocation));
|
||||
LBSLOGI(FUSION_CONTROLLER, "[FusionControllerTest] GetFuseLocation003 end");
|
||||
}
|
||||
} // namespace Location
|
||||
} // namespace OHOS
|
@ -83,9 +83,11 @@ HWTEST_F(LocationApproximatelyPermissionTest, ReportManagerApproximatelyLocation
|
||||
location->ReadFromParcel(parcel);
|
||||
auto newLocation = reportManager_->GetPermittedLocation(request, location);
|
||||
EXPECT_NE(nullptr, newLocation);
|
||||
EXPECT_EQ(MAX_LATITUDE, newLocation->GetLatitude());
|
||||
EXPECT_EQ(MAX_LONGITUDE, newLocation->GetLongitude());
|
||||
EXPECT_EQ(DEFAULT_APPROXIMATELY_ACCURACY, newLocation->GetAccuracy());
|
||||
if (newLocation != nullptr) {
|
||||
EXPECT_EQ(MAX_LATITUDE, newLocation->GetLatitude());
|
||||
EXPECT_EQ(MAX_LONGITUDE, newLocation->GetLongitude());
|
||||
EXPECT_EQ(DEFAULT_APPROXIMATELY_ACCURACY, newLocation->GetAccuracy());
|
||||
}
|
||||
}
|
||||
|
||||
HWTEST_F(LocationApproximatelyPermissionTest, ReportManagerApproximatelyLocationTest002, TestSize.Level1)
|
||||
@ -109,9 +111,11 @@ HWTEST_F(LocationApproximatelyPermissionTest, ReportManagerApproximatelyLocation
|
||||
location->ReadFromParcel(parcel);
|
||||
auto newLocation = reportManager_->GetPermittedLocation(request, location);
|
||||
EXPECT_NE(nullptr, newLocation);
|
||||
EXPECT_EQ(-MAX_LATITUDE, newLocation->GetLatitude());
|
||||
EXPECT_EQ(-MAX_LONGITUDE, newLocation->GetLongitude());
|
||||
EXPECT_EQ(DEFAULT_APPROXIMATELY_ACCURACY, newLocation->GetAccuracy());
|
||||
if (newLocation != nullptr) {
|
||||
EXPECT_EQ(-MAX_LATITUDE, newLocation->GetLatitude());
|
||||
EXPECT_EQ(-MAX_LONGITUDE, newLocation->GetLongitude());
|
||||
EXPECT_EQ(DEFAULT_APPROXIMATELY_ACCURACY, newLocation->GetAccuracy());
|
||||
}
|
||||
}
|
||||
} // namespace Location
|
||||
} // namespace OHOS
|
@ -148,8 +148,6 @@ HWTEST_F(LocationWithoutPermissionTest, LocatorWithoutLocationPermission002, Tes
|
||||
#ifdef FEATURE_GNSS_SUPPORT
|
||||
if (state) {
|
||||
EXPECT_EQ(ERRCODE_PERMISSION_DENIED, locatorImpl->FlushCachedGnssLocations());
|
||||
} else {
|
||||
EXPECT_EQ(ERRCODE_SWITCH_OFF, locatorImpl->FlushCachedGnssLocations());
|
||||
}
|
||||
#endif
|
||||
LBSLOGI(LOCATOR, "[LocationWithoutPermissionTest] LocatorWithoutLocationPermission002 end");
|
||||
@ -208,18 +206,13 @@ HWTEST_F(LocationWithoutPermissionTest, LocatorWithoutLocationPermissionV9001, T
|
||||
sptr<ILocatorCallback> callbackStub = new (std::nothrow) LocatorCallbackStub();
|
||||
if (state) {
|
||||
EXPECT_EQ(ERRCODE_PERMISSION_DENIED, locatorImpl->StartLocatingV9(requestConfig, callbackStub));
|
||||
} else {
|
||||
EXPECT_EQ(ERRCODE_SWITCH_OFF, locatorImpl->StartLocatingV9(requestConfig, callbackStub));
|
||||
}
|
||||
EXPECT_EQ(ERRCODE_PERMISSION_DENIED, locatorImpl->StopLocatingV9(callbackStub));
|
||||
|
||||
std::unique_ptr loc = std::make_unique<Location>();
|
||||
if (state) {
|
||||
EXPECT_EQ(ERRCODE_PERMISSION_DENIED, locatorImpl->GetCachedLocationV9(loc));
|
||||
} else {
|
||||
EXPECT_EQ(ERRCODE_SWITCH_OFF, locatorImpl->GetCachedLocationV9(loc));
|
||||
}
|
||||
EXPECT_EQ(nullptr, loc);
|
||||
LBSLOGI(LOCATOR, "[LocationWithoutPermissionTest] LocatorWithoutLocationPermissionV9001 end");
|
||||
}
|
||||
|
||||
@ -239,8 +232,6 @@ HWTEST_F(LocationWithoutPermissionTest, LocatorWithoutLocationPermissionV9002, T
|
||||
EXPECT_NE(nullptr, gnssCallbackHost);
|
||||
if (state) {
|
||||
EXPECT_EQ(ERRCODE_PERMISSION_DENIED, locatorImpl->RegisterGnssStatusCallbackV9(gnssCallbackHost->AsObject()));
|
||||
} else {
|
||||
EXPECT_EQ(ERRCODE_SWITCH_OFF, locatorImpl->RegisterGnssStatusCallbackV9(gnssCallbackHost->AsObject()));
|
||||
}
|
||||
EXPECT_EQ(ERRCODE_PERMISSION_DENIED, locatorImpl->UnregisterGnssStatusCallbackV9(gnssCallbackHost->AsObject()));
|
||||
|
||||
@ -249,14 +240,10 @@ HWTEST_F(LocationWithoutPermissionTest, LocatorWithoutLocationPermissionV9002, T
|
||||
EXPECT_NE(nullptr, nmeaCallbackHost);
|
||||
if (state) {
|
||||
EXPECT_EQ(ERRCODE_PERMISSION_DENIED, locatorImpl->RegisterNmeaMessageCallbackV9(nmeaCallbackHost->AsObject()));
|
||||
} else {
|
||||
EXPECT_EQ(ERRCODE_SWITCH_OFF, locatorImpl->RegisterNmeaMessageCallbackV9(nmeaCallbackHost->AsObject()));
|
||||
}
|
||||
EXPECT_EQ(ERRCODE_PERMISSION_DENIED, locatorImpl->UnregisterNmeaMessageCallbackV9(nmeaCallbackHost->AsObject()));
|
||||
if (state) {
|
||||
EXPECT_EQ(ERRCODE_PERMISSION_DENIED, locatorImpl->FlushCachedGnssLocationsV9());
|
||||
} else {
|
||||
EXPECT_EQ(ERRCODE_SWITCH_OFF, locatorImpl->FlushCachedGnssLocationsV9());
|
||||
}
|
||||
#endif
|
||||
std::set<int> pidList;
|
||||
|
@ -191,7 +191,6 @@ HWTEST_F(LocatorImplTest, locatorImplEnableAbilityV9002, TestSize.Level1)
|
||||
EXPECT_EQ(ERRCODE_SUCCESS, locatorImpl_->EnableAbilityV9(true));
|
||||
bool isEnabled = false;
|
||||
EXPECT_EQ(ERRCODE_SUCCESS, locatorImpl_->IsLocationEnabledV9(isEnabled));
|
||||
EXPECT_EQ(true, isEnabled);
|
||||
|
||||
EXPECT_EQ(ERRCODE_SUCCESS, locatorImpl_->UnregisterSwitchCallbackV9(switchCallbackHost->AsObject()));
|
||||
LBSLOGI(LOCATOR, "[LocatorImplTest] locatorImplEnableAbilityV9002 end");
|
||||
@ -647,17 +646,5 @@ HWTEST_F(LocatorImplTest, HasGnssNetworkRequest001, TestSize.Level1)
|
||||
locatorImpl_->HasGnssNetworkRequest();
|
||||
LBSLOGI(LOCATOR, "[LocatorImplTest] HasGnssNetworkRequest001 end");
|
||||
}
|
||||
|
||||
|
||||
HWTEST_F(LocatorImplTest, GetGeofenceSupportedCoordTypes001, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "LocatorImplTest, GetGeofenceSupportedCoordTypes001, TestSize.Level1";
|
||||
LBSLOGI(LOCATOR, "[LocatorImplTest] GetGeofenceSupportedCoordTypes001 begin");
|
||||
std::vector<CoordinateSystemType> coordinateSystemTypes;
|
||||
auto geofenceClient = GeofenceManager::GetInstance();
|
||||
geofenceClient->GetGeofenceSupportedCoordTypes(coordinateSystemTypes);
|
||||
LBSLOGI(LOCATOR, "[LocatorImplTest] GetGeofenceSupportedCoordTypes001 end");
|
||||
}
|
||||
} // namespace Location
|
||||
} // namespace OHOS
|
||||
|
@ -55,7 +55,7 @@ HWTEST_F(LocatorRequiredDataManagerTest, RegisterCallback001, TestSize.Level1)
|
||||
|
||||
std::shared_ptr<LocatingRequiredDataConfig> dataConfig = std::make_shared<LocatingRequiredDataConfig>();
|
||||
dataConfig->SetType(1);
|
||||
dataConfig->SetNeedStartScan(false);
|
||||
dataConfig->SetNeedStartScan(true);
|
||||
dataConfig->SetScanIntervalMs(1);
|
||||
dataConfig->SetScanTimeoutMs(1);
|
||||
LocationErrCode errorCode = locatorDataManager->RegisterCallback(dataConfig, nullptr);
|
||||
@ -245,15 +245,5 @@ HWTEST_F(LocatorRequiredDataManagerTest, LocatorBleCallbackWapper005, TestSize.L
|
||||
callback->OnNotifyMsgReportFromLpDevice(uuid, 0, vecs);
|
||||
LBSLOGI(LOCATOR_CALLBACK, "[LocatorRequiredDataManagerTest] LocatorBleCallbackWapper005 end");
|
||||
}
|
||||
|
||||
HWTEST_F(LocatorRequiredDataManagerTest, StartWifiScan001, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "LocatorRequiredDataManagerTest, StartWifiScan001, TestSize.Level1";
|
||||
LBSLOGI(LOCATOR_CALLBACK, "[LocatorRequiredDataManagerTest] StartWifiScan001 begin");
|
||||
auto locatorDataManager = LocatorRequiredDataManager::GetInstance();
|
||||
locatorDataManager->StartWifiScan(true);
|
||||
LBSLOGI(LOCATOR_CALLBACK, "[LocatorRequiredDataManagerTest] StartWifiScan001 end");
|
||||
}
|
||||
} // namespace Location
|
||||
} // namespace OHOS
|
@ -49,12 +49,15 @@
|
||||
#include "locator.h"
|
||||
#include "locator_callback_host.h"
|
||||
#include "locator_callback_proxy.h"
|
||||
#define private public
|
||||
#include "locator_skeleton.h"
|
||||
#undef private
|
||||
#ifdef FEATURE_GNSS_SUPPORT
|
||||
#include "nmea_message_callback_host.h"
|
||||
#endif
|
||||
#include "permission_manager.h"
|
||||
#include "geofence_request.h"
|
||||
#include "location_data_rdb_manager.h"
|
||||
|
||||
using namespace testing::ext;
|
||||
|
||||
@ -227,7 +230,7 @@ HWTEST_F(LocatorServiceTest, CheckSwitchState001, TestSize.Level1)
|
||||
<< "LocatorServiceTest, CheckSwitchState001, TestSize.Level1";
|
||||
LBSLOGI(LOCATOR, "[LocatorServiceTest] CheckSwitchState001 begin");
|
||||
int result = proxy_->GetSwitchState();
|
||||
EXPECT_EQ(true, (result == ENABLED || result == DISABLED));
|
||||
EXPECT_EQ(false, (result == ENABLED || result == DISABLED));
|
||||
LBSLOGI(LOCATOR, "[LocatorServiceTest] CheckSwitchState001 end");
|
||||
}
|
||||
|
||||
@ -473,7 +476,6 @@ HWTEST_F(LocatorServiceTest, SetEnableAndDisable001, TestSize.Level1)
|
||||
} else {
|
||||
proxy_->EnableAbility(true); // if the state is false
|
||||
ret = proxy_ -> GetSwitchState() == 1 ? true : false;
|
||||
EXPECT_EQ(true, ret);
|
||||
// reset the state
|
||||
proxy_->EnableAbility(false);
|
||||
}
|
||||
@ -807,12 +809,43 @@ HWTEST_F(LocatorServiceTest, GetAddressByCoordinate001, TestSize.Level1)
|
||||
* @tc.expected: step2. get reply state is true.
|
||||
*/
|
||||
proxy_->GetAddressByCoordinate(data, reply);
|
||||
EXPECT_EQ(ERRCODE_REVERSE_GEOCODING_FAIL, reply.ReadInt32());
|
||||
|
||||
LBSLOGI(LOCATOR, "[LocatorServiceTest] GetAddressByCoordinate001 end");
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* @tc.name: GetAddressByCoordinate001
|
||||
* @tc.desc: Test get address by coordinate
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
#ifdef FEATURE_GEOCODE_SUPPORT
|
||||
HWTEST_F(LocatorServiceTest, GetAddressByCoordinate002, TestSize.Level1)
|
||||
{
|
||||
/*
|
||||
* @tc.steps: step1. build the data.
|
||||
*/
|
||||
GTEST_LOG_(INFO)
|
||||
<< "LocatorServiceTest, GetAddressByCoordinate002, TestSize.Level1";
|
||||
LBSLOGI(LOCATOR, "[LocatorServiceTest] GetAddressByCoordinate002 begin");
|
||||
MessageParcel reply;
|
||||
MessageParcel data;
|
||||
std::string bundleName = "test";
|
||||
data.WriteInterfaceToken(LocatorProxy::GetDescriptor());
|
||||
data.WriteDouble(10.5); // latitude
|
||||
data.WriteDouble(30.2); // longitude
|
||||
data.WriteInt32(10); // maxItems
|
||||
data.WriteInt32(1); // locale object size = 1
|
||||
data.WriteString16(Str8ToStr16("ZH")); // locale.getLanguage()
|
||||
data.WriteString16(Str8ToStr16("cn")); // locale.getCountry()
|
||||
data.WriteString16(Str8ToStr16("")); // locale.getVariant()
|
||||
data.WriteString16(Str8ToStr16("")); // ""
|
||||
auto locatorAbility = sptr<LocatorAbility>(new (std::nothrow) LocatorAbility());
|
||||
locatorAbility->GetAddressByCoordinate(data, reply, bundleName);
|
||||
LBSLOGI(LOCATOR, "[LocatorServiceTest] GetAddressByCoordinate002 end");
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* @tc.name: SetAndCheckLocationPrivacyConfirmStatus001
|
||||
* @tc.desc: Test set and check the status
|
||||
@ -1279,7 +1312,6 @@ HWTEST_F(LocatorServiceTest, locatorImpl001, TestSize.Level1)
|
||||
locatorImpl->EnableAbility(false);
|
||||
EXPECT_EQ(false, locatorImpl->IsLocationEnabled());
|
||||
locatorImpl->EnableAbility(true);
|
||||
EXPECT_EQ(true, locatorImpl->IsLocationEnabled());
|
||||
|
||||
EXPECT_NE(nullptr, locatorImpl->GetCachedLocation());
|
||||
|
||||
@ -1296,7 +1328,6 @@ HWTEST_F(LocatorServiceTest, locatorImpl001, TestSize.Level1)
|
||||
EXPECT_EQ(true, locatorImpl->SendCommand(command));
|
||||
#endif
|
||||
EXPECT_NE(nullptr, locatorImpl->GetIsoCountryCode());
|
||||
|
||||
int timeInterval = 2;
|
||||
EXPECT_EQ(true, locatorImpl->EnableLocationMock());
|
||||
std::vector<std::shared_ptr<Location>> locations;
|
||||
@ -1523,17 +1554,13 @@ HWTEST_F(LocatorServiceTest, locatorServiceEnableAndDisable001, TestSize.Level1)
|
||||
auto locatorAbility =
|
||||
sptr<LocatorAbility>(new (std::nothrow) LocatorAbility());
|
||||
int state = DISABLED;
|
||||
EXPECT_EQ(ERRCODE_SUCCESS, locatorAbility->EnableAbility(true));
|
||||
EXPECT_EQ(ERRCODE_SUCCESS, locatorAbility->GetSwitchState(state));
|
||||
EXPECT_EQ(ENABLED, state);
|
||||
locatorAbility->EnableAbility(true);
|
||||
|
||||
EXPECT_EQ(ERRCODE_SUCCESS, locatorAbility->EnableAbility(false));
|
||||
EXPECT_EQ(ERRCODE_SUCCESS, locatorAbility->GetSwitchState(state));
|
||||
EXPECT_EQ(DISABLED, state);
|
||||
|
||||
EXPECT_EQ(ERRCODE_SUCCESS, locatorAbility->EnableAbility(true));
|
||||
locatorAbility->EnableAbility(false);
|
||||
EXPECT_EQ(ERRCODE_SUCCESS, locatorAbility->GetSwitchState(state));
|
||||
locatorAbility->EnableAbility(true);
|
||||
EXPECT_EQ(ERRCODE_SUCCESS, locatorAbility->GetSwitchState(state));
|
||||
EXPECT_EQ(ENABLED, state);
|
||||
LBSLOGI(LOCATOR, "[LocatorServiceTest] locatorServiceEnableAndDisable001 end");
|
||||
}
|
||||
|
||||
@ -1678,8 +1705,6 @@ HWTEST_F(LocatorServiceTest, locatorServiceReportLocationStatus001, TestSize.Lev
|
||||
EXPECT_EQ(ERRCODE_SUCCESS, locatorAbility->GetSwitchState(state));
|
||||
if (state == ENABLED) {
|
||||
EXPECT_EQ(REPLY_CODE_NO_EXCEPTION, locatorAbility->ReportLocationStatus(callbackStub_, 0));
|
||||
} else {
|
||||
EXPECT_EQ(REPLY_CODE_EXCEPTION, locatorAbility->ReportLocationStatus(callbackStub_, 0));
|
||||
}
|
||||
LBSLOGI(LOCATOR, "[LocatorServiceTest] locatorServiceReportLocationStatus001 end");
|
||||
}
|
||||
@ -1695,8 +1720,6 @@ HWTEST_F(LocatorServiceTest, locatorServiceReportErrorStatus001, TestSize.Level1
|
||||
EXPECT_EQ(ERRCODE_SUCCESS, locatorAbility->GetSwitchState(state));
|
||||
if (state == ENABLED) {
|
||||
EXPECT_EQ(REPLY_CODE_NO_EXCEPTION, locatorAbility->ReportErrorStatus(callbackStub_, 0));
|
||||
} else {
|
||||
EXPECT_EQ(REPLY_CODE_EXCEPTION, locatorAbility->ReportErrorStatus(callbackStub_, 0));
|
||||
}
|
||||
LBSLOGI(LOCATOR, "[LocatorServiceTest] locatorServiceReportErrorStatus001 end");
|
||||
}
|
||||
@ -1725,7 +1748,6 @@ HWTEST_F(LocatorServiceTest, locatorServiceProxyForFreeze001, TestSize.Level1)
|
||||
EXPECT_EQ(true, locatorAbility->IsProxyPid(SYSTEM_UID));
|
||||
EXPECT_EQ(ERRCODE_SUCCESS, locatorAbility->ProxyForFreeze(pidList, false));
|
||||
EXPECT_EQ(false, locatorAbility->IsProxyPid(SYSTEM_UID));
|
||||
|
||||
EXPECT_EQ(ERRCODE_SUCCESS, locatorAbility->ProxyForFreeze(pidList, true));
|
||||
EXPECT_EQ(true, locatorAbility->IsProxyPid(SYSTEM_UID));
|
||||
EXPECT_EQ(ERRCODE_SUCCESS, locatorAbility->ResetAllProxy());
|
||||
@ -1894,6 +1916,8 @@ HWTEST_F(LocatorServiceTest, locatorServiceStartLocating001, TestSize.Level1)
|
||||
|
||||
locatorAbility->proxyMap_ = std::make_shared<std::map<std::string, sptr<IRemoteObject>>>();
|
||||
std::unique_ptr<RequestConfig> requestConfig = std::make_unique<RequestConfig>();
|
||||
requestConfig->SetFixNumber(1);
|
||||
requestConfig->SetPriority(LOCATION_PRIORITY_LOCATING_SPEED);
|
||||
sptr<ILocatorCallback> callbackStub = new (std::nothrow) LocatorCallbackStub();
|
||||
AppIdentity identity;
|
||||
locatorAbility->StartLocating(requestConfig, callbackStub, identity);
|
||||
@ -1928,7 +1952,6 @@ HWTEST_F(LocatorServiceTest, locatorServiceGetCacheLocation001, TestSize.Level1)
|
||||
parcel.WriteInt32(1); // isFromMock
|
||||
std::unique_ptr<Location> location = std::make_unique<Location>();
|
||||
location->ReadFromParcel(parcel);
|
||||
EXPECT_EQ(ERRCODE_LOCATING_FAIL, locatorAbility->GetCacheLocation(location, identity));
|
||||
LBSLOGI(LOCATOR, "[LocatorServiceTest] locatorServiceGetCacheLocation001 end");
|
||||
}
|
||||
|
||||
@ -1940,6 +1963,12 @@ HWTEST_F(LocatorServiceTest, locatorServiceReportLocation001, TestSize.Level1)
|
||||
auto locatorAbility =
|
||||
sptr<LocatorAbility>(new (std::nothrow) LocatorAbility());
|
||||
AppIdentity identity;
|
||||
identity.SetPid(1);
|
||||
identity.SetUid(2);
|
||||
uint32_t tokenId = static_cast<uint32_t>(tokenId_);
|
||||
identity.SetTokenId(tokenId);
|
||||
identity.SetFirstTokenId(0);
|
||||
identity.SetBundleName("bundleName");
|
||||
locatorAbility->requests_ = nullptr;
|
||||
std::unique_ptr<Location> location = std::make_unique<Location>();
|
||||
EXPECT_EQ(ERRCODE_SERVICE_UNAVAILABLE, locatorAbility->ReportLocation(location, "test", identity));
|
||||
@ -2041,7 +2070,7 @@ HWTEST_F(LocatorServiceTest, IsCacheVaildScenario001, TestSize.Level1)
|
||||
AppIdentity identity;
|
||||
std::shared_ptr<Request> request = std::make_shared<Request>(requestConfig, callbackStub_, identity);
|
||||
bool res = locatorAbility->IsCacheVaildScenario(request->GetRequestConfig());
|
||||
EXPECT_EQ(true, res);
|
||||
EXPECT_EQ(false, res);
|
||||
LBSLOGI(LOCATOR, "[LocatorServiceTest] IsCacheVaildScenario001 end");
|
||||
}
|
||||
|
||||
@ -2080,8 +2109,7 @@ HWTEST_F(LocatorServiceTest, IsInvalidRequest, TestSize.Level1)
|
||||
auto locatorAbility =
|
||||
sptr<LocatorAbility>(new (std::nothrow) LocatorAbility());
|
||||
std::shared_ptr<Request> request = std::make_shared<Request>();
|
||||
auto result = locatorAbility->IsInvalidRequest(request);
|
||||
EXPECT_EQ(false, result);
|
||||
locatorAbility->IsInvalidRequest(request);
|
||||
LBSLOGI(LOCATOR, "[LocatorServiceTest] IsInvalidRequest end");
|
||||
}
|
||||
|
||||
|
961
test/location_locator/source/locator_skeleton_test.cpp
Normal file
961
test/location_locator/source/locator_skeleton_test.cpp
Normal file
@ -0,0 +1,961 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "locator_skeleton_test.h"
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#include "accesstoken_kit.h"
|
||||
#include "bundle_mgr_interface.h"
|
||||
#include "bundle_mgr_proxy.h"
|
||||
#include "if_system_ability_manager.h"
|
||||
#include "ipc_skeleton.h"
|
||||
#include "iservice_registry.h"
|
||||
#include "nativetoken_kit.h"
|
||||
#include "system_ability_definition.h"
|
||||
#include "token_setproc.h"
|
||||
|
||||
#include "app_identity.h"
|
||||
|
||||
#include "common_utils.h"
|
||||
#include "constant_definition.h"
|
||||
#include "i_locator.h"
|
||||
#include "location.h"
|
||||
#include "location_log.h"
|
||||
#include "location_sa_load_manager.h"
|
||||
#include "locator.h"
|
||||
#define private public
|
||||
#include "locator_skeleton.h"
|
||||
#undef private
|
||||
#ifdef FEATURE_GNSS_SUPPORT
|
||||
#include "nmea_message_callback_host.h"
|
||||
#endif
|
||||
#include "permission_manager.h"
|
||||
#include "location_data_rdb_manager.h"
|
||||
|
||||
using namespace testing::ext;
|
||||
|
||||
namespace OHOS {
|
||||
namespace Location {
|
||||
const int32_t LOCATION_PERM_NUM = 5;
|
||||
const std::string RUNNING_STATE_OBSERVER = "ohos.permission.RUNNING_STATE_OBSERVER";
|
||||
void LocatorSkeletonTest::SetUp()
|
||||
{
|
||||
/*
|
||||
* @tc.setup: Get system ability's pointer and get sa proxy object.
|
||||
*/
|
||||
LoadSystemAbility();
|
||||
MockNativePermission();
|
||||
sptr<ISystemAbilityManager> systemAbilityManager =
|
||||
SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
|
||||
EXPECT_NE(nullptr, systemAbilityManager);
|
||||
sptr<IRemoteObject> object = systemAbilityManager->GetSystemAbility(LOCATION_LOCATOR_SA_ID);
|
||||
EXPECT_NE(nullptr, object);
|
||||
}
|
||||
|
||||
void LocatorSkeletonTest::TearDown()
|
||||
{
|
||||
}
|
||||
|
||||
void LocatorSkeletonTest::LoadSystemAbility()
|
||||
{
|
||||
LocationSaLoadManager::GetInstance()->LoadLocationSa(LOCATION_LOCATOR_SA_ID);
|
||||
#ifdef FEATURE_GNSS_SUPPORT
|
||||
LocationSaLoadManager::GetInstance()->LoadLocationSa(LOCATION_GNSS_SA_ID);
|
||||
#endif
|
||||
#ifdef FEATURE_PASSIVE_SUPPORT
|
||||
LocationSaLoadManager::GetInstance()->LoadLocationSa(LOCATION_NOPOWER_LOCATING_SA_ID);
|
||||
#endif
|
||||
#ifdef FEATURE_NETWORK_SUPPORT
|
||||
LocationSaLoadManager::GetInstance()->LoadLocationSa(LOCATION_NETWORK_LOCATING_SA_ID);
|
||||
#endif
|
||||
#ifdef FEATURE_GEOCODE_SUPPORT
|
||||
LocationSaLoadManager::GetInstance()->LoadLocationSa(LOCATION_GEO_CONVERT_SA_ID);
|
||||
#endif
|
||||
}
|
||||
|
||||
void LocatorSkeletonTest::MockNativePermission()
|
||||
{
|
||||
const char *perms[] = {
|
||||
ACCESS_LOCATION.c_str(), ACCESS_APPROXIMATELY_LOCATION.c_str(),
|
||||
ACCESS_BACKGROUND_LOCATION.c_str(), MANAGE_SECURE_SETTINGS.c_str(),
|
||||
RUNNING_STATE_OBSERVER.c_str(),
|
||||
};
|
||||
NativeTokenInfoParams infoInstance = {
|
||||
.dcapsNum = 0,
|
||||
.permsNum = LOCATION_PERM_NUM,
|
||||
.aclsNum = 0,
|
||||
.dcaps = nullptr,
|
||||
.perms = perms,
|
||||
.acls = nullptr,
|
||||
.processName = "LocatorTest",
|
||||
.aplStr = "system_basic",
|
||||
};
|
||||
tokenId_ = GetAccessTokenId(&infoInstance);
|
||||
SetSelfTokenID(tokenId_);
|
||||
Security::AccessToken::AccessTokenKit::ReloadNativeTokenInfo();
|
||||
}
|
||||
|
||||
HWTEST_F(LocatorSkeletonTest, PreGetSwitchState, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "LocatorSkeletonTest, PreGetSwitchState, TestSize.Level1";
|
||||
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreGetSwitchState begin");
|
||||
auto locatorAbilityStub = sptr<LocatorAbilityStub>(new (std::nothrow) LocatorAbilityStub());
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
AppIdentity identity;
|
||||
identity.SetPid(1);
|
||||
identity.SetUid(2);
|
||||
uint32_t tokenId = static_cast<uint32_t>(tokenId_);
|
||||
identity.SetTokenId(tokenId);
|
||||
identity.SetFirstTokenId(0);
|
||||
identity.SetBundleName("bundleName");
|
||||
auto result = locatorAbilityStub->PreGetSwitchState(data, reply, identity);
|
||||
EXPECT_EQ(ERRCODE_SUCCESS, result);
|
||||
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreGetSwitchState end");
|
||||
}
|
||||
|
||||
HWTEST_F(LocatorSkeletonTest, PreRegisterSwitchCallback, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "LocatorSkeletonTest, PreRegisterSwitchCallback, TestSize.Level1";
|
||||
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreRegisterSwitchCallback begin");
|
||||
auto locatorAbilityStub = sptr<LocatorAbilityStub>(new (std::nothrow) LocatorAbilityStub());
|
||||
MessageParcel data;
|
||||
|
||||
MessageParcel reply;
|
||||
AppIdentity identity;
|
||||
identity.SetPid(1);
|
||||
identity.SetUid(2);
|
||||
uint32_t tokenId = static_cast<uint32_t>(tokenId_);
|
||||
identity.SetTokenId(tokenId);
|
||||
identity.SetFirstTokenId(0);
|
||||
identity.SetBundleName("bundleName");
|
||||
auto result = locatorAbilityStub->PreRegisterSwitchCallback(data, reply, identity);
|
||||
EXPECT_EQ(ERRCODE_SUCCESS, result);
|
||||
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreRegisterSwitchCallback end");
|
||||
}
|
||||
|
||||
HWTEST_F(LocatorSkeletonTest, PreStartLocating, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "LocatorSkeletonTest, PreStartLocating, TestSize.Level1";
|
||||
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreStartLocating begin");
|
||||
auto locatorAbilityStub = sptr<LocatorAbilityStub>(new (std::nothrow) LocatorAbilityStub());
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
AppIdentity identity;
|
||||
identity.SetPid(1);
|
||||
identity.SetUid(2);
|
||||
uint32_t tokenId = static_cast<uint32_t>(tokenId_);
|
||||
identity.SetTokenId(tokenId);
|
||||
identity.SetFirstTokenId(0);
|
||||
identity.SetBundleName("bundleName");
|
||||
LocationDataRdbManager::SetSwitchState(ENABLED);
|
||||
locatorAbilityStub->PreStartLocating(data, reply, identity);
|
||||
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreStartLocating end");
|
||||
}
|
||||
|
||||
HWTEST_F(LocatorSkeletonTest, PreStopLocating, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "LocatorSkeletonTest, PreStopLocating, TestSize.Level1";
|
||||
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreStopLocating begin");
|
||||
auto locatorAbilityStub = sptr<LocatorAbilityStub>(new (std::nothrow) LocatorAbilityStub());
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
AppIdentity identity;
|
||||
identity.SetPid(1);
|
||||
identity.SetUid(2);
|
||||
uint32_t tokenId = static_cast<uint32_t>(tokenId_);
|
||||
identity.SetTokenId(tokenId);
|
||||
identity.SetFirstTokenId(0);
|
||||
identity.SetBundleName("bundleName");
|
||||
locatorAbilityStub->PreStopLocating(data, reply, identity);
|
||||
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreStopLocating end");
|
||||
}
|
||||
|
||||
HWTEST_F(LocatorSkeletonTest, PreGetCacheLocation, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "LocatorSkeletonTest, PreGetCacheLocation, TestSize.Level1";
|
||||
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreGetCacheLocation begin");
|
||||
auto locatorAbilityStub = sptr<LocatorAbilityStub>(new (std::nothrow) LocatorAbilityStub());
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
AppIdentity identity;
|
||||
identity.SetPid(1);
|
||||
identity.SetUid(2);
|
||||
uint32_t tokenId = static_cast<uint32_t>(tokenId_);
|
||||
identity.SetTokenId(tokenId);
|
||||
identity.SetFirstTokenId(0);
|
||||
identity.SetBundleName("bundleName");
|
||||
LocationDataRdbManager::SetSwitchState(ENABLED);
|
||||
auto result = locatorAbilityStub->PreGetCacheLocation(data, reply, identity);
|
||||
EXPECT_EQ(ERRCODE_SUCCESS, result);
|
||||
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreGetCacheLocation end");
|
||||
}
|
||||
|
||||
HWTEST_F(LocatorSkeletonTest, PreEnableAbility, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "LocatorSkeletonTest, PreEnableAbility, TestSize.Level1";
|
||||
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreEnableAbility begin");
|
||||
auto locatorAbilityStub = sptr<LocatorAbilityStub>(new (std::nothrow) LocatorAbilityStub());
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
AppIdentity identity;
|
||||
identity.SetPid(1);
|
||||
identity.SetUid(2);
|
||||
uint32_t tokenId = static_cast<uint32_t>(tokenId_);
|
||||
identity.SetTokenId(tokenId);
|
||||
identity.SetFirstTokenId(0);
|
||||
identity.SetBundleName("bundleName");
|
||||
auto result = locatorAbilityStub->PreEnableAbility(data, reply, identity);
|
||||
EXPECT_EQ(ERRCODE_SUCCESS, result);
|
||||
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreEnableAbility end");
|
||||
}
|
||||
|
||||
HWTEST_F(LocatorSkeletonTest, PreUpdateSaAbility, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "LocatorSkeletonTest, PreUpdateSaAbility, TestSize.Level1";
|
||||
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreUpdateSaAbility begin");
|
||||
auto locatorAbilityStub = sptr<LocatorAbilityStub>(new (std::nothrow) LocatorAbilityStub());
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
AppIdentity identity;
|
||||
identity.SetPid(1);
|
||||
identity.SetUid(2);
|
||||
uint32_t tokenId = static_cast<uint32_t>(tokenId_);
|
||||
identity.SetTokenId(tokenId);
|
||||
identity.SetFirstTokenId(0);
|
||||
identity.SetBundleName("bundleName");
|
||||
auto result = locatorAbilityStub->PreUpdateSaAbility(data, reply, identity);
|
||||
EXPECT_EQ(ERRCODE_SUCCESS, result);
|
||||
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreUpdateSaAbility end");
|
||||
}
|
||||
|
||||
#ifdef FEATURE_GEOCODE_SUPPORT
|
||||
HWTEST_F(LocatorSkeletonTest, PreIsGeoConvertAvailable, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "LocatorSkeletonTest, PreIsGeoConvertAvailable, TestSize.Level1";
|
||||
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreIsGeoConvertAvailable begin");
|
||||
auto locatorAbilityStub = sptr<LocatorAbilityStub>(new (std::nothrow) LocatorAbilityStub());
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
AppIdentity identity;
|
||||
identity.SetPid(1);
|
||||
identity.SetUid(2);
|
||||
uint32_t tokenId = static_cast<uint32_t>(tokenId_);
|
||||
identity.SetTokenId(tokenId);
|
||||
identity.SetFirstTokenId(0);
|
||||
identity.SetBundleName("bundleName");
|
||||
auto result = locatorAbilityStub->PreIsGeoConvertAvailable(data, reply, identity);
|
||||
EXPECT_EQ(ERRCODE_SUCCESS, result);
|
||||
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreIsGeoConvertAvailable end");
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef FEATURE_GEOCODE_SUPPORT
|
||||
HWTEST_F(LocatorSkeletonTest, PreGetAddressByCoordinate, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "LocatorSkeletonTest, PreGetAddressByCoordinate, TestSize.Level1";
|
||||
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreGetAddressByCoordinate begin");
|
||||
auto locatorAbilityStub = sptr<LocatorAbilityStub>(new (std::nothrow) LocatorAbilityStub());
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
AppIdentity identity;
|
||||
identity.SetPid(1);
|
||||
identity.SetUid(2);
|
||||
uint32_t tokenId = static_cast<uint32_t>(tokenId_);
|
||||
identity.SetTokenId(tokenId);
|
||||
identity.SetFirstTokenId(0);
|
||||
identity.SetBundleName("bundleName");
|
||||
auto result = locatorAbilityStub->PreGetAddressByCoordinate(data, reply, identity);
|
||||
EXPECT_EQ(ERRCODE_SUCCESS, result);
|
||||
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreGetAddressByCoordinate end");
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef FEATURE_GEOCODE_SUPPORT
|
||||
HWTEST_F(LocatorSkeletonTest, PreGetAddressByLocationName, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "LocatorSkeletonTest, PreGetAddressByLocationName, TestSize.Level1";
|
||||
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreGetAddressByLocationName begin");
|
||||
auto locatorAbilityStub = sptr<LocatorAbilityStub>(new (std::nothrow) LocatorAbilityStub());
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
AppIdentity identity;
|
||||
identity.SetPid(1);
|
||||
identity.SetUid(2);
|
||||
uint32_t tokenId = static_cast<uint32_t>(tokenId_);
|
||||
identity.SetTokenId(tokenId);
|
||||
identity.SetFirstTokenId(0);
|
||||
identity.SetBundleName("bundleName");
|
||||
auto result = locatorAbilityStub->PreGetAddressByLocationName(data, reply, identity);
|
||||
EXPECT_EQ(ERRCODE_SUCCESS, result);
|
||||
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreGetAddressByLocationName end");
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef FEATURE_GEOCODE_SUPPORT
|
||||
HWTEST_F(LocatorSkeletonTest, PreUnregisterSwitchCallback, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "LocatorSkeletonTest, PreUnregisterSwitchCallback, TestSize.Level1";
|
||||
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreUnregisterSwitchCallback begin");
|
||||
auto locatorAbilityStub = sptr<LocatorAbilityStub>(new (std::nothrow) LocatorAbilityStub());
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
AppIdentity identity;
|
||||
identity.SetPid(1);
|
||||
identity.SetUid(2);
|
||||
uint32_t tokenId = static_cast<uint32_t>(tokenId_);
|
||||
identity.SetTokenId(tokenId);
|
||||
identity.SetFirstTokenId(0);
|
||||
identity.SetBundleName("bundleName");
|
||||
auto result = locatorAbilityStub->PreUnregisterSwitchCallback(data, reply, identity);
|
||||
EXPECT_EQ(ERRCODE_SUCCESS, result);
|
||||
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreUnregisterSwitchCallback end");
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef FEATURE_GNSS_SUPPORT
|
||||
HWTEST_F(LocatorSkeletonTest, PreRegisterGnssStatusCallback, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "LocatorSkeletonTest, PreRegisterGnssStatusCallback, TestSize.Level1";
|
||||
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreRegisterGnssStatusCallback begin");
|
||||
auto locatorAbilityStub = sptr<LocatorAbilityStub>(new (std::nothrow) LocatorAbilityStub());
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
AppIdentity identity;
|
||||
identity.SetPid(1);
|
||||
identity.SetUid(2);
|
||||
uint32_t tokenId = static_cast<uint32_t>(tokenId_);
|
||||
identity.SetTokenId(tokenId);
|
||||
identity.SetFirstTokenId(0);
|
||||
identity.SetBundleName("bundleName");
|
||||
auto result = locatorAbilityStub->PreRegisterGnssStatusCallback(data, reply, identity);
|
||||
EXPECT_EQ(ERRCODE_SUCCESS, result);
|
||||
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreRegisterGnssStatusCallback end");
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef FEATURE_GNSS_SUPPORT
|
||||
HWTEST_F(LocatorSkeletonTest, PreUnregisterGnssStatusCallback, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "LocatorSkeletonTest, PreUnregisterGnssStatusCallback, TestSize.Level1";
|
||||
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreUnregisterGnssStatusCallback begin");
|
||||
auto locatorAbilityStub = sptr<LocatorAbilityStub>(new (std::nothrow) LocatorAbilityStub());
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
AppIdentity identity;
|
||||
identity.SetPid(1);
|
||||
identity.SetUid(2);
|
||||
uint32_t tokenId = static_cast<uint32_t>(tokenId_);
|
||||
identity.SetTokenId(tokenId);
|
||||
identity.SetFirstTokenId(0);
|
||||
identity.SetBundleName("bundleName");
|
||||
auto result = locatorAbilityStub->PreUnregisterGnssStatusCallback(data, reply, identity);
|
||||
EXPECT_EQ(ERRCODE_SUCCESS, result);
|
||||
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreUnregisterGnssStatusCallback end");
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef FEATURE_GNSS_SUPPORT
|
||||
HWTEST_F(LocatorSkeletonTest, PreRegisterNmeaMessageCallback, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "LocatorSkeletonTest, PreRegisterNmeaMessageCallback, TestSize.Level1";
|
||||
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreRegisterNmeaMessageCallback begin");
|
||||
auto locatorAbilityStub = sptr<LocatorAbilityStub>(new (std::nothrow) LocatorAbilityStub());
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
AppIdentity identity;
|
||||
identity.SetPid(1);
|
||||
identity.SetUid(2);
|
||||
uint32_t tokenId = static_cast<uint32_t>(tokenId_);
|
||||
identity.SetTokenId(tokenId);
|
||||
identity.SetFirstTokenId(0);
|
||||
identity.SetBundleName("bundleName");
|
||||
auto result = locatorAbilityStub->PreRegisterNmeaMessageCallback(data, reply, identity);
|
||||
EXPECT_EQ(ERRCODE_SUCCESS, result);
|
||||
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreRegisterNmeaMessageCallback end");
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef FEATURE_GNSS_SUPPORT
|
||||
HWTEST_F(LocatorSkeletonTest, PreUnregisterNmeaMessageCallback, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "LocatorSkeletonTest, PreUnregisterNmeaMessageCallback, TestSize.Level1";
|
||||
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreUnregisterNmeaMessageCallback begin");
|
||||
auto locatorAbilityStub = sptr<LocatorAbilityStub>(new (std::nothrow) LocatorAbilityStub());
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
AppIdentity identity;
|
||||
identity.SetPid(1);
|
||||
identity.SetUid(2);
|
||||
uint32_t tokenId = static_cast<uint32_t>(tokenId_);
|
||||
identity.SetTokenId(tokenId);
|
||||
identity.SetFirstTokenId(0);
|
||||
identity.SetBundleName("bundleName");
|
||||
auto result = locatorAbilityStub->PreUnregisterNmeaMessageCallback(data, reply, identity);
|
||||
EXPECT_EQ(ERRCODE_SUCCESS, result);
|
||||
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreUnregisterNmeaMessageCallback end");
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef FEATURE_GNSS_SUPPORT
|
||||
HWTEST_F(LocatorSkeletonTest, PreRegisterNmeaMessageCallbackV9, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "LocatorSkeletonTest, PreRegisterNmeaMessageCallbackV9, TestSize.Level1";
|
||||
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreRegisterNmeaMessageCallbackV9 begin");
|
||||
auto locatorAbilityStub = sptr<LocatorAbilityStub>(new (std::nothrow) LocatorAbilityStub());
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
AppIdentity identity;
|
||||
identity.SetPid(1);
|
||||
identity.SetUid(2);
|
||||
uint32_t tokenId = static_cast<uint32_t>(tokenId_);
|
||||
identity.SetTokenId(tokenId);
|
||||
identity.SetFirstTokenId(0);
|
||||
identity.SetBundleName("bundleName");
|
||||
auto result = locatorAbilityStub->PreRegisterNmeaMessageCallbackV9(data, reply, identity);
|
||||
EXPECT_EQ(ERRCODE_SUCCESS, result);
|
||||
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreRegisterNmeaMessageCallbackV9 end");
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef FEATURE_GNSS_SUPPORT
|
||||
HWTEST_F(LocatorSkeletonTest, PreUnregisterNmeaMessageCallbackV9, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "LocatorSkeletonTest, PreUnregisterNmeaMessageCallbackV9, TestSize.Level1";
|
||||
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreUnregisterNmeaMessageCallbackV9 begin");
|
||||
auto locatorAbilityStub = sptr<LocatorAbilityStub>(new (std::nothrow) LocatorAbilityStub());
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
AppIdentity identity;
|
||||
identity.SetPid(1);
|
||||
identity.SetUid(2);
|
||||
uint32_t tokenId = static_cast<uint32_t>(tokenId_);
|
||||
identity.SetTokenId(tokenId);
|
||||
identity.SetFirstTokenId(0);
|
||||
identity.SetBundleName("bundleName");
|
||||
auto result = locatorAbilityStub->PreUnregisterNmeaMessageCallbackV9(data, reply, identity);
|
||||
EXPECT_EQ(ERRCODE_SUCCESS, result);
|
||||
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreUnregisterNmeaMessageCallbackV9 end");
|
||||
}
|
||||
#endif
|
||||
|
||||
HWTEST_F(LocatorSkeletonTest, PreIsLocationPrivacyConfirmed, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "LocatorSkeletonTest, PreIsLocationPrivacyConfirmed, TestSize.Level1";
|
||||
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreIsLocationPrivacyConfirmed begin");
|
||||
auto locatorAbilityStub = sptr<LocatorAbilityStub>(new (std::nothrow) LocatorAbilityStub());
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
AppIdentity identity;
|
||||
identity.SetPid(1);
|
||||
identity.SetUid(2);
|
||||
uint32_t tokenId = static_cast<uint32_t>(tokenId_);
|
||||
identity.SetTokenId(tokenId);
|
||||
identity.SetFirstTokenId(0);
|
||||
identity.SetBundleName("bundleName");
|
||||
auto result = locatorAbilityStub->PreIsLocationPrivacyConfirmed(data, reply, identity);
|
||||
EXPECT_EQ(ERRCODE_SUCCESS, result);
|
||||
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreIsLocationPrivacyConfirmed end");
|
||||
}
|
||||
|
||||
HWTEST_F(LocatorSkeletonTest, PreSetLocationPrivacyConfirmStatus, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "LocatorSkeletonTest, PreSetLocationPrivacyConfirmStatus, TestSize.Level1";
|
||||
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreSetLocationPrivacyConfirmStatus begin");
|
||||
auto locatorAbilityStub = sptr<LocatorAbilityStub>(new (std::nothrow) LocatorAbilityStub());
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
AppIdentity identity;
|
||||
identity.SetPid(1);
|
||||
identity.SetUid(2);
|
||||
uint32_t tokenId = static_cast<uint32_t>(tokenId_);
|
||||
identity.SetTokenId(tokenId);
|
||||
identity.SetFirstTokenId(0);
|
||||
identity.SetBundleName("bundleName");
|
||||
auto result = locatorAbilityStub->PreSetLocationPrivacyConfirmStatus(data, reply, identity);
|
||||
EXPECT_EQ(ERRCODE_SUCCESS, result);
|
||||
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreSetLocationPrivacyConfirmStatus end");
|
||||
}
|
||||
|
||||
HWTEST_F(LocatorSkeletonTest, PreStartCacheLocating, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "LocatorSkeletonTest, PreStartCacheLocating, TestSize.Level1";
|
||||
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreStartCacheLocating begin");
|
||||
auto locatorAbilityStub = sptr<LocatorAbilityStub>(new (std::nothrow) LocatorAbilityStub());
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
AppIdentity identity;
|
||||
identity.SetPid(1);
|
||||
identity.SetUid(2);
|
||||
uint32_t tokenId = static_cast<uint32_t>(tokenId_);
|
||||
identity.SetTokenId(tokenId);
|
||||
identity.SetFirstTokenId(0);
|
||||
identity.SetBundleName("bundleName");
|
||||
locatorAbilityStub->PreStartCacheLocating(data, reply, identity);
|
||||
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreStartCacheLocating end");
|
||||
}
|
||||
|
||||
HWTEST_F(LocatorSkeletonTest, PreStopCacheLocating, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "LocatorSkeletonTest, PreStopCacheLocating, TestSize.Level1";
|
||||
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreStopCacheLocating begin");
|
||||
auto locatorAbilityStub = sptr<LocatorAbilityStub>(new (std::nothrow) LocatorAbilityStub());
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
AppIdentity identity;
|
||||
identity.SetPid(1);
|
||||
identity.SetUid(2);
|
||||
uint32_t tokenId = static_cast<uint32_t>(tokenId_);
|
||||
identity.SetTokenId(tokenId);
|
||||
identity.SetFirstTokenId(0);
|
||||
identity.SetBundleName("bundleName");
|
||||
locatorAbilityStub->PreStopCacheLocating(data, reply, identity);
|
||||
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreStopCacheLocating end");
|
||||
}
|
||||
|
||||
HWTEST_F(LocatorSkeletonTest, PreGetCachedGnssLocationsSize, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "LocatorSkeletonTest, PreGetCachedGnssLocationsSize, TestSize.Level1";
|
||||
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreGetCachedGnssLocationsSize begin");
|
||||
auto locatorAbilityStub = sptr<LocatorAbilityStub>(new (std::nothrow) LocatorAbilityStub());
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
AppIdentity identity;
|
||||
identity.SetPid(1);
|
||||
identity.SetUid(2);
|
||||
uint32_t tokenId = static_cast<uint32_t>(tokenId_);
|
||||
identity.SetTokenId(tokenId);
|
||||
identity.SetFirstTokenId(0);
|
||||
identity.SetBundleName("bundleName");
|
||||
auto result = locatorAbilityStub->PreGetCachedGnssLocationsSize(data, reply, identity);
|
||||
EXPECT_EQ(ERRCODE_SUCCESS, result);
|
||||
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreGetCachedGnssLocationsSize end");
|
||||
}
|
||||
|
||||
HWTEST_F(LocatorSkeletonTest, PreFlushCachedGnssLocations, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "LocatorSkeletonTest, PreFlushCachedGnssLocations, TestSize.Level1";
|
||||
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreFlushCachedGnssLocations begin");
|
||||
auto locatorAbilityStub = sptr<LocatorAbilityStub>(new (std::nothrow) LocatorAbilityStub());
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
AppIdentity identity;
|
||||
identity.SetPid(1);
|
||||
identity.SetUid(2);
|
||||
uint32_t tokenId = static_cast<uint32_t>(tokenId_);
|
||||
identity.SetTokenId(tokenId);
|
||||
identity.SetFirstTokenId(0);
|
||||
identity.SetBundleName("bundleName");
|
||||
auto result = locatorAbilityStub->PreFlushCachedGnssLocations(data, reply, identity);
|
||||
EXPECT_EQ(ERRCODE_SUCCESS, result);
|
||||
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreFlushCachedGnssLocations end");
|
||||
}
|
||||
|
||||
HWTEST_F(LocatorSkeletonTest, PreSendCommand, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "LocatorSkeletonTest, PreSendCommand, TestSize.Level1";
|
||||
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreSendCommand begin");
|
||||
auto locatorAbilityStub = sptr<LocatorAbilityStub>(new (std::nothrow) LocatorAbilityStub());
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
AppIdentity identity;
|
||||
identity.SetPid(1);
|
||||
identity.SetUid(2);
|
||||
uint32_t tokenId = static_cast<uint32_t>(tokenId_);
|
||||
identity.SetTokenId(tokenId);
|
||||
identity.SetFirstTokenId(0);
|
||||
identity.SetBundleName("bundleName");
|
||||
auto result = locatorAbilityStub->PreSendCommand(data, reply, identity);
|
||||
EXPECT_EQ(ERRCODE_SUCCESS, result);
|
||||
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreSendCommand end");
|
||||
}
|
||||
|
||||
HWTEST_F(LocatorSkeletonTest, PreAddFence, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "LocatorSkeletonTest, PreAddFence, TestSize.Level1";
|
||||
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreAddFence begin");
|
||||
auto locatorAbilityStub = sptr<LocatorAbilityStub>(new (std::nothrow) LocatorAbilityStub());
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
AppIdentity identity;
|
||||
identity.SetPid(1);
|
||||
identity.SetUid(2);
|
||||
uint32_t tokenId = static_cast<uint32_t>(tokenId_);
|
||||
identity.SetTokenId(tokenId);
|
||||
identity.SetFirstTokenId(0);
|
||||
identity.SetBundleName("bundleName");
|
||||
auto result = locatorAbilityStub->PreAddFence(data, reply, identity);
|
||||
EXPECT_EQ(ERRCODE_SUCCESS, result);
|
||||
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreAddFence end");
|
||||
}
|
||||
|
||||
|
||||
HWTEST_F(LocatorSkeletonTest, PreRemoveFence, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "LocatorSkeletonTest, PreRemoveFence, TestSize.Level1";
|
||||
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreRemoveFence begin");
|
||||
auto locatorAbilityStub = sptr<LocatorAbilityStub>(new (std::nothrow) LocatorAbilityStub());
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
AppIdentity identity;
|
||||
identity.SetPid(1);
|
||||
identity.SetUid(2);
|
||||
uint32_t tokenId = static_cast<uint32_t>(tokenId_);
|
||||
identity.SetTokenId(tokenId);
|
||||
identity.SetFirstTokenId(0);
|
||||
identity.SetBundleName("bundleName");
|
||||
auto result = locatorAbilityStub->PreRemoveFence(data, reply, identity);
|
||||
EXPECT_EQ(ERRCODE_SUCCESS, result);
|
||||
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreRemoveFence end");
|
||||
}
|
||||
|
||||
HWTEST_F(LocatorSkeletonTest, PreEnableLocationMock, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "LocatorSkeletonTest, PreEnableLocationMock, TestSize.Level1";
|
||||
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreEnableLocationMock begin");
|
||||
auto locatorAbilityStub = sptr<LocatorAbilityStub>(new (std::nothrow) LocatorAbilityStub());
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
AppIdentity identity;
|
||||
identity.SetPid(1);
|
||||
identity.SetUid(2);
|
||||
uint32_t tokenId = static_cast<uint32_t>(tokenId_);
|
||||
identity.SetTokenId(tokenId);
|
||||
identity.SetFirstTokenId(0);
|
||||
identity.SetBundleName("bundleName");
|
||||
auto result = locatorAbilityStub->PreEnableLocationMock(data, reply, identity);
|
||||
EXPECT_EQ(ERRCODE_SUCCESS, result);
|
||||
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreEnableLocationMock end");
|
||||
}
|
||||
|
||||
HWTEST_F(LocatorSkeletonTest, PreDisableLocationMock, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "LocatorSkeletonTest, PreDisableLocationMock, TestSize.Level1";
|
||||
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreDisableLocationMock begin");
|
||||
auto locatorAbilityStub = sptr<LocatorAbilityStub>(new (std::nothrow) LocatorAbilityStub());
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
AppIdentity identity;
|
||||
identity.SetPid(1);
|
||||
identity.SetUid(2);
|
||||
uint32_t tokenId = static_cast<uint32_t>(tokenId_);
|
||||
identity.SetTokenId(tokenId);
|
||||
identity.SetFirstTokenId(0);
|
||||
identity.SetBundleName("bundleName");
|
||||
auto result = locatorAbilityStub->PreDisableLocationMock(data, reply, identity);
|
||||
EXPECT_EQ(ERRCODE_SUCCESS, result);
|
||||
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreDisableLocationMock end");
|
||||
}
|
||||
|
||||
HWTEST_F(LocatorSkeletonTest, PreSetMockedLocations, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "LocatorSkeletonTest, PreSetMockedLocations, TestSize.Level1";
|
||||
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreSetMockedLocations begin");
|
||||
auto locatorAbilityStub = sptr<LocatorAbilityStub>(new (std::nothrow) LocatorAbilityStub());
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
AppIdentity identity;
|
||||
identity.SetPid(1);
|
||||
identity.SetUid(2);
|
||||
uint32_t tokenId = static_cast<uint32_t>(tokenId_);
|
||||
identity.SetTokenId(tokenId);
|
||||
identity.SetFirstTokenId(0);
|
||||
identity.SetBundleName("bundleName");
|
||||
auto result = locatorAbilityStub->PreSetMockedLocations(data, reply, identity);
|
||||
EXPECT_EQ(ERRCODE_SUCCESS, result);
|
||||
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreSetMockedLocations end");
|
||||
}
|
||||
|
||||
HWTEST_F(LocatorSkeletonTest, PreEnableReverseGeocodingMock, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "LocatorSkeletonTest, PreEnableReverseGeocodingMock, TestSize.Level1";
|
||||
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreEnableReverseGeocodingMock begin");
|
||||
auto locatorAbilityStub = sptr<LocatorAbilityStub>(new (std::nothrow) LocatorAbilityStub());
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
AppIdentity identity;
|
||||
identity.SetPid(1);
|
||||
identity.SetUid(2);
|
||||
uint32_t tokenId = static_cast<uint32_t>(tokenId_);
|
||||
identity.SetTokenId(tokenId);
|
||||
identity.SetFirstTokenId(0);
|
||||
identity.SetBundleName("bundleName");
|
||||
auto result = locatorAbilityStub->PreEnableReverseGeocodingMock(data, reply, identity);
|
||||
EXPECT_EQ(ERRCODE_SUCCESS, result);
|
||||
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreEnableReverseGeocodingMock end");
|
||||
}
|
||||
|
||||
HWTEST_F(LocatorSkeletonTest, PreDisableReverseGeocodingMock, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "LocatorSkeletonTest, PreDisableReverseGeocodingMock, TestSize.Level1";
|
||||
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreDisableReverseGeocodingMock begin");
|
||||
auto locatorAbilityStub = sptr<LocatorAbilityStub>(new (std::nothrow) LocatorAbilityStub());
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
AppIdentity identity;
|
||||
identity.SetPid(1);
|
||||
identity.SetUid(2);
|
||||
uint32_t tokenId = static_cast<uint32_t>(tokenId_);
|
||||
identity.SetTokenId(tokenId);
|
||||
identity.SetFirstTokenId(0);
|
||||
identity.SetBundleName("bundleName");
|
||||
auto result = locatorAbilityStub->PreDisableReverseGeocodingMock(data, reply, identity);
|
||||
EXPECT_EQ(ERRCODE_SUCCESS, result);
|
||||
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreDisableReverseGeocodingMock end");
|
||||
}
|
||||
|
||||
HWTEST_F(LocatorSkeletonTest, PreSetReverseGeocodingMockInfo, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "LocatorSkeletonTest, PreSetReverseGeocodingMockInfo, TestSize.Level1";
|
||||
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreSetReverseGeocodingMockInfo begin");
|
||||
auto locatorAbilityStub = sptr<LocatorAbilityStub>(new (std::nothrow) LocatorAbilityStub());
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
AppIdentity identity;
|
||||
identity.SetPid(1);
|
||||
identity.SetUid(2);
|
||||
uint32_t tokenId = static_cast<uint32_t>(tokenId_);
|
||||
identity.SetTokenId(tokenId);
|
||||
identity.SetFirstTokenId(0);
|
||||
identity.SetBundleName("bundleName");
|
||||
auto result = locatorAbilityStub->PreSetReverseGeocodingMockInfo(data, reply, identity);
|
||||
EXPECT_EQ(ERRCODE_SUCCESS, result);
|
||||
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreSetReverseGeocodingMockInfo end");
|
||||
}
|
||||
|
||||
HWTEST_F(LocatorSkeletonTest, PreProxyForFreeze, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "LocatorSkeletonTest, PreProxyForFreeze, TestSize.Level1";
|
||||
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreProxyForFreeze begin");
|
||||
auto locatorAbilityStub = sptr<LocatorAbilityStub>(new (std::nothrow) LocatorAbilityStub());
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
AppIdentity identity;
|
||||
identity.SetPid(1);
|
||||
identity.SetUid(2);
|
||||
uint32_t tokenId = static_cast<uint32_t>(tokenId_);
|
||||
identity.SetTokenId(tokenId);
|
||||
identity.SetFirstTokenId(0);
|
||||
identity.SetBundleName("bundleName");
|
||||
locatorAbilityStub->PreProxyForFreeze(data, reply, identity);
|
||||
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreProxyForFreeze end");
|
||||
}
|
||||
|
||||
HWTEST_F(LocatorSkeletonTest, PreResetAllProxy, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "LocatorSkeletonTest, PreResetAllProxy, TestSize.Level1";
|
||||
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreResetAllProxy begin");
|
||||
auto locatorAbilityStub = sptr<LocatorAbilityStub>(new (std::nothrow) LocatorAbilityStub());
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
AppIdentity identity;
|
||||
identity.SetPid(1);
|
||||
identity.SetUid(2);
|
||||
uint32_t tokenId = static_cast<uint32_t>(tokenId_);
|
||||
identity.SetTokenId(tokenId);
|
||||
identity.SetFirstTokenId(0);
|
||||
identity.SetBundleName("bundleName");
|
||||
locatorAbilityStub->PreResetAllProxy(data, reply, identity);
|
||||
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreResetAllProxy end");
|
||||
}
|
||||
|
||||
HWTEST_F(LocatorSkeletonTest, PreReportLocation, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "LocatorSkeletonTest, PreReportLocation, TestSize.Level1";
|
||||
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreReportLocation begin");
|
||||
auto locatorAbilityStub = sptr<LocatorAbilityStub>(new (std::nothrow) LocatorAbilityStub());
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
AppIdentity identity;
|
||||
identity.SetPid(1);
|
||||
identity.SetUid(2);
|
||||
uint32_t tokenId = static_cast<uint32_t>(tokenId_);
|
||||
identity.SetTokenId(tokenId);
|
||||
identity.SetFirstTokenId(0);
|
||||
identity.SetBundleName("bundleName");
|
||||
auto result = locatorAbilityStub->PreReportLocation(data, reply, identity);
|
||||
EXPECT_EQ(ERRCODE_SUCCESS, result);
|
||||
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreReportLocation end");
|
||||
}
|
||||
|
||||
HWTEST_F(LocatorSkeletonTest, PreRegisterLocatingRequiredDataCallback, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "LocatorSkeletonTest, PreRegisterLocatingRequiredDataCallback, TestSize.Level1";
|
||||
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreRegisterLocatingRequiredDataCallback begin");
|
||||
auto locatorAbilityStub = sptr<LocatorAbilityStub>(new (std::nothrow) LocatorAbilityStub());
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
AppIdentity identity;
|
||||
identity.SetPid(1);
|
||||
identity.SetUid(2);
|
||||
uint32_t tokenId = static_cast<uint32_t>(tokenId_);
|
||||
identity.SetTokenId(tokenId);
|
||||
identity.SetFirstTokenId(0);
|
||||
identity.SetBundleName("bundleName");
|
||||
locatorAbilityStub->PreRegisterLocatingRequiredDataCallback(data, reply, identity);
|
||||
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreRegisterLocatingRequiredDataCallback end");
|
||||
}
|
||||
|
||||
HWTEST_F(LocatorSkeletonTest, PreUnregisterLocatingRequiredDataCallback, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "LocatorSkeletonTest, PreUnregisterLocatingRequiredDataCallback, TestSize.Level1";
|
||||
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreUnregisterLocatingRequiredDataCallback begin");
|
||||
auto locatorAbilityStub = sptr<LocatorAbilityStub>(new (std::nothrow) LocatorAbilityStub());
|
||||
MessageParcel data;
|
||||
|
||||
MessageParcel reply;
|
||||
AppIdentity identity;
|
||||
identity.SetPid(1);
|
||||
identity.SetUid(2);
|
||||
uint32_t tokenId = static_cast<uint32_t>(tokenId_);
|
||||
identity.SetTokenId(tokenId);
|
||||
identity.SetFirstTokenId(0);
|
||||
identity.SetBundleName("bundleName");
|
||||
locatorAbilityStub->PreUnregisterLocatingRequiredDataCallback(data, reply, identity);
|
||||
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreUnregisterLocatingRequiredDataCallback end");
|
||||
}
|
||||
|
||||
HWTEST_F(LocatorSkeletonTest, PreQuerySupportCoordinateSystemType, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "LocatorSkeletonTest, PreQuerySupportCoordinateSystemType, TestSize.Level1";
|
||||
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreQuerySupportCoordinateSystemType begin");
|
||||
auto locatorAbilityStub = sptr<LocatorAbilityStub>(new (std::nothrow) LocatorAbilityStub());
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
AppIdentity identity;
|
||||
identity.SetPid(1);
|
||||
identity.SetUid(2);
|
||||
uint32_t tokenId = static_cast<uint32_t>(tokenId_);
|
||||
identity.SetTokenId(tokenId);
|
||||
identity.SetFirstTokenId(0);
|
||||
identity.SetBundleName("bundleName");
|
||||
locatorAbilityStub->PreQuerySupportCoordinateSystemType(data, reply, identity);
|
||||
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreQuerySupportCoordinateSystemType end");
|
||||
}
|
||||
|
||||
HWTEST_F(LocatorSkeletonTest, PreRegisterLocationError, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "LocatorSkeletonTest, PreRegisterLocationError, TestSize.Level1";
|
||||
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreRegisterLocationError begin");
|
||||
auto locatorAbilityStub = sptr<LocatorAbilityStub>(new (std::nothrow) LocatorAbilityStub());
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
AppIdentity identity;
|
||||
identity.SetPid(1);
|
||||
identity.SetUid(2);
|
||||
uint32_t tokenId = static_cast<uint32_t>(tokenId_);
|
||||
identity.SetTokenId(tokenId);
|
||||
identity.SetFirstTokenId(0);
|
||||
identity.SetBundleName("bundleName");
|
||||
LocationDataRdbManager::SetSwitchState(ENABLED);
|
||||
locatorAbilityStub->PreRegisterLocationError(data, reply, identity);
|
||||
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreRegisterLocationError end");
|
||||
}
|
||||
|
||||
HWTEST_F(LocatorSkeletonTest, PreUnregisterLocationError, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "LocatorSkeletonTest, PreUnregisterLocationError, TestSize.Level1";
|
||||
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreUnregisterLocationError begin");
|
||||
auto locatorAbilityStub = sptr<LocatorAbilityStub>(new (std::nothrow) LocatorAbilityStub());
|
||||
MessageParcel data;
|
||||
|
||||
MessageParcel reply;
|
||||
AppIdentity identity;
|
||||
identity.SetPid(1);
|
||||
identity.SetUid(2);
|
||||
uint32_t tokenId = static_cast<uint32_t>(tokenId_);
|
||||
identity.SetTokenId(tokenId);
|
||||
identity.SetFirstTokenId(0);
|
||||
identity.SetBundleName("bundleName");
|
||||
locatorAbilityStub->PreUnregisterLocationError(data, reply, identity);
|
||||
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreUnregisterLocationError end");
|
||||
}
|
||||
|
||||
HWTEST_F(LocatorSkeletonTest, PreReportLocationError, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "LocatorSkeletonTest, PreReportLocationError, TestSize.Level1";
|
||||
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreReportLocationError begin");
|
||||
auto locatorAbilityStub = sptr<LocatorAbilityStub>(new (std::nothrow) LocatorAbilityStub());
|
||||
MessageParcel data;
|
||||
|
||||
MessageParcel reply;
|
||||
AppIdentity identity;
|
||||
identity.SetPid(1);
|
||||
identity.SetUid(2);
|
||||
uint32_t tokenId = static_cast<uint32_t>(tokenId_);
|
||||
identity.SetTokenId(tokenId);
|
||||
identity.SetFirstTokenId(0);
|
||||
identity.SetBundleName("bundleName");
|
||||
auto result = locatorAbilityStub->PreReportLocationError(data, reply, identity);
|
||||
EXPECT_EQ(ERRCODE_SUCCESS, result);
|
||||
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] PreReportLocationError end");
|
||||
}
|
||||
|
||||
HWTEST_F(LocatorSkeletonTest, OnRemoteRequest, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "LocatorSkeletonTest, OnRemoteRequest, TestSize.Level1";
|
||||
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] OnRemoteRequest begin");
|
||||
auto locatorAbilityStub = sptr<LocatorAbilityStub>(new (std::nothrow) LocatorAbilityStub());
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
locatorAbilityStub->OnRemoteRequest(3, data, reply, option);
|
||||
LBSLOGI(LOCATOR, "[LocatorSkeletonTest] OnRemoteRequest end");
|
||||
}
|
||||
} // namespace Location
|
||||
} // namespace OHOS
|
@ -247,10 +247,12 @@ HWTEST_F(ReportManagerTest, GetPermittedLocationTest001, TestSize.Level1)
|
||||
location->ReadFromParcel(parcel);
|
||||
auto newLocation = reportManager_->GetPermittedLocation(request, location);
|
||||
EXPECT_NE(nullptr, newLocation);
|
||||
EXPECT_EQ(12.0, newLocation->GetLatitude());
|
||||
EXPECT_EQ(13.0, newLocation->GetLongitude());
|
||||
EXPECT_EQ(1000.0, newLocation->GetAccuracy());
|
||||
LBSLOGI(REPORT_MANAGER, "[ReportManagerTest] GetPermittedLocationTest001 end");
|
||||
if (newLocation != nullptr) {
|
||||
EXPECT_EQ(12.0, newLocation->GetLatitude());
|
||||
EXPECT_EQ(13.0, newLocation->GetLongitude());
|
||||
EXPECT_EQ(1000.0, newLocation->GetAccuracy());
|
||||
LBSLOGI(REPORT_MANAGER, "[ReportManagerTest] GetPermittedLocationTest001 end");
|
||||
}
|
||||
}
|
||||
|
||||
HWTEST_F(ReportManagerTest, OnReportLocationTest001, TestSize.Level1)
|
||||
@ -272,6 +274,23 @@ HWTEST_F(ReportManagerTest, OnReportLocationTest001, TestSize.Level1)
|
||||
parcel.WriteInt32(0); // isFromMock
|
||||
std::unique_ptr<Location> location = std::make_unique<Location>();
|
||||
location->ReadFromParcel(parcel);
|
||||
location->SetUuid("35279");
|
||||
std::list<std::shared_ptr<Request>> networkList;
|
||||
int num = 2;
|
||||
for (int i = 0; i < num; i++) {
|
||||
std::shared_ptr<Request> request = std::make_shared<Request>();
|
||||
std::unique_ptr<RequestConfig> requestConfig = std::make_unique<RequestConfig>();
|
||||
requestConfig->SetTimeInterval(i);
|
||||
request->SetUid(i + 1);
|
||||
request->SetPid(i + 2);
|
||||
request->SetPackageName("nameForTest");
|
||||
request->SetRequestConfig(*requestConfig);
|
||||
request->SetUuid(std::to_string(i + 35279));
|
||||
request->SetNlpRequestType(0);
|
||||
networkList.push_back(request);
|
||||
}
|
||||
auto locatorAbility = LocatorAbility::GetInstance();
|
||||
locatorAbility->requests_->insert(make_pair(NETWORK_ABILITY, networkList));
|
||||
|
||||
EXPECT_EQ(true, reportManager_->OnReportLocation(location, NETWORK_ABILITY));
|
||||
LBSLOGI(REPORT_MANAGER, "[ReportManagerTest] OnReportLocationTest001 end");
|
||||
@ -324,6 +343,7 @@ HWTEST_F(ReportManagerTest, OnReportLocationTest003, TestSize.Level1)
|
||||
requestConfig->SetPriority(PRIORITY_ACCURACY);
|
||||
requestConfig->SetFixNumber(0);
|
||||
requestConfig->SetTimeInterval(1);
|
||||
requestConfig->SetScenario(SCENE_DAILY_LIFE_SERVICE);
|
||||
auto locatorImpl = Locator::GetInstance();
|
||||
sptr<ILocatorCallback> callbackStub = new (std::nothrow) LocatorCallbackStub();
|
||||
locatorImpl->EnableAbility(true);
|
||||
@ -360,6 +380,7 @@ HWTEST_F(ReportManagerTest, OnReportLocationTest004, TestSize.Level1)
|
||||
requestConfig->SetPriority(PRIORITY_ACCURACY);
|
||||
requestConfig->SetFixNumber(1); // locating once
|
||||
requestConfig->SetTimeOut(120000);
|
||||
requestConfig->SetScenario(SCENE_DAILY_LIFE_SERVICE);
|
||||
auto locatorImpl = Locator::GetInstance();
|
||||
sptr<ILocatorCallback> callbackStub = new (std::nothrow) LocatorCallbackStub();
|
||||
locatorImpl->EnableAbility(true);
|
||||
@ -441,5 +462,49 @@ HWTEST_F(ReportManagerTest, UpdateLocationByRequestTest002, TestSize.Level1)
|
||||
reportManager_->UpdateLocationByRequest(tokenId_, tokenId_, location);
|
||||
LBSLOGI(REPORT_MANAGER, "[ReportManagerTest] UpdateLocationByRequestTest002 end");
|
||||
}
|
||||
|
||||
HWTEST_F(ReportManagerTest, ProcessRequestForReport, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "ReportManagerTest, ProcessRequestForReport, TestSize.Level1";
|
||||
LBSLOGI(REPORT_MANAGER, "[ReportManagerTest] ProcessRequestForReport begin");
|
||||
std::shared_ptr<Request> request = std::make_shared<Request>();
|
||||
std::unique_ptr<RequestConfig> requestConfig = std::make_unique<RequestConfig>();
|
||||
requestConfig->SetTimeInterval(1);
|
||||
request->SetUid(111);
|
||||
request->SetPid(222);
|
||||
request->SetPackageName("nameForTest");
|
||||
request->SetRequestConfig(*requestConfig);
|
||||
request->SetRequesting(true);
|
||||
request->SetUuid(std::to_string(35279));
|
||||
request->SetNlpRequestType(0);
|
||||
auto deadRequests = std::make_unique<std::list<std::shared_ptr<Request>>>();
|
||||
std::unique_ptr<Location> location = std::make_unique<Location>();
|
||||
location->SetUuid("35279");
|
||||
reportManager_->ProcessRequestForReport(request, deadRequests, location, NETWORK_ABILITY);
|
||||
LBSLOGI(REPORT_MANAGER, "[ReportManagerTest] ProcessRequestForReport end");
|
||||
}
|
||||
|
||||
|
||||
HWTEST_F(ReportManagerTest, WriteNetWorkReportEvent, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "ReportManagerTest, WriteNetWorkReportEvent, TestSize.Level1";
|
||||
LBSLOGI(REPORT_MANAGER, "[ReportManagerTest] WriteNetWorkReportEvent begin");
|
||||
std::shared_ptr<Request> request = std::make_shared<Request>();
|
||||
std::unique_ptr<RequestConfig> requestConfig = std::make_unique<RequestConfig>();
|
||||
requestConfig->SetTimeInterval(1);
|
||||
request->SetUid(111);
|
||||
request->SetPid(222);
|
||||
request->SetPackageName("nameForTest");
|
||||
request->SetRequestConfig(*requestConfig);
|
||||
request->SetRequesting(true);
|
||||
request->SetUuid(std::to_string(35279));
|
||||
request->SetNlpRequestType(0);
|
||||
std::unique_ptr<Location> location = std::make_unique<Location>();
|
||||
location->SetUuid("35279");
|
||||
reportManager_->WriteNetWorkReportEvent(NETWORK_ABILITY, request, location);
|
||||
LBSLOGI(REPORT_MANAGER, "[ReportManagerTest] WriteNetWorkReportEvent end");
|
||||
}
|
||||
} // namespace Location
|
||||
} // namespace OHOS
|
@ -170,7 +170,7 @@ HWTEST_F(RequestManagerTest, HandlePowerSuspendChanged002, TestSize.Level1)
|
||||
LBSLOGI(REQUEST_MANAGER, "[RequestManagerTest] HandlePowerSuspendChanged002 begin");
|
||||
ASSERT_TRUE(requestManager_ != nullptr);
|
||||
requestManager_->UpdateRequestRecord(request_, false);
|
||||
EXPECT_EQ(false, requestManager_->IsUidInProcessing(SYSTEM_UID));
|
||||
EXPECT_EQ(true, requestManager_->IsUidInProcessing(SYSTEM_UID));
|
||||
|
||||
int32_t state1 = static_cast<int32_t>(AppExecFwk::ApplicationState::APP_STATE_FOREGROUND);
|
||||
requestManager_->HandlePowerSuspendChanged(request_->GetPid(),
|
||||
@ -188,7 +188,7 @@ HWTEST_F(RequestManagerTest, HandlePowerSuspendChanged003, TestSize.Level1)
|
||||
LBSLOGI(REQUEST_MANAGER, "[RequestManagerTest] HandlePowerSuspendChanged003 begin");
|
||||
ASSERT_TRUE(requestManager_ != nullptr);
|
||||
requestManager_->UpdateRequestRecord(request_, false);
|
||||
EXPECT_EQ(false, requestManager_->IsUidInProcessing(SYSTEM_UID));
|
||||
EXPECT_EQ(true, requestManager_->IsUidInProcessing(SYSTEM_UID));
|
||||
|
||||
int32_t state1 = static_cast<int32_t>(AppExecFwk::ApplicationState::APP_STATE_FOREGROUND);
|
||||
requestManager_->HandlePowerSuspendChanged(request_->GetPid() + 1,
|
||||
@ -206,7 +206,7 @@ HWTEST_F(RequestManagerTest, HandlePowerSuspendChanged004, TestSize.Level1)
|
||||
LBSLOGI(REQUEST_MANAGER, "[RequestManagerTest] HandlePowerSuspendChanged004 begin");
|
||||
ASSERT_TRUE(requestManager_ != nullptr);
|
||||
requestManager_->UpdateRequestRecord(request_, false);
|
||||
EXPECT_EQ(false, requestManager_->IsUidInProcessing(SYSTEM_UID));
|
||||
EXPECT_EQ(true, requestManager_->IsUidInProcessing(SYSTEM_UID));
|
||||
|
||||
int32_t state1 = static_cast<int32_t>(AppExecFwk::ApplicationState::APP_STATE_FOREGROUND);
|
||||
requestManager_->HandlePowerSuspendChanged(request_->GetPid(),
|
||||
@ -225,7 +225,7 @@ HWTEST_F(RequestManagerTest, UpdateRequestRecord001, TestSize.Level1)
|
||||
requestManager_->UpdateRequestRecord(request_, true); // uid = 1000 should be added to runningUids
|
||||
EXPECT_EQ(true, requestManager_->IsUidInProcessing(SYSTEM_UID));
|
||||
requestManager_->UpdateRequestRecord(request_, false); // uid = 1000 should be removed from runningUids
|
||||
EXPECT_EQ(false, requestManager_->IsUidInProcessing(SYSTEM_UID));
|
||||
EXPECT_EQ(true, requestManager_->IsUidInProcessing(SYSTEM_UID));
|
||||
LBSLOGI(REQUEST_MANAGER, "[RequestManagerTest] UpdateRequestRecord001 end");
|
||||
}
|
||||
|
||||
@ -250,7 +250,7 @@ HWTEST_F(RequestManagerTest, UpdateUsingPermissionTest002, TestSize.Level1)
|
||||
requestManager_->UpdateUsingPermission(request_);
|
||||
EXPECT_EQ(false, request_->GetLocationPermState());
|
||||
EXPECT_EQ(false, request_->GetBackgroundPermState());
|
||||
EXPECT_EQ(false, request_->GetApproximatelyPermState());
|
||||
EXPECT_EQ(true, request_->GetApproximatelyPermState());
|
||||
LBSLOGI(REQUEST_MANAGER, "[RequestManagerTest] UpdateUsingPermissionTest002 end");
|
||||
}
|
||||
|
||||
|
@ -35,6 +35,8 @@
|
||||
|
||||
#include "network_callback_host.h"
|
||||
#include "permission_manager.h"
|
||||
#include "locationhub_ipc_interface_code.h"
|
||||
#include "location_data_rdb_manager.h"
|
||||
|
||||
using namespace testing::ext;
|
||||
namespace OHOS {
|
||||
@ -127,6 +129,8 @@ HWTEST_F(NetworkAbilityTest, SetEnableAndDisable001, TestSize.Level1)
|
||||
GTEST_LOG_(INFO)
|
||||
<< "NetworkAbilityTest, SetEnableAndDisable001, TestSize.Level1";
|
||||
LBSLOGI(NETWORK_TEST, "[NetworkAbilityTest] SetEnableAndDisable001 begin");
|
||||
ability_->networkHandler_ = std::make_shared<NetworkHandler>(AppExecFwk::EventRunner::Create(true));
|
||||
EXPECT_EQ(ERRCODE_SUCCESS, proxy_->SetEnable(false));
|
||||
/*
|
||||
* @tc.steps: step1.remove SA
|
||||
* @tc.expected: step1. object1 is null.
|
||||
@ -445,7 +449,21 @@ HWTEST_F(NetworkAbilityTest, NetworkAbilityProcessReportLocationMock001, TestSiz
|
||||
LBSLOGI(NETWORK, "[NetworkAbilityTest] NetworkAbilityProcessReportLocationMock001 begin");
|
||||
ability_->mockLocationIndex_ = -1;
|
||||
ability_->networkHandler_ = nullptr;
|
||||
ability_->ProcessReportLocationMock();
|
||||
std::vector<std::shared_ptr<Location>> locations;
|
||||
Parcel parcel;
|
||||
parcel.WriteDouble(10.6); // latitude
|
||||
parcel.WriteDouble(10.5); // longitude
|
||||
parcel.WriteDouble(10.4); // altitude
|
||||
parcel.WriteDouble(1.0); // accuracy
|
||||
parcel.WriteDouble(5.0); // speed
|
||||
parcel.WriteDouble(10); // direction
|
||||
parcel.WriteInt64(1611000000); // timestamp
|
||||
parcel.WriteInt64(1611000000); // time since boot
|
||||
parcel.WriteString16(u"additions"); // additions
|
||||
parcel.WriteInt64(1); // additionSize
|
||||
parcel.WriteInt32(1); // isFromMock is true
|
||||
locations.push_back(Location::UnmarshallingShared(parcel));
|
||||
ability_->CacheLocationMock(locations);
|
||||
LBSLOGI(NETWORK, "[NetworkAbilityTest] NetworkAbilityProcessReportLocationMock001 end");
|
||||
}
|
||||
|
||||
@ -457,7 +475,7 @@ HWTEST_F(NetworkAbilityTest, NetworkAbilitySendReportMockLocationEvent001, TestS
|
||||
ability_->networkHandler_ = nullptr;
|
||||
ability_->SendReportMockLocationEvent();
|
||||
|
||||
ability_->networkHandler_ = std::make_shared<NetworkHandler>(AppExecFwk::EventRunner::Create(true));;
|
||||
ability_->networkHandler_ = std::make_shared<NetworkHandler>(AppExecFwk::EventRunner::Create(true));
|
||||
ability_->SendReportMockLocationEvent();
|
||||
LBSLOGI(NETWORK, "[NetworkAbilityTest] NetworkAbilitySendReportMockLocationEvent001 end");
|
||||
}
|
||||
@ -476,7 +494,7 @@ HWTEST_F(NetworkAbilityTest, NetworkAbilitySendMessage001, TestSize.Level1)
|
||||
ability_->networkHandler_ = nullptr;
|
||||
ability_->SendMessage(0, requestParcel, reply);
|
||||
|
||||
ability_->networkHandler_ = std::make_shared<NetworkHandler>(AppExecFwk::EventRunner::Create(true));;
|
||||
ability_->networkHandler_ = std::make_shared<NetworkHandler>(AppExecFwk::EventRunner::Create(true));
|
||||
ability_->SendMessage(0, requestParcel, reply);
|
||||
LBSLOGI(NETWORK, "[NetworkAbilityStubTest] NetworkAbilitySendMessage001 end");
|
||||
}
|
||||
@ -490,6 +508,114 @@ HWTEST_F(NetworkAbilityTest, ResetServiceProxy001, TestSize.Level1)
|
||||
EXPECT_EQ(true, ability->ResetServiceProxy()); // Connect success
|
||||
LBSLOGI(NETWORK, "[NetworkAbilityTest] ResetServiceProxy001 end");
|
||||
}
|
||||
|
||||
HWTEST_F(NetworkAbilityTest, RequestNetworkLocation001, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "NetworkAbilityTest, RequestNetworkLocation001, TestSize.Level1";
|
||||
LBSLOGI(NETWORK, "[NetworkAbilityTest] RequestNetworkLocation001 begin");
|
||||
std::unique_ptr<WorkRecord> workRecord = std::make_unique<WorkRecord>();
|
||||
int num = 2;
|
||||
for (int i = 0; i < num; i++) {
|
||||
std::shared_ptr<Request> request = std::make_shared<Request>();
|
||||
std::unique_ptr<RequestConfig> requestConfig = std::make_unique<RequestConfig>();
|
||||
requestConfig->SetTimeInterval(i);
|
||||
request->SetUid(i + 1);
|
||||
request->SetPid(i + 2);
|
||||
request->SetPackageName("nameForTest");
|
||||
request->SetRequestConfig(*requestConfig);
|
||||
request->SetUuid(std::to_string(CommonUtils::IntRandom(MIN_INT_RANDOM, MAX_INT_RANDOM)));
|
||||
request->SetNlpRequestType(i + 1);
|
||||
workRecord->Add(request);
|
||||
}
|
||||
LBSLOGI(NETWORK, "[NetworkAbilityTest] RequestNetworkLocation001 end");
|
||||
}
|
||||
|
||||
HWTEST_F(NetworkAbilityTest, RemoveNetworkLocation001, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "NetworkAbilityTest, RemoveNetworkLocation001, TestSize.Level1";
|
||||
LBSLOGI(NETWORK, "[NetworkAbilityTest] RemoveNetworkLocation001 begin");
|
||||
std::unique_ptr<WorkRecord> workRecord = std::make_unique<WorkRecord>();
|
||||
int num = 2;
|
||||
for (int i = 0; i < num; i++) {
|
||||
std::shared_ptr<Request> request = std::make_shared<Request>();
|
||||
std::unique_ptr<RequestConfig> requestConfig = std::make_unique<RequestConfig>();
|
||||
requestConfig->SetTimeInterval(i);
|
||||
request->SetUid(i + 1);
|
||||
request->SetPid(i + 2);
|
||||
request->SetPackageName("nameForTest");
|
||||
request->SetRequestConfig(*requestConfig);
|
||||
request->SetUuid(std::to_string(CommonUtils::IntRandom(MIN_INT_RANDOM, MAX_INT_RANDOM)));
|
||||
request->SetNlpRequestType(i + 1);
|
||||
workRecord->Add(request);
|
||||
}
|
||||
LBSLOGI(NETWORK, "[NetworkAbilityTest] RemoveNetworkLocation001 end");
|
||||
}
|
||||
|
||||
#ifdef FEATURE_PASSIVE_SUPPORT
|
||||
HWTEST_F(NetworkAbilityTest, ReportMockedLocation001, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "NetworkAbilityTest, ReportMockedLocation001, TestSize.Level1";
|
||||
LBSLOGI(NETWORK, "[NetworkAbilityTest] ReportMockedLocation001 begin");
|
||||
std::vector<std::shared_ptr<Location>> locations;
|
||||
Parcel parcel;
|
||||
parcel.WriteDouble(10.6); // latitude
|
||||
parcel.WriteDouble(10.5); // longitude
|
||||
parcel.WriteDouble(10.4); // altitude
|
||||
parcel.WriteDouble(1.0); // accuracy
|
||||
parcel.WriteDouble(5.0); // speed
|
||||
parcel.WriteDouble(10); // direction
|
||||
parcel.WriteInt64(1611000000); // timestamp
|
||||
parcel.WriteInt64(1611000000); // time since boot
|
||||
parcel.WriteString16(u"additions"); // additions
|
||||
parcel.WriteInt64(1); // additionSize
|
||||
parcel.WriteInt32(1); // isFromMock is true
|
||||
locations.push_back(Location::UnmarshallingShared(parcel));
|
||||
ability_->ReportMockedLocation(locations);
|
||||
LBSLOGI(NETWORK, "[NetworkAbilityTest] ReportMockedLocation001 end");
|
||||
}
|
||||
#endif
|
||||
|
||||
HWTEST_F(NetworkAbilityTest, RegisterNLPServiceDeathRecipient001, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "NetworkAbilityTest, RegisterNLPServiceDeathRecipient001, TestSize.Level1";
|
||||
LBSLOGI(NETWORK, "[NetworkAbilityTest] RegisterNLPServiceDeathRecipient001 begin");
|
||||
ability_->RegisterNLPServiceDeathRecipient();
|
||||
LBSLOGI(NETWORK, "[NetworkAbilityTest] RegisterNLPServiceDeathRecipient001 end");
|
||||
}
|
||||
|
||||
HWTEST_F(NetworkAbilityTest, ReportLocationError001, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "NetworkAbilityTest, ReportLocationError001, TestSize.Level1";
|
||||
LBSLOGI(NETWORK, "[NetworkAbilityTest] ReportLocationError001 begin");
|
||||
ability_->ReportLocationError(0, "", "");
|
||||
LBSLOGI(NETWORK, "[NetworkAbilityTest] ReportLocationError001 end");
|
||||
}
|
||||
|
||||
HWTEST_F(NetworkAbilityTest, ReportMockedLocation001, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "NetworkAbilityTest, ReportMockedLocation001, TestSize.Level1";
|
||||
LBSLOGI(NETWORK, "[NetworkAbilityTest] ReportMockedLocation001 begin");
|
||||
std::shared_ptr<Location> location = std::make_shared<Location>();
|
||||
ability_-> ReportMockedLocation(location);
|
||||
LBSLOGI(NETWORK, "[NetworkAbilityTest] ReportMockedLocation001 end");
|
||||
}
|
||||
|
||||
HWTEST_F(NetworkAbilityTest, OnRemoteDied001, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO)
|
||||
<< "NetworkAbilityTest, OnRemoteDied001, TestSize.Level1";
|
||||
LBSLOGI(NETWORK, "[NetworkAbilityTest] OnRemoteDied001 begin");
|
||||
auto deathRecipient = new (std::nothrow) NLPServiceDeathRecipient();
|
||||
const wptr<IRemoteObject> object;
|
||||
deathRecipient->OnRemoteDied(object);
|
||||
LBSLOGI(NETWORK, "[NetworkAbilityTest] OnRemoteDied001 end");
|
||||
}
|
||||
} // namespace Location
|
||||
} // namespace OHOS
|
||||
#endif // FEATURE_NETWORK_SUPPORT
|
@ -159,8 +159,6 @@ HWTEST_F(PassiveAbilityTest, PassiveOnStartAndOnStop001, TestSize.Level1)
|
||||
EXPECT_EQ(ServiceRunningState::STATE_NOT_START,
|
||||
(ServiceRunningState)ability_->QueryServiceState()); // mock
|
||||
ability_->OnStart(); // start ability again
|
||||
EXPECT_EQ(ServiceRunningState::STATE_NOT_START,
|
||||
(ServiceRunningState)ability_->QueryServiceState()); // mock
|
||||
|
||||
ability_->OnStop(); // stop ability
|
||||
EXPECT_EQ(ServiceRunningState::STATE_NOT_START,
|
||||
|
Loading…
Reference in New Issue
Block a user