1bc03f14fSopenharmony_ci/*
2bc03f14fSopenharmony_ci * Copyright (C) 2024 Huawei Device Co., Ltd.
3bc03f14fSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the 'License');
4bc03f14fSopenharmony_ci * you may not use this file except in compliance with the License.
5bc03f14fSopenharmony_ci * You may obtain a copy of the License at
6bc03f14fSopenharmony_ci *
7bc03f14fSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8bc03f14fSopenharmony_ci *
9bc03f14fSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10bc03f14fSopenharmony_ci * distributed under the License is distributed on an 'AS IS' BASIS,
11bc03f14fSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12bc03f14fSopenharmony_ci * See the License for the specific language governing permissions and
13bc03f14fSopenharmony_ci * limitations under the License.
14bc03f14fSopenharmony_ci */
15bc03f14fSopenharmony_ci
16bc03f14fSopenharmony_ciimport { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index';
17bc03f14fSopenharmony_ciimport pasteboard from '@ohos.pasteboard';
18bc03f14fSopenharmony_ciimport UDC from '@ohos.data.unifiedDataChannel';
19bc03f14fSopenharmony_ciimport UTD from '@ohos.data.uniformTypeDescriptor'
20bc03f14fSopenharmony_ciimport image from '@ohos.multimedia.image';
21bc03f14fSopenharmony_ci
22bc03f14fSopenharmony_ciconst KEY_TEST_ELEMENT = 'TestKey';
23bc03f14fSopenharmony_ciconst VALUE_TEST_ELEMENT = 'TestValue';
24bc03f14fSopenharmony_ciconst TEST_BUNDLE_NAME = 'MyBundleName';
25bc03f14fSopenharmony_ciconst TEST_ABILITY_NAME = 'MyAbilityName';
26bc03f14fSopenharmony_ci
27bc03f14fSopenharmony_cilet U8_ARRAY = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
28bc03f14fSopenharmony_ci
29bc03f14fSopenharmony_civar data = new UDC.UnifiedData();
30bc03f14fSopenharmony_ci
31bc03f14fSopenharmony_cidescribe('PasteBoardUdmfDelayJSTest', function () {
32bc03f14fSopenharmony_ci    beforeAll(async function () {
33bc03f14fSopenharmony_ci        console.info('beforeAll');
34bc03f14fSopenharmony_ci    });
35bc03f14fSopenharmony_ci
36bc03f14fSopenharmony_ci    afterAll(async function () {
37bc03f14fSopenharmony_ci        console.info('afterAll');
38bc03f14fSopenharmony_ci    });
39bc03f14fSopenharmony_ci
40bc03f14fSopenharmony_ci    beforeEach(async function () {
41bc03f14fSopenharmony_ci        console.info('beforeEach');
42bc03f14fSopenharmony_ci        const systemPasteboard = pasteboard.getSystemPasteboard();
43bc03f14fSopenharmony_ci        await systemPasteboard.clearData();
44bc03f14fSopenharmony_ci        data = new UDC.UnifiedData();
45bc03f14fSopenharmony_ci    });
46bc03f14fSopenharmony_ci
47bc03f14fSopenharmony_ci    afterEach(async function () {
48bc03f14fSopenharmony_ci        console.info('afterEach');
49bc03f14fSopenharmony_ci    });
50bc03f14fSopenharmony_ci
51bc03f14fSopenharmony_ci    function getTextData(dataType) {
52bc03f14fSopenharmony_ci        let text = new UDC.Text();
53bc03f14fSopenharmony_ci        text.details = {
54bc03f14fSopenharmony_ci            Key: 'text' + KEY_TEST_ELEMENT,
55bc03f14fSopenharmony_ci            Value: 'text' + VALUE_TEST_ELEMENT,
56bc03f14fSopenharmony_ci        };
57bc03f14fSopenharmony_ci        data.addRecord(text);
58bc03f14fSopenharmony_ci        return data;
59bc03f14fSopenharmony_ci    }
60bc03f14fSopenharmony_ci
61bc03f14fSopenharmony_ci    function getPlainTextData(dataType) {
62bc03f14fSopenharmony_ci        let plainText = new UDC.PlainText();
63bc03f14fSopenharmony_ci        plainText.details = {
64bc03f14fSopenharmony_ci            Key: 'plainText' + KEY_TEST_ELEMENT,
65bc03f14fSopenharmony_ci            Value: 'plainText' + VALUE_TEST_ELEMENT,
66bc03f14fSopenharmony_ci        };
67bc03f14fSopenharmony_ci        plainText.textContent = 'textContent';
68bc03f14fSopenharmony_ci        plainText.abstract = 'abstract';
69bc03f14fSopenharmony_ci        data.addRecord(plainText);
70bc03f14fSopenharmony_ci        return data;
71bc03f14fSopenharmony_ci    }
72bc03f14fSopenharmony_ci
73bc03f14fSopenharmony_ci    function getHyperlinkData(dataType) {
74bc03f14fSopenharmony_ci        let link = new UDC.Hyperlink();
75bc03f14fSopenharmony_ci        link.details = {
76bc03f14fSopenharmony_ci            Key: 'hyperLink' + KEY_TEST_ELEMENT,
77bc03f14fSopenharmony_ci            Value: 'hyperLink' + VALUE_TEST_ELEMENT,
78bc03f14fSopenharmony_ci        };
79bc03f14fSopenharmony_ci        link.url = 'url';
80bc03f14fSopenharmony_ci        link.description = 'description';
81bc03f14fSopenharmony_ci        data.addRecord(link);
82bc03f14fSopenharmony_ci        return data;
83bc03f14fSopenharmony_ci    }
84bc03f14fSopenharmony_ci
85bc03f14fSopenharmony_ci    function getHtmlData(dataType) {
86bc03f14fSopenharmony_ci        let html = new UDC.HTML();
87bc03f14fSopenharmony_ci        html.details = {
88bc03f14fSopenharmony_ci            Key: 'html' + KEY_TEST_ELEMENT,
89bc03f14fSopenharmony_ci            Value: 'html' + VALUE_TEST_ELEMENT,
90bc03f14fSopenharmony_ci        };
91bc03f14fSopenharmony_ci        html.htmlContent = 'htmlContent';
92bc03f14fSopenharmony_ci        html.plainContent = 'plainContent';
93bc03f14fSopenharmony_ci        data.addRecord(html);
94bc03f14fSopenharmony_ci        return data;
95bc03f14fSopenharmony_ci    }
96bc03f14fSopenharmony_ci
97bc03f14fSopenharmony_ci    function getFileData(dataType) {
98bc03f14fSopenharmony_ci        let file = new UDC.File();
99bc03f14fSopenharmony_ci        file.details = {
100bc03f14fSopenharmony_ci            Key: 'file' + KEY_TEST_ELEMENT,
101bc03f14fSopenharmony_ci            Value: 'file' + VALUE_TEST_ELEMENT,
102bc03f14fSopenharmony_ci        };
103bc03f14fSopenharmony_ci        file.uri = 'uri';
104bc03f14fSopenharmony_ci        data.addRecord(file);
105bc03f14fSopenharmony_ci        return data;
106bc03f14fSopenharmony_ci    }
107bc03f14fSopenharmony_ci
108bc03f14fSopenharmony_ci    function getFolderData(dataType) {
109bc03f14fSopenharmony_ci        let folder = new UDC.Folder();
110bc03f14fSopenharmony_ci        folder.details = {
111bc03f14fSopenharmony_ci            Key: 'folder' + KEY_TEST_ELEMENT,
112bc03f14fSopenharmony_ci            Value: 'folder' + VALUE_TEST_ELEMENT,
113bc03f14fSopenharmony_ci        };
114bc03f14fSopenharmony_ci        folder.uri = 'folderUri';
115bc03f14fSopenharmony_ci        data.addRecord(folder);
116bc03f14fSopenharmony_ci        return data;
117bc03f14fSopenharmony_ci    }
118bc03f14fSopenharmony_ci
119bc03f14fSopenharmony_ci    function getImageData(dataType) {
120bc03f14fSopenharmony_ci        let image = new UDC.Image();
121bc03f14fSopenharmony_ci        image.details = {
122bc03f14fSopenharmony_ci            Key: 'image' + KEY_TEST_ELEMENT,
123bc03f14fSopenharmony_ci            Value: 'image' + VALUE_TEST_ELEMENT,
124bc03f14fSopenharmony_ci        };
125bc03f14fSopenharmony_ci        image.imageUri = 'imageUri';
126bc03f14fSopenharmony_ci        data.addRecord(image);
127bc03f14fSopenharmony_ci        return data;
128bc03f14fSopenharmony_ci    }
129bc03f14fSopenharmony_ci
130bc03f14fSopenharmony_ci    function getVideoData(dataType) {
131bc03f14fSopenharmony_ci        let video = new UDC.Video();
132bc03f14fSopenharmony_ci        video.details = {
133bc03f14fSopenharmony_ci            Key: 'video' + KEY_TEST_ELEMENT,
134bc03f14fSopenharmony_ci            Value: 'video' + VALUE_TEST_ELEMENT,
135bc03f14fSopenharmony_ci        };
136bc03f14fSopenharmony_ci        video.videoUri = 'videoUri';
137bc03f14fSopenharmony_ci        data.addRecord(video);
138bc03f14fSopenharmony_ci        return data;
139bc03f14fSopenharmony_ci    }
140bc03f14fSopenharmony_ci
141bc03f14fSopenharmony_ci    function getAudioData(dataType) {
142bc03f14fSopenharmony_ci        let audio = new UDC.Audio();
143bc03f14fSopenharmony_ci        audio.details = {
144bc03f14fSopenharmony_ci            Key: 'audio' + KEY_TEST_ELEMENT,
145bc03f14fSopenharmony_ci            Value: 'audio' + VALUE_TEST_ELEMENT,
146bc03f14fSopenharmony_ci        };
147bc03f14fSopenharmony_ci        audio.audioUri = 'audioUri';
148bc03f14fSopenharmony_ci        data.addRecord(audio);
149bc03f14fSopenharmony_ci        return data;
150bc03f14fSopenharmony_ci    }
151bc03f14fSopenharmony_ci
152bc03f14fSopenharmony_ci    function getSystemDefinedAppItemDataData(dataType) {
153bc03f14fSopenharmony_ci        let appItem = new UDC.SystemDefinedAppItem();
154bc03f14fSopenharmony_ci        appItem.appId = 'MyAppId';
155bc03f14fSopenharmony_ci        appItem.appName = 'MyAppName';
156bc03f14fSopenharmony_ci        appItem.abilityName = TEST_ABILITY_NAME;
157bc03f14fSopenharmony_ci        appItem.bundleName = TEST_BUNDLE_NAME;
158bc03f14fSopenharmony_ci        appItem.appIconId = 'MyAppIconId';
159bc03f14fSopenharmony_ci        appItem.appLabelId = 'MyAppLabelId';
160bc03f14fSopenharmony_ci        appItem.details = {
161bc03f14fSopenharmony_ci            appItemKey1: 1,
162bc03f14fSopenharmony_ci            appItemKey2: 'appItem' + VALUE_TEST_ELEMENT,
163bc03f14fSopenharmony_ci            appItemKey3: U8_ARRAY,
164bc03f14fSopenharmony_ci        };
165bc03f14fSopenharmony_ci        data.addRecord(appItem);
166bc03f14fSopenharmony_ci        return data;
167bc03f14fSopenharmony_ci    }
168bc03f14fSopenharmony_ci
169bc03f14fSopenharmony_ci    function getApplicationDefinedRecordData(dataType) {
170bc03f14fSopenharmony_ci        let applicationDefinedRecord = new UDC.ApplicationDefinedRecord();
171bc03f14fSopenharmony_ci        applicationDefinedRecord.applicationDefinedType = 'applicationDefinedType';
172bc03f14fSopenharmony_ci        applicationDefinedRecord.rawData = U8_ARRAY;
173bc03f14fSopenharmony_ci        data.addRecord(applicationDefinedRecord);
174bc03f14fSopenharmony_ci        return data;
175bc03f14fSopenharmony_ci    }
176bc03f14fSopenharmony_ci
177bc03f14fSopenharmony_ci    function getWantData(dataType) {
178bc03f14fSopenharmony_ci        let object = {
179bc03f14fSopenharmony_ci            bundleName: 'bundleName',
180bc03f14fSopenharmony_ci            abilityName: 'abilityName'
181bc03f14fSopenharmony_ci        }
182bc03f14fSopenharmony_ci        let wantRecord = new UDC.UnifiedRecord(UTD.UniformDataType.OPENHARMONY_WANT, object);
183bc03f14fSopenharmony_ci        data.addRecord(wantRecord);
184bc03f14fSopenharmony_ci        return data;
185bc03f14fSopenharmony_ci    }
186bc03f14fSopenharmony_ci
187bc03f14fSopenharmony_ci    function getPixelMapData(dataType) {
188bc03f14fSopenharmony_ci        const buffer = new ArrayBuffer(128);
189bc03f14fSopenharmony_ci        const opt = {
190bc03f14fSopenharmony_ci            size: { height: 5, width: 5 },
191bc03f14fSopenharmony_ci            pixelFormat: 3,
192bc03f14fSopenharmony_ci            editable: true,
193bc03f14fSopenharmony_ci            alphaType: 1,
194bc03f14fSopenharmony_ci            scaleMode: 1,
195bc03f14fSopenharmony_ci        };
196bc03f14fSopenharmony_ci        const pixelMap = image.createPixelMapSync(buffer, opt);
197bc03f14fSopenharmony_ci        let pixelMapRecord = new UDC.UnifiedRecord(UTD.UniformDataType.OPENHARMONY_PIXEL_MAP, pixelMap);
198bc03f14fSopenharmony_ci        data.addRecord(pixelMapRecord);
199bc03f14fSopenharmony_ci        return data;
200bc03f14fSopenharmony_ci    }
201bc03f14fSopenharmony_ci
202bc03f14fSopenharmony_ci    /**
203bc03f14fSopenharmony_ci     * @tc.name TextTest001
204bc03f14fSopenharmony_ci     * @tc.desc Test Unified Record of Text
205bc03f14fSopenharmony_ci     * @tc.type FUNC
206bc03f14fSopenharmony_ci     */
207bc03f14fSopenharmony_ci    it('TextTest001', 0, async function (done) {
208bc03f14fSopenharmony_ci        let properties = new UDC.UnifiedDataProperties();
209bc03f14fSopenharmony_ci        properties.getDelayData = getTextData;
210bc03f14fSopenharmony_ci        data.properties = properties;
211bc03f14fSopenharmony_ci        const systemPasteboard = pasteboard.getSystemPasteboard();
212bc03f14fSopenharmony_ci        await systemPasteboard.setUnifiedData(data);
213bc03f14fSopenharmony_ci        const flag = await systemPasteboard.hasPasteData();
214bc03f14fSopenharmony_ci        expect(flag).assertEqual(true);
215bc03f14fSopenharmony_ci        let unifiedData = await systemPasteboard.getUnifiedData();
216bc03f14fSopenharmony_ci        let records = unifiedData.getRecords();
217bc03f14fSopenharmony_ci        expect(records.length).assertEqual(1);
218bc03f14fSopenharmony_ci        expect(records[0].details.Key).assertEqual('text' + KEY_TEST_ELEMENT);
219bc03f14fSopenharmony_ci        expect(records[0].details.Value).assertEqual('text' + VALUE_TEST_ELEMENT);
220bc03f14fSopenharmony_ci        let pasteData = await systemPasteboard.getData();
221bc03f14fSopenharmony_ci        expect(pasteData.getRecordCount()).assertEqual(1);
222bc03f14fSopenharmony_ci        expect(pasteData.getPrimaryMimeType()).assertEqual('general.text');
223bc03f14fSopenharmony_ci        done();
224bc03f14fSopenharmony_ci        console.info('TextTest001 end');
225bc03f14fSopenharmony_ci    });
226bc03f14fSopenharmony_ci
227bc03f14fSopenharmony_ci    /**
228bc03f14fSopenharmony_ci     * @tc.name PlainTextTest001
229bc03f14fSopenharmony_ci     * @tc.desc Test Unified Record of Plain Text
230bc03f14fSopenharmony_ci     * @tc.type FUNC
231bc03f14fSopenharmony_ci     */
232bc03f14fSopenharmony_ci    it('PlainTextTest001', 0, async function (done) {
233bc03f14fSopenharmony_ci        console.info('PlainTextTest001 begin');
234bc03f14fSopenharmony_ci        let properties = new UDC.UnifiedDataProperties();
235bc03f14fSopenharmony_ci        properties.getDelayData = getPlainTextData;
236bc03f14fSopenharmony_ci        data.properties = properties;
237bc03f14fSopenharmony_ci        const systemPasteboard = pasteboard.getSystemPasteboard();
238bc03f14fSopenharmony_ci        await systemPasteboard.setUnifiedData(data);
239bc03f14fSopenharmony_ci        const flag = await systemPasteboard.hasPasteData();
240bc03f14fSopenharmony_ci        expect(flag).assertEqual(true);
241bc03f14fSopenharmony_ci        let unifiedData = await systemPasteboard.getUnifiedData();
242bc03f14fSopenharmony_ci        let records = unifiedData.getRecords();
243bc03f14fSopenharmony_ci        expect(records.length).assertEqual(1);
244bc03f14fSopenharmony_ci        expect(records[0].details.Key).assertEqual('plainText' + KEY_TEST_ELEMENT);
245bc03f14fSopenharmony_ci        expect(records[0].details.Value).assertEqual('plainText' + VALUE_TEST_ELEMENT);
246bc03f14fSopenharmony_ci        expect(records[0].textContent).assertEqual('textContent');
247bc03f14fSopenharmony_ci        expect(records[0].abstract).assertEqual('abstract');
248bc03f14fSopenharmony_ci        let pasteData = await systemPasteboard.getData();
249bc03f14fSopenharmony_ci        expect(pasteData.getRecordCount()).assertEqual(1);
250bc03f14fSopenharmony_ci        expect(pasteData.getPrimaryMimeType()).assertEqual(pasteboard.MIMETYPE_TEXT_PLAIN);
251bc03f14fSopenharmony_ci        const primaryText = pasteData.getPrimaryText();
252bc03f14fSopenharmony_ci        expect(primaryText).assertEqual('textContent');
253bc03f14fSopenharmony_ci        done();
254bc03f14fSopenharmony_ci        console.info('PlainTextTest001 end');
255bc03f14fSopenharmony_ci    });
256bc03f14fSopenharmony_ci
257bc03f14fSopenharmony_ci    /**
258bc03f14fSopenharmony_ci     * @tc.name HyperlinkTest001
259bc03f14fSopenharmony_ci     * @tc.desc Test Unified Record of Hyper Link
260bc03f14fSopenharmony_ci     * @tc.type FUNC
261bc03f14fSopenharmony_ci     */
262bc03f14fSopenharmony_ci    it('HyperlinkTest001', 0, async function (done) {
263bc03f14fSopenharmony_ci        console.info('HyperlinkTest001 begin');
264bc03f14fSopenharmony_ci        let properties = new UDC.UnifiedDataProperties();
265bc03f14fSopenharmony_ci        properties.getDelayData = getHyperlinkData;
266bc03f14fSopenharmony_ci        data.properties = properties;
267bc03f14fSopenharmony_ci        const systemPasteboard = pasteboard.getSystemPasteboard();
268bc03f14fSopenharmony_ci        await systemPasteboard.setUnifiedData(data);
269bc03f14fSopenharmony_ci        const flag = await systemPasteboard.hasPasteData();
270bc03f14fSopenharmony_ci        expect(flag).assertEqual(true);
271bc03f14fSopenharmony_ci        let unifiedData = await systemPasteboard.getUnifiedData();
272bc03f14fSopenharmony_ci        let records = unifiedData.getRecords();
273bc03f14fSopenharmony_ci        expect(records.length).assertEqual(1);
274bc03f14fSopenharmony_ci        expect(records[0].details.Key).assertEqual('hyperLink' + KEY_TEST_ELEMENT);
275bc03f14fSopenharmony_ci        expect(records[0].details.Value).assertEqual('hyperLink' + VALUE_TEST_ELEMENT);
276bc03f14fSopenharmony_ci        expect(records[0].url).assertEqual('url');
277bc03f14fSopenharmony_ci        expect(records[0].description).assertEqual('description');
278bc03f14fSopenharmony_ci        let pasteData = await systemPasteboard.getData();
279bc03f14fSopenharmony_ci        expect(pasteData.getRecordCount()).assertEqual(1);
280bc03f14fSopenharmony_ci        expect(pasteData.getPrimaryMimeType()).assertEqual(pasteboard.MIMETYPE_TEXT_PLAIN);
281bc03f14fSopenharmony_ci        const primaryText = pasteData.getPrimaryText();
282bc03f14fSopenharmony_ci        expect(primaryText).assertEqual('url');
283bc03f14fSopenharmony_ci        done();
284bc03f14fSopenharmony_ci        console.info('HyperlinkTest001 end');
285bc03f14fSopenharmony_ci    });
286bc03f14fSopenharmony_ci
287bc03f14fSopenharmony_ci    /**
288bc03f14fSopenharmony_ci     * @tc.name HtmlTest001
289bc03f14fSopenharmony_ci     * @tc.desc Test Unified Record of Html
290bc03f14fSopenharmony_ci     * @tc.type FUNC
291bc03f14fSopenharmony_ci     */
292bc03f14fSopenharmony_ci    it('HtmlTest001', 0, async function (done) {
293bc03f14fSopenharmony_ci        console.info('HtmlTest001 begin');
294bc03f14fSopenharmony_ci        let properties = new UDC.UnifiedDataProperties();
295bc03f14fSopenharmony_ci        properties.getDelayData = getHtmlData;
296bc03f14fSopenharmony_ci        data.properties = properties;
297bc03f14fSopenharmony_ci        const systemPasteboard = pasteboard.getSystemPasteboard();
298bc03f14fSopenharmony_ci        await systemPasteboard.setUnifiedData(data);
299bc03f14fSopenharmony_ci        const flag = await systemPasteboard.hasPasteData();
300bc03f14fSopenharmony_ci        expect(flag).assertEqual(true);
301bc03f14fSopenharmony_ci        let unifiedData = await systemPasteboard.getUnifiedData();
302bc03f14fSopenharmony_ci        let records = unifiedData.getRecords();
303bc03f14fSopenharmony_ci        expect(records.length).assertEqual(1);
304bc03f14fSopenharmony_ci        expect(records[0].details.Key).assertEqual('html' + KEY_TEST_ELEMENT);
305bc03f14fSopenharmony_ci        expect(records[0].details.Value).assertEqual('html' + VALUE_TEST_ELEMENT);
306bc03f14fSopenharmony_ci        expect(records[0].htmlContent).assertEqual('htmlContent');
307bc03f14fSopenharmony_ci        expect(records[0].plainContent).assertEqual('plainContent');
308bc03f14fSopenharmony_ci        let pasteData = await systemPasteboard.getData();
309bc03f14fSopenharmony_ci        expect(pasteData.getRecordCount()).assertEqual(1);
310bc03f14fSopenharmony_ci        expect(pasteData.getPrimaryMimeType()).assertEqual(pasteboard.MIMETYPE_TEXT_HTML);
311bc03f14fSopenharmony_ci        const primaryHtml = pasteData.getPrimaryHtml();
312bc03f14fSopenharmony_ci        expect(primaryHtml).assertEqual('htmlContent');
313bc03f14fSopenharmony_ci        done();
314bc03f14fSopenharmony_ci        console.info('HtmlTest001 end');
315bc03f14fSopenharmony_ci    });
316bc03f14fSopenharmony_ci
317bc03f14fSopenharmony_ci    /**
318bc03f14fSopenharmony_ci     * @tc.name FileTest001
319bc03f14fSopenharmony_ci     * @tc.desc Test Unified Record of File
320bc03f14fSopenharmony_ci     * @tc.type FUNC
321bc03f14fSopenharmony_ci     */
322bc03f14fSopenharmony_ci    it('FileTest001', 0, async function (done) {
323bc03f14fSopenharmony_ci        console.info('FileTest001 begin');
324bc03f14fSopenharmony_ci        let properties = new UDC.UnifiedDataProperties();
325bc03f14fSopenharmony_ci        properties.getDelayData = getFileData;
326bc03f14fSopenharmony_ci        data.properties = properties;
327bc03f14fSopenharmony_ci        const systemPasteboard = pasteboard.getSystemPasteboard();
328bc03f14fSopenharmony_ci        await systemPasteboard.setUnifiedData(data);
329bc03f14fSopenharmony_ci        const flag = await systemPasteboard.hasPasteData();
330bc03f14fSopenharmony_ci        expect(flag).assertEqual(true);
331bc03f14fSopenharmony_ci        let unifiedData = await systemPasteboard.getUnifiedData();
332bc03f14fSopenharmony_ci        let records = unifiedData.getRecords();
333bc03f14fSopenharmony_ci        expect(records.length).assertEqual(1);
334bc03f14fSopenharmony_ci        expect(records[0].details.Key).assertEqual('file' + KEY_TEST_ELEMENT);
335bc03f14fSopenharmony_ci        expect(records[0].details.Value).assertEqual('file' + VALUE_TEST_ELEMENT);
336bc03f14fSopenharmony_ci        expect(records[0].uri).assertEqual('uri');
337bc03f14fSopenharmony_ci        done();
338bc03f14fSopenharmony_ci        let pasteData = await systemPasteboard.getData();
339bc03f14fSopenharmony_ci        expect(pasteData.getRecordCount()).assertEqual(1);
340bc03f14fSopenharmony_ci        expect(pasteData.hasMimeType(pasteboard.MIMETYPE_TEXT_URI)).assertEqual(true);
341bc03f14fSopenharmony_ci        const primaryUri = pasteData.getPrimaryUri();
342bc03f14fSopenharmony_ci        expect(primaryUri).assertEqual('uri');
343bc03f14fSopenharmony_ci        done();
344bc03f14fSopenharmony_ci        console.info('FileTest001 end');
345bc03f14fSopenharmony_ci    });
346bc03f14fSopenharmony_ci
347bc03f14fSopenharmony_ci    /**
348bc03f14fSopenharmony_ci     * @tc.name FolderTest001
349bc03f14fSopenharmony_ci     * @tc.desc Test Unified Record of Folder
350bc03f14fSopenharmony_ci     * @tc.type FUNC
351bc03f14fSopenharmony_ci     */
352bc03f14fSopenharmony_ci    it('FolderTest001', 0, async function (done) {
353bc03f14fSopenharmony_ci        console.info('FolderTest001 begin');
354bc03f14fSopenharmony_ci        let properties = new UDC.UnifiedDataProperties();
355bc03f14fSopenharmony_ci        properties.getDelayData = getFolderData;
356bc03f14fSopenharmony_ci        data.properties = properties;
357bc03f14fSopenharmony_ci        const systemPasteboard = pasteboard.getSystemPasteboard();
358bc03f14fSopenharmony_ci        await systemPasteboard.setUnifiedData(data);
359bc03f14fSopenharmony_ci        const flag = await systemPasteboard.hasPasteData();
360bc03f14fSopenharmony_ci        expect(flag).assertEqual(true);
361bc03f14fSopenharmony_ci        let unifiedData = await systemPasteboard.getUnifiedData();
362bc03f14fSopenharmony_ci        let records = unifiedData.getRecords();
363bc03f14fSopenharmony_ci        expect(records.length).assertEqual(1);
364bc03f14fSopenharmony_ci        expect(records[0].details.Key).assertEqual('folder' + KEY_TEST_ELEMENT);
365bc03f14fSopenharmony_ci        expect(records[0].details.Value).assertEqual('folder' + VALUE_TEST_ELEMENT);
366bc03f14fSopenharmony_ci        expect(records[0].uri).assertEqual('folderUri');
367bc03f14fSopenharmony_ci        let pasteData = await systemPasteboard.getData();
368bc03f14fSopenharmony_ci        expect(pasteData.getRecordCount()).assertEqual(1);
369bc03f14fSopenharmony_ci        expect(pasteData.hasMimeType(pasteboard.MIMETYPE_TEXT_URI)).assertEqual(true);
370bc03f14fSopenharmony_ci        const primaryUri = pasteData.getPrimaryUri();
371bc03f14fSopenharmony_ci        expect(primaryUri).assertEqual('folderUri');
372bc03f14fSopenharmony_ci        done();
373bc03f14fSopenharmony_ci        console.info('FolderTest001 end');
374bc03f14fSopenharmony_ci    });
375bc03f14fSopenharmony_ci
376bc03f14fSopenharmony_ci    /**
377bc03f14fSopenharmony_ci     * @tc.name ImageTest001
378bc03f14fSopenharmony_ci     * @tc.desc Test Unified Record of Image
379bc03f14fSopenharmony_ci     * @tc.type FUNC
380bc03f14fSopenharmony_ci     */
381bc03f14fSopenharmony_ci    it('ImageTest001', 0, async function (done) {
382bc03f14fSopenharmony_ci        console.info('ImageTest001 begin');
383bc03f14fSopenharmony_ci        let properties = new UDC.UnifiedDataProperties();
384bc03f14fSopenharmony_ci        properties.getDelayData = getImageData;
385bc03f14fSopenharmony_ci        data.properties = properties;
386bc03f14fSopenharmony_ci        const systemPasteboard = pasteboard.getSystemPasteboard();
387bc03f14fSopenharmony_ci        await systemPasteboard.setUnifiedData(data);
388bc03f14fSopenharmony_ci        const flag = await systemPasteboard.hasPasteData();
389bc03f14fSopenharmony_ci        expect(flag).assertEqual(true);
390bc03f14fSopenharmony_ci        let unifiedData = await systemPasteboard.getUnifiedData();
391bc03f14fSopenharmony_ci        let records = unifiedData.getRecords();
392bc03f14fSopenharmony_ci        expect(records.length).assertEqual(1);
393bc03f14fSopenharmony_ci        expect(records[0].details.Key).assertEqual('image' + KEY_TEST_ELEMENT);
394bc03f14fSopenharmony_ci        expect(records[0].details.Value).assertEqual('image' + VALUE_TEST_ELEMENT);
395bc03f14fSopenharmony_ci        expect(records[0].imageUri).assertEqual('imageUri');
396bc03f14fSopenharmony_ci        let pasteData = await systemPasteboard.getData();
397bc03f14fSopenharmony_ci        expect(pasteData.getRecordCount()).assertEqual(1);
398bc03f14fSopenharmony_ci        expect(pasteData.hasMimeType(pasteboard.MIMETYPE_TEXT_URI)).assertEqual(true);
399bc03f14fSopenharmony_ci        const primaryUri = pasteData.getPrimaryUri();
400bc03f14fSopenharmony_ci        expect(primaryUri).assertEqual('imageUri');
401bc03f14fSopenharmony_ci        done();
402bc03f14fSopenharmony_ci        console.info('ImageTest001 end');
403bc03f14fSopenharmony_ci    });
404bc03f14fSopenharmony_ci
405bc03f14fSopenharmony_ci    /**
406bc03f14fSopenharmony_ci     * @tc.name VideoTest001
407bc03f14fSopenharmony_ci     * @tc.desc Test Unified Record of Video
408bc03f14fSopenharmony_ci     * @tc.type FUNC
409bc03f14fSopenharmony_ci     */
410bc03f14fSopenharmony_ci    it('VideoTest001', 0, async function (done) {
411bc03f14fSopenharmony_ci        console.info('VideoTest001 begin');
412bc03f14fSopenharmony_ci        let properties = new UDC.UnifiedDataProperties();
413bc03f14fSopenharmony_ci        properties.getDelayData = getVideoData;
414bc03f14fSopenharmony_ci        data.properties = properties;
415bc03f14fSopenharmony_ci        const systemPasteboard = pasteboard.getSystemPasteboard();
416bc03f14fSopenharmony_ci        await systemPasteboard.setUnifiedData(data);
417bc03f14fSopenharmony_ci        const flag = await systemPasteboard.hasPasteData();
418bc03f14fSopenharmony_ci        expect(flag).assertEqual(true);
419bc03f14fSopenharmony_ci        let unifiedData = await systemPasteboard.getUnifiedData();
420bc03f14fSopenharmony_ci        let records = unifiedData.getRecords();
421bc03f14fSopenharmony_ci        expect(records.length).assertEqual(1);
422bc03f14fSopenharmony_ci        expect(records[0].details.Key).assertEqual('video' + KEY_TEST_ELEMENT);
423bc03f14fSopenharmony_ci        expect(records[0].details.Value).assertEqual('video' + VALUE_TEST_ELEMENT);
424bc03f14fSopenharmony_ci        expect(records[0].videoUri).assertEqual('videoUri');
425bc03f14fSopenharmony_ci        let pasteData = await systemPasteboard.getData();
426bc03f14fSopenharmony_ci        expect(pasteData.getRecordCount()).assertEqual(1);
427bc03f14fSopenharmony_ci        expect(pasteData.hasMimeType(pasteboard.MIMETYPE_TEXT_URI)).assertEqual(true);
428bc03f14fSopenharmony_ci        const primaryUri = pasteData.getPrimaryUri();
429bc03f14fSopenharmony_ci        expect(primaryUri).assertEqual('videoUri');
430bc03f14fSopenharmony_ci        done();
431bc03f14fSopenharmony_ci        console.info('VideoTest001 end');
432bc03f14fSopenharmony_ci    });
433bc03f14fSopenharmony_ci
434bc03f14fSopenharmony_ci    /**
435bc03f14fSopenharmony_ci     * @tc.name AudioTest001
436bc03f14fSopenharmony_ci     * @tc.desc Test Unified Record of Audio
437bc03f14fSopenharmony_ci     * @tc.type FUNC
438bc03f14fSopenharmony_ci     */
439bc03f14fSopenharmony_ci    it('AudioTest001', 0, async function (done) {
440bc03f14fSopenharmony_ci        console.info('AudioTest001 begin');
441bc03f14fSopenharmony_ci        let properties = new UDC.UnifiedDataProperties();
442bc03f14fSopenharmony_ci        properties.getDelayData = getAudioData;
443bc03f14fSopenharmony_ci        data.properties = properties;
444bc03f14fSopenharmony_ci        const systemPasteboard = pasteboard.getSystemPasteboard();
445bc03f14fSopenharmony_ci        await systemPasteboard.setUnifiedData(data);
446bc03f14fSopenharmony_ci        const flag = await systemPasteboard.hasPasteData();
447bc03f14fSopenharmony_ci        expect(flag).assertEqual(true);
448bc03f14fSopenharmony_ci        let unifiedData = await systemPasteboard.getUnifiedData();
449bc03f14fSopenharmony_ci        let records = unifiedData.getRecords();
450bc03f14fSopenharmony_ci        expect(records.length).assertEqual(1);
451bc03f14fSopenharmony_ci        expect(records[0].details.Key).assertEqual('audio' + KEY_TEST_ELEMENT);
452bc03f14fSopenharmony_ci        expect(records[0].details.Value).assertEqual('audio' + VALUE_TEST_ELEMENT);
453bc03f14fSopenharmony_ci        expect(records[0].audioUri).assertEqual('audioUri');
454bc03f14fSopenharmony_ci        let pasteData = await systemPasteboard.getData();
455bc03f14fSopenharmony_ci        expect(pasteData.getRecordCount()).assertEqual(1);
456bc03f14fSopenharmony_ci        expect(pasteData.hasMimeType(pasteboard.MIMETYPE_TEXT_URI)).assertEqual(true);
457bc03f14fSopenharmony_ci        const primaryUri = pasteData.getPrimaryUri();
458bc03f14fSopenharmony_ci        expect(primaryUri).assertEqual('audioUri');
459bc03f14fSopenharmony_ci        done();
460bc03f14fSopenharmony_ci        console.info('AudioTest001 end');
461bc03f14fSopenharmony_ci    });
462bc03f14fSopenharmony_ci
463bc03f14fSopenharmony_ci    /**
464bc03f14fSopenharmony_ci     * @tc.name SystemDefinedAppItemTest001
465bc03f14fSopenharmony_ci     * @tc.desc Test Unified Record of SystemDefinedAppItem
466bc03f14fSopenharmony_ci     * @tc.type FUNC
467bc03f14fSopenharmony_ci     */
468bc03f14fSopenharmony_ci    it('SystemDefinedAppItemTest001', 0, async function (done) {
469bc03f14fSopenharmony_ci        console.info('SystemDefinedAppItemTest001 begin');
470bc03f14fSopenharmony_ci        let properties = new UDC.UnifiedDataProperties();
471bc03f14fSopenharmony_ci        properties.getDelayData = getSystemDefinedAppItemDataData;
472bc03f14fSopenharmony_ci        data.properties = properties;
473bc03f14fSopenharmony_ci        const systemPasteboard = pasteboard.getSystemPasteboard();
474bc03f14fSopenharmony_ci        await systemPasteboard.setUnifiedData(data);
475bc03f14fSopenharmony_ci        const flag = await systemPasteboard.hasPasteData();
476bc03f14fSopenharmony_ci        expect(flag).assertEqual(true);
477bc03f14fSopenharmony_ci        let unifiedData = await systemPasteboard.getUnifiedData();
478bc03f14fSopenharmony_ci        let records = unifiedData.getRecords();
479bc03f14fSopenharmony_ci        expect(records.length).assertEqual(1);
480bc03f14fSopenharmony_ci        let pasteData = await systemPasteboard.getData();
481bc03f14fSopenharmony_ci        expect(pasteData.getRecordCount()).assertEqual(1);
482bc03f14fSopenharmony_ci        expect(pasteData.getPrimaryMimeType()).assertEqual('openharmony.app-item');
483bc03f14fSopenharmony_ci        done();
484bc03f14fSopenharmony_ci        console.info('SystemDefinedAppItemTest001 end');
485bc03f14fSopenharmony_ci    });
486bc03f14fSopenharmony_ci
487bc03f14fSopenharmony_ci    /**
488bc03f14fSopenharmony_ci     * @tc.name ApplicationDefinedRecordTest001
489bc03f14fSopenharmony_ci     * @tc.desc Test Unified Record of ApplicationDefinedRecord
490bc03f14fSopenharmony_ci     * @tc.type FUNC
491bc03f14fSopenharmony_ci     */
492bc03f14fSopenharmony_ci    it('ApplicationDefinedRecordTest001', 0, async function (done) {
493bc03f14fSopenharmony_ci        console.info('ApplicationDefinedRecordTest001 begin');
494bc03f14fSopenharmony_ci        let properties = new UDC.UnifiedDataProperties();
495bc03f14fSopenharmony_ci        properties.getDelayData = getApplicationDefinedRecordData;
496bc03f14fSopenharmony_ci        data.properties = properties;
497bc03f14fSopenharmony_ci        const systemPasteboard = pasteboard.getSystemPasteboard();
498bc03f14fSopenharmony_ci        await systemPasteboard.setUnifiedData(data);
499bc03f14fSopenharmony_ci        const flag = await systemPasteboard.hasPasteData();
500bc03f14fSopenharmony_ci        expect(flag).assertEqual(true);
501bc03f14fSopenharmony_ci        let unifiedData = await systemPasteboard.getUnifiedData();
502bc03f14fSopenharmony_ci        let records = unifiedData.getRecords();
503bc03f14fSopenharmony_ci        expect(records.length).assertEqual(1);
504bc03f14fSopenharmony_ci        expect(records[0].applicationDefinedType).assertEqual('applicationDefinedType');
505bc03f14fSopenharmony_ci        for (let i = 0; i < U8_ARRAY.length; i++) {
506bc03f14fSopenharmony_ci            expect(records[0].rawData[i]).assertEqual(U8_ARRAY[i]);
507bc03f14fSopenharmony_ci        }
508bc03f14fSopenharmony_ci        let pasteData = await systemPasteboard.getData();
509bc03f14fSopenharmony_ci        expect(pasteData.getRecordCount()).assertEqual(1);
510bc03f14fSopenharmony_ci        expect(pasteData.getPrimaryMimeType()).assertEqual('applicationDefinedType');
511bc03f14fSopenharmony_ci        done();
512bc03f14fSopenharmony_ci        console.info('ApplicationDefinedRecordTest001 end');
513bc03f14fSopenharmony_ci    });
514bc03f14fSopenharmony_ci
515bc03f14fSopenharmony_ci    /**
516bc03f14fSopenharmony_ci     * @tc.name WantTest001
517bc03f14fSopenharmony_ci     * @tc.desc Test Unified Record of Want
518bc03f14fSopenharmony_ci     * @tc.type FUNC
519bc03f14fSopenharmony_ci     */
520bc03f14fSopenharmony_ci    it('WantTest001', 0, async function (done) {
521bc03f14fSopenharmony_ci        console.info('WantTest001 begin');
522bc03f14fSopenharmony_ci        let properties = new UDC.UnifiedDataProperties();
523bc03f14fSopenharmony_ci        properties.getDelayData = getWantData;
524bc03f14fSopenharmony_ci        data.properties = properties;
525bc03f14fSopenharmony_ci        const systemPasteboard = pasteboard.getSystemPasteboard();
526bc03f14fSopenharmony_ci        await systemPasteboard.setUnifiedData(data);
527bc03f14fSopenharmony_ci        const flag = await systemPasteboard.hasPasteData();
528bc03f14fSopenharmony_ci        expect(flag).assertEqual(true);
529bc03f14fSopenharmony_ci        let unifiedData = await systemPasteboard.getUnifiedData();
530bc03f14fSopenharmony_ci        let records = unifiedData.getRecords();
531bc03f14fSopenharmony_ci        expect(records.length).assertEqual(1);
532bc03f14fSopenharmony_ci        let pasteData = await systemPasteboard.getData();
533bc03f14fSopenharmony_ci        expect(pasteData.getRecordCount()).assertEqual(1);
534bc03f14fSopenharmony_ci        expect(pasteData.getPrimaryMimeType()).assertEqual('text/want');
535bc03f14fSopenharmony_ci        done();
536bc03f14fSopenharmony_ci        console.info('WantTest001 end');
537bc03f14fSopenharmony_ci    });
538bc03f14fSopenharmony_ci
539bc03f14fSopenharmony_ci    /**
540bc03f14fSopenharmony_ci     * @tc.name PixelMapTest001
541bc03f14fSopenharmony_ci     * @tc.desc Test Unified Record of PixelMap
542bc03f14fSopenharmony_ci     * @tc.type FUNC
543bc03f14fSopenharmony_ci     */
544bc03f14fSopenharmony_ci    it('PixelMapTest001', 0, async function (done) {
545bc03f14fSopenharmony_ci        console.info('PixelMapTest001 begin');
546bc03f14fSopenharmony_ci        let properties = new UDC.UnifiedDataProperties();
547bc03f14fSopenharmony_ci        properties.getDelayData = getPixelMapData;
548bc03f14fSopenharmony_ci        data.properties = properties;
549bc03f14fSopenharmony_ci        const systemPasteboard = pasteboard.getSystemPasteboard();
550bc03f14fSopenharmony_ci        await systemPasteboard.setUnifiedData(data);
551bc03f14fSopenharmony_ci        const flag = await systemPasteboard.hasPasteData();
552bc03f14fSopenharmony_ci        expect(flag).assertEqual(true);
553bc03f14fSopenharmony_ci        let unifiedData = await systemPasteboard.getUnifiedData();
554bc03f14fSopenharmony_ci        let records = unifiedData.getRecords();
555bc03f14fSopenharmony_ci        expect(records.length).assertEqual(1);
556bc03f14fSopenharmony_ci        let pasteData = await systemPasteboard.getData();
557bc03f14fSopenharmony_ci        expect(pasteData.getRecordCount()).assertEqual(1);
558bc03f14fSopenharmony_ci        expect(pasteData.getPrimaryMimeType()).assertEqual('pixelMap');
559bc03f14fSopenharmony_ci        done();
560bc03f14fSopenharmony_ci        console.info('PixelMapTest001 end');
561bc03f14fSopenharmony_ci    });
562bc03f14fSopenharmony_ci});