• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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// @ts-nocheck
16import { describe, beforeAll, afterAll, it, expect } from 'deccjsunit/index';
17import pasteboard from '@ohos.pasteboard';
18
19describe('PasteBoardJSTest', function () {
20  let changeCount = Number(0);
21  beforeAll(async function () {
22    const systemPasteboard = pasteboard.getSystemPasteboard();
23    changeCount = systemPasteboard.getChangeCount();
24    console.info('beforeAll');
25  });
26
27  afterAll(async function () {
28    console.info('afterAll');
29  });
30
31  /**
32   * @tc.name      pasteboard_Sync_getChangeCount_test1
33   * @tc.desc      changeCount should add 1 when process setPasteData
34   * @tc.type      Function
35   * @tc.require   AR000H5HVI
36   */
37  it('pasteboard_Sync_getChangeCount_test1', 0, async function (done) {
38    const systemPasteboard = pasteboard.getSystemPasteboard();
39    await systemPasteboard.clearData();
40    const textData = 'Hello World!';
41    const pasteData = pasteboard.createPlainTextData(textData);
42    await systemPasteboard.setPasteData(pasteData);
43    let newCount = systemPasteboard.getChangeCount();
44    let expectCount = changeCount + 1;
45    expect(newCount).assertEqual(expectCount);
46    done();
47  });
48
49  /**
50   * @tc.name      pasteboard_Sync_getChangeCount_test2
51   * @tc.desc      changeCount should add 2 when process another setPasteData
52   * @tc.type      Function
53   * @tc.require   AR000H5HVI
54   */
55  it('pasteboard_Sync_getChangeCount_test2', 0, async function (done) {
56    const systemPasteboard = pasteboard.getSystemPasteboard();
57    await systemPasteboard.clearData();
58    const htmlText = '<html><head></head><body>Hello World!</body></html>';
59    const pasteData = pasteboard.createHtmlData(htmlText);
60    await systemPasteboard.setPasteData(pasteData);
61    let newCount = systemPasteboard.getChangeCount();
62    let expectCount = changeCount + 2;
63    expect(newCount).assertEqual(expectCount);
64    done();
65  });
66
67});