Signed-off-by: gao-wen <gaowen17@huawei.com>
This commit is contained in:
gao-wen 2024-10-29 16:57:06 +08:00
parent beec91bca1
commit 3e6682e2d9
3 changed files with 128 additions and 0 deletions

View File

@ -45,6 +45,7 @@ ohos_unittest("PasteboardFrameworkTest") {
"${pasteboard_root_path}/framework/framework/serializable/serializable.cpp",
"${pasteboard_service_path}/load/src/config.cpp",
"src/convert_utils_test.cpp",
"src/distributed_module_config_test.cpp",
"src/dm_adapter_test.cpp",
"src/event_center_test.cpp",
"src/ffrt_utils_test.cpp",

View File

@ -0,0 +1,69 @@
/*
* Copyright (c) 2022-2023 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 <gtest/gtest.h>
#include "device/distributed_module_config.h"
#include "pasteboard_error.h"
namespace OHOS::MiscServices {
using namespace testing::ext;
class DistributedModuleConfigTest : public testing::Test {
public:
static void SetUpTestCase(void);
static void TearDownTestCase(void);
void SetUp();
void TearDown();
};
void DistributedModuleConfigTest::SetUpTestCase(void) {}
void DistributedModuleConfigTest::TearDownTestCase(void) {}
void DistributedModuleConfigTest::SetUp(void) {}
void DistributedModuleConfigTest::TearDown(void) {}
/**
* @tc.name: IsOnTest
* @tc.desc: Is On.
* @tc.type: FUNC
* @tc.require:
* @tc.author:
*/
HWTEST_F(DistributedModuleConfigTest, IsOnTest, TestSize.Level0)
{
DistributedModuleConfig config;
config.Init();
bool result = config.IsOn();
config.DeInit();
EXPECT_FALSE(result);
}
/**
* @tc.name: WatchTest
* @tc.desc: Watch.
* @tc.type: FUNC
* @tc.require:
* @tc.author:
*/
HWTEST_F(DistributedModuleConfigTest, WatchTest, TestSize.Level0)
{
DistributedModuleConfig::Observer observer;
DistributedModuleConfig config;
config.Watch(observer);
EXPECT_FALSE(observer);
}
} // namespace OHOS::MiscServices

View File

@ -131,4 +131,62 @@ HWTEST_F(DMAdapterTest, IsSameAccount, TestSize.Level0)
bool ret = DMAdapter::GetInstance().IsSameAccount(networkId);
ASSERT_FALSE(ret);
}
/**
* @tc.name: GetDevices
* @tc.desc: Get Devices.
* @tc.type: FUNC
* @tc.require:
* @tc.author:
*/
HWTEST_F(DMAdapterTest, GetDevices, TestSize.Level0)
{
DMAdapter::GetInstance().SetDevices();
std::vector<DmDeviceInfo> devices = DMAdapter::GetInstance().GetDevices();
ASSERT_TRUE(devices.empty());
}
/**
* @tc.name: GetLocalDeviceType
* @tc.desc: Get Local Device Type
* @tc.type: FUNC
* @tc.require:
* @tc.author:
*/
HWTEST_F(DMAdapterTest, GetLocalDeviceType, TestSize.Level0)
{
int32_t type = 14;
int32_t ret = DMAdapter::GetInstance().GetLocalDeviceType();
ASSERT_EQ(ret, type);
}
/**
* @tc.name: GetDeviceName001
* @tc.desc: Get Local Device Type
* @tc.type: FUNC
* @tc.require:
* @tc.author:
*/
HWTEST_F(DMAdapterTest, GetDeviceName001, TestSize.Level0)
{
std::string networkId = "invalidnetworkId";
std::string expectedDeviceName = "unknown";
std::string actualDeviceName = DMAdapter::GetInstance().GetDeviceName(networkId);
EXPECT_EQ(expectedDeviceName, actualDeviceName);
}
/**
* @tc.name: GetDeviceName002
* @tc.desc: Get Local Device Type
* @tc.type: FUNC
* @tc.require:
* @tc.author:
*/
HWTEST_F(DMAdapterTest, GetDeviceName002, TestSize.Level0)
{
std::string networkId = DMAdapter::GetInstance().GetLocalNetworkId();
std::string expectedDeviceName = "unknown";
std::string actualDeviceName = DMAdapter::GetInstance().GetDeviceName(networkId);
EXPECT_EQ(expectedDeviceName, actualDeviceName);
}
} // namespace OHOS::MiscServices