1 /*
2 * Copyright (c) 2025 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 #include <gtest/gtest.h>
17 #include <unistd.h>
18 #include "ipc_skeleton.h"
19 #include "message_parcel_warp.h"
20 #include "pasteboard_error.h"
21 #include "pasteboard_hilog.h"
22 #include "pasteboard_service.h"
23 #include "paste_data_entry.h"
24 #include <thread>
25
26 using namespace testing;
27 using namespace testing::ext;
28 using namespace OHOS;
29 using namespace OHOS::MiscServices;
30 using namespace std::chrono;
31 using namespace OHOS::Security::AccessToken;
32
33 namespace OHOS {
34 namespace {
35 constexpr int64_t MIN_ASHMEM_DATA_SIZE = 32 * 1024;
36 } // namespace
37
38 class PasteboardServiceGetLocalDataTest : public testing::Test {
39 public:
40 static void SetUpTestCase(void);
41 static void TearDownTestCase(void);
42 void SetUp();
43 void TearDown();
44 int32_t WritePasteData(PasteData &pasteData, std::vector<uint8_t> &buffer, int &fd,
45 int64_t &tlvSize, MessageParcelWarp &messageData, MessageParcel &parcelPata);
46 };
47
SetUpTestCase(void)48 void PasteboardServiceGetLocalDataTest::SetUpTestCase(void) { }
49
TearDownTestCase(void)50 void PasteboardServiceGetLocalDataTest::TearDownTestCase(void) { }
51
SetUp(void)52 void PasteboardServiceGetLocalDataTest::SetUp(void) { }
53
TearDown(void)54 void PasteboardServiceGetLocalDataTest::TearDown(void) { }
55
WritePasteData(PasteData & pasteData,std::vector<uint8_t> & buffer,int & fd,int64_t & tlvSize,MessageParcelWarp & messageData,MessageParcel & parcelPata)56 int32_t PasteboardServiceGetLocalDataTest::WritePasteData(PasteData &pasteData, std::vector<uint8_t> &buffer, int &fd,
57 int64_t &tlvSize, MessageParcelWarp &messageData, MessageParcel &parcelPata)
58 {
59 std::vector<uint8_t> pasteDataTlv(0);
60 bool result = pasteData.Encode(pasteDataTlv);
61 if (!result) {
62 PASTEBOARD_HILOGE(PASTEBOARD_MODULE_CLIENT, "paste data encode failed.");
63 return static_cast<int32_t>(PasteboardError::SERIALIZATION_ERROR);
64 }
65 tlvSize = static_cast<int64_t>(pasteDataTlv.size());
66 if (tlvSize > MIN_ASHMEM_DATA_SIZE) {
67 if (!messageData.WriteRawData(parcelPata, pasteDataTlv.data(), pasteDataTlv.size())) {
68 PASTEBOARD_HILOGE(PASTEBOARD_MODULE_CLIENT, "Failed to WriteRawData");
69 return static_cast<int32_t>(PasteboardError::SERIALIZATION_ERROR);
70 }
71 fd = messageData.GetWriteDataFd();
72 pasteDataTlv.clear();
73 } else {
74 fd = messageData.CreateTmpFd();
75 if (fd < 0) {
76 PASTEBOARD_HILOGE(PASTEBOARD_MODULE_CLIENT, "Failed to create tmp fd");
77 return static_cast<int32_t>(PasteboardError::SERIALIZATION_ERROR);
78 }
79 }
80 buffer = std::move(pasteDataTlv);
81 PASTEBOARD_HILOGI(PASTEBOARD_MODULE_CLIENT, "set: fd:%{public}d, size:%{public}" PRId64, fd, tlvSize);
82 return static_cast<int32_t>(PasteboardError::E_OK);
83 }
84
85 namespace MiscServices {
86 /**
87 * @tc.name: GetLocalDataTest001
88 * @tc.desc: test Func GetLocalData
89 * @tc.type: FUNC
90 */
91 HWTEST_F(PasteboardServiceGetLocalDataTest, GetLocalDataTest001, TestSize.Level0)
92 {
93 PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "GetLocalDataTest001 start");
94 auto tempPasteboard = std::make_shared<PasteboardService>();
95 EXPECT_NE(tempPasteboard, nullptr);
96
97 AppInfo appInfo;
98 PasteData pasteData;
99 int32_t ret = tempPasteboard->GetLocalData(appInfo, pasteData);
100 EXPECT_EQ(ret, static_cast<int32_t>(PasteboardError::NO_DATA_ERROR));
101 PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "GetLocalDataTest001 end");
102 }
103
104 /**
105 * @tc.name: GetLocalDataTest002
106 * @tc.desc: test Func GetLocalData
107 * @tc.type: FUNC
108 */
109 HWTEST_F(PasteboardServiceGetLocalDataTest, GetLocalDataTest002, TestSize.Level0)
110 {
111 PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "GetLocalDataTest002 start");
112 auto tempPasteboard = std::make_shared<PasteboardService>();
113 EXPECT_NE(tempPasteboard, nullptr);
114
115 AppInfo appInfo;
116 appInfo.userId = tempPasteboard->GetCurrentAccountId();
117 PasteData pasteData;
118 std::string plainText = "hello";
119 pasteData.AddTextRecord(plainText);
120
121 std::vector<uint8_t> pasteDataTlv(0);
122 int fd = -1;
123 int64_t tlvSize = 0;
124 MessageParcelWarp messageData;
125 MessageParcel parcelPata;
126 sptr<IPasteboardDelayGetter> delayGetter = nullptr;
127 sptr<IPasteboardEntryGetter> entryGetter = nullptr;
128
129 int32_t ret = WritePasteData(pasteData, pasteDataTlv, fd, tlvSize, messageData, parcelPata);
130 ret = tempPasteboard->SetPasteData(dup(fd), tlvSize, pasteDataTlv, delayGetter, entryGetter);
131
132 PasteData getPasteData;
133 ret = tempPasteboard->GetLocalData(appInfo, getPasteData);
134 EXPECT_EQ(ret, static_cast<int32_t>(PasteboardError::E_OK));
135 PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "GetLocalDataTest002 end");
136 }
137
138 /**
139 * @tc.name: GetLocalDataTest003
140 * @tc.desc: test Func GetLocalData
141 * @tc.type: FUNC
142 */
143 HWTEST_F(PasteboardServiceGetLocalDataTest, GetLocalDataTest003, TestSize.Level0)
144 {
145 PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "GetLocalDataTest003 start");
146 auto tempPasteboard = std::make_shared<PasteboardService>();
147 EXPECT_NE(tempPasteboard, nullptr);
148
149 AppInfo appInfo;
150 appInfo.userId = tempPasteboard->GetCurrentAccountId();
151 PasteData pasteData;
152 std::string plainText = "hello";
153 pasteData.AddTextRecord(plainText);
154
155 ShareOption shareOption = ShareOption::InApp;
156 pasteData.SetShareOption(shareOption);
157
158 std::vector<uint8_t> pasteDataTlv(0);
159 int fd = -1;
160 int64_t tlvSize = 0;
161 MessageParcelWarp messageData;
162 MessageParcel parcelPata;
163 sptr<IPasteboardDelayGetter> delayGetter = nullptr;
164 sptr<IPasteboardEntryGetter> entryGetter = nullptr;
165
166 int32_t ret = WritePasteData(pasteData, pasteDataTlv, fd, tlvSize, messageData, parcelPata);
167 ret = tempPasteboard->SetPasteData(dup(fd), tlvSize, pasteDataTlv, delayGetter, entryGetter);
168
169 PasteData getPasteData;
170 ret = tempPasteboard->GetLocalData(appInfo, getPasteData);
171 EXPECT_EQ(ret, static_cast<int32_t>(PasteboardError::PERMISSION_VERIFICATION_ERROR));
172 PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "GetLocalDataTest003 end");
173 }
174
175 /**
176 * @tc.name: GetLocalDataTest004
177 * @tc.desc: test Func GetLocalData
178 * @tc.type: FUNC
179 */
180 HWTEST_F(PasteboardServiceGetLocalDataTest, GetLocalDataTest004, TestSize.Level0)
181 {
182 PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "GetLocalDataTest004 start");
183 auto tempPasteboard = std::make_shared<PasteboardService>();
184 EXPECT_NE(tempPasteboard, nullptr);
185
186 AppInfo appInfo;
187 appInfo.userId = tempPasteboard->GetCurrentAccountId();
188 PasteData pasteData;
189 std::string plainText = "hello";
190 pasteData.AddTextRecord(plainText);
191
192 ShareOption shareOption = ShareOption::LocalDevice;
193 pasteData.SetShareOption(shareOption);
194
195 std::vector<uint8_t> pasteDataTlv(0);
196 int fd = -1;
197 int64_t tlvSize = 0;
198 MessageParcelWarp messageData;
199 MessageParcel parcelPata;
200 sptr<IPasteboardDelayGetter> delayGetter = nullptr;
201 sptr<IPasteboardEntryGetter> entryGetter = nullptr;
202
203 int32_t ret = WritePasteData(pasteData, pasteDataTlv, fd, tlvSize, messageData, parcelPata);
204 ret = tempPasteboard->SetPasteData(dup(fd), tlvSize, pasteDataTlv, delayGetter, entryGetter);
205
206 PasteData getPasteData;
207 ret = tempPasteboard->GetLocalData(appInfo, getPasteData);
208 EXPECT_EQ(ret, static_cast<int32_t>(PasteboardError::E_OK));
209 PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "GetLocalDataTest004 end");
210 }
211
212 /**
213 * @tc.name: GetLocalDataTest005
214 * @tc.desc: test Func GetLocalData
215 * @tc.type: FUNC
216 */
217 HWTEST_F(PasteboardServiceGetLocalDataTest, GetLocalDataTest005, TestSize.Level0)
218 {
219 PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "GetLocalDataTest005 start");
220 auto tempPasteboard = std::make_shared<PasteboardService>();
221 EXPECT_NE(tempPasteboard, nullptr);
222
223 AppInfo appInfo;
224 appInfo.userId = tempPasteboard->GetCurrentAccountId();
225 PasteData pasteData;
226 std::string plainText = "hello";
227 pasteData.AddTextRecord(plainText);
228
229 ShareOption shareOption = ShareOption::CrossDevice;
230 pasteData.SetShareOption(shareOption);
231
232 std::vector<uint8_t> pasteDataTlv(0);
233 int fd = -1;
234 int64_t tlvSize = 0;
235 MessageParcelWarp messageData;
236 MessageParcel parcelPata;
237 sptr<IPasteboardDelayGetter> delayGetter = nullptr;
238 sptr<IPasteboardEntryGetter> entryGetter = nullptr;
239
240 int32_t ret = WritePasteData(pasteData, pasteDataTlv, fd, tlvSize, messageData, parcelPata);
241 ret = tempPasteboard->SetPasteData(dup(fd), tlvSize, pasteDataTlv, delayGetter, entryGetter);
242
243 PasteData getPasteData;
244 ret = tempPasteboard->GetLocalData(appInfo, getPasteData);
245 EXPECT_EQ(ret, static_cast<int32_t>(PasteboardError::E_OK));
246 PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "GetLocalDataTest005 end");
247 }
248
249 /**
250 * @tc.name: GetLocalDataTest006
251 * @tc.desc: test Func GetLocalData
252 * @tc.type: FUNC
253 */
254 HWTEST_F(PasteboardServiceGetLocalDataTest, GetLocalDataTest006, TestSize.Level0)
255 {
256 PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "GetLocalDataTest006 start");
257 auto tempPasteboard = std::make_shared<PasteboardService>();
258 EXPECT_NE(tempPasteboard, nullptr);
259
260 AppInfo appInfo;
261 appInfo.userId = tempPasteboard->GetCurrentAccountId();
262 PasteData pasteData;
263 std::string plainText = "hello";
264 pasteData.AddTextRecord(plainText);
265
266 ShareOption shareOption = ShareOption::InApp;
267 pasteData.SetShareOption(shareOption);
268 pasteData.SetDraggedDataFlag(false);
269
270 std::vector<uint8_t> pasteDataTlv(0);
271 int fd = -1;
272 int64_t tlvSize = 0;
273 MessageParcelWarp messageData;
274 MessageParcel parcelPata;
275 sptr<IPasteboardDelayGetter> delayGetter = nullptr;
276 sptr<IPasteboardEntryGetter> entryGetter = nullptr;
277
278 int32_t ret = WritePasteData(pasteData, pasteDataTlv, fd, tlvSize, messageData, parcelPata);
279 ret = tempPasteboard->SetPasteData(dup(fd), tlvSize, pasteDataTlv, delayGetter, entryGetter);
280
281 PasteData getPasteData;
282 ret = tempPasteboard->GetLocalData(appInfo, getPasteData);
283 EXPECT_EQ(ret, static_cast<int32_t>(PasteboardError::PERMISSION_VERIFICATION_ERROR));
284 PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "GetLocalDataTest006 end");
285 }
286
287 /**
288 * @tc.name: GetLocalDataTest007
289 * @tc.desc: test Func GetLocalData
290 * @tc.type: FUNC
291 */
292 HWTEST_F(PasteboardServiceGetLocalDataTest, GetLocalDataTest007, TestSize.Level0)
293 {
294 PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "GetLocalDataTest007 start");
295 auto tempPasteboard = std::make_shared<PasteboardService>();
296 EXPECT_NE(tempPasteboard, nullptr);
297
298 AppInfo appInfo;
299 appInfo.userId = tempPasteboard->GetCurrentAccountId();
300 PasteData pasteData;
301 std::string plainText = "hello";
302 pasteData.AddTextRecord(plainText);
303
304 ShareOption shareOption = ShareOption::LocalDevice;
305 pasteData.SetShareOption(shareOption);
306 pasteData.SetDraggedDataFlag(false);
307
308 std::vector<uint8_t> pasteDataTlv(0);
309 int fd = -1;
310 int64_t tlvSize = 0;
311 MessageParcelWarp messageData;
312 MessageParcel parcelPata;
313 sptr<IPasteboardDelayGetter> delayGetter = nullptr;
314 sptr<IPasteboardEntryGetter> entryGetter = nullptr;
315
316 int32_t ret = WritePasteData(pasteData, pasteDataTlv, fd, tlvSize, messageData, parcelPata);
317 ret = tempPasteboard->SetPasteData(dup(fd), tlvSize, pasteDataTlv, delayGetter, entryGetter);
318
319 PasteData getPasteData;
320 ret = tempPasteboard->GetLocalData(appInfo, getPasteData);
321 EXPECT_EQ(ret, static_cast<int32_t>(PasteboardError::E_OK));
322 PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "GetLocalDataTest007 end");
323 }
324
325 /**
326 * @tc.name: GetLocalDataTest008
327 * @tc.desc: test Func GetLocalData
328 * @tc.type: FUNC
329 */
330 HWTEST_F(PasteboardServiceGetLocalDataTest, GetLocalDataTest008, TestSize.Level0)
331 {
332 PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "GetLocalDataTest008 start");
333 auto tempPasteboard = std::make_shared<PasteboardService>();
334 EXPECT_NE(tempPasteboard, nullptr);
335
336 AppInfo appInfo;
337 appInfo.userId = tempPasteboard->GetCurrentAccountId();
338 PasteData pasteData;
339 std::string plainText = "hello";
340 pasteData.AddTextRecord(plainText);
341
342 ShareOption shareOption = ShareOption::CrossDevice;
343 pasteData.SetShareOption(shareOption);
344 pasteData.SetDraggedDataFlag(false);
345
346 std::vector<uint8_t> pasteDataTlv(0);
347 int fd = -1;
348 int64_t tlvSize = 0;
349 MessageParcelWarp messageData;
350 MessageParcel parcelPata;
351 sptr<IPasteboardDelayGetter> delayGetter = nullptr;
352 sptr<IPasteboardEntryGetter> entryGetter = nullptr;
353
354 int32_t ret = WritePasteData(pasteData, pasteDataTlv, fd, tlvSize, messageData, parcelPata);
355 ret = tempPasteboard->SetPasteData(dup(fd), tlvSize, pasteDataTlv, delayGetter, entryGetter);
356
357 PasteData getPasteData;
358 ret = tempPasteboard->GetLocalData(appInfo, getPasteData);
359 EXPECT_EQ(ret, static_cast<int32_t>(PasteboardError::E_OK));
360 PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "GetLocalDataTest008 end");
361 }
362
363 /**
364 * @tc.name: GetLocalDataTest009
365 * @tc.desc: test Func GetLocalData
366 * @tc.type: FUNC
367 */
368 HWTEST_F(PasteboardServiceGetLocalDataTest, GetLocalDataTest009, TestSize.Level0)
369 {
370 PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "GetLocalDataTest009 start");
371 auto tempPasteboard = std::make_shared<PasteboardService>();
372 EXPECT_NE(tempPasteboard, nullptr);
373
374 AppInfo appInfo;
375 appInfo.userId = tempPasteboard->GetCurrentAccountId();
376 PasteData pasteData;
377 std::string plainText = "hello";
378 pasteData.AddTextRecord(plainText);
379
380 ShareOption shareOption = ShareOption::InApp;
381 pasteData.SetShareOption(shareOption);
382 pasteData.SetDraggedDataFlag(true);
383
384 std::vector<uint8_t> pasteDataTlv(0);
385 int fd = -1;
386 int64_t tlvSize = 0;
387 MessageParcelWarp messageData;
388 MessageParcel parcelPata;
389 sptr<IPasteboardDelayGetter> delayGetter = nullptr;
390 sptr<IPasteboardEntryGetter> entryGetter = nullptr;
391
392 int32_t ret = WritePasteData(pasteData, pasteDataTlv, fd, tlvSize, messageData, parcelPata);
393 ret = tempPasteboard->SetPasteData(dup(fd), tlvSize, pasteDataTlv, delayGetter, entryGetter);
394
395 PasteData getPasteData;
396 ret = tempPasteboard->GetLocalData(appInfo, getPasteData);
397 EXPECT_EQ(ret, static_cast<int32_t>(PasteboardError::INVALID_PARAM_ERROR));
398 PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "GetLocalDataTest009 end");
399 }
400
401 /**
402 * @tc.name: GetLocalDataTest010
403 * @tc.desc: test Func GetLocalData
404 * @tc.type: FUNC
405 */
406 HWTEST_F(PasteboardServiceGetLocalDataTest, GetLocalDataTest010, TestSize.Level0)
407 {
408 PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "GetLocalDataTest010 start");
409 auto tempPasteboard = std::make_shared<PasteboardService>();
410 EXPECT_NE(tempPasteboard, nullptr);
411
412 AppInfo appInfo;
413 appInfo.userId = tempPasteboard->GetCurrentAccountId();
414 PasteData pasteData;
415 std::string plainText = "hello";
416 pasteData.AddTextRecord(plainText);
417
418 ShareOption shareOption = ShareOption::LocalDevice;
419 pasteData.SetShareOption(shareOption);
420 pasteData.SetDraggedDataFlag(true);
421
422 std::vector<uint8_t> pasteDataTlv(0);
423 int fd = -1;
424 int64_t tlvSize = 0;
425 MessageParcelWarp messageData;
426 MessageParcel parcelPata;
427 sptr<IPasteboardDelayGetter> delayGetter = nullptr;
428 sptr<IPasteboardEntryGetter> entryGetter = nullptr;
429
430 int32_t ret = WritePasteData(pasteData, pasteDataTlv, fd, tlvSize, messageData, parcelPata);
431 ret = tempPasteboard->SetPasteData(dup(fd), tlvSize, pasteDataTlv, delayGetter, entryGetter);
432
433 PasteData getPasteData;
434 ret = tempPasteboard->GetLocalData(appInfo, getPasteData);
435 EXPECT_EQ(ret, static_cast<int32_t>(PasteboardError::INVALID_PARAM_ERROR));
436 PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "GetLocalDataTest010 end");
437 }
438
439 /**
440 * @tc.name: GetLocalDataTest011
441 * @tc.desc: test Func GetLocalData
442 * @tc.type: FUNC
443 */
444 HWTEST_F(PasteboardServiceGetLocalDataTest, GetLocalDataTest011, TestSize.Level0)
445 {
446 PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "GetLocalDataTest011 start");
447 auto tempPasteboard = std::make_shared<PasteboardService>();
448 EXPECT_NE(tempPasteboard, nullptr);
449
450 AppInfo appInfo;
451 appInfo.userId = tempPasteboard->GetCurrentAccountId();
452 PasteData pasteData;
453 std::string plainText = "hello";
454 pasteData.AddTextRecord(plainText);
455
456 ShareOption shareOption = ShareOption::CrossDevice;
457 pasteData.SetShareOption(shareOption);
458 pasteData.SetDraggedDataFlag(true);
459
460 std::vector<uint8_t> pasteDataTlv(0);
461 int fd = -1;
462 int64_t tlvSize = 0;
463 MessageParcelWarp messageData;
464 MessageParcel parcelPata;
465 sptr<IPasteboardDelayGetter> delayGetter = nullptr;
466 sptr<IPasteboardEntryGetter> entryGetter = nullptr;
467
468 int32_t ret = WritePasteData(pasteData, pasteDataTlv, fd, tlvSize, messageData, parcelPata);
469 ret = tempPasteboard->SetPasteData(dup(fd), tlvSize, pasteDataTlv, delayGetter, entryGetter);
470
471 PasteData getPasteData;
472 ret = tempPasteboard->GetLocalData(appInfo, getPasteData);
473 EXPECT_EQ(ret, static_cast<int32_t>(PasteboardError::INVALID_PARAM_ERROR));
474 PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "GetLocalDataTest011 end");
475 }
476
477 /**
478 * @tc.name: GetLocalDataTest012
479 * @tc.desc: test Func GetLocalData
480 * @tc.type: FUNC
481 */
482 HWTEST_F(PasteboardServiceGetLocalDataTest, GetLocalDataTest012, TestSize.Level0)
483 {
484 PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "GetLocalDataTest012 start");
485 auto tempPasteboard = std::make_shared<PasteboardService>();
486 EXPECT_NE(tempPasteboard, nullptr);
487
488 AppInfo appInfo;
489 appInfo.userId = tempPasteboard->GetCurrentAccountId();
490 PasteData pasteData;
491 std::string plainText = "hello";
492 pasteData.AddTextRecord(plainText);
493
494 ShareOption shareOption = ShareOption::InApp;
495 pasteData.SetShareOption(shareOption);
496 pasteData.SetDraggedDataFlag(false);
497 pasteData.SetInvalid();
498
499 std::vector<uint8_t> pasteDataTlv(0);
500 int fd = -1;
501 int64_t tlvSize = 0;
502 MessageParcelWarp messageData;
503 MessageParcel parcelPata;
504 sptr<IPasteboardDelayGetter> delayGetter = nullptr;
505 sptr<IPasteboardEntryGetter> entryGetter = nullptr;
506
507 int32_t ret = WritePasteData(pasteData, pasteDataTlv, fd, tlvSize, messageData, parcelPata);
508 ret = tempPasteboard->SetPasteData(dup(fd), tlvSize, pasteDataTlv, delayGetter, entryGetter);
509
510 PasteData getPasteData;
511 ret = tempPasteboard->GetLocalData(appInfo, getPasteData);
512 EXPECT_EQ(ret, static_cast<int32_t>(PasteboardError::PERMISSION_VERIFICATION_ERROR));
513 PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "GetLocalDataTest012 end");
514 }
515
516 /**
517 * @tc.name: GetLocalDataTest013
518 * @tc.desc: test Func GetLocalData
519 * @tc.type: FUNC
520 */
521 HWTEST_F(PasteboardServiceGetLocalDataTest, GetLocalDataTest013, TestSize.Level0)
522 {
523 PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "GetLocalDataTest013 start");
524 auto tempPasteboard = std::make_shared<PasteboardService>();
525 EXPECT_NE(tempPasteboard, nullptr);
526
527 AppInfo appInfo;
528 appInfo.userId = tempPasteboard->GetCurrentAccountId();
529 PasteData pasteData;
530 std::string plainText = "hello";
531 pasteData.AddTextRecord(plainText);
532
533 ShareOption shareOption = ShareOption::LocalDevice;
534 pasteData.SetShareOption(shareOption);
535 pasteData.SetDraggedDataFlag(false);
536 pasteData.SetInvalid();
537
538 std::vector<uint8_t> pasteDataTlv(0);
539 int fd = -1;
540 int64_t tlvSize = 0;
541 MessageParcelWarp messageData;
542 MessageParcel parcelPata;
543 sptr<IPasteboardDelayGetter> delayGetter = nullptr;
544 sptr<IPasteboardEntryGetter> entryGetter = nullptr;
545
546 int32_t ret = WritePasteData(pasteData, pasteDataTlv, fd, tlvSize, messageData, parcelPata);
547 ret = tempPasteboard->SetPasteData(dup(fd), tlvSize, pasteDataTlv, delayGetter, entryGetter);
548
549 PasteData getPasteData;
550 ret = tempPasteboard->GetLocalData(appInfo, getPasteData);
551 EXPECT_EQ(ret, static_cast<int32_t>(PasteboardError::E_OK));
552 PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "GetLocalDataTest013 end");
553 }
554
555 /**
556 * @tc.name: GetLocalDataTest014
557 * @tc.desc: test Func GetLocalData
558 * @tc.type: FUNC
559 */
560 HWTEST_F(PasteboardServiceGetLocalDataTest, GetLocalDataTest014, TestSize.Level0)
561 {
562 PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "GetLocalDataTest014 start");
563 auto tempPasteboard = std::make_shared<PasteboardService>();
564 EXPECT_NE(tempPasteboard, nullptr);
565
566 AppInfo appInfo;
567 appInfo.userId = tempPasteboard->GetCurrentAccountId();
568 PasteData pasteData;
569 std::string plainText = "hello";
570 pasteData.AddTextRecord(plainText);
571
572 ShareOption shareOption = ShareOption::CrossDevice;
573 pasteData.SetShareOption(shareOption);
574 pasteData.SetDraggedDataFlag(false);
575 pasteData.SetInvalid();
576
577 std::vector<uint8_t> pasteDataTlv(0);
578 int fd = -1;
579 int64_t tlvSize = 0;
580 MessageParcelWarp messageData;
581 MessageParcel parcelPata;
582 sptr<IPasteboardDelayGetter> delayGetter = nullptr;
583 sptr<IPasteboardEntryGetter> entryGetter = nullptr;
584
585 int32_t ret = WritePasteData(pasteData, pasteDataTlv, fd, tlvSize, messageData, parcelPata);
586 ret = tempPasteboard->SetPasteData(dup(fd), tlvSize, pasteDataTlv, delayGetter, entryGetter);
587
588 PasteData getPasteData;
589 ret = tempPasteboard->GetLocalData(appInfo, getPasteData);
590 EXPECT_EQ(ret, static_cast<int32_t>(PasteboardError::E_OK));
591 PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "GetLocalDataTest014 end");
592 }
593
594 /**
595 * @tc.name: GetLocalDataTest015
596 * @tc.desc: test Func GetLocalData
597 * @tc.type: FUNC
598 */
599 HWTEST_F(PasteboardServiceGetLocalDataTest, GetLocalDataTest015, TestSize.Level0)
600 {
601 PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "GetLocalDataTest015 start");
602 auto tempPasteboard = std::make_shared<PasteboardService>();
603 EXPECT_NE(tempPasteboard, nullptr);
604
605 AppInfo appInfo;
606 appInfo.userId = tempPasteboard->GetCurrentAccountId();
607 PasteData pasteData;
608 std::string plainText = "hello";
609 pasteData.AddTextRecord(plainText);
610
611 ShareOption shareOption = ShareOption::InApp;
612 pasteData.SetShareOption(shareOption);
613 pasteData.SetDraggedDataFlag(true);
614 pasteData.SetInvalid();
615
616 std::vector<uint8_t> pasteDataTlv(0);
617 int fd = -1;
618 int64_t tlvSize = 0;
619 MessageParcelWarp messageData;
620 MessageParcel parcelPata;
621 sptr<IPasteboardDelayGetter> delayGetter = nullptr;
622 sptr<IPasteboardEntryGetter> entryGetter = nullptr;
623
624 int32_t ret = WritePasteData(pasteData, pasteDataTlv, fd, tlvSize, messageData, parcelPata);
625 ret = tempPasteboard->SetPasteData(dup(fd), tlvSize, pasteDataTlv, delayGetter, entryGetter);
626
627 PasteData getPasteData;
628 ret = tempPasteboard->GetLocalData(appInfo, getPasteData);
629 EXPECT_EQ(ret, static_cast<int32_t>(PasteboardError::INVALID_PARAM_ERROR));
630 PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "GetLocalDataTest015 end");
631 }
632
633 /**
634 * @tc.name: GetLocalDataTest016
635 * @tc.desc: test Func GetLocalData
636 * @tc.type: FUNC
637 */
638 HWTEST_F(PasteboardServiceGetLocalDataTest, GetLocalDataTest016, TestSize.Level0)
639 {
640 PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "GetLocalDataTest016 start");
641 auto tempPasteboard = std::make_shared<PasteboardService>();
642 EXPECT_NE(tempPasteboard, nullptr);
643
644 AppInfo appInfo;
645 appInfo.userId = tempPasteboard->GetCurrentAccountId();
646 PasteData pasteData;
647 std::string plainText = "hello";
648 pasteData.AddTextRecord(plainText);
649
650 ShareOption shareOption = ShareOption::LocalDevice;
651 pasteData.SetShareOption(shareOption);
652 pasteData.SetDraggedDataFlag(true);
653 pasteData.SetInvalid();
654
655 std::vector<uint8_t> pasteDataTlv(0);
656 int fd = -1;
657 int64_t tlvSize = 0;
658 MessageParcelWarp messageData;
659 MessageParcel parcelPata;
660 sptr<IPasteboardDelayGetter> delayGetter = nullptr;
661 sptr<IPasteboardEntryGetter> entryGetter = nullptr;
662
663 int32_t ret = WritePasteData(pasteData, pasteDataTlv, fd, tlvSize, messageData, parcelPata);
664 ret = tempPasteboard->SetPasteData(dup(fd), tlvSize, pasteDataTlv, delayGetter, entryGetter);
665
666 PasteData getPasteData;
667 ret = tempPasteboard->GetLocalData(appInfo, getPasteData);
668 EXPECT_EQ(ret, static_cast<int32_t>(PasteboardError::INVALID_PARAM_ERROR));
669 PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "GetLocalDataTest016 end");
670 }
671
672 /**
673 * @tc.name: GetLocalDataTest017
674 * @tc.desc: test Func GetLocalData
675 * @tc.type: FUNC
676 */
677 HWTEST_F(PasteboardServiceGetLocalDataTest, GetLocalDataTest017, TestSize.Level0)
678 {
679 PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "GetLocalDataTest017 start");
680 auto tempPasteboard = std::make_shared<PasteboardService>();
681 EXPECT_NE(tempPasteboard, nullptr);
682
683 AppInfo appInfo;
684 appInfo.userId = tempPasteboard->GetCurrentAccountId();
685 PasteData pasteData;
686 std::string plainText = "hello";
687 pasteData.AddTextRecord(plainText);
688
689 ShareOption shareOption = ShareOption::CrossDevice;
690 pasteData.SetShareOption(shareOption);
691 pasteData.SetDraggedDataFlag(true);
692 pasteData.SetInvalid();
693
694 std::vector<uint8_t> pasteDataTlv(0);
695 int fd = -1;
696 int64_t tlvSize = 0;
697 MessageParcelWarp messageData;
698 MessageParcel parcelPata;
699 sptr<IPasteboardDelayGetter> delayGetter = nullptr;
700 sptr<IPasteboardEntryGetter> entryGetter = nullptr;
701
702 int32_t ret = WritePasteData(pasteData, pasteDataTlv, fd, tlvSize, messageData, parcelPata);
703 ret = tempPasteboard->SetPasteData(dup(fd), tlvSize, pasteDataTlv, delayGetter, entryGetter);
704
705 PasteData getPasteData;
706 ret = tempPasteboard->GetLocalData(appInfo, getPasteData);
707 EXPECT_EQ(ret, static_cast<int32_t>(PasteboardError::INVALID_PARAM_ERROR));
708 PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "GetLocalDataTest017 end");
709 }
710
711 /**
712 * @tc.name: GetLocalDataTest018
713 * @tc.desc: test Func GetLocalData
714 * @tc.type: FUNC
715 */
716 HWTEST_F(PasteboardServiceGetLocalDataTest, GetLocalDataTest018, TestSize.Level0)
717 {
718 PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "GetLocalDataTest018 start");
719 auto tempPasteboard = std::make_shared<PasteboardService>();
720 EXPECT_NE(tempPasteboard, nullptr);
721
722 AppInfo appInfo;
723 appInfo.userId = tempPasteboard->GetCurrentAccountId();
724 PasteData pasteData;
725 std::string plainText = "hello";
726 pasteData.AddTextRecord(plainText);
727
728 ShareOption shareOption = ShareOption::InApp;
729 pasteData.SetShareOption(shareOption);
730 pasteData.SetDraggedDataFlag(false);
731 pasteData.SetDelayData(false);
732
733 std::vector<uint8_t> pasteDataTlv(0);
734 int fd = -1;
735 int64_t tlvSize = 0;
736 MessageParcelWarp messageData;
737 MessageParcel parcelPata;
738 sptr<IPasteboardDelayGetter> delayGetter = nullptr;
739 sptr<IPasteboardEntryGetter> entryGetter = nullptr;
740
741 int32_t ret = WritePasteData(pasteData, pasteDataTlv, fd, tlvSize, messageData, parcelPata);
742 ret = tempPasteboard->SetPasteData(dup(fd), tlvSize, pasteDataTlv, delayGetter, entryGetter);
743
744 PasteData getPasteData;
745 ret = tempPasteboard->GetLocalData(appInfo, getPasteData);
746 EXPECT_EQ(ret, static_cast<int32_t>(PasteboardError::PERMISSION_VERIFICATION_ERROR));
747 PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "GetLocalDataTest018 end");
748 }
749
750 /**
751 * @tc.name: GetLocalDataTest019
752 * @tc.desc: test Func GetLocalData
753 * @tc.type: FUNC
754 */
755 HWTEST_F(PasteboardServiceGetLocalDataTest, GetLocalDataTest019, TestSize.Level0)
756 {
757 PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "GetLocalDataTest019 start");
758 auto tempPasteboard = std::make_shared<PasteboardService>();
759 EXPECT_NE(tempPasteboard, nullptr);
760
761 AppInfo appInfo;
762 appInfo.userId = tempPasteboard->GetCurrentAccountId();
763 PasteData pasteData;
764 std::string plainText = "hello";
765 pasteData.AddTextRecord(plainText);
766
767 ShareOption shareOption = ShareOption::LocalDevice;
768 pasteData.SetShareOption(shareOption);
769 pasteData.SetDraggedDataFlag(false);
770 pasteData.SetDelayData(false);
771
772 std::vector<uint8_t> pasteDataTlv(0);
773 int fd = -1;
774 int64_t tlvSize = 0;
775 MessageParcelWarp messageData;
776 MessageParcel parcelPata;
777 sptr<IPasteboardDelayGetter> delayGetter = nullptr;
778 sptr<IPasteboardEntryGetter> entryGetter = nullptr;
779
780 int32_t ret = WritePasteData(pasteData, pasteDataTlv, fd, tlvSize, messageData, parcelPata);
781 ret = tempPasteboard->SetPasteData(dup(fd), tlvSize, pasteDataTlv, delayGetter, entryGetter);
782
783 PasteData getPasteData;
784 ret = tempPasteboard->GetLocalData(appInfo, getPasteData);
785 EXPECT_EQ(ret, static_cast<int32_t>(PasteboardError::E_OK));
786 PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "GetLocalDataTest019 end");
787 }
788
789 /**
790 * @tc.name: GetLocalDataTest020
791 * @tc.desc: test Func GetLocalData
792 * @tc.type: FUNC
793 */
794 HWTEST_F(PasteboardServiceGetLocalDataTest, GetLocalDataTest020, TestSize.Level0)
795 {
796 PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "GetLocalDataTest020 start");
797 auto tempPasteboard = std::make_shared<PasteboardService>();
798 EXPECT_NE(tempPasteboard, nullptr);
799
800 AppInfo appInfo;
801 appInfo.userId = tempPasteboard->GetCurrentAccountId();
802 PasteData pasteData;
803 std::string plainText = "hello";
804 pasteData.AddTextRecord(plainText);
805
806 ShareOption shareOption = ShareOption::CrossDevice;
807 pasteData.SetShareOption(shareOption);
808 pasteData.SetDraggedDataFlag(false);
809 pasteData.SetDelayData(false);
810
811 std::vector<uint8_t> pasteDataTlv(0);
812 int fd = -1;
813 int64_t tlvSize = 0;
814 MessageParcelWarp messageData;
815 MessageParcel parcelPata;
816 sptr<IPasteboardDelayGetter> delayGetter = nullptr;
817 sptr<IPasteboardEntryGetter> entryGetter = nullptr;
818
819 int32_t ret = WritePasteData(pasteData, pasteDataTlv, fd, tlvSize, messageData, parcelPata);
820 ret = tempPasteboard->SetPasteData(dup(fd), tlvSize, pasteDataTlv, delayGetter, entryGetter);
821
822 PasteData getPasteData;
823 ret = tempPasteboard->GetLocalData(appInfo, getPasteData);
824 EXPECT_EQ(ret, static_cast<int32_t>(PasteboardError::E_OK));
825 PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "GetLocalDataTest020 end");
826 }
827
828 /**
829 * @tc.name: GetLocalDataTest0021
830 * @tc.desc: test Func GetLocalData
831 * @tc.type: FUNC
832 */
833 HWTEST_F(PasteboardServiceGetLocalDataTest, GetLocalDataTest0021, TestSize.Level0)
834 {
835 PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "GetLocalDataTest021 start");
836 auto tempPasteboard = std::make_shared<PasteboardService>();
837 EXPECT_NE(tempPasteboard, nullptr);
838
839 AppInfo appInfo;
840 appInfo.userId = tempPasteboard->GetCurrentAccountId();
841 PasteData pasteData;
842 std::string plainText = "hello";
843 pasteData.AddTextRecord(plainText);
844
845 ShareOption shareOption = ShareOption::InApp;
846 pasteData.SetShareOption(shareOption);
847 pasteData.SetDraggedDataFlag(false);
848 pasteData.SetDelayData(true);
849
850 std::vector<uint8_t> pasteDataTlv(0);
851 int fd = -1;
852 int64_t tlvSize = 0;
853 MessageParcelWarp messageData;
854 MessageParcel parcelPata;
855 sptr<IPasteboardDelayGetter> delayGetter = nullptr;
856 sptr<IPasteboardEntryGetter> entryGetter = nullptr;
857
858 int32_t ret = WritePasteData(pasteData, pasteDataTlv, fd, tlvSize, messageData, parcelPata);
859 ret = tempPasteboard->SetPasteData(dup(fd), tlvSize, pasteDataTlv, delayGetter, entryGetter);
860
861 PasteData getPasteData;
862 ret = tempPasteboard->GetLocalData(appInfo, getPasteData);
863 EXPECT_EQ(ret, static_cast<int32_t>(PasteboardError::PERMISSION_VERIFICATION_ERROR));
864 PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "GetLocalDataTest021 end");
865 }
866
867 /**
868 * @tc.name: GetLocalDataTest0022
869 * @tc.desc: test Func GetLocalData
870 * @tc.type: FUNC
871 */
872 HWTEST_F(PasteboardServiceGetLocalDataTest, GetLocalDataTest0022, TestSize.Level0)
873 {
874 PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "GetLocalDataTest022 start");
875 auto tempPasteboard = std::make_shared<PasteboardService>();
876 EXPECT_NE(tempPasteboard, nullptr);
877
878 AppInfo appInfo;
879 appInfo.userId = tempPasteboard->GetCurrentAccountId();
880 PasteData pasteData;
881 std::string plainText = "hello";
882 pasteData.AddTextRecord(plainText);
883
884 ShareOption shareOption = ShareOption::LocalDevice;
885 pasteData.SetShareOption(shareOption);
886 pasteData.SetDraggedDataFlag(false);
887 pasteData.SetDelayData(true);
888
889 std::vector<uint8_t> pasteDataTlv(0);
890 int fd = -1;
891 int64_t tlvSize = 0;
892 MessageParcelWarp messageData;
893 MessageParcel parcelPata;
894 sptr<IPasteboardDelayGetter> delayGetter = nullptr;
895 sptr<IPasteboardEntryGetter> entryGetter = nullptr;
896
897 int32_t ret = WritePasteData(pasteData, pasteDataTlv, fd, tlvSize, messageData, parcelPata);
898 ret = tempPasteboard->SetPasteData(dup(fd), tlvSize, pasteDataTlv, delayGetter, entryGetter);
899
900 PasteData getPasteData;
901 ret = tempPasteboard->GetLocalData(appInfo, getPasteData);
902 EXPECT_EQ(ret, static_cast<int32_t>(PasteboardError::E_OK));
903 PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "GetLocalDataTest022 end");
904 }
905
906 /**
907 * @tc.name: GetLocalDataTest0023
908 * @tc.desc: test Func GetLocalData
909 * @tc.type: FUNC
910 */
911 HWTEST_F(PasteboardServiceGetLocalDataTest, GetLocalDataTest0023, TestSize.Level0)
912 {
913 PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "GetLocalDataTest023 start");
914 auto tempPasteboard = std::make_shared<PasteboardService>();
915 EXPECT_NE(tempPasteboard, nullptr);
916
917 AppInfo appInfo;
918 appInfo.userId = tempPasteboard->GetCurrentAccountId();
919 PasteData pasteData;
920 std::string plainText = "hello";
921 pasteData.AddTextRecord(plainText);
922
923 ShareOption shareOption = ShareOption::CrossDevice;
924 pasteData.SetShareOption(shareOption);
925 pasteData.SetDraggedDataFlag(false);
926 pasteData.SetDelayData(true);
927
928 std::vector<uint8_t> pasteDataTlv(0);
929 int fd = -1;
930 int64_t tlvSize = 0;
931 MessageParcelWarp messageData;
932 MessageParcel parcelPata;
933 sptr<IPasteboardDelayGetter> delayGetter = nullptr;
934 sptr<IPasteboardEntryGetter> entryGetter = nullptr;
935
936 int32_t ret = WritePasteData(pasteData, pasteDataTlv, fd, tlvSize, messageData, parcelPata);
937 ret = tempPasteboard->SetPasteData(dup(fd), tlvSize, pasteDataTlv, delayGetter, entryGetter);
938
939 PasteData getPasteData;
940 ret = tempPasteboard->GetLocalData(appInfo, getPasteData);
941 EXPECT_EQ(ret, static_cast<int32_t>(PasteboardError::E_OK));
942 PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "GetLocalDataTest023 end");
943 }
944
945 /**
946 * @tc.name: GetLocalDataTest0024
947 * @tc.desc: test Func GetLocalData
948 * @tc.type: FUNC
949 */
950 HWTEST_F(PasteboardServiceGetLocalDataTest, GetLocalDataTest0024, TestSize.Level0)
951 {
952 PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "GetLocalDataTest024 start");
953 auto tempPasteboard = std::make_shared<PasteboardService>();
954 EXPECT_NE(tempPasteboard, nullptr);
955
956 AppInfo appInfo;
957 appInfo.userId = tempPasteboard->GetCurrentAccountId();
958 PasteData pasteData;
959 std::string plainText = "hello";
960 pasteData.AddTextRecord(plainText);
961
962 ShareOption shareOption = ShareOption::InApp;
963 pasteData.SetShareOption(shareOption);
964 pasteData.SetDraggedDataFlag(false);
965 pasteData.SetDelayData(false);
966 pasteData.SetDelayRecord(false);
967
968 std::vector<uint8_t> pasteDataTlv(0);
969 int fd = -1;
970 int64_t tlvSize = 0;
971 MessageParcelWarp messageData;
972 MessageParcel parcelPata;
973 sptr<IPasteboardDelayGetter> delayGetter = nullptr;
974 sptr<IPasteboardEntryGetter> entryGetter = nullptr;
975
976 int32_t ret = WritePasteData(pasteData, pasteDataTlv, fd, tlvSize, messageData, parcelPata);
977 ret = tempPasteboard->SetPasteData(dup(fd), tlvSize, pasteDataTlv, delayGetter, entryGetter);
978
979 PasteData getPasteData;
980 ret = tempPasteboard->GetLocalData(appInfo, getPasteData);
981 EXPECT_EQ(ret, static_cast<int32_t>(PasteboardError::PERMISSION_VERIFICATION_ERROR));
982 PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "GetLocalDataTest024 end");
983 }
984
985 /**
986 * @tc.name: GetLocalDataTest0025
987 * @tc.desc: test Func GetLocalData
988 * @tc.type: FUNC
989 */
990 HWTEST_F(PasteboardServiceGetLocalDataTest, GetLocalDataTest0025, TestSize.Level0)
991 {
992 PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "GetLocalDataTest025 start");
993 auto tempPasteboard = std::make_shared<PasteboardService>();
994 EXPECT_NE(tempPasteboard, nullptr);
995
996 AppInfo appInfo;
997 appInfo.userId = tempPasteboard->GetCurrentAccountId();
998 PasteData pasteData;
999 std::string plainText = "hello";
1000 pasteData.AddTextRecord(plainText);
1001
1002 ShareOption shareOption = ShareOption::LocalDevice;
1003 pasteData.SetShareOption(shareOption);
1004 pasteData.SetDraggedDataFlag(false);
1005 pasteData.SetDelayData(false);
1006 pasteData.SetDelayRecord(false);
1007
1008 std::vector<uint8_t> pasteDataTlv(0);
1009 int fd = -1;
1010 int64_t tlvSize = 0;
1011 MessageParcelWarp messageData;
1012 MessageParcel parcelPata;
1013 sptr<IPasteboardDelayGetter> delayGetter = nullptr;
1014 sptr<IPasteboardEntryGetter> entryGetter = nullptr;
1015
1016 int32_t ret = WritePasteData(pasteData, pasteDataTlv, fd, tlvSize, messageData, parcelPata);
1017 ret = tempPasteboard->SetPasteData(dup(fd), tlvSize, pasteDataTlv, delayGetter, entryGetter);
1018
1019 PasteData getPasteData;
1020 ret = tempPasteboard->GetLocalData(appInfo, getPasteData);
1021 EXPECT_EQ(ret, static_cast<int32_t>(PasteboardError::E_OK));
1022 PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "GetLocalDataTest025 end");
1023 }
1024
1025 /**
1026 * @tc.name: GetLocalDataTest0026
1027 * @tc.desc: test Func GetLocalData
1028 * @tc.type: FUNC
1029 */
1030 HWTEST_F(PasteboardServiceGetLocalDataTest, GetLocalDataTest0026, TestSize.Level0)
1031 {
1032 PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "GetLocalDataTest026 start");
1033 auto tempPasteboard = std::make_shared<PasteboardService>();
1034 EXPECT_NE(tempPasteboard, nullptr);
1035
1036 AppInfo appInfo;
1037 appInfo.userId = tempPasteboard->GetCurrentAccountId();
1038 PasteData pasteData;
1039 std::string plainText = "hello";
1040 pasteData.AddTextRecord(plainText);
1041
1042 ShareOption shareOption = ShareOption::CrossDevice;
1043 pasteData.SetShareOption(shareOption);
1044 pasteData.SetDraggedDataFlag(false);
1045 pasteData.SetDelayData(false);
1046 pasteData.SetDelayRecord(false);
1047
1048 std::vector<uint8_t> pasteDataTlv(0);
1049 int fd = -1;
1050 int64_t tlvSize = 0;
1051 MessageParcelWarp messageData;
1052 MessageParcel parcelPata;
1053 sptr<IPasteboardDelayGetter> delayGetter = nullptr;
1054 sptr<IPasteboardEntryGetter> entryGetter = nullptr;
1055
1056 int32_t ret = WritePasteData(pasteData, pasteDataTlv, fd, tlvSize, messageData, parcelPata);
1057 ret = tempPasteboard->SetPasteData(dup(fd), tlvSize, pasteDataTlv, delayGetter, entryGetter);
1058
1059 PasteData getPasteData;
1060 ret = tempPasteboard->GetLocalData(appInfo, getPasteData);
1061 EXPECT_EQ(ret, static_cast<int32_t>(PasteboardError::E_OK));
1062 PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "GetLocalDataTest026 end");
1063 }
1064
1065 /**
1066 * @tc.name: GetLocalDataTest0027
1067 * @tc.desc: test Func GetLocalData
1068 * @tc.type: FUNC
1069 */
1070 HWTEST_F(PasteboardServiceGetLocalDataTest, GetLocalDataTest0027, TestSize.Level0)
1071 {
1072 PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "GetLocalDataTest027 start");
1073 auto tempPasteboard = std::make_shared<PasteboardService>();
1074 EXPECT_NE(tempPasteboard, nullptr);
1075
1076 AppInfo appInfo;
1077 appInfo.userId = tempPasteboard->GetCurrentAccountId();
1078 PasteData pasteData;
1079 std::string plainText = "hello";
1080 pasteData.AddTextRecord(plainText);
1081
1082 ShareOption shareOption = ShareOption::InApp;
1083 pasteData.SetShareOption(shareOption);
1084 pasteData.SetDraggedDataFlag(false);
1085 pasteData.SetDelayData(false);
1086 pasteData.SetDelayRecord(true);
1087
1088 std::vector<uint8_t> pasteDataTlv(0);
1089 int fd = -1;
1090 int64_t tlvSize = 0;
1091 MessageParcelWarp messageData;
1092 MessageParcel parcelPata;
1093 sptr<IPasteboardDelayGetter> delayGetter = nullptr;
1094 sptr<IPasteboardEntryGetter> entryGetter = nullptr;
1095
1096 int32_t ret = WritePasteData(pasteData, pasteDataTlv, fd, tlvSize, messageData, parcelPata);
1097 ret = tempPasteboard->SetPasteData(dup(fd), tlvSize, pasteDataTlv, delayGetter, entryGetter);
1098
1099 PasteData getPasteData;
1100 ret = tempPasteboard->GetLocalData(appInfo, getPasteData);
1101 EXPECT_EQ(ret, static_cast<int32_t>(PasteboardError::PERMISSION_VERIFICATION_ERROR));
1102 PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "GetLocalDataTest027 end");
1103 }
1104
1105 /**
1106 * @tc.name: GetLocalDataTest0028
1107 * @tc.desc: test Func GetLocalData
1108 * @tc.type: FUNC
1109 */
1110 HWTEST_F(PasteboardServiceGetLocalDataTest, GetLocalDataTest0028, TestSize.Level0)
1111 {
1112 PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "GetLocalDataTest028 start");
1113 auto tempPasteboard = std::make_shared<PasteboardService>();
1114 EXPECT_NE(tempPasteboard, nullptr);
1115
1116 AppInfo appInfo;
1117 appInfo.userId = tempPasteboard->GetCurrentAccountId();
1118 PasteData pasteData;
1119 std::string plainText = "hello";
1120 pasteData.AddTextRecord(plainText);
1121
1122 ShareOption shareOption = ShareOption::LocalDevice;
1123 pasteData.SetShareOption(shareOption);
1124 pasteData.SetDraggedDataFlag(false);
1125 pasteData.SetDelayData(false);
1126 pasteData.SetDelayRecord(true);
1127
1128 std::vector<uint8_t> pasteDataTlv(0);
1129 int fd = -1;
1130 int64_t tlvSize = 0;
1131 MessageParcelWarp messageData;
1132 MessageParcel parcelPata;
1133 sptr<IPasteboardDelayGetter> delayGetter = nullptr;
1134 sptr<IPasteboardEntryGetter> entryGetter = nullptr;
1135
1136 int32_t ret = WritePasteData(pasteData, pasteDataTlv, fd, tlvSize, messageData, parcelPata);
1137 ret = tempPasteboard->SetPasteData(dup(fd), tlvSize, pasteDataTlv, delayGetter, entryGetter);
1138
1139 PasteData getPasteData;
1140 ret = tempPasteboard->GetLocalData(appInfo, getPasteData);
1141 EXPECT_EQ(ret, static_cast<int32_t>(PasteboardError::E_OK));
1142 PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "GetLocalDataTest028 end");
1143 }
1144
1145 /**
1146 * @tc.name: GetLocalDataTest0029
1147 * @tc.desc: test Func GetLocalData
1148 * @tc.type: FUNC
1149 */
1150 HWTEST_F(PasteboardServiceGetLocalDataTest, GetLocalDataTest0029, TestSize.Level0)
1151 {
1152 PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "GetLocalDataTest029 start");
1153 auto tempPasteboard = std::make_shared<PasteboardService>();
1154 EXPECT_NE(tempPasteboard, nullptr);
1155
1156 AppInfo appInfo;
1157 appInfo.userId = tempPasteboard->GetCurrentAccountId();
1158 PasteData pasteData;
1159 std::string plainText = "hello";
1160 pasteData.AddTextRecord(plainText);
1161
1162 ShareOption shareOption = ShareOption::CrossDevice;
1163 pasteData.SetShareOption(shareOption);
1164 pasteData.SetDraggedDataFlag(false);
1165 pasteData.SetDelayData(false);
1166 pasteData.SetDelayRecord(true);
1167
1168 std::vector<uint8_t> pasteDataTlv(0);
1169 int fd = -1;
1170 int64_t tlvSize = 0;
1171 MessageParcelWarp messageData;
1172 MessageParcel parcelPata;
1173 sptr<IPasteboardDelayGetter> delayGetter = nullptr;
1174 sptr<IPasteboardEntryGetter> entryGetter = nullptr;
1175
1176 int32_t ret = WritePasteData(pasteData, pasteDataTlv, fd, tlvSize, messageData, parcelPata);
1177 ret = tempPasteboard->SetPasteData(dup(fd), tlvSize, pasteDataTlv, delayGetter, entryGetter);
1178
1179 PasteData getPasteData;
1180 ret = tempPasteboard->GetLocalData(appInfo, getPasteData);
1181 EXPECT_EQ(ret, static_cast<int32_t>(PasteboardError::E_OK));
1182 PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "GetLocalDataTest029 end");
1183 }
1184
1185 /**
1186 * @tc.name: GetLocalDataTest0030
1187 * @tc.desc: test Func GetLocalData
1188 * @tc.type: FUNC
1189 */
1190 HWTEST_F(PasteboardServiceGetLocalDataTest, GetLocalDataTest0030, TestSize.Level0)
1191 {
1192 PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "GetLocalDataTest030 start");
1193 auto tempPasteboard = std::make_shared<PasteboardService>();
1194 EXPECT_NE(tempPasteboard, nullptr);
1195
1196 AppInfo appInfo;
1197 appInfo.userId = tempPasteboard->GetCurrentAccountId();
1198 PasteData pasteData;
1199 std::string plainText = "hello";
1200 pasteData.AddTextRecord(plainText);
1201
1202 ShareOption shareOption = ShareOption::InApp;
1203 pasteData.SetShareOption(shareOption);
1204 pasteData.SetDraggedDataFlag(false);
1205 pasteData.SetDelayData(true);
1206 pasteData.SetDelayRecord(false);
1207
1208 std::vector<uint8_t> pasteDataTlv(0);
1209 int fd = -1;
1210 int64_t tlvSize = 0;
1211 MessageParcelWarp messageData;
1212 MessageParcel parcelPata;
1213 sptr<IPasteboardDelayGetter> delayGetter = nullptr;
1214 sptr<IPasteboardEntryGetter> entryGetter = nullptr;
1215
1216 int32_t ret = WritePasteData(pasteData, pasteDataTlv, fd, tlvSize, messageData, parcelPata);
1217 ret = tempPasteboard->SetPasteData(dup(fd), tlvSize, pasteDataTlv, delayGetter, entryGetter);
1218
1219 PasteData getPasteData;
1220 ret = tempPasteboard->GetLocalData(appInfo, getPasteData);
1221 EXPECT_EQ(ret, static_cast<int32_t>(PasteboardError::PERMISSION_VERIFICATION_ERROR));
1222 PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "GetLocalDataTest030 end");
1223 }
1224
1225 /**
1226 * @tc.name: GetLocalDataTest0031
1227 * @tc.desc: test Func GetLocalData
1228 * @tc.type: FUNC
1229 */
1230 HWTEST_F(PasteboardServiceGetLocalDataTest, GetLocalDataTest0031, TestSize.Level0)
1231 {
1232 PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "GetLocalDataTest031 start");
1233 auto tempPasteboard = std::make_shared<PasteboardService>();
1234 EXPECT_NE(tempPasteboard, nullptr);
1235
1236 AppInfo appInfo;
1237 appInfo.userId = tempPasteboard->GetCurrentAccountId();
1238 PasteData pasteData;
1239 std::string plainText = "hello";
1240 pasteData.AddTextRecord(plainText);
1241
1242 ShareOption shareOption = ShareOption::LocalDevice;
1243 pasteData.SetShareOption(shareOption);
1244 pasteData.SetDraggedDataFlag(false);
1245 pasteData.SetDelayData(true);
1246 pasteData.SetDelayRecord(false);
1247
1248 std::vector<uint8_t> pasteDataTlv(0);
1249 int fd = -1;
1250 int64_t tlvSize = 0;
1251 MessageParcelWarp messageData;
1252 MessageParcel parcelPata;
1253 sptr<IPasteboardDelayGetter> delayGetter = nullptr;
1254 sptr<IPasteboardEntryGetter> entryGetter = nullptr;
1255
1256 int32_t ret = WritePasteData(pasteData, pasteDataTlv, fd, tlvSize, messageData, parcelPata);
1257 ret = tempPasteboard->SetPasteData(dup(fd), tlvSize, pasteDataTlv, delayGetter, entryGetter);
1258
1259 PasteData getPasteData;
1260 ret = tempPasteboard->GetLocalData(appInfo, getPasteData);
1261 EXPECT_EQ(ret, static_cast<int32_t>(PasteboardError::E_OK));
1262 PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "GetLocalDataTest031 end");
1263 }
1264
1265 /**
1266 * @tc.name: GetLocalDataTest0032
1267 * @tc.desc: test Func GetLocalData
1268 * @tc.type: FUNC
1269 */
1270 HWTEST_F(PasteboardServiceGetLocalDataTest, GetLocalDataTest0032, TestSize.Level0)
1271 {
1272 PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "GetLocalDataTest032 start");
1273 auto tempPasteboard = std::make_shared<PasteboardService>();
1274 EXPECT_NE(tempPasteboard, nullptr);
1275
1276 AppInfo appInfo;
1277 appInfo.userId = tempPasteboard->GetCurrentAccountId();
1278 PasteData pasteData;
1279 std::string plainText = "hello";
1280 pasteData.AddTextRecord(plainText);
1281
1282 ShareOption shareOption = ShareOption::CrossDevice;
1283 pasteData.SetShareOption(shareOption);
1284 pasteData.SetDraggedDataFlag(false);
1285 pasteData.SetDelayData(true);
1286 pasteData.SetDelayRecord(false);
1287
1288 std::vector<uint8_t> pasteDataTlv(0);
1289 int fd = -1;
1290 int64_t tlvSize = 0;
1291 MessageParcelWarp messageData;
1292 MessageParcel parcelPata;
1293 sptr<IPasteboardDelayGetter> delayGetter = nullptr;
1294 sptr<IPasteboardEntryGetter> entryGetter = nullptr;
1295
1296 int32_t ret = WritePasteData(pasteData, pasteDataTlv, fd, tlvSize, messageData, parcelPata);
1297 ret = tempPasteboard->SetPasteData(dup(fd), tlvSize, pasteDataTlv, delayGetter, entryGetter);
1298
1299 PasteData getPasteData;
1300 ret = tempPasteboard->GetLocalData(appInfo, getPasteData);
1301 EXPECT_EQ(ret, static_cast<int32_t>(PasteboardError::E_OK));
1302 PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "GetLocalDataTest032 end");
1303 }
1304
1305 /**
1306 * @tc.name: GetLocalDataTest0033
1307 * @tc.desc: test Func GetLocalData
1308 * @tc.type: FUNC
1309 */
1310 HWTEST_F(PasteboardServiceGetLocalDataTest, GetLocalDataTest0033, TestSize.Level0)
1311 {
1312 PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "GetLocalDataTest033 start");
1313 auto tempPasteboard = std::make_shared<PasteboardService>();
1314 EXPECT_NE(tempPasteboard, nullptr);
1315
1316 AppInfo appInfo;
1317 appInfo.userId = tempPasteboard->GetCurrentAccountId();
1318 PasteData pasteData;
1319 std::string plainText = "hello";
1320 pasteData.AddTextRecord(plainText);
1321
1322 ShareOption shareOption = ShareOption::InApp;
1323 pasteData.SetShareOption(shareOption);
1324 pasteData.SetDraggedDataFlag(false);
1325 pasteData.SetDelayData(true);
1326 pasteData.SetDelayRecord(true);
1327
1328 std::vector<uint8_t> pasteDataTlv(0);
1329 int fd = -1;
1330 int64_t tlvSize = 0;
1331 MessageParcelWarp messageData;
1332 MessageParcel parcelPata;
1333 sptr<IPasteboardDelayGetter> delayGetter = nullptr;
1334 sptr<IPasteboardEntryGetter> entryGetter = nullptr;
1335
1336 int32_t ret = WritePasteData(pasteData, pasteDataTlv, fd, tlvSize, messageData, parcelPata);
1337 ret = tempPasteboard->SetPasteData(dup(fd), tlvSize, pasteDataTlv, delayGetter, entryGetter);
1338
1339 PasteData getPasteData;
1340 ret = tempPasteboard->GetLocalData(appInfo, getPasteData);
1341 EXPECT_EQ(ret, static_cast<int32_t>(PasteboardError::PERMISSION_VERIFICATION_ERROR));
1342 PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "GetLocalDataTest033 end");
1343 }
1344
1345 /**
1346 * @tc.name: GetLocalDataTest0034
1347 * @tc.desc: test Func GetLocalData
1348 * @tc.type: FUNC
1349 */
1350 HWTEST_F(PasteboardServiceGetLocalDataTest, GetLocalDataTest0034, TestSize.Level0)
1351 {
1352 PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "GetLocalDataTest034 start");
1353 auto tempPasteboard = std::make_shared<PasteboardService>();
1354 EXPECT_NE(tempPasteboard, nullptr);
1355
1356 AppInfo appInfo;
1357 appInfo.userId = tempPasteboard->GetCurrentAccountId();
1358 PasteData pasteData;
1359 std::string plainText = "hello";
1360 pasteData.AddTextRecord(plainText);
1361
1362 ShareOption shareOption = ShareOption::LocalDevice;
1363 pasteData.SetShareOption(shareOption);
1364 pasteData.SetDraggedDataFlag(false);
1365 pasteData.SetDelayData(true);
1366 pasteData.SetDelayRecord(true);
1367
1368 std::vector<uint8_t> pasteDataTlv(0);
1369 int fd = -1;
1370 int64_t tlvSize = 0;
1371 MessageParcelWarp messageData;
1372 MessageParcel parcelPata;
1373 sptr<IPasteboardDelayGetter> delayGetter = nullptr;
1374 sptr<IPasteboardEntryGetter> entryGetter = nullptr;
1375
1376 int32_t ret = WritePasteData(pasteData, pasteDataTlv, fd, tlvSize, messageData, parcelPata);
1377 ret = tempPasteboard->SetPasteData(dup(fd), tlvSize, pasteDataTlv, delayGetter, entryGetter);
1378
1379 PasteData getPasteData;
1380 ret = tempPasteboard->GetLocalData(appInfo, getPasteData);
1381 EXPECT_EQ(ret, static_cast<int32_t>(PasteboardError::E_OK));
1382 PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "GetLocalDataTest034 end");
1383 }
1384
1385 /**
1386 * @tc.name: GetLocalDataTest0035
1387 * @tc.desc: test Func GetLocalData
1388 * @tc.type: FUNC
1389 */
1390 HWTEST_F(PasteboardServiceGetLocalDataTest, GetLocalDataTest0035, TestSize.Level0)
1391 {
1392 PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "GetLocalDataTest035 start");
1393 auto tempPasteboard = std::make_shared<PasteboardService>();
1394 EXPECT_NE(tempPasteboard, nullptr);
1395
1396 AppInfo appInfo;
1397 appInfo.userId = tempPasteboard->GetCurrentAccountId();
1398 PasteData pasteData;
1399 std::string plainText = "hello";
1400 pasteData.AddTextRecord(plainText);
1401
1402 ShareOption shareOption = ShareOption::CrossDevice;
1403 pasteData.SetShareOption(shareOption);
1404 pasteData.SetDraggedDataFlag(false);
1405 pasteData.SetDelayData(true);
1406 pasteData.SetDelayRecord(true);
1407
1408 std::vector<uint8_t> pasteDataTlv(0);
1409 int fd = -1;
1410 int64_t tlvSize = 0;
1411 MessageParcelWarp messageData;
1412 MessageParcel parcelPata;
1413 sptr<IPasteboardDelayGetter> delayGetter = nullptr;
1414 sptr<IPasteboardEntryGetter> entryGetter = nullptr;
1415
1416 int32_t ret = WritePasteData(pasteData, pasteDataTlv, fd, tlvSize, messageData, parcelPata);
1417 ret = tempPasteboard->SetPasteData(dup(fd), tlvSize, pasteDataTlv, delayGetter, entryGetter);
1418
1419 PasteData getPasteData;
1420 ret = tempPasteboard->GetLocalData(appInfo, getPasteData);
1421 EXPECT_EQ(ret, static_cast<int32_t>(PasteboardError::E_OK));
1422 PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "GetLocalDataTest035 end");
1423 }
1424
1425 /**
1426 * @tc.name: GetLocalDataTest0036
1427 * @tc.desc: test Func GetLocalData
1428 * @tc.type: FUNC
1429 */
1430 HWTEST_F(PasteboardServiceGetLocalDataTest, GetLocalDataTest0036, TestSize.Level0)
1431 {
1432 PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "GetLocalDataTest036 start");
1433 auto tempPasteboard = std::make_shared<PasteboardService>();
1434 EXPECT_NE(tempPasteboard, nullptr);
1435
1436 AppInfo appInfo;
1437 appInfo.userId = tempPasteboard->GetCurrentAccountId();
1438 PasteData pasteData;
1439 std::string plainText = "hello";
1440 pasteData.AddTextRecord(plainText);
1441
1442 std::vector<uint8_t> pasteDataTlv(0);
1443 int fd = -1;
1444 int64_t tlvSize = 0;
1445 MessageParcelWarp messageData;
1446 MessageParcel parcelPata;
1447 sptr<IPasteboardDelayGetter> delayGetter = nullptr;
1448 sptr<IPasteboardEntryGetter> entryGetter = nullptr;
1449
1450 int32_t ret = WritePasteData(pasteData, pasteDataTlv, fd, tlvSize, messageData, parcelPata);
1451 ret = tempPasteboard->SetPasteData(dup(fd), tlvSize, pasteDataTlv, delayGetter, entryGetter);
1452
1453 PasteData getPasteData;
1454 ret = tempPasteboard->GetLocalData(appInfo, getPasteData);
1455 EXPECT_EQ(ret, static_cast<int32_t>(PasteboardError::E_OK));
1456
1457 tempPasteboard->copyTime_.Clear();
1458 ret = tempPasteboard->GetLocalData(appInfo, getPasteData);
1459 EXPECT_EQ(ret, static_cast<int32_t>(PasteboardError::NO_DATA_ERROR));
1460 PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "GetLocalDataTest036 end");
1461 }
1462
1463 /**
1464 * @tc.name: GetLocalDataTest037
1465 * @tc.desc: test Func GetLocalData
1466 * @tc.type: FUNC
1467 */
1468 HWTEST_F(PasteboardServiceGetLocalDataTest, GetLocalDataTest037, TestSize.Level0)
1469 {
1470 PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "GetLocalDataTest037 start");
1471 auto tempPasteboard = std::make_shared<PasteboardService>();
1472 EXPECT_NE(tempPasteboard, nullptr);
1473
1474 AppInfo appInfo;
1475 appInfo.userId = tempPasteboard->GetCurrentAccountId();
1476 PasteData pasteData;
1477 std::string plainText = "hello";
1478 pasteData.AddTextRecord(plainText);
1479
1480 std::vector<uint8_t> pasteDataTlv(0);
1481 int fd = -1;
1482 int64_t tlvSize = 0;
1483 MessageParcelWarp messageData;
1484 MessageParcel parcelPata;
1485 sptr<IPasteboardDelayGetter> delayGetter = nullptr;
1486 sptr<IPasteboardEntryGetter> entryGetter = nullptr;
1487
1488 int32_t ret = WritePasteData(pasteData, pasteDataTlv, fd, tlvSize, messageData, parcelPata);
1489 ret = tempPasteboard->SetPasteData(dup(fd), tlvSize, pasteDataTlv, delayGetter, entryGetter);
1490
1491 PasteData getPasteData;
1492 ret = tempPasteboard->GetLocalData(appInfo, getPasteData);
1493 EXPECT_EQ(ret, static_cast<int32_t>(PasteboardError::E_OK));
1494
1495 tempPasteboard->clips_.Clear();
1496 ret = tempPasteboard->GetLocalData(appInfo, getPasteData);
1497 EXPECT_EQ(ret, static_cast<int32_t>(PasteboardError::NO_DATA_ERROR));
1498 PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "GetLocalDataTest037 end");
1499 }
1500
1501 /**
1502 * @tc.name: GetLocalDataTest038
1503 * @tc.desc: test Func GetLocalData
1504 * @tc.type: FUNC
1505 */
1506 HWTEST_F(PasteboardServiceGetLocalDataTest, GetLocalDataTest038, TestSize.Level0)
1507 {
1508 PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "GetLocalDataTest038 start");
1509 auto tempPasteboard = std::make_shared<PasteboardService>();
1510 EXPECT_NE(tempPasteboard, nullptr);
1511
1512 AppInfo appInfo;
1513 appInfo.userId = tempPasteboard->GetCurrentAccountId();
1514 PasteData pasteData;
1515 std::string plainText = "hello";
1516 pasteData.AddTextRecord(plainText);
1517
1518 std::vector<uint8_t> pasteDataTlv(0);
1519 int fd = -1;
1520 int64_t tlvSize = 0;
1521 MessageParcelWarp messageData;
1522 MessageParcel parcelPata;
1523 sptr<IPasteboardDelayGetter> delayGetter = nullptr;
1524 sptr<IPasteboardEntryGetter> entryGetter = nullptr;
1525
1526 int32_t ret = WritePasteData(pasteData, pasteDataTlv, fd, tlvSize, messageData, parcelPata);
1527 ret = tempPasteboard->SetPasteData(dup(fd), tlvSize, pasteDataTlv, delayGetter, entryGetter);
1528
1529 PasteData getPasteData;
1530 ret = tempPasteboard->GetLocalData(appInfo, getPasteData);
1531 EXPECT_EQ(ret, static_cast<int32_t>(PasteboardError::E_OK));
1532
1533 tempPasteboard->copyTime_.Clear();
1534 tempPasteboard->clips_.Clear();
1535 ret = tempPasteboard->GetLocalData(appInfo, getPasteData);
1536 EXPECT_EQ(ret, static_cast<int32_t>(PasteboardError::NO_DATA_ERROR));
1537 PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "GetLocalDataTest038 end");
1538 }
1539 } // namespace MiscServices
1540 } // namespace OHOS