* Copyright (c) 2025 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 <cJSON.h>
#include "poi_info_manager_test.h"
#include "poi_info_callback_napi.h"
#include "common_utils.h"
using namespace testing::ext;
namespace OHOS {
namespace Location {
void PoiInfoManagerTest::SetUp()
{
poiInfoManager_ = PoiInfoManager::GetInstance();
EXPECT_NE(nullptr, poiInfoManager_);
}
void PoiInfoManagerTest::TearDown()
{
poiInfoManager_ = nullptr;
}
std::unique_ptr<Location> PoiInfoManagerTest::MockLocation()
{
std::unique_ptr<Location> location = std::make_unique<Location>();
MessageParcel parcel;
parcel.WriteDouble(12.0);
parcel.WriteDouble(13.0);
parcel.WriteDouble(14.0);
parcel.WriteDouble(1000.0);
parcel.WriteDouble(10.0);
parcel.WriteDouble(90.0);
parcel.WriteInt64(1000000000);
parcel.WriteInt64(1000000100);
parcel.WriteString16(u"additions");
parcel.WriteInt64(1);
parcel.WriteInt32(1);
location->ReadFromParcel(parcel);
std::vector<std::string> additionMap = location->GetAdditions();
return location;
}
std::string PoiInfoManagerTest::MockPoiString(uint64_t delayTimeMilSec)
{
cJSON *root = cJSON_CreateObject();
cJSON *poisArray = cJSON_CreateArray();
cJSON *poi1 = cJSON_CreateObject();
cJSON_AddStringToObject(poi1, "id", "42345678");
cJSON_AddNumberToObject(poi1, "confidence", 1);
cJSON_AddStringToObject(poi1, "name", "静安嘉里中心NB1-03A/NAB1-03C号单元");
cJSON_AddNumberToObject(poi1, "lon", 31.111);
cJSON_AddNumberToObject(poi1, "lat", 124.111);
cJSON_AddStringToObject(poi1, "address", "南京西路街道南京西路1563号");
cJSON_AddStringToObject(poi1, "formatAddress", "上海市静安区南京西路街道南京西路1563号静安嘉里中心NB1-03A/NAB1-03C号单元");
cJSON *poi2 = cJSON_CreateObject();
cJSON_AddStringToObject(poi2, "id", "4537867");
cJSON_AddNumberToObject(poi2, "confidence", 1);
cJSON_AddStringToObject(poi2, "name", "静安嘉里中心NB1-03A/NAB1-03C号单元");
cJSON_AddNumberToObject(poi2, "lon", 31.111);
cJSON_AddNumberToObject(poi2, "lat", 124.111);
cJSON_AddStringToObject(poi2, "address", "南京西路街道南京西路1563号");
cJSON_AddStringToObject(poi2, "formatAddress", "上海市静安区南京西路街道南京西路1563号静安嘉里中心NB1-03A/NAB1-03C号单元");
cJSON_AddItemToArray(poisArray, poi1);
cJSON_AddItemToArray(poisArray, poi2);
cJSON_AddItemToObject(root, "pois", poisArray);
cJSON_AddStringToObject(root, "semanticDescription", "Wagas沃歌斯(静安嘉里中心店)附近");
cJSON_AddNumberToObject(root, "time", CommonUtils::GetCurrentTimeMilSec() - delayTimeMilSec);
char *jsonStr = cJSON_PrintUnformatted(root);
std::string jsonString(jsonStr);
cJSON_free(jsonStr);
cJSON_Delete(root);
return jsonString;
}
HWTEST_F(PoiInfoManagerTest, PoiInfoManagerTest001, TestSize.Level1)
{
GTEST_LOG_(INFO)
<< "PoiInfoManagerTest, PoiInfoManagerTest001, TestSize.Level1";
LBSLOGI(REPORT_MANAGER, "[PoiInfoManagerTest] PoiInfoManagerTest001 begin");
std::unique_ptr<Location> location = MockLocation();
ASSERT_TRUE(poiInfoManager_ != nullptr);
poiInfoManager_->UpdateCachedPoiInfo(location);
poiInfoManager_->UpdateLocationPoiInfo(location);
std::string mockPoiInfo = "poiInfos:" + MockPoiString(0);
std::u16string mockPoiInfoStr16 = Str8ToStr16(mockPoiInfo);
std::u16string mockStr16 = Str8ToStr16("test1:{empty}");
std::vector<std::u16string> mockAdditionsStr16;
mockAdditionsStr16.push_back(mockPoiInfoStr16);
mockAdditionsStr16.push_back(mockStr16);
location->VectorString16ToVectorString8(mockAdditionsStr16);
poiInfoManager_->UpdateCachedPoiInfo(location);
poiInfoManager_->SetLatestPoiInfoTime(CommonUtils::GetCurrentTimeMilSec());
poiInfoManager_->UpdateLocationPoiInfo(location);
std::unique_ptr<Location> location1 = MockLocation();
poiInfoManager_->UpdateLocationPoiInfo(location1);
poiInfoManager_->ClearPoiInfos(location1);
LBSLOGI(REPORT_MANAGER, "[PoiInfoManagerTest] PoiInfoManagerTest001 end");
}
HWTEST_F(PoiInfoManagerTest, PoiInfoManagerTest002, TestSize.Level1)
{
GTEST_LOG_(INFO)
<< "PoiInfoManagerTest, PoiInfoManagerTest002, TestSize.Level1";
LBSLOGI(REPORT_MANAGER, "[PoiInfoManagerTest] PoiInfoManagerTest002 begin");
ASSERT_TRUE(poiInfoManager_ != nullptr);
std::unique_ptr<Location> location = MockLocation();
poiInfoManager_->UpdateCachedPoiInfo(location);
poiInfoManager_->UpdateLocationPoiInfo(location);
std::string mockPoiInfo = "poiInfos:" + MockPoiString(60000);
std::u16string mockPoiInfoStr16 = Str8ToStr16(mockPoiInfo);
std::u16string mockStr16 = Str8ToStr16("test1:{empty}");
std::vector<std::u16string> mockAdditionsStr16;
mockAdditionsStr16.push_back(mockPoiInfoStr16);
mockAdditionsStr16.push_back(mockStr16);
location->VectorString16ToVectorString8(mockAdditionsStr16);
poiInfoManager_->UpdateCachedPoiInfo(location);
poiInfoManager_->SetLatestPoiInfoTime(CommonUtils::GetCurrentTimeMilSec() - 60000);
poiInfoManager_->UpdateLocationPoiInfo(location);
LBSLOGI(REPORT_MANAGER, "[PoiInfoManagerTest] PoiInfoManagerTest002 end");
}
HWTEST_F(PoiInfoManagerTest, PreRequestPoiInfoTest001, TestSize.Level1)
{
GTEST_LOG_(INFO)
<< "PoiInfoManagerTest, PreRequestPoiInfoTest001, TestSize.Level1";
LBSLOGI(REPORT_MANAGER, "[PoiInfoManagerTest] PreRequestPoiInfoTest001 begin");
ASSERT_TRUE(poiInfoManager_ != nullptr);
AppIdentity identity;
sptr<IPoiInfoCallback> callback = sptr<IPoiInfoCallback>(new PoiInfoCallbackNapi());
poiInfoManager_->PreRequestPoiInfo(callback->AsObject(), identity);
LBSLOGI(REPORT_MANAGER, "[PoiInfoManagerTest] PreRequestPoiInfoTest001 end");
}
HWTEST_F(PoiInfoManagerTest, RequestPoiInfoTest001, TestSize.Level1)
{
GTEST_LOG_(INFO)
<< "PoiInfoManagerTest, RequestPoiInfoTest001, TestSize.Level1";
LBSLOGI(REPORT_MANAGER, "[PoiInfoManagerTest] RequestPoiInfoTest001 begin");
ASSERT_TRUE(poiInfoManager_ != nullptr);
AppIdentity identity;
sptr<IPoiInfoCallback> callback = sptr<IPoiInfoCallback>(new PoiInfoCallbackNapi());
sptr<IRemoteObject> cb = callback->AsObject();
poiInfoManager_->RequestPoiInfo(cb, identity);
LBSLOGI(REPORT_MANAGER, "[PoiInfoManagerTest] RequestPoiInfoTest001 end");
}
HWTEST_F(PoiInfoManagerTest, ConnectPoiServiceTest001, TestSize.Level1)
{
GTEST_LOG_(INFO)
<< "PoiInfoManagerTest, ConnectPoiServiceTest001, TestSize.Level1";
LBSLOGI(REPORT_MANAGER, "[PoiInfoManagerTest] ConnectPoiServiceTest001 begin");
ASSERT_TRUE(poiInfoManager_ != nullptr);
poiInfoManager_->ConnectPoiService();
LBSLOGI(REPORT_MANAGER, "[PoiInfoManagerTest] ConnectPoiServiceTest001 end");
}
HWTEST_F(PoiInfoManagerTest, PreDisconnectAbilityConnectTest001, TestSize.Level1)
{
GTEST_LOG_(INFO)
<< "PoiInfoManagerTest, PreDisconnectAbilityConnectTest001, TestSize.Level1";
LBSLOGI(REPORT_MANAGER, "[PoiInfoManagerTest] PreDisconnectAbilityConnectTest001 begin");
ASSERT_TRUE(poiInfoManager_ != nullptr);
poiInfoManager_->PreDisconnectAbilityConnect();
LBSLOGI(REPORT_MANAGER, "[PoiInfoManagerTest] PreDisconnectAbilityConnectTest001 end");
}
HWTEST_F(PoiInfoManagerTest, DisconnectAbilityConnectTest001, TestSize.Level1)
{
GTEST_LOG_(INFO)
<< "PoiInfoManagerTest, DisconnectAbilityConnectTest001, TestSize.Level1";
LBSLOGI(REPORT_MANAGER, "[PoiInfoManagerTest] DisconnectAbilityConnectTest001 begin");
ASSERT_TRUE(poiInfoManager_ != nullptr);
poiInfoManager_->DisconnectAbilityConnect();
LBSLOGI(REPORT_MANAGER, "[PoiInfoManagerTest] DisconnectAbilityConnectTest001 end");
}
HWTEST_F(PoiInfoManagerTest, IsConnectTest001, TestSize.Level1)
{
GTEST_LOG_(INFO)
<< "PoiInfoManagerTest, IsConnectTest001, TestSize.Level1";
LBSLOGI(REPORT_MANAGER, "[PoiInfoManagerTest] IsConnectTest001 begin");
ASSERT_TRUE(poiInfoManager_ != nullptr);
poiInfoManager_->IsConnect();
LBSLOGI(REPORT_MANAGER, "[PoiInfoManagerTest] IsConnectTest001 end");
}
HWTEST_F(PoiInfoManagerTest, RegisterPoiServiceDeathRecipientTest001, TestSize.Level1)
{
GTEST_LOG_(INFO)
<< "PoiInfoManagerTest, RegisterPoiServiceDeathRecipientTest001, TestSize.Level1";
LBSLOGI(REPORT_MANAGER, "[PoiInfoManagerTest] RegisterPoiServiceDeathRecipientTest001 begin");
ASSERT_TRUE(poiInfoManager_ != nullptr);
poiInfoManager_->RegisterPoiServiceDeathRecipient();
LBSLOGI(REPORT_MANAGER, "[PoiInfoManagerTest] RegisterPoiServiceDeathRecipientTest001 end");
}
HWTEST_F(PoiInfoManagerTest, UnregisterPoiServiceDeathRecipientTest001, TestSize.Level1)
{
GTEST_LOG_(INFO)
<< "PoiInfoManagerTest, UnregisterPoiServiceDeathRecipientTest001, TestSize.Level1";
LBSLOGI(REPORT_MANAGER, "[PoiInfoManagerTest] UnregisterPoiServiceDeathRecipientTest001 begin");
ASSERT_TRUE(poiInfoManager_ != nullptr);
poiInfoManager_->UnregisterPoiServiceDeathRecipient();
LBSLOGI(REPORT_MANAGER, "[PoiInfoManagerTest] UnregisterPoiServiceDeathRecipientTest001 end");
}
HWTEST_F(PoiInfoManagerTest, NotifyDisConnectedTest001, TestSize.Level1)
{
GTEST_LOG_(INFO)
<< "PoiInfoManagerTest, NotifyDisConnectedTest001, TestSize.Level1";
LBSLOGI(REPORT_MANAGER, "[PoiInfoManagerTest] NotifyDisConnectedTest001 begin");
ASSERT_TRUE(poiInfoManager_ != nullptr);
poiInfoManager_->NotifyDisConnected();
LBSLOGI(REPORT_MANAGER, "[PoiInfoManagerTest] NotifyDisConnectedTest001 end");
}
HWTEST_F(PoiInfoManagerTest, PreResetServiceProxyTest001, TestSize.Level1)
{
GTEST_LOG_(INFO)
<< "PoiInfoManagerTest, PreResetServiceProxyTest001, TestSize.Level1";
LBSLOGI(REPORT_MANAGER, "[PoiInfoManagerTest] PreResetServiceProxyTest001 begin");
ASSERT_TRUE(poiInfoManager_ != nullptr);
poiInfoManager_->PreResetServiceProxy();
LBSLOGI(REPORT_MANAGER, "[PoiInfoManagerTest] PreResetServiceProxyTest001 end");
}
HWTEST_F(PoiInfoManagerTest, ResetServiceProxyTest001, TestSize.Level1)
{
GTEST_LOG_(INFO)
<< "PoiInfoManagerTest, ResetServiceProxyTest001, TestSize.Level1";
LBSLOGI(REPORT_MANAGER, "[PoiInfoManagerTest] ResetServiceProxyTest001 begin");
ASSERT_TRUE(poiInfoManager_ != nullptr);
poiInfoManager_->ResetServiceProxy();
LBSLOGI(REPORT_MANAGER, "[PoiInfoManagerTest] ResetServiceProxyTest001 end");
}
HWTEST_F(PoiInfoManagerTest, PoiInfoManagerGetLatestPoiInfo001, TestSize.Level1)
{
GTEST_LOG_(INFO)
<< "PoiInfoManagerTest, PoiInfoManagerGetLatestPoiInfo001, TestSize.Level1";
LBSLOGI(REPORT_MANAGER, "[PoiInfoManagerTest] PoiInfoManagerGetLatestPoiInfo001 begin");
ASSERT_TRUE(poiInfoManager_ != nullptr);
poiInfoManager_->SetLatestPoiInfo("test_poi_info");
std::string result = poiInfoManager_->GetLatestPoiInfo();
EXPECT_EQ("test_poi_info", result);
LBSLOGI(REPORT_MANAGER, "[PoiInfoManagerTest] PoiInfoManagerGetLatestPoiInfo001 end");
}
HWTEST_F(PoiInfoManagerTest, PoiInfoManagerGetLatestPoiInfoTime001, TestSize.Level1)
{
GTEST_LOG_(INFO)
<< "PoiInfoManagerTest, PoiInfoManagerGetLatestPoiInfoTime001, TestSize.Level1";
LBSLOGI(REPORT_MANAGER, "[PoiInfoManagerTest] PoiInfoManagerGetLatestPoiInfoTime001 begin");
ASSERT_TRUE(poiInfoManager_ != nullptr);
uint64_t currentTime = CommonUtils::GetCurrentTimeMilSec();
poiInfoManager_->SetLatestPoiInfoTime(currentTime);
uint64_t result = poiInfoManager_->GetLatestPoiInfoTime();
EXPECT_EQ(currentTime, result);
LBSLOGI(REPORT_MANAGER, "[PoiInfoManagerTest] PoiInfoManagerGetLatestPoiInfoTime001 end");
}
HWTEST_F(PoiInfoManagerTest, PoiInfoManagerGetPoiInfoTime001, TestSize.Level1)
{
GTEST_LOG_(INFO)
<< "PoiInfoManagerTest, PoiInfoManagerGetPoiInfoTime001, TestSize.Level1";
LBSLOGI(REPORT_MANAGER, "[PoiInfoManagerTest] PoiInfoManagerGetPoiInfoTime001 begin");
ASSERT_TRUE(poiInfoManager_ != nullptr);
std::string poiInfos = "{\"time\":1234567890,\"pois\":[]}";
uint64_t result = poiInfoManager_->GetPoiInfoTime(poiInfos);
EXPECT_EQ(1234567890, result);
LBSLOGI(REPORT_MANAGER, "[PoiInfoManagerTest] PoiInfoManagerGetPoiInfoTime001 end");
}
HWTEST_F(PoiInfoManagerTest, PoiInfoManagerGetPoiInfoTime002, TestSize.Level1)
{
GTEST_LOG_(INFO)
<< "PoiInfoManagerTest, PoiInfoManagerGetPoiInfoTime002, TestSize.Level1";
LBSLOGI(REPORT_MANAGER, "[PoiInfoManagerTest] PoiInfoManagerGetPoiInfoTime002 begin");
ASSERT_TRUE(poiInfoManager_ != nullptr);
std::string poiInfos = "{\"pois\":[]}";
uint64_t result = poiInfoManager_->GetPoiInfoTime(poiInfos);
EXPECT_EQ(0, result);
LBSLOGI(REPORT_MANAGER, "[PoiInfoManagerTest] PoiInfoManagerGetPoiInfoTime002 end");
}
HWTEST_F(PoiInfoManagerTest, PoiInfoManagerIsConnect001, TestSize.Level1)
{
GTEST_LOG_(INFO)
<< "PoiInfoManagerTest, PoiInfoManagerIsConnect001, TestSize.Level1";
LBSLOGI(REPORT_MANAGER, "[PoiInfoManagerTest] PoiInfoManagerIsConnect001 begin");
ASSERT_TRUE(poiInfoManager_ != nullptr);
bool result = poiInfoManager_->IsConnect();
LBSLOGI(REPORT_MANAGER, "[PoiInfoManagerTest] PoiInfoManagerIsConnect001 result = %{public}d", result);
LBSLOGI(REPORT_MANAGER, "[PoiInfoManagerTest] PoiInfoManagerIsConnect001 end");
}
HWTEST_F(PoiInfoManagerTest, PoiInfoManagerDisconnectAbilityConnect001, TestSize.Level1)
{
GTEST_LOG_(INFO)
<< "PoiInfoManagerTest, PoiInfoManagerDisconnectAbilityConnect001, TestSize.Level1";
LBSLOGI(REPORT_MANAGER, "[PoiInfoManagerTest] PoiInfoManagerDisconnectAbilityConnect001 begin");
ASSERT_TRUE(poiInfoManager_ != nullptr);
poiInfoManager_->DisconnectAbilityConnect();
LBSLOGI(REPORT_MANAGER, "[PoiInfoManagerTest] PoiInfoManagerDisconnectAbilityConnect001 end");
}
HWTEST_F(PoiInfoManagerTest, PoiInfoManagerNotifyConnected001, TestSize.Level1)
{
GTEST_LOG_(INFO)
<< "PoiInfoManagerTest, PoiInfoManagerNotifyConnected001, TestSize.Level1";
LBSLOGI(REPORT_MANAGER, "[PoiInfoManagerTest] PoiInfoManagerNotifyConnected001 begin");
ASSERT_TRUE(poiInfoManager_ != nullptr);
sptr<IRemoteObject> remoteObject = nullptr;
poiInfoManager_->NotifyConnected(remoteObject);
LBSLOGI(REPORT_MANAGER, "[PoiInfoManagerTest] PoiInfoManagerNotifyConnected001 end");
}
HWTEST_F(PoiInfoManagerTest, PoiInfoManagerNotifyDisConnected001, TestSize.Level1)
{
GTEST_LOG_(INFO)
<< "PoiInfoManagerTest, PoiInfoManagerNotifyDisConnected001, TestSize.Level1";
LBSLOGI(REPORT_MANAGER, "[PoiInfoManagerTest] PoiInfoManagerNotifyDisConnected001 begin");
ASSERT_TRUE(poiInfoManager_ != nullptr);
poiInfoManager_->NotifyDisConnected();
LBSLOGI(REPORT_MANAGER, "[PoiInfoManagerTest] PoiInfoManagerNotifyDisConnected001 end");
}
HWTEST_F(PoiInfoManagerTest, PoiInfoManagerResetServiceProxy001, TestSize.Level1)
{
GTEST_LOG_(INFO)
<< "PoiInfoManagerTest, PoiInfoManagerResetServiceProxy001, TestSize.Level1";
LBSLOGI(REPORT_MANAGER, "[PoiInfoManagerTest] PoiInfoManagerResetServiceProxy001 begin");
ASSERT_TRUE(poiInfoManager_ != nullptr);
poiInfoManager_->ResetServiceProxy();
LBSLOGI(REPORT_MANAGER, "[PoiInfoManagerTest] PoiInfoManagerResetServiceProxy001 end");
}
HWTEST_F(PoiInfoManagerTest, PoiInfoManagerParsePoiInfoFromStr001, TestSize.Level1)
{
GTEST_LOG_(INFO)
<< "PoiInfoManagerTest, PoiInfoManagerParsePoiInfoFromStr001, TestSize.Level1";
LBSLOGI(REPORT_MANAGER, "[PoiInfoManagerTest] PoiInfoManagerParsePoiInfoFromStr001 begin");
ASSERT_TRUE(poiInfoManager_ != nullptr);
std::string jsonStr = MockPoiString(0);
PoiInfo poiInfo = poiInfoManager_->ParsePoiInfoFromStr(jsonStr);
EXPECT_TRUE(poiInfo.poiArray.size() > 0);
LBSLOGI(REPORT_MANAGER, "[PoiInfoManagerTest] PoiInfoManagerParsePoiInfoFromStr001 end");
}
HWTEST_F(PoiInfoManagerTest, PoiInfoManagerParsePoiInfoFromStr002, TestSize.Level1)
{
GTEST_LOG_(INFO)
<< "PoiInfoManagerTest, PoiInfoManagerParsePoiInfoFromStr002, TestSize.Level1";
LBSLOGI(REPORT_MANAGER, "[PoiInfoManagerTest] PoiInfoManagerParsePoiInfoFromStr002 begin");
ASSERT_TRUE(poiInfoManager_ != nullptr);
std::string invalidJson = "invalid json";
PoiInfo poiInfo = poiInfoManager_->ParsePoiInfoFromStr(invalidJson);
EXPECT_EQ(0, poiInfo.poiArray.size());
LBSLOGI(REPORT_MANAGER, "[PoiInfoManagerTest] PoiInfoManagerParsePoiInfoFromStr002 end");
}
HWTEST_F(PoiInfoManagerTest, PoiServiceDeathRecipient001, TestSize.Level1)
{
GTEST_LOG_(INFO)
<< "PoiInfoManagerTest, PoiServiceDeathRecipient001, TestSize.Level1";
LBSLOGI(REPORT_MANAGER, "[PoiInfoManagerTest] PoiServiceDeathRecipient001 begin");
sptr<PoiServiceDeathRecipient> recipient = new (std::nothrow) PoiServiceDeathRecipient();
EXPECT_NE(nullptr, recipient);
recipient->OnRemoteDied(nullptr);
LBSLOGI(REPORT_MANAGER, "[PoiInfoManagerTest] PoiServiceDeathRecipient001 end");
}
HWTEST_F(PoiInfoManagerTest, PoiInfoHandler001, TestSize.Level1)
{
GTEST_LOG_(INFO)
<< "PoiInfoManagerTest, PoiInfoHandler001, TestSize.Level1";
LBSLOGI(REPORT_MANAGER, "[PoiInfoManagerTest] PoiInfoHandler001 begin");
auto runner = AppExecFwk::EventRunner::Create(true, AppExecFwk::ThreadMode::FFRT);
EXPECT_NE(nullptr, runner);
auto handler = std::make_shared<PoiInfoHandler>(runner);
EXPECT_NE(nullptr, handler);
LBSLOGI(REPORT_MANAGER, "[PoiInfoManagerTest] PoiInfoHandler001 end");
}
HWTEST_F(PoiInfoManagerTest, PoiInfoManagerAddCachedPoiInfoToLocation001, TestSize.Level1)
{
GTEST_LOG_(INFO)
<< "PoiInfoManagerTest, PoiInfoManagerAddCachedPoiInfoToLocation001, TestSize.Level1";
LBSLOGI(REPORT_MANAGER, "[PoiInfoManagerTest] PoiInfoManagerAddCachedPoiInfoToLocation001 begin");
ASSERT_TRUE(poiInfoManager_ != nullptr);
std::unique_ptr<Location> location = MockLocation();
poiInfoManager_->SetLatestPoiInfo("poiInfos:{\"pois\":[]}");
poiInfoManager_->AddCachedPoiInfoToLocation(location);
LBSLOGI(REPORT_MANAGER, "[PoiInfoManagerTest] PoiInfoManagerAddCachedPoiInfoToLocation001 end");
}
HWTEST_F(PoiInfoManagerTest, PoiInfoManagerClearPoiInfos001, TestSize.Level1)
{
GTEST_LOG_(INFO)
<< "PoiInfoManagerTest, PoiInfoManagerClearPoiInfos001, TestSize.Level1";
LBSLOGI(REPORT_MANAGER, "[PoiInfoManagerTest] PoiInfoManagerClearPoiInfos001 begin");
ASSERT_TRUE(poiInfoManager_ != nullptr);
std::unique_ptr<Location> location = MockLocation();
std::vector<std::string> additions;
additions.push_back("poiInfos:{\"pois\":[]}");
additions.push_back("other_key:value");
location->SetAdditions(additions, false);
poiInfoManager_->ClearPoiInfos(location);
LBSLOGI(REPORT_MANAGER, "[PoiInfoManagerTest] PoiInfoManagerClearPoiInfos001 end");
}
HWTEST_F(PoiInfoManagerTest, PoiInfoCallback001, TestSize.Level1)
{
GTEST_LOG_(INFO)
<< "PoiInfoManagerTest, PoiInfoCallback001, TestSize.Level1";
LBSLOGI(REPORT_MANAGER, "[PoiInfoManagerTest] PoiInfoCallback001 begin");
sptr<PoiInfoCallback> callback = new (std::nothrow) PoiInfoCallback();
EXPECT_NE(nullptr, callback);
std::shared_ptr<PoiInfo> nullPoiInfo = nullptr;
callback->OnPoiInfoChange(nullPoiInfo);
callback->OnErrorReport("test_error");
LBSLOGI(REPORT_MANAGER, "[PoiInfoManagerTest] PoiInfoCallback001 end");
}
HWTEST_F(PoiInfoManagerTest, PoiInfoCallbackOnRemoteRequest001, TestSize.Level1)
{
GTEST_LOG_(INFO)
<< "PoiInfoManagerTest, PoiInfoCallbackOnRemoteRequest001, TestSize.Level1";
LBSLOGI(REPORT_MANAGER, "[PoiInfoManagerTest] PoiInfoCallbackOnRemoteRequest001 begin");
sptr<PoiInfoCallback> callback = new (std::nothrow) PoiInfoCallback();
EXPECT_NE(nullptr, callback);
MessageParcel data;
MessageParcel reply;
MessageOption option;
int32_t result = callback->OnRemoteRequest(0, data, reply, option);
EXPECT_EQ(-1, result);
LBSLOGI(REPORT_MANAGER, "[PoiInfoManagerTest] PoiInfoCallbackOnRemoteRequest001 end");
}
}
}