• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #define LOG_TAG "PasteboardCapiTest"
17 
18 #include <gtest/gtest.h>
19 #include <unistd.h>
20 
21 #include "token_setproc.h"
22 #include "accesstoken_kit.h"
23 #include "nativetoken_kit.h"
24 
25 #include "oh_pasteboard.h"
26 #include "oh_pasteboard_err_code.h"
27 #include "oh_pasteboard_observer_impl.h"
28 #include "udmf.h"
29 #include "udmf_meta.h"
30 #include "uds.h"
31 #include "pasteboard_hilog.h"
32 #include "pasteboard_client.h"
33 #include "os_account_manager.h"
34 
35 using namespace testing::ext;
36 using namespace OHOS::Security::AccessToken;
37 using namespace OHOS::MiscServices;
38 
39 namespace OHOS {
40 namespace Test {
41 class PasteboardCapiTest : public testing::Test {
42 public:
43     static void SetUpTestCase(void);
44     static void TearDownTestCase(void);
45     void SetUp();
46     void TearDown();
47     static void CallbackFunc(void* context, Pasteboard_NotifyType type);
48     static void RemoveCallbackSideEffects();
49     static void ContextFinalizeFunc(void* context);
50     static int callbackValue;
51     static void AllocTestTokenId();
52     static void DeleteTestTokenId();
53     static void SetTestTokenId();
54     static void RestoreSelfTokenId();
55     static void* GetDataCallback(void* context, const char* type);
56     static constexpr int INIT_VALUE = 0;
57     static constexpr int UPDATE_VALUE = 1;
58     static constexpr int uriLen = 10;
59     static uint64_t selfTokenId_;
60     static AccessTokenID testTokenId_;
61     static constexpr char PLAINTEXT_CONTENT[] = "PLAINTEXT_CONTENT";
62     static constexpr char HYPERLINK_URL[] = "file://data/image.png";
63     static constexpr char HTML_URL[] = "file://data/image.png";
64     static constexpr char HTML_TEXT[] = "<P>html text</P>";
65 };
66 uint64_t PasteboardCapiTest::selfTokenId_ = 0;
67 AccessTokenID PasteboardCapiTest::testTokenId_ = 0;
68 int PasteboardCapiTest::callbackValue = 0;
69 static Pasteboard_GetDataParams *g_params = nullptr;
70 
SetUpTestCase(void)71 void PasteboardCapiTest::SetUpTestCase(void)
72 {
73     callbackValue = INIT_VALUE;
74     selfTokenId_ = GetSelfTokenID();
75     AllocTestTokenId();
76 }
77 
TearDownTestCase(void)78 void PasteboardCapiTest::TearDownTestCase(void)
79 {
80     RemoveCallbackSideEffects();
81     DeleteTestTokenId();
82 }
83 
SetUp(void)84 void PasteboardCapiTest::SetUp(void)
85 {
86 }
87 
TearDown(void)88 void PasteboardCapiTest::TearDown(void)
89 {
90 }
91 
AllocTestTokenId()92 void PasteboardCapiTest::AllocTestTokenId()
93 {
94     std::vector<int32_t> ids;
95     auto ret = AccountSA::OsAccountManager::QueryActiveOsAccountIds(ids);
96     if (ret != ERR_OK || ids.empty()) {
97         PASTEBOARD_HILOGE(PASTEBOARD_MODULE_SERVICE, "query active user failed errCode = %{public}d", ret);
98         return;
99     }
100     HapInfoParams infoParams = {
101         .userID = ids[0],
102         .bundleName = "ohos.privacy_test.pasteboard",
103         .instIndex = 0,
104         .appIDDesc = "privacy_test.pasteboard"
105     };
106     PermissionStateFull testState = {
107         .permissionName = "ohos.permission.DUMP",
108         .isGeneral = true,
109         .resDeviceID = { "local" },
110         .grantStatus = { PermissionState::PERMISSION_GRANTED },
111         .grantFlags = { 1 }
112     };
113     HapPolicyParams policyParams = {
114         .apl = APL_NORMAL,
115         .domain = "test.domain.pasteboard",
116         .permList = {},
117         .permStateList = { testState }
118     };
119 
120     AccessTokenKit::AllocHapToken(infoParams, policyParams);
121     testTokenId_ = Security::AccessToken::AccessTokenKit::GetHapTokenID(
122         infoParams.userID, infoParams.bundleName, infoParams.instIndex);
123     PASTEBOARD_HILOGD(PASTEBOARD_MODULE_SERVICE, "userID = %{public}d, testTokenId = 0x%{public}x.", infoParams.userID,
124         testTokenId_);
125 }
126 
DeleteTestTokenId()127 void PasteboardCapiTest::DeleteTestTokenId()
128 {
129     AccessTokenKit::DeleteToken(testTokenId_);
130 }
131 
132 
SetTestTokenId()133 void PasteboardCapiTest::SetTestTokenId()
134 {
135     auto ret = SetSelfTokenID(testTokenId_);
136     PASTEBOARD_HILOGD(PASTEBOARD_MODULE_SERVICE, "testTokenId = 0x%{public}x, ret = %{public}d!", testTokenId_, ret);
137 }
138 
RestoreSelfTokenId()139 void PasteboardCapiTest::RestoreSelfTokenId()
140 {
141     auto ret = SetSelfTokenID(selfTokenId_);
142     PASTEBOARD_HILOGD(PASTEBOARD_MODULE_SERVICE, "ret = %{public}d!", ret);
143 }
144 
CallbackFunc(void * context,Pasteboard_NotifyType type)145 void PasteboardCapiTest::CallbackFunc(void* context, Pasteboard_NotifyType type)
146 {
147     callbackValue = UPDATE_VALUE;
148 }
149 
RemoveCallbackSideEffects()150 void PasteboardCapiTest::RemoveCallbackSideEffects()
151 {
152     callbackValue = INIT_VALUE;
153 }
154 
ContextFinalizeFunc(void * context)155 void PasteboardCapiTest::ContextFinalizeFunc(void* context) {}
156 
GetDataCallback(void * context,const char * type)157 void* PasteboardCapiTest::GetDataCallback(void* context, const char* type)
158 {
159     if (std::string(type) == "general.plain-text") {
160         OH_UdsPlainText* plainText = OH_UdsPlainText_Create();
161         OH_UdsPlainText_SetContent(plainText, PLAINTEXT_CONTENT);
162         return plainText;
163     } else if (std::string(type) == "general.hyperlink") {
164         OH_UdsHyperlink* link = OH_UdsHyperlink_Create();
165         OH_UdsHyperlink_SetUrl(link, HYPERLINK_URL);
166         return link;
167     } else if (std::string(type) == "general.html") {
168         OH_UdsHtml* html = OH_UdsHtml_Create();
169         OH_UdsHtml_SetContent(html, HTML_URL);
170         return html;
171     }
172     return nullptr;
173 }
174 
175 /**
176  * @tc.name: OH_PasteboardSubscriber_Create001
177  * @tc.desc: OH_PasteboardObserver_Create test
178  * @tc.type: FUNC
179  * @tc.require: AROOOH5R5G
180  */
181 HWTEST_F(PasteboardCapiTest, OH_PasteboardSubscriber_Create001, TestSize.Level1)
182 {
183     OH_PasteboardObserver* observer = OH_PasteboardObserver_Create();
184     EXPECT_NE(observer, nullptr);
185 
186     OH_PasteboardObserver_Destroy(observer);
187     OH_PasteboardObserver_Destroy(nullptr);
188 }
189 
190 /**
191  * @tc.name: OH_PasteboardObserver_SetData001
192  * @tc.desc: OH_PasteboardObserver_SetData test valid
193  * @tc.type: FUNC
194  * @tc.require: AROOOH5R5G
195  */
196 HWTEST_F(PasteboardCapiTest, OH_PasteboardObserver_SetData001, TestSize.Level1)
197 {
198     OH_Pasteboard* pasteboard = OH_Pasteboard_Create();
199     void* context = static_cast<void*>(pasteboard);
200     OH_PasteboardObserver* observer = OH_PasteboardObserver_Create();
201 
202     int setRes1 = OH_PasteboardObserver_SetData(observer, context, CallbackFunc, ContextFinalizeFunc);
203     EXPECT_EQ(setRes1, ERR_OK);
204 
205     OH_PasteboardObserver_Destroy(observer);
206     OH_Pasteboard_Destroy(pasteboard);
207 }
208 
209 /**
210  * @tc.name: OH_PasteboardObserver_SetData002
211  * @tc.desc: OH_PasteboardObserver_SetData test invalid
212  * @tc.type: FUNC
213  * @tc.require: AROOOH5R5G
214  */
215 HWTEST_F(PasteboardCapiTest, OH_PasteboardObserver_SetData002, TestSize.Level1)
216 {
217     OH_Pasteboard* pasteboard = OH_Pasteboard_Create();
218     void* context = static_cast<void*>(pasteboard);
219     OH_PasteboardObserver* observer = OH_PasteboardObserver_Create();
220 
221     int setRes1 = OH_PasteboardObserver_SetData(nullptr, context, CallbackFunc, ContextFinalizeFunc);
222     EXPECT_EQ(setRes1, ERR_INVALID_PARAMETER);
223 
224     int setRes2 = OH_PasteboardObserver_SetData(observer, context, nullptr, ContextFinalizeFunc);
225     EXPECT_EQ(setRes2, ERR_INVALID_PARAMETER);
226 
227     int setRes3 = OH_PasteboardObserver_SetData(observer, context, CallbackFunc, nullptr);
228     EXPECT_EQ(setRes3, ERR_INVALID_PARAMETER);
229 
230     OH_PasteboardObserver_Destroy(observer);
231     OH_Pasteboard_Destroy(pasteboard);
232 }
233 
234 /**
235  * @tc.name: OH_Pasteboard_Create001
236  * @tc.desc: OH_Pasteboard_Create test valid
237  * @tc.type: FUNC
238  * @tc.require: AROOOH5R5G
239  */
240 HWTEST_F(PasteboardCapiTest, OH_Pasteboard_Create001, TestSize.Level1)
241 {
242     OH_Pasteboard* pasteboard = OH_Pasteboard_Create();
243     EXPECT_NE(pasteboard, nullptr);
244 
245     OH_Pasteboard_Destroy(pasteboard);
246 }
247 
248 /**
249  * @tc.name: OH_Pasteboard_Subscribe001
250  * @tc.desc: OH_Pasteboard_Subscribe test valid
251  * @tc.type: FUNC
252  * @tc.require: AROOOH5R5G
253  */
254 HWTEST_F(PasteboardCapiTest, OH_Pasteboard_Subscribe001, TestSize.Level1)
255 {
256     OH_Pasteboard* pasteboard = OH_Pasteboard_Create();
257     OH_PasteboardObserver* observer = OH_PasteboardObserver_Create();
258     OH_PasteboardObserver_SetData(observer, nullptr, CallbackFunc, ContextFinalizeFunc);
259 
260     int res = OH_Pasteboard_Subscribe(pasteboard, NOTIFY_LOCAL_DATA_CHANGE, observer);
261     EXPECT_EQ(res, ERR_OK);
262 
263     int resRepeat = OH_Pasteboard_Subscribe(pasteboard, NOTIFY_LOCAL_DATA_CHANGE, observer);
264     EXPECT_EQ(resRepeat, ERR_OK);
265 
266     OH_Pasteboard_Destroy(pasteboard);
267     OH_PasteboardObserver_Destroy(observer);
268 }
269 
270 /**
271  * @tc.name: OH_Pasteboard_Subscribe002
272  * @tc.desc: OH_Pasteboard_Subscribe test invalid
273  * @tc.type: FUNC
274  * @tc.require: AROOOH5R5G
275  */
276 HWTEST_F(PasteboardCapiTest, OH_Pasteboard_Subscribe002, TestSize.Level1)
277 {
278     OH_Pasteboard* pasteboard = OH_Pasteboard_Create();
279     OH_PasteboardObserver* observer = OH_PasteboardObserver_Create();
280     OH_PasteboardObserver_SetData(observer, nullptr, CallbackFunc, ContextFinalizeFunc);
281 
282     int res1 = OH_Pasteboard_Subscribe(nullptr, NOTIFY_LOCAL_DATA_CHANGE, observer);
283     EXPECT_EQ(res1, ERR_INVALID_PARAMETER);
284 
285     int res2 = OH_Pasteboard_Subscribe(pasteboard, 10, observer);
286     EXPECT_EQ(res2, ERR_INVALID_PARAMETER);
287 
288     int res3 = OH_Pasteboard_Subscribe(pasteboard, -1, observer);
289     EXPECT_EQ(res3, ERR_INVALID_PARAMETER);
290 
291     int res4 = OH_Pasteboard_Subscribe(pasteboard, NOTIFY_LOCAL_DATA_CHANGE, nullptr);
292     EXPECT_EQ(res4, ERR_INVALID_PARAMETER);
293 
294     OH_Pasteboard_Destroy(pasteboard);
295     OH_PasteboardObserver_Destroy(observer);
296 }
297 
298 /**
299  * @tc.name: OH_Pasteboard_Unsubscribe001
300  * @tc.desc: OH_Pasteboard_Unsubscribe test valid
301  * @tc.type: FUNC
302  * @tc.require: AROOOH5R5G
303  */
304 HWTEST_F(PasteboardCapiTest, OH_Pasteboard_Unsubscribe001, TestSize.Level1)
305 {
306     OH_Pasteboard* pasteboard = OH_Pasteboard_Create();
307     OH_PasteboardObserver* observer = OH_PasteboardObserver_Create();
308     OH_PasteboardObserver_SetData(observer, nullptr, CallbackFunc, ContextFinalizeFunc);
309 
310     OH_Pasteboard_Subscribe(pasteboard, NOTIFY_LOCAL_DATA_CHANGE, observer);
311 
312     int res = OH_Pasteboard_Unsubscribe(pasteboard, NOTIFY_LOCAL_DATA_CHANGE, observer);
313     EXPECT_EQ(res, ERR_OK);
314 
315     OH_Pasteboard_Destroy(pasteboard);
316     OH_PasteboardObserver_Destroy(observer);
317 }
318 
319 /**
320  * @tc.name: OH_Pasteboard_Unsubscribe002
321  * @tc.desc: OH_Pasteboard_Unsubscribe test invalid
322  * @tc.type: FUNC
323  * @tc.require: AROOOH5R5G
324  */
325 HWTEST_F(PasteboardCapiTest, OH_Pasteboard_Unsubscribe002, TestSize.Level1)
326 {
327     OH_Pasteboard* pasteboard = OH_Pasteboard_Create();
328     OH_PasteboardObserver* observer = OH_PasteboardObserver_Create();
329     OH_PasteboardObserver_SetData(observer, nullptr, CallbackFunc, ContextFinalizeFunc);
330 
331     int res1 = OH_Pasteboard_Unsubscribe(nullptr, NOTIFY_LOCAL_DATA_CHANGE, observer);
332     EXPECT_EQ(res1, ERR_INVALID_PARAMETER);
333 
334     int res2 = OH_Pasteboard_Unsubscribe(pasteboard, 10, observer);
335     EXPECT_EQ(res2, ERR_INVALID_PARAMETER);
336 
337     int res3 = OH_Pasteboard_Unsubscribe(pasteboard, -1, observer);
338     EXPECT_EQ(res3, ERR_INVALID_PARAMETER);
339 
340     int res4 = OH_Pasteboard_Unsubscribe(pasteboard, NOTIFY_LOCAL_DATA_CHANGE, nullptr);
341     EXPECT_EQ(res4, ERR_INVALID_PARAMETER);
342 
343     OH_Pasteboard_Destroy(pasteboard);
344     OH_PasteboardObserver_Destroy(observer);
345 }
346 
347 /**
348  * @tc.name: OH_Pasteboard_IsRemoteData001
349  * @tc.desc: OH_Pasteboard_IsRemoteData test valid
350  * @tc.type: FUNC
351  * @tc.require: AROOOH5R5G
352  */
353 HWTEST_F(PasteboardCapiTest, OH_Pasteboard_IsRemoteData001, TestSize.Level1)
354 {
355     OH_Pasteboard* pasteboard = OH_Pasteboard_Create();
356 
357     bool res = OH_Pasteboard_IsRemoteData(pasteboard);
358     EXPECT_FALSE(res);
359 
360     OH_Pasteboard_Destroy(pasteboard);
361 }
362 
363 /**
364  * @tc.name: OH_Pasteboard_GetDataSource001
365  * @tc.desc: OH_Pasteboard_GetDataSource test valid
366  * @tc.type: FUNC
367  * @tc.require: AROOOH5R5G
368  */
369 HWTEST_F(PasteboardCapiTest, OH_Pasteboard_GetDataSource001, TestSize.Level1)
370 {
371     OH_Pasteboard* pasteboard = OH_Pasteboard_Create();
372     OH_UdmfData* setData = OH_UdmfData_Create();
373     OH_UdmfRecord* record = OH_UdmfRecord_Create();
374     OH_UdsPlainText* plainText = OH_UdsPlainText_Create();
375     char content[] = "hello world";
376     OH_UdsPlainText_SetContent(plainText, content);
377     OH_UdmfRecord_AddPlainText(record, plainText);
378     OH_UdmfData_AddRecord(setData, record);
379 
380     OH_Pasteboard_SetData(pasteboard, setData);
381 
382     int len = 100;
383     char source[100];
384     int res = OH_Pasteboard_GetDataSource(pasteboard, source, len);
385     EXPECT_EQ(res, ERR_OK);
386 
387     int res1 = OH_Pasteboard_GetDataSource(nullptr, source, len);
388     EXPECT_EQ(res1, ERR_INVALID_PARAMETER);
389 
390     int res2 = OH_Pasteboard_GetDataSource(pasteboard, nullptr, len);
391     EXPECT_EQ(res2, ERR_INVALID_PARAMETER);
392 
393     int res3 = OH_Pasteboard_GetDataSource(pasteboard, source, 0);
394     EXPECT_EQ(res3, ERR_INVALID_PARAMETER);
395 
396     OH_Pasteboard_Destroy(pasteboard);
397 }
398 
399 /**
400  * @tc.name: OH_Pasteboard_GetMimeTypes001
401  * @tc.desc: OH_Pasteboard_GetMimeTypes test empty data
402  * @tc.type: FUNC
403  * @tc.require: AR20241012964265
404  */
405 HWTEST_F(PasteboardCapiTest, OH_Pasteboard_GetMimeTypes001, TestSize.Level1)
406 {
407     OH_Pasteboard* pasteboard = OH_Pasteboard_Create();
408     ASSERT_TRUE(pasteboard);
409     OH_Pasteboard_ClearData(pasteboard);
410     unsigned int count = 1000;
411     char** res = OH_Pasteboard_GetMimeTypes(pasteboard, &count);
412     EXPECT_EQ(0, count);
413     EXPECT_TRUE(res == nullptr);
414 }
415 
416 /**
417  * @tc.name: OH_Pasteboard_GetMimeTypes002
418  * @tc.desc: OH_Pasteboard_GetMimeTypes test plainText
419  * @tc.type: FUNC
420  * @tc.require: AR20241012964265
421  */
422 HWTEST_F(PasteboardCapiTest, OH_Pasteboard_GetMimeTypes002, TestSize.Level1)
423 {
424     OH_Pasteboard* pasteboard = OH_Pasteboard_Create();
425     ASSERT_TRUE(pasteboard);
426     OH_UdmfData* setData = OH_UdmfData_Create();
427     ASSERT_TRUE(setData);
428     OH_UdmfRecord* record = OH_UdmfRecord_Create();
429     ASSERT_TRUE(record);
430     OH_UdsPlainText* plainText = OH_UdsPlainText_Create();
431     ASSERT_TRUE(plainText);
432     char content[] = "hello world";
433     OH_UdsPlainText_SetContent(plainText, content);
434     OH_UdmfRecord_AddPlainText(record, plainText);
435     OH_UdmfData_AddRecord(setData, record);
436     OH_Pasteboard_SetData(pasteboard, setData);
437 
438     unsigned int count = 1000;
439     char** res = OH_Pasteboard_GetMimeTypes(pasteboard, &count);
440     EXPECT_EQ(1, count);
441     EXPECT_TRUE(res != nullptr);
442     EXPECT_STREQ(MIMETYPE_TEXT_PLAIN, res[0]);
443 
444     OH_Pasteboard_Destroy(pasteboard);
445 }
446 
447 /**
448  * @tc.name: OH_Pasteboard_GetMimeTypes003
449  * @tc.desc: OH_Pasteboard_GetMimeTypes test multi Mime types
450  * @tc.type: FUNC
451  * @tc.require: AR20241012964265
452  */
453 HWTEST_F(PasteboardCapiTest, OH_Pasteboard_GetMimeTypes003, TestSize.Level1)
454 {
455     OH_Pasteboard* pasteboard = OH_Pasteboard_Create();
456     ASSERT_TRUE(pasteboard);
457     OH_UdmfData* setData = OH_UdmfData_Create();
458     ASSERT_TRUE(setData);
459     OH_UdmfRecord* record = OH_UdmfRecord_Create();
460     ASSERT_TRUE(record);
461     OH_UdsPlainText* plainText = OH_UdsPlainText_Create();
462     ASSERT_TRUE(plainText);
463     char content[] = "hello world";
464     OH_UdsPlainText_SetContent(plainText, content);
465     OH_UdmfRecord_AddPlainText(record, plainText);
466     OH_UdmfData_AddRecord(setData, record);
467 
468     OH_UdmfRecord* record2 = OH_UdmfRecord_Create();
469     ASSERT_TRUE(record2);
470     OH_UdsHtml* htmlText = OH_UdsHtml_Create();
471     ASSERT_TRUE(htmlText);
472     char html[] = "<div class='disabled'>hello</div>";
473     OH_UdsHtml_SetContent(htmlText, html);
474     OH_UdmfRecord_AddHtml(record2, htmlText);
475     OH_UdmfData_AddRecord(setData, record2);
476     OH_Pasteboard_SetData(pasteboard, setData);
477 
478     unsigned int count = 1000;
479     char** res = OH_Pasteboard_GetMimeTypes(pasteboard, &count);
480     EXPECT_EQ(2, count);
481     EXPECT_TRUE(res != nullptr);
482     EXPECT_TRUE((strcmp(MIMETYPE_TEXT_PLAIN, res[0]) == 0 && strcmp(MIMETYPE_TEXT_HTML, res[1]) == 0) ||
483         (strcmp(MIMETYPE_TEXT_PLAIN, res[1]) == 0 && strcmp(MIMETYPE_TEXT_HTML, res[0]) == 0));
484 
485     OH_Pasteboard_Destroy(pasteboard);
486 }
487 
488 /**
489  * @tc.name: OH_Pasteboard_GetMimeTypes004
490  * @tc.desc: OH_Pasteboard_GetMimeTypes test multi Mime types
491  * @tc.type: FUNC
492  * @tc.require:
493  */
494 HWTEST_F(PasteboardCapiTest, OH_Pasteboard_GetMimeTypes004, TestSize.Level1)
495 {
496     OH_Pasteboard* pasteboard = OH_Pasteboard_Create();
497     ASSERT_TRUE(pasteboard);
498     OH_UdmfData* setData = OH_UdmfData_Create();
499     ASSERT_TRUE(setData);
500     OH_UdmfRecord* record = OH_UdmfRecord_Create();
501     ASSERT_TRUE(record);
502 
503     OH_UdsPlainText* plainText = OH_UdsPlainText_Create();
504     ASSERT_TRUE(plainText);
505     char content[] = "hello world";
506     OH_UdsPlainText_SetContent(plainText, content);
507 
508     OH_UdsHtml* htmlText = OH_UdsHtml_Create();
509     ASSERT_TRUE(htmlText);
510     char html[] = "<div class='disabled'>hello</div>";
511     OH_UdsHtml_SetContent(htmlText, html);
512 
513     OH_UdmfRecord_AddPlainText(record, plainText);
514     OH_UdmfRecord_AddHtml(record, htmlText);
515     OH_UdmfData_AddRecord(setData, record);
516 
517     OH_Pasteboard_SetData(pasteboard, setData);
518 
519     unsigned int count = 1000;
520     char** res = OH_Pasteboard_GetMimeTypes(pasteboard, &count);
521     EXPECT_EQ(2, count);
522     EXPECT_TRUE(res != nullptr);
523     EXPECT_TRUE((strcmp(MIMETYPE_TEXT_PLAIN, res[0]) == 0 && strcmp(MIMETYPE_TEXT_HTML, res[1]) == 0) ||
524         (strcmp(MIMETYPE_TEXT_PLAIN, res[1]) == 0 && strcmp(MIMETYPE_TEXT_HTML, res[0]) == 0));
525 
526     OH_Pasteboard_Destroy(pasteboard);
527 }
528 
529 /**
530  * @tc.name: OH_Pasteboard_HasType001
531  * @tc.desc: OH_Pasteboard_HasType test valid
532  * @tc.type: FUNC
533  * @tc.require: AROOOH5R5G
534  */
535 HWTEST_F(PasteboardCapiTest, OH_Pasteboard_HasType001, TestSize.Level1)
536 {
537     OH_Pasteboard* pasteboard = OH_Pasteboard_Create();
538     OH_UdmfData* setData = OH_UdmfData_Create();
539     OH_UdmfRecord* record = OH_UdmfRecord_Create();
540     OH_UdsPlainText* plainText = OH_UdsPlainText_Create();
541     char content[] = "hello world";
542     OH_UdsPlainText_SetContent(plainText, content);
543     OH_UdmfRecord_AddPlainText(record, plainText);
544     OH_UdmfData_AddRecord(setData, record);
545 
546     OH_Pasteboard_SetData(pasteboard, setData);
547     char type[] = "general.plain-text";
548     bool res = OH_Pasteboard_HasType(pasteboard, type);
549     EXPECT_FALSE(res);
550 
551     OH_Pasteboard_Destroy(pasteboard);
552 }
553 
554 /**
555  * @tc.name: OH_Pasteboard_HasType002
556  * @tc.desc: OH_Pasteboard_HasType test mutil entry
557  * @tc.type: FUNC
558  * @tc.require: AROOOH5R5G
559  */
560 HWTEST_F(PasteboardCapiTest, OH_Pasteboard_HasType002, TestSize.Level1)
561 {
562     OH_Pasteboard* pasteboard = OH_Pasteboard_Create();
563     ASSERT_TRUE(pasteboard);
564     OH_UdmfData* setData = OH_UdmfData_Create();
565     ASSERT_TRUE(setData);
566     OH_UdmfRecord* record = OH_UdmfRecord_Create();
567     ASSERT_TRUE(record);
568 
569     OH_UdsPlainText* plainText = OH_UdsPlainText_Create();
570     ASSERT_TRUE(plainText);
571     char content[] = "hello world";
572     OH_UdsPlainText_SetContent(plainText, content);
573 
574     OH_UdsHtml* htmlText = OH_UdsHtml_Create();
575     ASSERT_TRUE(htmlText);
576     char html[] = "<div class='disabled'>hello</div>";
577     OH_UdsHtml_SetContent(htmlText, html);
578 
579     OH_UdmfRecord_AddPlainText(record, plainText);
580     OH_UdmfRecord_AddHtml(record, htmlText);
581     OH_UdmfData_AddRecord(setData, record);
582 
583     OH_Pasteboard_SetData(pasteboard, setData);
584 
585     bool res = OH_Pasteboard_HasType(pasteboard, "text/plain");
586     EXPECT_TRUE(res);
587 
588     res = OH_Pasteboard_HasType(pasteboard, "text/html");
589     EXPECT_TRUE(res);
590 
591     OH_Pasteboard_Destroy(pasteboard);
592 }
593 
594 /**
595  * @tc.name: OH_UdmfData_HasType001
596  * @tc.desc: OH_UdmfData_HasType test mutil entry
597  * @tc.type: FUNC
598  * @tc.require: AROOOH5R5G
599  */
600 HWTEST_F(PasteboardCapiTest, OH_UdmfData_HasType001, TestSize.Level1)
601 {
602     OH_Pasteboard* pasteboard = OH_Pasteboard_Create();
603     ASSERT_TRUE(pasteboard);
604     OH_UdmfData* setData = OH_UdmfData_Create();
605     ASSERT_TRUE(setData);
606     OH_UdmfRecord* record = OH_UdmfRecord_Create();
607     ASSERT_TRUE(record);
608 
609     OH_UdsPlainText* plainText = OH_UdsPlainText_Create();
610     ASSERT_TRUE(plainText);
611     char content[] = "hello world";
612     OH_UdsPlainText_SetContent(plainText, content);
613 
614     OH_UdsHtml* htmlText = OH_UdsHtml_Create();
615     ASSERT_TRUE(htmlText);
616     char html[] = "<div class='disabled'>hello</div>";
617     OH_UdsHtml_SetContent(htmlText, html);
618 
619     OH_UdmfRecord_AddPlainText(record, plainText);
620     OH_UdmfRecord_AddHtml(record, htmlText);
621     OH_UdmfData_AddRecord(setData, record);
622 
623     OH_Pasteboard_SetData(pasteboard, setData);
624 
625     int status = -1;
626     OH_UdmfData* getData = OH_Pasteboard_GetData(pasteboard, &status);
627     EXPECT_TRUE(status == 0);
628 
629     char type[] = "general.plain-text";
630     bool res = OH_UdmfData_HasType(getData, type);
631     EXPECT_TRUE(res);
632 
633     char type2[] = "general.html";
634     res = OH_UdmfData_HasType(getData, type2);
635     EXPECT_TRUE(res);
636 
637     OH_Pasteboard_Destroy(pasteboard);
638 }
639 
640 /**
641  * @tc.name: OH_Pasteboard_HasData001
642  * @tc.desc: OH_Pasteboard_HasData test valid
643  * @tc.type: FUNC
644  * @tc.require: AROOOH5R5G
645  */
646 HWTEST_F(PasteboardCapiTest, OH_Pasteboard_HasData001, TestSize.Level1)
647 {
648     OH_Pasteboard* pasteboard = OH_Pasteboard_Create();
649     OH_Pasteboard_ClearData(pasteboard);
650     bool res = OH_Pasteboard_HasData(pasteboard);
651     EXPECT_FALSE(res);
652 
653     OH_UdmfData* setData = OH_UdmfData_Create();
654     OH_UdmfRecord* record = OH_UdmfRecord_Create();
655     OH_UdsPlainText* plainText = OH_UdsPlainText_Create();
656     char content[] = "hello world";
657     OH_UdsPlainText_SetContent(plainText, content);
658     OH_UdmfRecord_AddPlainText(record, plainText);
659     OH_UdmfData_AddRecord(setData, record);
660 
661     OH_Pasteboard_SetData(pasteboard, setData);
662 
663     res = OH_Pasteboard_HasData(pasteboard);
664     EXPECT_TRUE(res);
665 
666     OH_Pasteboard_Destroy(pasteboard);
667 }
668 
669 /**
670  * @tc.name: OH_Pasteboard_ClearData001
671  * @tc.desc: OH_Pasteboard_ClearData test valid
672  * @tc.type: FUNC
673  * @tc.require: AROOOH5R5G
674  */
675 HWTEST_F(PasteboardCapiTest, OH_Pasteboard_ClearData001, TestSize.Level1)
676 {
677     OH_Pasteboard* pasteboard = OH_Pasteboard_Create();
678     bool res = OH_Pasteboard_ClearData(pasteboard);
679     EXPECT_EQ(res, ERR_OK);
680 
681     int res2 = OH_Pasteboard_ClearData(nullptr);
682     EXPECT_EQ(res2, ERR_INVALID_PARAMETER);
683 
684     OH_Pasteboard_Destroy(pasteboard);
685 }
686 
687 /**
688  * @tc.name: OH_Pasteboard_SetData001
689  * @tc.desc: OH_Pasteboard_SetData test valid
690  * @tc.type: FUNC
691  * @tc.require: AROOOH5R5G
692  */
693 HWTEST_F(PasteboardCapiTest, OH_Pasteboard_SetData001, TestSize.Level1)
694 {
695     OH_Pasteboard* pasteboard = OH_Pasteboard_Create();
696     OH_UdmfData *setData = OH_UdmfData_Create();
697     OH_UdmfRecord *record = OH_UdmfRecord_Create();
698     OH_UdsPlainText *plainText = OH_UdsPlainText_Create();
699     char content[] = "hello world";
700     OH_UdsPlainText_SetContent(plainText, content);
701     OH_UdmfRecord_AddPlainText(record, plainText);
702     OH_UdmfData_AddRecord(setData, record);
703 
704     bool res = OH_Pasteboard_SetData(pasteboard, setData);
705     EXPECT_EQ(res, ERR_OK);
706 
707     int res1 = OH_Pasteboard_SetData(pasteboard, nullptr);
708     EXPECT_EQ(res1, ERR_INVALID_PARAMETER);
709 
710     int res2 = OH_Pasteboard_SetData(nullptr, setData);
711     EXPECT_EQ(res2, ERR_INVALID_PARAMETER);
712 
713     OH_Pasteboard_Destroy(pasteboard);
714     OH_UdsPlainText_Destroy(plainText);
715     OH_UdmfRecord_Destroy(record);
716     OH_UdmfData_Destroy(setData);
717 }
718 
719 /**
720  * @tc.name: OH_Pasteboard_SetData002
721  * @tc.desc: OH_Pasteboard_SetData test file uri
722  * @tc.type: FUNC
723  */
724 HWTEST_F(PasteboardCapiTest, OH_Pasteboard_SetData002, TestSize.Level1)
725 {
726     const char *uri1 = "file://PasteboardNdkTest/data/storage/el2/base/files/file.txt";
727     OH_Pasteboard* pasteboard = OH_Pasteboard_Create();
728     OH_UdmfData *uData = OH_UdmfData_Create();
729     OH_UdmfRecord *uRecord = OH_UdmfRecord_Create();
730     OH_UdsFileUri *uFileUri = OH_UdsFileUri_Create();
731 
732     OH_UdsFileUri_SetFileUri(uFileUri, uri1);
733     OH_UdmfRecord_AddFileUri(uRecord, uFileUri);
734     OH_UdmfData_AddRecord(uData, uRecord);
735     int32_t ret = OH_Pasteboard_SetData(pasteboard, uData);
736     EXPECT_EQ(ret, ERR_OK);
737 
738     OH_Pasteboard_Destroy(pasteboard);
739     OH_UdsFileUri_Destroy(uFileUri);
740     OH_UdmfRecord_Destroy(uRecord);
741     OH_UdmfData_Destroy(uData);
742 
743     PasteData pasteData;
744     ret = PasteboardClient::GetInstance()->GetPasteData(pasteData);
745     ASSERT_EQ(ret, static_cast<int32_t>(PasteboardError::E_OK));
746 
747     auto record = pasteData.GetRecordAt(0);
748     ASSERT_NE(record, nullptr);
749     auto mimeType = record->GetMimeType();
750     EXPECT_EQ(mimeType, MIMETYPE_TEXT_URI);
751     auto entries = record->GetEntries();
752     ASSERT_EQ(entries.size(), 1);
753     auto entry = entries.front();
754     ASSERT_NE(entry, nullptr);
755     auto utdId = entry->GetUtdId();
756     EXPECT_STREQ(utdId.c_str(), UDMF_META_GENERAL_FILE_URI);
757     mimeType = entry->GetMimeType();
758     EXPECT_STREQ(mimeType.c_str(), MIMETYPE_TEXT_URI);
759     auto uri2 = entry->ConvertToUri();
760     ASSERT_NE(uri2, nullptr);
761     auto uriStr = uri2->ToString();
762     EXPECT_STREQ(uri1, uriStr.c_str());
763 }
764 
765 /**
766  * @tc.name: OH_Pasteboard_SetData003
767  * @tc.desc: OH_Pasteboard_SetData test hyperlink
768  * @tc.type: FUNC
769  */
770 HWTEST_F(PasteboardCapiTest, OH_Pasteboard_SetData003, TestSize.Level1)
771 {
772     const char *link1 = "link://data/storage/el2/base/files/file.txt";
773     OH_Pasteboard* pasteboard = OH_Pasteboard_Create();
774     OH_UdmfData *uData = OH_UdmfData_Create();
775     OH_UdmfRecord *uRecord = OH_UdmfRecord_Create();
776     OH_UdsHyperlink *uHyperlink = OH_UdsHyperlink_Create();
777 
778     OH_UdsHyperlink_SetUrl(uHyperlink, link1);
779     OH_UdmfRecord_AddHyperlink(uRecord, uHyperlink);
780     OH_UdmfData_AddRecord(uData, uRecord);
781     int32_t ret = OH_Pasteboard_SetData(pasteboard, uData);
782     EXPECT_EQ(ret, ERR_OK);
783 
784     OH_Pasteboard_Destroy(pasteboard);
785     OH_UdsHyperlink_Destroy(uHyperlink);
786     OH_UdmfRecord_Destroy(uRecord);
787     OH_UdmfData_Destroy(uData);
788 
789     PasteData pasteData;
790     ret = PasteboardClient::GetInstance()->GetPasteData(pasteData);
791     ASSERT_EQ(ret, static_cast<int32_t>(PasteboardError::E_OK));
792 
793     auto record = pasteData.GetRecordAt(0);
794     ASSERT_NE(record, nullptr);
795     auto mimeType = record->GetMimeType();
796     EXPECT_EQ(mimeType, MIMETYPE_TEXT_PLAIN);
797     auto entry = record->GetEntryByMimeType(MIMETYPE_TEXT_PLAIN);
798     ASSERT_NE(entry, nullptr);
799     auto utdId = entry->GetUtdId();
800     EXPECT_STREQ(utdId.c_str(), UDMF_META_HYPERLINK);
801     mimeType = entry->GetMimeType();
802     EXPECT_STREQ(mimeType.c_str(), MIMETYPE_TEXT_PLAIN);
803     auto link2 = entry->ConvertToPlainText();
804     ASSERT_NE(link2, nullptr);
805     EXPECT_STREQ(link1, link2->c_str());
806 }
807 
808 /**
809  * @tc.name: OH_Pasteboard_GetData001
810  * @tc.desc: OH_Pasteboard_GetData test valid
811  * @tc.type: FUNC
812  * @tc.require: AROOOH5R5G
813  */
814 HWTEST_F(PasteboardCapiTest, OH_Pasteboard_GetData001, TestSize.Level1)
815 {
816     OH_Pasteboard* pasteboard = OH_Pasteboard_Create();
817     OH_UdmfData* setData = OH_UdmfData_Create();
818     OH_UdmfRecord* record = OH_UdmfRecord_Create();
819     OH_UdsPlainText* plainText = OH_UdsPlainText_Create();
820     char content[] = "hello world";
821     OH_UdsPlainText_SetContent(plainText, content);
822     OH_UdmfRecord_AddPlainText(record, plainText);
823     OH_UdmfData_AddRecord(setData, record);
824 
825     int res = OH_Pasteboard_SetData(pasteboard, setData);
826     EXPECT_EQ(res, ERR_OK);
827 
828     int status = -1;
829     OH_UdmfData* getData = OH_Pasteboard_GetData(pasteboard, &status);
830     EXPECT_EQ(status, ERR_OK);
831     EXPECT_NE(getData, nullptr);
832 
833     unsigned int count = 0;
834     OH_UdmfRecord **getRecords = OH_UdmfData_GetRecords(getData, &count);
835     EXPECT_EQ(count, 1);
836     OH_UdsPlainText *getPlainText = OH_UdsPlainText_Create();
837     OH_UdmfRecord_GetPlainText(getRecords[0], getPlainText);
838     const char *getContent = OH_UdsPlainText_GetContent(getPlainText);
839     EXPECT_EQ(strcmp(getContent, content), 0);
840 
841     OH_Pasteboard_Destroy(pasteboard);
842     OH_UdsPlainText_Destroy(plainText);
843     OH_UdsPlainText_Destroy(getPlainText);
844     OH_UdmfRecord_Destroy(record);
845     OH_UdmfData_Destroy(setData);
846     OH_UdmfData_Destroy(getData);
847 }
848 
849 /**
850  * @tc.name: OH_Pasteboard_GetData002
851  * @tc.desc: OH_Pasteboard_GetData test valid
852  * @tc.type: FUNC
853  * @tc.require: AROOOH5R5G
854  */
855 HWTEST_F(PasteboardCapiTest, OH_Pasteboard_GetData002, TestSize.Level1)
856 {
857     OH_Pasteboard* pasteboard = OH_Pasteboard_Create();
858     OH_UdmfData* setData = OH_UdmfData_Create();
859     OH_UdmfRecord* record = OH_UdmfRecord_Create();
860     OH_UdmfRecordProvider* provider = OH_UdmfRecordProvider_Create();
861     EXPECT_NE(provider, nullptr);
862     OH_UdmfRecordProvider_SetData(provider, static_cast<void *>(record), GetDataCallback, ContextFinalizeFunc);
863     OH_UdmfData_AddRecord(setData, record);
864 
865     const char* types[3] = { "general.plain-text", "general.hyperlink", "general.html" };
866     OH_UdmfRecord_SetProvider(record, types, 3, provider);
867     int res = OH_Pasteboard_SetData(pasteboard, setData);
868     EXPECT_EQ(res, ERR_OK);
869 
870     int status = -1;
871     OH_UdmfData* getData = OH_Pasteboard_GetData(pasteboard, &status);
872     EXPECT_EQ(status, ERR_OK);
873     EXPECT_NE(getData, nullptr);
874 
875     unsigned int count = 0;
876     OH_UdmfRecord **getRecords = OH_UdmfData_GetRecords(getData, &count);
877     EXPECT_EQ(count, 1);
878     OH_UdsPlainText *getPlainText = OH_UdsPlainText_Create();
879     OH_UdmfRecord_GetPlainText(getRecords[0], getPlainText);
880     const char *getContent = OH_UdsPlainText_GetContent(getPlainText);
881     EXPECT_EQ(strcmp(getContent, PLAINTEXT_CONTENT), 0);
882 
883     OH_UdsHyperlink *getHyperLink = OH_UdsHyperlink_Create();
884     OH_UdmfRecord_GetHyperlink(getRecords[0], getHyperLink);
885     const char *getUrl = OH_UdsHyperlink_GetUrl(getHyperLink);
886     EXPECT_EQ(strcmp(getUrl, HYPERLINK_URL), 0);
887     OH_Pasteboard_Destroy(pasteboard);
888     OH_UdsPlainText_Destroy(getPlainText);
889     OH_UdsHyperlink_Destroy(getHyperLink);
890     OH_UdmfRecord_Destroy(record);
891     OH_UdmfData_Destroy(setData);
892     OH_UdmfData_Destroy(getData);
893 }
894 
895 /**
896  * @tc.name: OH_Pasteboard_GetData003
897  * @tc.desc: OH_Pasteboard_GetData test valid
898  * @tc.type: FUNC
899  * @tc.require: AROOOH5R5G
900  */
901 HWTEST_F(PasteboardCapiTest, OH_Pasteboard_GetData003, TestSize.Level1)
902 {
903     char typeId[] = "ApplicationDefined-myType";
904     unsigned char entry[] = "CreateGeneralRecord1";
905     unsigned int count = sizeof(entry);
906     OH_UdmfRecord *record = OH_UdmfRecord_Create();
907     int addRes1 = OH_UdmfRecord_AddGeneralEntry(record, typeId, entry, count);
908     EXPECT_EQ(addRes1, ERR_OK);
909 
910     OH_UdmfData* setData = OH_UdmfData_Create();
911     OH_UdmfData_AddRecord(setData, record);
912     OH_Pasteboard* pasteboard = OH_Pasteboard_Create();
913     int res = OH_Pasteboard_SetData(pasteboard, setData);
914     EXPECT_EQ(res, ERR_OK);
915 
916     int status = -1;
917     OH_UdmfData* getData = OH_Pasteboard_GetData(pasteboard, &status);
918     EXPECT_EQ(status, ERR_OK);
919     EXPECT_NE(getData, nullptr);
920 
921     unsigned int getrecordCount = 0;
922     OH_UdmfRecord **getRecords = OH_UdmfData_GetRecords(getData, &getrecordCount);
923     EXPECT_EQ(getrecordCount, 1);
924 
925     unsigned int getCount = 0;
926     unsigned char *getEntry;
927     int getRes = OH_UdmfRecord_GetGeneralEntry(getRecords[0], typeId, &getEntry, &getCount);
928     EXPECT_EQ(getRes, ERR_OK);
929     EXPECT_EQ(getCount, count);
930     EXPECT_EQ(memcmp(entry, getEntry, getCount), 0);
931 
932     OH_Pasteboard_Destroy(pasteboard);
933     OH_UdmfRecord_Destroy(record);
934     OH_UdmfData_Destroy(setData);
935     OH_UdmfData_Destroy(getData);
936 }
937 
938 /**
939  * @tc.name: OH_Pasteboard_GetData004
940  * @tc.desc: OH_Pasteboard_GetData test data type
941  * @tc.type: FUNC
942  */
943 HWTEST_F(PasteboardCapiTest, OH_Pasteboard_GetData004, TestSize.Level1)
944 {
945     PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "OH_Pasteboard_GetData004 start");
946     OH_Pasteboard* pasteboard = OH_Pasteboard_Create();
947     OH_UdmfData* setData = OH_UdmfData_Create();
948     OH_UdmfRecord* record = OH_UdmfRecord_Create();
949 
950     OH_UdmfRecordProvider* provider = OH_UdmfRecordProvider_Create();
951     EXPECT_NE(provider, nullptr);
952     OH_UdmfRecordProvider_SetData(provider, static_cast<void *>(record), GetDataCallback, ContextFinalizeFunc);
953 
954     const char* types[3] = { "general.plain-text", "general.hyperlink", "general.html" };
955     OH_UdmfRecord_SetProvider(record, types, 3, provider);
956     OH_UdmfData_AddRecord(setData, record);
957 
958     int res = OH_Pasteboard_SetData(pasteboard, setData);
959     EXPECT_EQ(res, ERR_OK);
960 
961     PasteData pasteData;
962     auto ret = PasteboardClient::GetInstance()->GetPasteData(pasteData);
963     ASSERT_TRUE(ret == static_cast<int32_t>(PasteboardError::E_OK));
964 
965     auto record1 = pasteData.GetRecordAt(0);
966     auto mimeType = record1->GetMimeType();
967     EXPECT_EQ(mimeType, MIMETYPE_TEXT_PLAIN);
968 
969     OH_Pasteboard_Destroy(pasteboard);
970     OH_UdmfRecord_Destroy(record);
971     OH_UdmfData_Destroy(setData);
972     OH_UdmfRecordProvider_Destroy(provider);
973     PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "OH_Pasteboard_GetData004 end");
974 }
975 
976 /**
977  * @tc.name: OH_Pasteboard_GetData005
978  * @tc.desc: OH_Pasteboard_GetData test data type
979  * @tc.type: FUNC
980  */
981 HWTEST_F(PasteboardCapiTest, OH_Pasteboard_GetData005, TestSize.Level1)
982 {
983     PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "OH_Pasteboard_GetData005 start");
984     OH_Pasteboard* pasteboard = OH_Pasteboard_Create();
985     OH_UdmfData* setData = OH_UdmfData_Create();
986     OH_UdmfRecord* record = OH_UdmfRecord_Create();
987 
988     OH_UdmfRecordProvider* provider = OH_UdmfRecordProvider_Create();
989     EXPECT_NE(provider, nullptr);
990     OH_UdmfRecordProvider_SetData(provider, static_cast<void *>(record), GetDataCallback, ContextFinalizeFunc);
991     const char* types[3] = { "general.plain-text", "general.hyperlink", "general.html" };
992     OH_UdmfRecord_SetProvider(record, types, 3, provider);
993 
994     OH_UdsHyperlink *link = OH_UdsHyperlink_Create();
995     OH_UdsHyperlink_SetUrl(link, HYPERLINK_URL);
996     OH_UdmfRecord_AddHyperlink(record, link);
997 
998     OH_UdmfData_AddRecord(setData, record);
999     auto res = OH_Pasteboard_SetData(pasteboard, setData);
1000     EXPECT_EQ(res, ERR_OK);
1001 
1002     PasteData pasteData;
1003     auto ret = PasteboardClient::GetInstance()->GetPasteData(pasteData);
1004     ASSERT_TRUE(ret == static_cast<int32_t>(PasteboardError::E_OK));
1005 
1006     auto record1 = pasteData.GetRecordAt(0);
1007     auto mimeType = record1->GetMimeType();
1008     EXPECT_EQ(mimeType, MIMETYPE_TEXT_PLAIN);
1009 
1010     auto text = record1->GetPlainTextV0();
1011     EXPECT_EQ(strcmp(text->c_str(), PLAINTEXT_CONTENT), 0);
1012 
1013     OH_Pasteboard_Destroy(pasteboard);
1014     OH_UdmfRecord_Destroy(record);
1015     OH_UdmfData_Destroy(setData);
1016     OH_UdsHyperlink_Destroy(link);
1017     OH_UdmfRecordProvider_Destroy(provider);
1018     PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "OH_Pasteboard_GetData005 end");
1019 }
1020 
1021 /**
1022  * @tc.name: OH_Pasteboard_GetData006
1023  * @tc.desc: OH_Pasteboard_GetData test data type
1024  * @tc.type: FUNC
1025  */
1026 HWTEST_F(PasteboardCapiTest, OH_Pasteboard_GetData006, TestSize.Level1)
1027 {
1028     PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "OH_Pasteboard_GetData006 start");
1029     OH_Pasteboard* pasteboard = OH_Pasteboard_Create();
1030     OH_UdmfData* setData = OH_UdmfData_Create();
1031     OH_UdmfRecord* record = OH_UdmfRecord_Create();
1032 
1033     OH_UdsHtml *html = OH_UdsHtml_Create();
1034     OH_UdsHtml_SetContent(html, HTML_TEXT);
1035     OH_UdmfRecord_AddHtml(record, html);
1036 
1037     OH_UdmfRecordProvider* provider = OH_UdmfRecordProvider_Create();
1038     EXPECT_NE(provider, nullptr);
1039     OH_UdmfRecordProvider_SetData(provider, static_cast<void *>(record), GetDataCallback, ContextFinalizeFunc);
1040     const char* types[3] = { "general.plain-text", "general.hyperlink", "general.html" };
1041     OH_UdmfRecord_SetProvider(record, types, 3, provider);
1042 
1043     OH_UdmfData_AddRecord(setData, record);
1044     bool res = OH_Pasteboard_SetData(pasteboard, setData);
1045     EXPECT_EQ(res, ERR_OK);
1046 
1047     PasteData pasteData;
1048     auto ret = PasteboardClient::GetInstance()->GetPasteData(pasteData);
1049     ASSERT_TRUE(ret == static_cast<int32_t>(PasteboardError::E_OK));
1050 
1051     auto record1 = pasteData.GetRecordAt(0);
1052     auto mimeType = record1->GetMimeType();
1053     EXPECT_EQ(mimeType, MIMETYPE_TEXT_HTML);
1054 
1055     auto html1 = record1->GetHtmlTextV0();
1056     EXPECT_EQ(strcmp(html1->c_str(), HTML_TEXT), 0);
1057 
1058     OH_Pasteboard_Destroy(pasteboard);
1059     OH_UdmfRecord_Destroy(record);
1060     OH_UdmfData_Destroy(setData);
1061     OH_UdmfRecordProvider_Destroy(provider);
1062     PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "OH_Pasteboard_GetData006 end");
1063 }
1064 
1065 /**
1066  * @tc.name: OH_Pasteboard_GetData007
1067  * @tc.desc: OH_Pasteboard_GetData test data type
1068  * @tc.type: FUNC
1069  */
1070 HWTEST_F(PasteboardCapiTest, OH_Pasteboard_GetData007, TestSize.Level1)
1071 {
1072     PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "OH_Pasteboard_GetData007 start");
1073     std::string plainText = "helloWorld";
1074     auto newData = PasteboardClient::GetInstance()->CreatePlainTextData(plainText);
1075     auto ret = PasteboardClient::GetInstance()->SetPasteData(*newData);
1076     ASSERT_TRUE(ret == static_cast<int32_t>(PasteboardError::E_OK));
1077 
1078     OH_Pasteboard* pasteboard = OH_Pasteboard_Create();
1079     int status = -1;
1080     OH_UdmfData* getData = OH_Pasteboard_GetData(pasteboard, &status);
1081     EXPECT_EQ(status, ERR_OK);
1082     EXPECT_NE(getData, nullptr);
1083 
1084     unsigned int getrecordCount = 0;
1085     OH_UdmfRecord **getRecords = OH_UdmfData_GetRecords(getData, &getrecordCount);
1086     EXPECT_EQ(getrecordCount, 1);
1087     OH_UdsPlainText *getPlainText = OH_UdsPlainText_Create();
1088     OH_UdmfRecord_GetPlainText(getRecords[0], getPlainText);
1089     const char *getContent = OH_UdsPlainText_GetContent(getPlainText);
1090     EXPECT_STREQ(getContent, plainText.c_str());
1091 
1092     OH_Pasteboard_Destroy(pasteboard);
1093     PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "OH_Pasteboard_GetData007 end");
1094 }
1095 
1096 /**
1097  * @tc.name: OH_Pasteboard_GetDataWithMultiAttributes001
1098  * @tc.desc: should get html & text when set html & text with https uri without tag
1099  * @tc.type: FUNC
1100  */
1101 HWTEST_F(PasteboardCapiTest, OH_Pasteboard_GetDataWithMultiAttributes001, TestSize.Level1)
1102 {
1103     const char *htmlContent = "<p>Hello world!<img src=\"https://storage/local/files/Images/hello.png\"/></p>";
1104     const char *plainContent = "Hello world!";
1105 
1106     OH_UdsHtml *uHtml = OH_UdsHtml_Create();
1107     OH_UdsHtml_SetContent(uHtml, htmlContent);
1108     OH_UdsHtml_SetPlainContent(uHtml, plainContent);
1109 
1110     OH_UdmfRecord *uRecord = OH_UdmfRecord_Create();
1111     OH_UdmfRecord_AddHtml(uRecord, uHtml);
1112     OH_UdsHtml_Destroy(uHtml);
1113     uHtml = nullptr;
1114 
1115     OH_UdmfData *uData = OH_UdmfData_Create();
1116     OH_UdmfData_AddRecord(uData, uRecord);
1117 
1118     OH_Pasteboard *pasteboard = OH_Pasteboard_Create();
1119     int ret = OH_Pasteboard_SetData(pasteboard, uData);
1120     OH_UdmfRecord_Destroy(uRecord);
1121     OH_UdmfData_Destroy(uData);
1122     uData = nullptr;
1123     uRecord = nullptr;
1124     EXPECT_EQ(ret, ERR_OK);
1125 
1126     ret = -1;
1127     uData = OH_Pasteboard_GetData(pasteboard, &ret);
1128     OH_Pasteboard_Destroy(pasteboard);
1129     pasteboard = nullptr;
1130     EXPECT_EQ(ret, ERR_OK);
1131     EXPECT_NE(uData, nullptr);
1132 
1133     unsigned int count = 0;
1134     OH_UdmfRecord **records = OH_UdmfData_GetRecords(uData, &count);
1135     EXPECT_EQ(count, 1);
1136     EXPECT_NE(records, nullptr);
1137 
1138     if (count == 1 && records != nullptr) {
1139         uHtml = OH_UdsHtml_Create();
1140         OH_UdmfRecord_GetHtml(records[0], uHtml);
1141 
1142         const char *htmlText = OH_UdsHtml_GetContent(uHtml);
1143         const char *plainText = OH_UdsHtml_GetPlainContent(uHtml);
1144         EXPECT_STREQ(htmlText, htmlContent);
1145         EXPECT_STREQ(plainText, plainContent);
1146 
1147         OH_UdsHtml_Destroy(uHtml);
1148         uHtml = nullptr;
1149     }
1150 
1151     OH_UdmfData_Destroy(uData);
1152     uData = nullptr;
1153 }
1154 
1155 /**
1156  * @tc.name: OH_Pasteboard_GetDataWithMultiAttributes002
1157  * @tc.desc: should get html & text when set html & text with https uri and tag
1158  * @tc.type: FUNC
1159  */
1160 HWTEST_F(PasteboardCapiTest, OH_Pasteboard_GetDataWithMultiAttributes002, TestSize.Level1)
1161 {
1162     const char *htmlContent = "<p>Hello world!<img src=\"https://storage/local/files/Images/hello.png\"/></p>";
1163     const char *plainContent = "Hello world!";
1164 
1165     OH_UdsHtml *uHtml = OH_UdsHtml_Create();
1166     OH_UdsHtml_SetContent(uHtml, htmlContent);
1167     OH_UdsHtml_SetPlainContent(uHtml, plainContent);
1168 
1169     OH_UdmfRecord *uRecord = OH_UdmfRecord_Create();
1170     OH_UdmfRecord_AddHtml(uRecord, uHtml);
1171     OH_UdsHtml_Destroy(uHtml);
1172     uHtml = nullptr;
1173 
1174     OH_UdmfData *uData = OH_UdmfData_Create();
1175     OH_UdmfData_AddRecord(uData, uRecord);
1176 
1177     OH_UdmfProperty *uProp = OH_UdmfProperty_Create(uData);
1178     int ret = OH_UdmfProperty_SetTag(uProp, PasteData::WEBVIEW_PASTEDATA_TAG.c_str()); // set webview tag
1179     EXPECT_EQ(ret, ERR_OK);
1180 
1181     OH_Pasteboard *pasteboard = OH_Pasteboard_Create();
1182     ret = OH_Pasteboard_SetData(pasteboard, uData);
1183     OH_UdmfRecord_Destroy(uRecord);
1184     OH_UdmfData_Destroy(uData);
1185     uData = nullptr;
1186     uRecord = nullptr;
1187     EXPECT_EQ(ret, ERR_OK);
1188 
1189     ret = -1;
1190     uData = OH_Pasteboard_GetData(pasteboard, &ret);
1191     OH_Pasteboard_Destroy(pasteboard);
1192     pasteboard = nullptr;
1193     EXPECT_EQ(ret, ERR_OK);
1194     EXPECT_NE(uData, nullptr);
1195 
1196     unsigned int count = 0;
1197     OH_UdmfRecord **records = OH_UdmfData_GetRecords(uData, &count);
1198     EXPECT_EQ(count, 1);
1199     EXPECT_NE(records, nullptr);
1200 
1201     if (count == 1 && records != nullptr) {
1202         uHtml = OH_UdsHtml_Create();
1203         OH_UdmfRecord_GetHtml(records[0], uHtml);
1204 
1205         const char *htmlText = OH_UdsHtml_GetContent(uHtml);
1206         const char *plainText = OH_UdsHtml_GetPlainContent(uHtml);
1207         EXPECT_STREQ(htmlText, htmlContent);
1208         EXPECT_STREQ(plainText, plainContent);
1209 
1210         OH_UdsHtml_Destroy(uHtml);
1211         uHtml = nullptr;
1212     }
1213 
1214     OH_UdmfData_Destroy(uData);
1215     uData = nullptr;
1216 }
1217 
1218 /**
1219  * @tc.name: OH_Pasteboard_GetDataWithMultiAttributes003
1220  * @tc.desc: should get html & text when set html & text with file uri without tag
1221  * @tc.type: FUNC
1222  */
1223 HWTEST_F(PasteboardCapiTest, OH_Pasteboard_GetDataWithMultiAttributes003, TestSize.Level1)
1224 {
1225     const char *htmlContent = "<p>Hello world!<img src=\"file:///storage/local/files/Images/hello.png\"/></p>";
1226     const char *plainContent = "Hello world!";
1227 
1228     OH_UdsHtml *uHtml = OH_UdsHtml_Create();
1229     OH_UdsHtml_SetContent(uHtml, htmlContent);
1230     OH_UdsHtml_SetPlainContent(uHtml, plainContent);
1231 
1232     OH_UdmfRecord *uRecord = OH_UdmfRecord_Create();
1233     OH_UdmfRecord_AddHtml(uRecord, uHtml);
1234     OH_UdsHtml_Destroy(uHtml);
1235     uHtml = nullptr;
1236 
1237     OH_UdmfData *uData = OH_UdmfData_Create();
1238     OH_UdmfData_AddRecord(uData, uRecord);
1239 
1240     OH_Pasteboard *pasteboard = OH_Pasteboard_Create();
1241     int ret = OH_Pasteboard_SetData(pasteboard, uData);
1242     OH_UdmfRecord_Destroy(uRecord);
1243     OH_UdmfData_Destroy(uData);
1244     uData = nullptr;
1245     uRecord = nullptr;
1246     EXPECT_EQ(ret, ERR_OK);
1247 
1248     ret = -1;
1249     uData = OH_Pasteboard_GetData(pasteboard, &ret);
1250     OH_Pasteboard_Destroy(pasteboard);
1251     pasteboard = nullptr;
1252     EXPECT_EQ(ret, ERR_OK);
1253     EXPECT_NE(uData, nullptr);
1254 
1255     unsigned int count = 0;
1256     OH_UdmfRecord **records = OH_UdmfData_GetRecords(uData, &count);
1257     EXPECT_EQ(count, 1);
1258     EXPECT_NE(records, nullptr);
1259 
1260     if (count == 1 && records != nullptr) {
1261         uHtml = OH_UdsHtml_Create();
1262         OH_UdmfRecord_GetHtml(records[0], uHtml);
1263 
1264         const char *htmlText = OH_UdsHtml_GetContent(uHtml);
1265         const char *plainText = OH_UdsHtml_GetPlainContent(uHtml);
1266         EXPECT_NE(htmlText, nullptr);
1267         EXPECT_STREQ(plainText, plainContent);
1268 
1269         OH_UdsHtml_Destroy(uHtml);
1270         uHtml = nullptr;
1271     }
1272 
1273     OH_UdmfData_Destroy(uData);
1274     uData = nullptr;
1275 }
1276 
1277 /**
1278  * @tc.name: OH_Pasteboard_GetDataWithMultiAttributes004
1279  * @tc.desc: should get html & text when set html & text with file uri and tag
1280  * @tc.type: FUNC
1281  */
1282 HWTEST_F(PasteboardCapiTest, OH_Pasteboard_GetDataWithMultiAttributes004, TestSize.Level1)
1283 {
1284     const char *htmlContent = "<p>Hello world!<img src=\"file:///storage/local/files/Images/hello.png\"/></p>";
1285     const char *plainContent = "Hello world!";
1286 
1287     OH_UdsHtml *uHtml = OH_UdsHtml_Create();
1288     OH_UdsHtml_SetContent(uHtml, htmlContent);
1289     OH_UdsHtml_SetPlainContent(uHtml, plainContent);
1290 
1291     OH_UdmfRecord *uRecord = OH_UdmfRecord_Create();
1292     OH_UdmfRecord_AddHtml(uRecord, uHtml);
1293     OH_UdsHtml_Destroy(uHtml);
1294     uHtml = nullptr;
1295 
1296     OH_UdmfData *uData = OH_UdmfData_Create();
1297     OH_UdmfData_AddRecord(uData, uRecord);
1298 
1299     OH_UdmfProperty *uProp = OH_UdmfProperty_Create(uData);
1300     int ret = OH_UdmfProperty_SetTag(uProp, PasteData::WEBVIEW_PASTEDATA_TAG.c_str()); // set webview tag
1301     EXPECT_EQ(ret, ERR_OK);
1302 
1303     OH_Pasteboard *pasteboard = OH_Pasteboard_Create();
1304     ret = OH_Pasteboard_SetData(pasteboard, uData);
1305     OH_UdmfRecord_Destroy(uRecord);
1306     OH_UdmfData_Destroy(uData);
1307     uData = nullptr;
1308     uRecord = nullptr;
1309     EXPECT_EQ(ret, ERR_OK);
1310 
1311     ret = -1;
1312     uData = OH_Pasteboard_GetData(pasteboard, &ret);
1313     OH_Pasteboard_Destroy(pasteboard);
1314     pasteboard = nullptr;
1315     EXPECT_EQ(ret, ERR_OK);
1316     EXPECT_NE(uData, nullptr);
1317 
1318     unsigned int count = 0;
1319     OH_UdmfRecord **records = OH_UdmfData_GetRecords(uData, &count);
1320     EXPECT_EQ(count, 1);
1321     EXPECT_NE(records, nullptr);
1322 
1323     if (count == 1 && records != nullptr) {
1324         uHtml = OH_UdsHtml_Create();
1325         OH_UdmfRecord_GetHtml(records[0], uHtml);
1326 
1327         const char *htmlText = OH_UdsHtml_GetContent(uHtml);
1328         const char *plainText = OH_UdsHtml_GetPlainContent(uHtml);
1329         EXPECT_NE(htmlText, nullptr);
1330         EXPECT_STREQ(plainText, plainContent);
1331 
1332         OH_UdsHtml_Destroy(uHtml);
1333         uHtml = nullptr;
1334     }
1335 
1336     OH_UdmfData_Destroy(uData);
1337     uData = nullptr;
1338 }
1339 
OH_Pasteboard_ProgressListener(Pasteboard_ProgressInfo * progressInfo)1340 void OH_Pasteboard_ProgressListener(Pasteboard_ProgressInfo *progressInfo)
1341 {
1342     int percentage = OH_Pasteboard_ProgressInfo_GetProgress(progressInfo);
1343     printf("percentage = %d\n", percentage);
1344 }
1345 
1346 /**
1347  * @tc.name: OH_Pasteboard_GetDataWithProgress001
1348  * @tc.desc: should get html & text when set html & text with https uri and tag
1349  * @tc.type: FUNC
1350  */
1351 HWTEST_F(PasteboardCapiTest, OH_Pasteboard_GetDataWithProgress001, TestSize.Level1)
1352 {
1353     int status = -1;
1354     OH_Pasteboard* pasteboard = OH_Pasteboard_Create();
1355     OH_UdmfData* getData = OH_Pasteboard_GetDataWithProgress(pasteboard, nullptr, &status);
1356     EXPECT_EQ(status, ERR_INVALID_PARAMETER);
1357     EXPECT_EQ(getData, nullptr);
1358 
1359     g_params = OH_Pasteboard_GetDataParams_Create();
1360     EXPECT_NE(g_params, nullptr);
1361     getData = OH_Pasteboard_GetDataWithProgress(nullptr, g_params, &status);
1362     EXPECT_EQ(status, ERR_INVALID_PARAMETER);
1363     EXPECT_EQ(getData, nullptr);
1364     getData = OH_Pasteboard_GetDataWithProgress(pasteboard, g_params, nullptr);
1365     EXPECT_EQ(status, ERR_INVALID_PARAMETER);
1366     EXPECT_EQ(getData, nullptr);
1367     OH_Pasteboard_Destroy(pasteboard);
1368     OH_Pasteboard_GetDataParams_Destroy(g_params);
1369 }
1370 
1371 /**
1372  * @tc.name: OH_Pasteboard_GetDataWithProgress002
1373  * @tc.desc: should get html & text when set html & text with https uri and tag
1374  * @tc.type: FUNC
1375  */
1376 HWTEST_F(PasteboardCapiTest, OH_Pasteboard_GetDataWithProgress002, TestSize.Level1)
1377 {
1378     int status = -1;
1379     OH_Pasteboard *pasteboard = OH_Pasteboard_Create();
1380     g_params = OH_Pasteboard_GetDataParams_Create();
1381     EXPECT_NE(g_params, nullptr);
1382     const char *uri = "/data/storage/el2/base/haps/entry/files/data/storage/el2/base/haps/entry/"
1383         "files/data/storage/el2/base/haps/entry/files/data/storage/el2/base/haps/entry/files/data/"
1384         "storage/el2/base/haps/entry/files/data/storage/el2/base/haps/entry/files/haps/entry/files/dstFile.txt";
1385     OH_Pasteboard_GetDataParams_SetProgressIndicator(g_params, PASTEBOARD_NONE);
1386     OH_Pasteboard_GetDataParams_SetDestUri(g_params, uri, strlen(uri));
1387     OH_Pasteboard_GetDataParams_SetFileConflictOptions(g_params, PASTEBOARD_SKIP);
1388     OH_Pasteboard_GetDataParams_SetProgressListener(g_params, OH_Pasteboard_ProgressListener);
1389     OH_UdmfData* getData = OH_Pasteboard_GetDataWithProgress(pasteboard, g_params, &status);
1390     EXPECT_EQ(status, ERR_INVALID_PARAMETER);
1391     EXPECT_EQ(getData, nullptr);
1392     OH_Pasteboard_Destroy(pasteboard);
1393     OH_Pasteboard_GetDataParams_Destroy(g_params);
1394 }
1395 
1396 /**
1397  * @tc.name: OH_Pasteboard_GetDataWithProgress003
1398  * @tc.desc: should get html & text when set html & text with https uri and tag
1399  * @tc.type: FUNC
1400  */
1401 HWTEST_F(PasteboardCapiTest, OH_Pasteboard_GetDataWithProgress003, TestSize.Level1)
1402 {
1403     int status = -1;
1404     OH_Pasteboard* pasteboard = OH_Pasteboard_Create();
1405     g_params = OH_Pasteboard_GetDataParams_Create();
1406     EXPECT_NE(g_params, nullptr);
1407     const char *uri = "/data/storage/el2/base/haps/entry/files/dstFile.txt";
1408     OH_Pasteboard_GetDataParams_SetProgressIndicator(g_params, PASTEBOARD_NONE);
1409     OH_Pasteboard_GetDataParams_SetDestUri(g_params, uri, uriLen);
1410     OH_Pasteboard_GetDataParams_SetFileConflictOptions(g_params, PASTEBOARD_SKIP);
1411     OH_Pasteboard_GetDataParams_SetProgressListener(g_params, OH_Pasteboard_ProgressListener);
1412     OH_UdmfData* getData = OH_Pasteboard_GetDataWithProgress(pasteboard, g_params, &status);
1413     EXPECT_EQ(status, ERR_INVALID_PARAMETER);
1414     EXPECT_EQ(getData, nullptr);
1415     OH_Pasteboard_Destroy(pasteboard);
1416     OH_Pasteboard_GetDataParams_Destroy(g_params);
1417 }
1418 
1419 /**
1420  * @tc.name: OH_Pasteboard_GetDataWithProgress004
1421  * @tc.desc: should get html & text when set html & text with https uri and tag
1422  * @tc.type: FUNC
1423  */
1424 HWTEST_F(PasteboardCapiTest, OH_Pasteboard_GetDataWithProgress004, TestSize.Level1)
1425 {
1426     OH_Pasteboard* pasteboard = OH_Pasteboard_Create();
1427     int32_t ret = OH_Pasteboard_ClearData(pasteboard);
1428     EXPECT_EQ(ret, ERR_OK);
1429     g_params = OH_Pasteboard_GetDataParams_Create();
1430     EXPECT_NE(g_params, nullptr);
1431     const char *uri = "/data/storage/el2/base/haps/entry/files/dstFile.txt";
1432     OH_Pasteboard_GetDataParams_SetProgressIndicator(g_params, PASTEBOARD_NONE);
1433     OH_Pasteboard_GetDataParams_SetDestUri(g_params, uri, strlen(uri));
1434     OH_Pasteboard_GetDataParams_SetFileConflictOptions(g_params, PASTEBOARD_SKIP);
1435     OH_Pasteboard_GetDataParams_SetProgressListener(g_params, OH_Pasteboard_ProgressListener);
1436     int status = -1;
1437     OH_UdmfData* getData = OH_Pasteboard_GetDataWithProgress(pasteboard, g_params, &status);
1438     EXPECT_EQ(status, ERR_PASTEBOARD_GET_DATA_FAILED);
1439     EXPECT_EQ(getData, nullptr);
1440     OH_Pasteboard_Destroy(pasteboard);
1441     OH_Pasteboard_GetDataParams_Destroy(g_params);
1442 }
1443 
1444 /**
1445  * @tc.name: OH_Pasteboard_GetDataWithProgress005
1446  * @tc.desc: should get html & text when set html & text with https uri and tag
1447  * @tc.type: FUNC
1448  */
1449 HWTEST_F(PasteboardCapiTest, OH_Pasteboard_GetDataWithProgress005, TestSize.Level1)
1450 {
1451     std::string plainText = "helloWorld";
1452     auto newData = PasteboardClient::GetInstance()->CreatePlainTextData(plainText);
1453     auto ret = PasteboardClient::GetInstance()->SetPasteData(*newData);
1454     EXPECT_EQ(ret, static_cast<int32_t>(PasteboardError::E_OK));
1455 
1456     OH_Pasteboard* pasteboard = OH_Pasteboard_Create();
1457     g_params = OH_Pasteboard_GetDataParams_Create();
1458     EXPECT_NE(g_params, nullptr);
1459     OH_Pasteboard_GetDataParams_SetProgressIndicator(g_params, PASTEBOARD_NONE);
1460     OH_Pasteboard_GetDataParams_SetFileConflictOptions(g_params, PASTEBOARD_OVERWRITE);
1461     OH_Pasteboard_GetDataParams_SetProgressListener(g_params, OH_Pasteboard_ProgressListener);
1462     int status = -1;
1463     OH_UdmfData* getData = OH_Pasteboard_GetDataWithProgress(pasteboard, g_params, &status);
1464     EXPECT_EQ(status, ERR_OK);
1465     EXPECT_NE(getData, nullptr);
1466     OH_Pasteboard_Destroy(pasteboard);
1467     OH_Pasteboard_GetDataParams_Destroy(g_params);
1468 }
1469 
Pasteboard_ProgressListener(Pasteboard_ProgressInfo * progressInfo)1470 void Pasteboard_ProgressListener(Pasteboard_ProgressInfo *progressInfo)
1471 {
1472     int percentage = OH_Pasteboard_ProgressInfo_GetProgress(progressInfo);
1473     printf("percentage = %d\n", percentage);
1474     if (g_params != nullptr) {
1475         OH_Pasteboard_ProgressCancel(g_params);
1476     }
1477 }
1478 
1479 /**
1480  * @tc.name: OH_Pasteboard_GetDataWithProgress006
1481  * @tc.desc: should get html & text when set html & text with https uri and tag
1482  * @tc.type: FUNC
1483  */
1484 HWTEST_F(PasteboardCapiTest, OH_Pasteboard_GetDataWithProgress006, TestSize.Level1)
1485 {
1486     std::string plainText = "helloWorld";
1487     auto newData = PasteboardClient::GetInstance()->CreatePlainTextData(plainText);
1488     auto ret = PasteboardClient::GetInstance()->SetPasteData(*newData);
1489     EXPECT_EQ(ret, static_cast<int32_t>(PasteboardError::E_OK));
1490 
1491     OH_Pasteboard* pasteboard = OH_Pasteboard_Create();
1492     g_params = OH_Pasteboard_GetDataParams_Create();
1493     EXPECT_NE(g_params, nullptr);
1494     OH_Pasteboard_GetDataParams_SetProgressIndicator(g_params, PASTEBOARD_NONE);
1495     OH_Pasteboard_GetDataParams_SetFileConflictOptions(g_params, PASTEBOARD_OVERWRITE);
1496     OH_Pasteboard_GetDataParams_SetProgressListener(g_params, Pasteboard_ProgressListener);
1497     int status = -1;
1498     OH_UdmfData* getData = OH_Pasteboard_GetDataWithProgress(pasteboard, g_params, &status);
1499     EXPECT_EQ(status, ERR_OK);
1500     EXPECT_NE(getData, nullptr);
1501     OH_Pasteboard_Destroy(pasteboard);
1502     OH_Pasteboard_GetDataParams_Destroy(g_params);
1503 }
1504 
1505 /**
1506  * @tc.name: OH_Pasteboard_GetDataWithProgress007
1507  * @tc.desc: should get html & text when set html & text with https uri and tag
1508  * @tc.type: FUNC
1509  */
1510 HWTEST_F(PasteboardCapiTest, OH_Pasteboard_GetDataWithProgress007, TestSize.Level1)
1511 {
1512     std::string htmlText = "<div><span>test</span><img src='./text.jpg'></div>";
1513     auto newData = PasteboardClient::GetInstance()->CreateHtmlData(htmlText);
1514     auto ret = PasteboardClient::GetInstance()->SetPasteData(*newData);
1515     EXPECT_EQ(ret, static_cast<int32_t>(PasteboardError::E_OK));
1516 
1517     OH_Pasteboard* pasteboard = OH_Pasteboard_Create();
1518     g_params = OH_Pasteboard_GetDataParams_Create();
1519     EXPECT_NE(g_params, nullptr);
1520     const char *uri = "/data/storage/el2/base/haps/entry/files/";
1521     OH_Pasteboard_GetDataParams_SetDestUri(g_params, uri, strlen(uri));
1522     OH_Pasteboard_GetDataParams_SetProgressIndicator(g_params, PASTEBOARD_DEFAULT);
1523     OH_Pasteboard_GetDataParams_SetFileConflictOptions(g_params, PASTEBOARD_SKIP);
1524     OH_Pasteboard_GetDataParams_SetProgressListener(g_params, OH_Pasteboard_ProgressListener);
1525     int status = -1;
1526     OH_UdmfData* getData = OH_Pasteboard_GetDataWithProgress(pasteboard, g_params, &status);
1527     EXPECT_EQ(status, ERR_OK);
1528     EXPECT_NE(getData, nullptr);
1529     OH_Pasteboard_Destroy(pasteboard);
1530     OH_Pasteboard_GetDataParams_Destroy(g_params);
1531 }
1532 
1533 /**
1534  * @tc.name: OH_Pasteboard_GetDataWithProgress008
1535  * @tc.desc: should get html & text when set html & text with https uri and tag
1536  * @tc.type: FUNC
1537  */
1538 HWTEST_F(PasteboardCapiTest, OH_Pasteboard_GetDataWithProgress008, TestSize.Level1)
1539 {
1540     OHOS::Uri uri("./text.jpg");
1541     auto newData = PasteboardClient::GetInstance()->CreateUriData(uri);
1542     auto ret = PasteboardClient::GetInstance()->SetPasteData(*newData);
1543     EXPECT_EQ(ret, static_cast<int32_t>(PasteboardError::E_OK));
1544 
1545     OH_Pasteboard* pasteboard = OH_Pasteboard_Create();
1546     g_params = OH_Pasteboard_GetDataParams_Create();
1547     EXPECT_NE(g_params, nullptr);
1548     const char *uri2 = "/data/storage/el2/base/haps/entry/files/";
1549     OH_Pasteboard_GetDataParams_SetDestUri(g_params, uri2, strlen(uri2));
1550     OH_Pasteboard_GetDataParams_SetProgressIndicator(g_params, PASTEBOARD_NONE);
1551     OH_Pasteboard_GetDataParams_SetFileConflictOptions(g_params, PASTEBOARD_SKIP);
1552     OH_Pasteboard_GetDataParams_SetProgressListener(g_params, OH_Pasteboard_ProgressListener);
1553     int status = -1;
1554     OH_UdmfData* getData = OH_Pasteboard_GetDataWithProgress(pasteboard, g_params, &status);
1555     EXPECT_EQ(status, ERR_PASTEBOARD_COPY_FILE_ERROR);
1556     EXPECT_EQ(getData, nullptr);
1557     OH_Pasteboard_Destroy(pasteboard);
1558     OH_Pasteboard_GetDataParams_Destroy(g_params);
1559 }
1560 
1561 /**
1562  * @tc.name: OH_Pasteboard_GetDataParams_Destroy001
1563  * @tc.desc: handle data params destroy
1564  * @tc.type: FUNC
1565  */
1566 HWTEST_F(PasteboardCapiTest, OH_Pasteboard_GetDataParams_Destroy001, TestSize.Level1)
1567 {
1568     std::string plainText = "helloWorld";
1569     auto newData = PasteboardClient::GetInstance()->CreatePlainTextData(plainText);
1570     auto ret = PasteboardClient::GetInstance()->SetPasteData(*newData);
1571     EXPECT_EQ(ret, static_cast<int32_t>(PasteboardError::E_OK));
1572 
1573     OH_Pasteboard* pasteboard = OH_Pasteboard_Create();
1574     Pasteboard_GetDataParams *g_params = nullptr;
1575     OH_Pasteboard_Destroy(pasteboard);
1576     OH_Pasteboard_GetDataParams_Destroy(g_params);
1577 }
1578 
1579 /**
1580  * @tc.name: OH_Pasteboard_GetDataParams_Destroy002
1581  * @tc.desc: handle data params destroy
1582  * @tc.type: FUNC
1583  */
1584 HWTEST_F(PasteboardCapiTest, OH_Pasteboard_GetDataParams_Destroy002, TestSize.Level1)
1585 {
1586     std::string plainText = "helloWorld";
1587     auto newData = PasteboardClient::GetInstance()->CreatePlainTextData(plainText);
1588     auto ret = PasteboardClient::GetInstance()->SetPasteData(*newData);
1589     EXPECT_EQ(ret, static_cast<int32_t>(PasteboardError::E_OK));
1590 
1591     OH_Pasteboard* pasteboard = OH_Pasteboard_Create();
1592     g_params = OH_Pasteboard_GetDataParams_Create();
1593     g_params->destUri = nullptr;
1594     OH_Pasteboard_Destroy(pasteboard);
1595     OH_Pasteboard_GetDataParams_Destroy(g_params);
1596 }
1597 
1598 /**
1599  * @tc.name: OH_Pasteboard_GetDataParams_SetProgressIndicator001
1600  * @tc.desc: handle set progress indicator
1601  * @tc.type: FUNC
1602  */
1603 HWTEST_F(PasteboardCapiTest, OH_Pasteboard_GetDataParams_SetProgressIndicator001, TestSize.Level1)
1604 {
1605     std::string plainText = "helloWorld";
1606     auto newData = PasteboardClient::GetInstance()->CreatePlainTextData(plainText);
1607     auto ret = PasteboardClient::GetInstance()->SetPasteData(*newData);
1608     EXPECT_EQ(ret, static_cast<int32_t>(PasteboardError::E_OK));
1609 
1610     OH_Pasteboard* pasteboard = OH_Pasteboard_Create();
1611     Pasteboard_GetDataParams *g_params = nullptr;
1612     OH_Pasteboard_GetDataParams_SetProgressIndicator(g_params, PASTEBOARD_NONE);
1613     OH_Pasteboard_Destroy(pasteboard);
1614     OH_Pasteboard_GetDataParams_Destroy(g_params);
1615 }
1616 
1617 /**
1618  * @tc.name: OH_Pasteboard_GetDataParams_SetDestUri001
1619  * @tc.desc: handle set dest uri
1620  * @tc.type: FUNC
1621  */
1622 HWTEST_F(PasteboardCapiTest, OH_Pasteboard_GetDataParams_SetDestUri001, TestSize.Level1)
1623 {
1624     std::string plainText = "helloWorld";
1625     auto newData = PasteboardClient::GetInstance()->CreatePlainTextData(plainText);
1626     auto ret = PasteboardClient::GetInstance()->SetPasteData(*newData);
1627     EXPECT_EQ(ret, static_cast<int32_t>(PasteboardError::E_OK));
1628 
1629     OH_Pasteboard* pasteboard = OH_Pasteboard_Create();
1630     Pasteboard_GetDataParams *g_params = nullptr;
1631     auto uri = nullptr;
1632     uint32_t destUriLen = 0;
1633     OH_Pasteboard_GetDataParams_SetDestUri(g_params, uri, destUriLen);
1634     OH_Pasteboard_Destroy(pasteboard);
1635     OH_Pasteboard_GetDataParams_Destroy(g_params);
1636 }
1637 
1638 /**
1639  * @tc.name: OH_Pasteboard_GetDataParams_SetDestUri002
1640  * @tc.desc: handle set dest uri
1641  * @tc.type: FUNC
1642  */
1643 HWTEST_F(PasteboardCapiTest, OH_Pasteboard_GetDataParams_SetDestUri002, TestSize.Level1)
1644 {
1645     std::string plainText = "helloWorld";
1646     auto newData = PasteboardClient::GetInstance()->CreatePlainTextData(plainText);
1647     auto ret = PasteboardClient::GetInstance()->SetPasteData(*newData);
1648     EXPECT_EQ(ret, static_cast<int32_t>(PasteboardError::E_OK));
1649 
1650     OH_Pasteboard* pasteboard = OH_Pasteboard_Create();
1651     g_params = OH_Pasteboard_GetDataParams_Create();
1652     g_params->destUri = nullptr;
1653     auto uri = nullptr;
1654     uint32_t destUriLen = 0;
1655     OH_Pasteboard_GetDataParams_SetDestUri(g_params, uri, destUriLen);
1656     OH_Pasteboard_Destroy(pasteboard);
1657     OH_Pasteboard_GetDataParams_Destroy(g_params);
1658 }
1659 
1660 /**
1661  * @tc.name: OH_Pasteboard_GetDataParams_SetDestUri003
1662  * @tc.desc: handle set dest uri
1663  * @tc.type: FUNC
1664  */
1665 HWTEST_F(PasteboardCapiTest, OH_Pasteboard_GetDataParams_SetDestUri003, TestSize.Level1)
1666 {
1667     std::string plainText = "helloWorld";
1668     auto newData = PasteboardClient::GetInstance()->CreatePlainTextData(plainText);
1669     auto ret = PasteboardClient::GetInstance()->SetPasteData(*newData);
1670     EXPECT_EQ(ret, static_cast<int32_t>(PasteboardError::E_OK));
1671 
1672     OH_Pasteboard* pasteboard = OH_Pasteboard_Create();
1673     g_params = OH_Pasteboard_GetDataParams_Create();
1674     auto uri = nullptr;
1675     uint32_t destUriLen = 0;
1676     OH_Pasteboard_GetDataParams_SetDestUri(g_params, uri, destUriLen);
1677     OH_Pasteboard_Destroy(pasteboard);
1678     OH_Pasteboard_GetDataParams_Destroy(g_params);
1679 }
1680 
1681 /**
1682  * @tc.name: OH_Pasteboard_GetDataParams_SetDestUri004
1683  * @tc.desc: handle set dest uri
1684  * @tc.type: FUNC
1685  */
1686 HWTEST_F(PasteboardCapiTest, OH_Pasteboard_GetDataParams_SetDestUri004, TestSize.Level1)
1687 {
1688     std::string plainText = "helloWorld";
1689     auto newData = PasteboardClient::GetInstance()->CreatePlainTextData(plainText);
1690     auto ret = PasteboardClient::GetInstance()->SetPasteData(*newData);
1691     EXPECT_EQ(ret, static_cast<int32_t>(PasteboardError::E_OK));
1692 
1693     OH_Pasteboard* pasteboard = OH_Pasteboard_Create();
1694     g_params = OH_Pasteboard_GetDataParams_Create();
1695     auto uri = "/data/storage/el2/base/haps/entry/files/dstFile.txt";
1696     uint32_t destUriLen = 0;
1697     OH_Pasteboard_GetDataParams_SetDestUri(g_params, uri, destUriLen);
1698     OH_Pasteboard_Destroy(pasteboard);
1699     OH_Pasteboard_GetDataParams_Destroy(g_params);
1700 }
1701 
1702 /**
1703  * @tc.name: OH_Pasteboard_GetDataParams_SetDestUri005
1704  * @tc.desc: handle set dest uri
1705  * @tc.type: FUNC
1706  */
1707 HWTEST_F(PasteboardCapiTest, OH_Pasteboard_GetDataParams_SetDestUri005, TestSize.Level1)
1708 {
1709     std::string plainText = "helloWorld";
1710     auto newData = PasteboardClient::GetInstance()->CreatePlainTextData(plainText);
1711     auto ret = PasteboardClient::GetInstance()->SetPasteData(*newData);
1712     EXPECT_EQ(ret, static_cast<int32_t>(PasteboardError::E_OK));
1713 
1714     OH_Pasteboard* pasteboard = OH_Pasteboard_Create();
1715     g_params = OH_Pasteboard_GetDataParams_Create();
1716     auto uri = "/data/storage/el2/base/haps/entry/files/dstFile.txt";
1717     uint32_t destUriLen = 1025;
1718     OH_Pasteboard_GetDataParams_SetDestUri(g_params, uri, destUriLen);
1719     OH_Pasteboard_Destroy(pasteboard);
1720     OH_Pasteboard_GetDataParams_Destroy(g_params);
1721 }
1722 
1723 /**
1724  * @tc.name: OH_Pasteboard_GetDataParams_SetFileConflictOptions001
1725  * @tc.desc: handle set file conflict options
1726  * @tc.type: FUNC
1727  */
1728 HWTEST_F(PasteboardCapiTest, OH_Pasteboard_GetDataParams_SetFileConflictOptions001, TestSize.Level1)
1729 {
1730     std::string plainText = "helloWorld";
1731     auto newData = PasteboardClient::GetInstance()->CreatePlainTextData(plainText);
1732     auto ret = PasteboardClient::GetInstance()->SetPasteData(*newData);
1733     EXPECT_EQ(ret, static_cast<int32_t>(PasteboardError::E_OK));
1734 
1735     OH_Pasteboard* pasteboard = OH_Pasteboard_Create();
1736     Pasteboard_GetDataParams *g_params = nullptr;
1737     OH_Pasteboard_GetDataParams_SetFileConflictOptions(g_params, PASTEBOARD_OVERWRITE);
1738     OH_Pasteboard_Destroy(pasteboard);
1739     OH_Pasteboard_GetDataParams_Destroy(g_params);
1740 }
1741 
1742 /**
1743  * @tc.name: OH_Pasteboard_GetDataParams_SetProgressListener001
1744  * @tc.desc: handle set progress listener
1745  * @tc.type: FUNC
1746  */
1747 HWTEST_F(PasteboardCapiTest, OH_Pasteboard_GetDataParams_SetProgressListener001, TestSize.Level1)
1748 {
1749     std::string plainText = "helloWorld";
1750     auto newData = PasteboardClient::GetInstance()->CreatePlainTextData(plainText);
1751     auto ret = PasteboardClient::GetInstance()->SetPasteData(*newData);
1752     EXPECT_EQ(ret, static_cast<int32_t>(PasteboardError::E_OK));
1753 
1754     OH_Pasteboard* pasteboard = OH_Pasteboard_Create();
1755     Pasteboard_GetDataParams *g_params = nullptr;
1756     OH_Pasteboard_GetDataParams_SetProgressListener(g_params, Pasteboard_ProgressListener);
1757     OH_Pasteboard_Destroy(pasteboard);
1758     OH_Pasteboard_GetDataParams_Destroy(g_params);
1759 }
1760 
1761 /**
1762  * @tc.name: OH_Pasteboard_GetDataParams_GetProgress001
1763  * @tc.desc: handle get progress
1764  * @tc.type: FUNC
1765  */
1766 HWTEST_F(PasteboardCapiTest, OH_Pasteboard_GetDataParams_GetProgress001, TestSize.Level1)
1767 {
1768     std::string plainText = "helloWorld";
1769     auto newData = PasteboardClient::GetInstance()->CreatePlainTextData(plainText);
1770     auto ret = PasteboardClient::GetInstance()->SetPasteData(*newData);
1771     EXPECT_EQ(ret, static_cast<int32_t>(PasteboardError::E_OK));
1772 
1773     OH_Pasteboard* pasteboard = OH_Pasteboard_Create();
1774     Pasteboard_ProgressInfo *info = nullptr;
1775     OH_Pasteboard_ProgressInfo_GetProgress(info);
1776     OH_Pasteboard_Destroy(pasteboard);
1777 }
1778 
1779 /**
1780  * @tc.name: OH_Pasteboard_GetChangeCount001
1781  * @tc.desc: changeCount should not change after clear pasteboard
1782  * @tc.type: FUNC
1783  * @tc.require: AROOOH5R5G
1784  */
1785 HWTEST_F(PasteboardCapiTest, OH_Pasteboard_GetChangeCount001, TestSize.Level1)
1786 {
1787     OH_Pasteboard* pasteboard = OH_Pasteboard_Create();
1788     uint32_t changeCount = OH_Pasteboard_GetChangeCount(pasteboard);
1789     OH_Pasteboard_ClearData(pasteboard);
1790     uint32_t newCount = OH_Pasteboard_GetChangeCount(pasteboard);
1791     EXPECT_EQ(newCount, changeCount);
1792     OH_Pasteboard_Destroy(pasteboard);
1793 }
1794 
1795 /**
1796  * @tc.name: OH_Pasteboard_GetChangeCount002
1797  * @tc.desc: changeCount should add 1 after setData
1798  * @tc.type: FUNC
1799  * @tc.require: AROOOH5R5G
1800  */
1801 HWTEST_F(PasteboardCapiTest, OH_Pasteboard_GetChangeCount002, TestSize.Level1)
1802 {
1803     OH_Pasteboard* pasteboard = OH_Pasteboard_Create();
1804     uint32_t changeCount = OH_Pasteboard_GetChangeCount(pasteboard);
1805     OH_UdmfData* setData = OH_UdmfData_Create();
1806     OH_UdmfRecord* record = OH_UdmfRecord_Create();
1807     OH_UdsPlainText* plainText = OH_UdsPlainText_Create();
1808     char content[] = "hello world";
1809     OH_UdsPlainText_SetContent(plainText, content);
1810     OH_UdmfRecord_AddPlainText(record, plainText);
1811     OH_UdmfData_AddRecord(setData, record);
1812     OH_Pasteboard_SetData(pasteboard, setData);
1813     uint32_t newCount = OH_Pasteboard_GetChangeCount(pasteboard);
1814     EXPECT_EQ(newCount, changeCount + 1);
1815     OH_Pasteboard_Destroy(pasteboard);
1816 }
1817 
1818 /**
1819  * @tc.name: OH_Pasteboard_GetChangeCount003
1820  * @tc.desc: changeCount should add 2 after setData twice
1821  * @tc.type: FUNC
1822  * @tc.require: AROOOH5R5G
1823  */
1824 HWTEST_F(PasteboardCapiTest, OH_Pasteboard_GetChangeCount003, TestSize.Level1)
1825 {
1826     OH_Pasteboard* pasteboard = OH_Pasteboard_Create();
1827     uint32_t changeCount = OH_Pasteboard_GetChangeCount(pasteboard);
1828     OH_UdmfData* setData = OH_UdmfData_Create();
1829     OH_UdmfRecord* record = OH_UdmfRecord_Create();
1830     OH_UdsPlainText* plainText = OH_UdsPlainText_Create();
1831     char content[] = "hello world";
1832     OH_UdsPlainText_SetContent(plainText, content);
1833     OH_UdmfRecord_AddPlainText(record, plainText);
1834     OH_UdmfData_AddRecord(setData, record);
1835     OH_Pasteboard_SetData(pasteboard, setData);
1836     OH_UdmfRecord* record2 = OH_UdmfRecord_Create();
1837     OH_UdsHtml* htmlText = OH_UdsHtml_Create();
1838     char html[] = "<div class='disabled'>hello</div>";
1839     OH_UdsHtml_SetContent(htmlText, html);
1840     OH_UdmfRecord_AddHtml(record2, htmlText);
1841     OH_UdmfData_AddRecord(setData, record2);
1842     OH_Pasteboard_SetData(pasteboard, setData);
1843     uint32_t newCount = OH_Pasteboard_GetChangeCount(pasteboard);
1844     EXPECT_EQ(newCount, changeCount + 2);
1845     OH_Pasteboard_Destroy(pasteboard);
1846 }
1847 
1848 /**
1849  * @tc.name: OH_Pasteboard_HasTypeTest001
1850  * @tc.desc: OH_Pasteboard_HasTypeTest001
1851  * @tc.type: FUNC
1852  * @tc.require: AROOOH5R5G
1853  */
1854 HWTEST_F(PasteboardCapiTest, OH_Pasteboard_HasTypeTest001, TestSize.Level2)
1855 {
1856     OH_Pasteboard invalidPasteboard;
1857     const char* type = "text/plain";
1858     bool ret = OH_Pasteboard_HasType(&invalidPasteboard, type);
1859     EXPECT_TRUE(ret);
1860 }
1861 
1862 /**
1863  * @tc.name: OH_Pasteboard_HasTypeTest002
1864  * @tc.desc: OH_Pasteboard_HasTypeTest002
1865  * @tc.type: FUNC
1866  * @tc.require: AROOOH5R5G
1867  */
1868 HWTEST_F(PasteboardCapiTest, OH_Pasteboard_HasTypeTest002, TestSize.Level2)
1869 {
1870     OH_Pasteboard validPasteboard;
1871     bool ret = OH_Pasteboard_HasType(&validPasteboard, nullptr);
1872     EXPECT_FALSE(ret);
1873 }
1874 
1875 /**
1876  * @tc.name: OH_Pasteboard_HasTypeTest003
1877  * @tc.desc: OH_Pasteboard_HasTypeTest003
1878  * @tc.type: FUNC
1879  * @tc.require: AROOOH5R5G
1880  */
1881 HWTEST_F(PasteboardCapiTest, OH_Pasteboard_HasTypeTest003, TestSize.Level2)
1882 {
1883     OH_Pasteboard validPasteboard;
1884     const char* existingType = "text/plain";
1885     bool ret = OH_Pasteboard_HasType(&validPasteboard, existingType);
1886     EXPECT_TRUE(ret);
1887 }
1888 
1889 /**
1890  * @tc.name: OH_Pasteboard_HasTypeTest004
1891  * @tc.desc: OH_Pasteboard_HasTypeTest004
1892  * @tc.type: FUNC
1893  * @tc.require: AROOOH5R5G
1894  */
1895 HWTEST_F(PasteboardCapiTest, OH_Pasteboard_HasTypeTest004, TestSize.Level2)
1896 {
1897     OH_Pasteboard validPasteboard;
1898     const char* nonExistingType = "non/existing";
1899     bool ret = OH_Pasteboard_HasType(&validPasteboard, nonExistingType);
1900     EXPECT_FALSE(ret);
1901 }
1902 
1903 /**
1904  * @tc.name: OH_Pasteboard_HasDataTest001
1905  * @tc.desc: OH_Pasteboard_HasDataTest001
1906  * @tc.type: FUNC
1907  * @tc.require: AROOOH5R5G
1908  */
1909 HWTEST_F(PasteboardCapiTest, OH_Pasteboard_HasDataTest001, TestSize.Level2)
1910 {
1911     bool ret = OH_Pasteboard_HasData(nullptr);
1912     EXPECT_FALSE(ret);
1913 }
1914 
1915 /**
1916  * @tc.name: OH_Pasteboard_GetDataTest008
1917  * @tc.desc: OH_Pasteboard_GetDataTest008
1918  * @tc.type: FUNC
1919  * @tc.require: AROOOH5R5G
1920  */
1921 HWTEST_F(PasteboardCapiTest, OH_Pasteboard_GetDataTest008, TestSize.Level2)
1922 {
1923     OH_Pasteboard pasteboard;
1924     int status = 0;
1925 
1926     OH_UdmfData* res1 = OH_Pasteboard_GetData(&pasteboard, nullptr);
1927     EXPECT_EQ(res1, nullptr);
1928 
1929     OH_UdmfData* res2 = OH_Pasteboard_GetData(nullptr, &status);
1930     EXPECT_EQ(res2, nullptr);
1931 }
1932 } // namespace Test
1933 } // namespace OHOS
1934