!993 添加clip_plugin&paste_data_record的测试用例

Merge pull request !993 from Seiphro/master
This commit is contained in:
openharmony_ci 2024-11-22 03:12:55 +00:00 committed by Gitee
commit cd7834695f
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 61 additions and 12 deletions

View File

@ -42,6 +42,8 @@ ohos_unittest("PasteboardFrameworkTest") {
module_out_path = module_output_path
sources = [
"${pasteboard_root_path}/framework/framework/clip/clip_plugin.cpp",
"${pasteboard_root_path}/framework/framework/clip/default_clip.cpp",
"${pasteboard_root_path}/framework/framework/serializable/serializable.cpp",
"${pasteboard_service_path}/load/src/config.cpp",
"src/clip_plugin_test.cpp",
@ -76,6 +78,7 @@ ohos_unittest("PasteboardFrameworkTest") {
"c_utils:utils",
"ffrt:libffrt",
"hilog:libhilog",
"hisysevent:libhisysevent",
"image_framework:image_native",
"init:libbeget_proxy",
"init:libbegetutil",

View File

@ -37,13 +37,30 @@ void ClipPluginTest::SetUp(void) {}
void ClipPluginTest::TearDown(void) {}
class CustomClipPlugin : public ClipPlugin {
public:
int32_t SetPasteData(const GlobalEvent &event, const std::vector<uint8_t> &data) override
{
(void)event;
(void)data;
return 0;
}
std::pair<int32_t, int32_t> GetPasteData(const GlobalEvent &event, std::vector<uint8_t> &data) override
{
(void)event;
(void)data;
return std::make_pair(0, 0);
}
};
/**
* @tc.name: MarshalTest001
* @tc.desc: Marshal.
* @tc.type: FUNC
* @tc.require:
* @tc.author:
*/
* @tc.name: MarshalTest001
* @tc.desc: Marshal.
* @tc.type: FUNC
* @tc.require:
* @tc.author:
*/
HWTEST_F(ClipPluginTest, MarshalTest001, TestSize.Level0)
{
std::string PLUGIN_NAME_VAL = "distributed_clip";
@ -60,12 +77,12 @@ HWTEST_F(ClipPluginTest, MarshalTest001, TestSize.Level0)
}
/**
* @tc.name: UnmarshalTest001
* @tc.desc: Unmarshal.
* @tc.type: FUNC
* @tc.require:
* @tc.author:
*/
* @tc.name: UnmarshalTest001
* @tc.desc: Unmarshal.
* @tc.type: FUNC
* @tc.require:
* @tc.author:
*/
HWTEST_F(ClipPluginTest, UnmarshalTest001, TestSize.Level0)
{
std::string str = R"({
@ -85,4 +102,19 @@ HWTEST_F(ClipPluginTest, UnmarshalTest001, TestSize.Level0)
ASSERT_FALSE(globalEvent.Unmarshal(node));
cJSON_Delete(node);
}
/**
* @tc.name: PublishServiceStateTest
* @tc.desc: PublishServiceState.
* @tc.type: FUNC
* @tc.require:
* @tc.author:
*/
HWTEST_F(ClipPluginTest, PublishServiceStateTest, TestSize.Level0)
{
CustomClipPlugin clipPlugin;
std::string networkId = "testNetworkId";
int32_t result = clipPlugin.PublishServiceState(networkId, ClipPlugin::ServiceStatus::CONNECT_SUCC);
ASSERT_EQ(0, result);
}
} // namespace OHOS::MiscServices

View File

@ -799,4 +799,18 @@ HWTEST_F(PasteDataRecordTest, GetUDMFValueTest006, TestSize.Level0)
auto value = record.GetUDMFValue();
EXPECT_NE(value, nullptr);
}
/**
* @tc.name: IsDelayRecordTest
* @tc.desc: IsDelayRecord
* @tc.type: FUNC
*/
HWTEST_F(PasteDataRecordTest, IsDelayRecordTest, TestSize.Level0)
{
PasteDataRecord record(MIMETYPE_TEXT_WANT, nullptr, nullptr, nullptr, nullptr);
record.SetDelayRecordFlag(true);
EXPECT_TRUE(record.IsDelayRecord());
record.SetDelayRecordFlag(false);
EXPECT_FALSE(record.IsDelayRecord());
}
} // namespace OHOS::MiscServices