1bc03f14fSopenharmony_ci/* 2bc03f14fSopenharmony_ci * Copyright (C) 2022-2023 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// @ts-nocheck 16bc03f14fSopenharmony_ciimport { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'; 17bc03f14fSopenharmony_ciimport pasteboard from '@ohos.pasteboard'; 18bc03f14fSopenharmony_ciimport image from '@ohos.multimedia.image'; 19bc03f14fSopenharmony_ci 20bc03f14fSopenharmony_cidescribe('PasteBoardPerfJSTest', function () { 21bc03f14fSopenharmony_ci beforeAll(async function () { 22bc03f14fSopenharmony_ci console.info('beforeAll'); 23bc03f14fSopenharmony_ci }); 24bc03f14fSopenharmony_ci 25bc03f14fSopenharmony_ci afterAll(async function () { 26bc03f14fSopenharmony_ci console.info('afterAll'); 27bc03f14fSopenharmony_ci }); 28bc03f14fSopenharmony_ci 29bc03f14fSopenharmony_ci const BASE_CONUT = 200; 30bc03f14fSopenharmony_ci const pixelMapBuffer = new ArrayBuffer(10000); 31bc03f14fSopenharmony_ci const opt = { 32bc03f14fSopenharmony_ci size: { height: 50, width: 50 }, 33bc03f14fSopenharmony_ci pixelFormat: 3, 34bc03f14fSopenharmony_ci editable: true, 35bc03f14fSopenharmony_ci alphaType: 1, 36bc03f14fSopenharmony_ci scaleMode: 1, 37bc03f14fSopenharmony_ci }; 38bc03f14fSopenharmony_ci const htmlText = '<html><head></head><body>Hello!</body></html>'; 39bc03f14fSopenharmony_ci const uriText = 'https://www.baidu.com/'; 40bc03f14fSopenharmony_ci const plainText = 'Hello World!'; 41bc03f14fSopenharmony_ci const wantText = { 42bc03f14fSopenharmony_ci bundleName: 'com.example.myapplication8', 43bc03f14fSopenharmony_ci abilityName: 'com.example.myapplication8.MainAbility', 44bc03f14fSopenharmony_ci }; 45bc03f14fSopenharmony_ci 46bc03f14fSopenharmony_ci /** 47bc03f14fSopenharmony_ci * @tc.name getSystemPasteboard_performance_test_001 48bc03f14fSopenharmony_ci * @tc.desc getSystemPasteboard interface performance test 49bc03f14fSopenharmony_ci * @tc.type PERF 50bc03f14fSopenharmony_ci * @tc.require I5YP4X 51bc03f14fSopenharmony_ci */ 52bc03f14fSopenharmony_ci it('getSystemPasteboard_performance_test_001', 0, async function (done) { 53bc03f14fSopenharmony_ci let startTime = new Date().getTime(); 54bc03f14fSopenharmony_ci funcWithNoparam(pasteboard.getSystemPasteboard, BASE_CONUT); 55bc03f14fSopenharmony_ci computeAverageTime(startTime, BASE_CONUT, 'getSystemPasteboard_performance_test_001 averageTime:'); 56bc03f14fSopenharmony_ci done(); 57bc03f14fSopenharmony_ci }); 58bc03f14fSopenharmony_ci 59bc03f14fSopenharmony_ci /** 60bc03f14fSopenharmony_ci * @tc.name createData_performance_test_001 61bc03f14fSopenharmony_ci * @tc.desc createData interface performance test 62bc03f14fSopenharmony_ci * @tc.type PERF 63bc03f14fSopenharmony_ci * @tc.require I5YP4X 64bc03f14fSopenharmony_ci */ 65bc03f14fSopenharmony_ci it('createData_performance_test_001', 0, async function (done) { 66bc03f14fSopenharmony_ci let pixelMap = await image.createPixelMap(pixelMapBuffer, opt); 67bc03f14fSopenharmony_ci let startTime = new Date().getTime(); 68bc03f14fSopenharmony_ci funcWithTwoparam(pasteboard.createData, pasteboard.MIMETYPE_PIXELMAP, pixelMap, BASE_CONUT); 69bc03f14fSopenharmony_ci computeAverageTime(startTime, BASE_CONUT, 'createData_performance_test_001 averageTime:'); 70bc03f14fSopenharmony_ci done(); 71bc03f14fSopenharmony_ci }); 72bc03f14fSopenharmony_ci 73bc03f14fSopenharmony_ci /** 74bc03f14fSopenharmony_ci * @tc.name createRecord_performance_test_001 75bc03f14fSopenharmony_ci * @tc.desc createRecord interface performance test 76bc03f14fSopenharmony_ci * @tc.type PERF 77bc03f14fSopenharmony_ci * @tc.require I5YP4X 78bc03f14fSopenharmony_ci */ 79bc03f14fSopenharmony_ci it('createRecord_performance_test_001', 0, async function (done) { 80bc03f14fSopenharmony_ci let pixelMap = await image.createPixelMap(pixelMapBuffer, opt); 81bc03f14fSopenharmony_ci let startTime = new Date().getTime(); 82bc03f14fSopenharmony_ci funcWithTwoparam(pasteboard.createRecord, pasteboard.MIMETYPE_PIXELMAP, pixelMap, BASE_CONUT); 83bc03f14fSopenharmony_ci computeAverageTime(startTime, BASE_CONUT, 'createRecord_performance_test_001 averageTime:'); 84bc03f14fSopenharmony_ci done(); 85bc03f14fSopenharmony_ci }); 86bc03f14fSopenharmony_ci 87bc03f14fSopenharmony_ci /** 88bc03f14fSopenharmony_ci * @tc.name createHtmlData_performance_test_001 89bc03f14fSopenharmony_ci * @tc.desc createHtmlData interface performance test 90bc03f14fSopenharmony_ci * @tc.type PERF 91bc03f14fSopenharmony_ci * @tc.require I5YP4X 92bc03f14fSopenharmony_ci */ 93bc03f14fSopenharmony_ci it('createHtmlData_performance_test_001', 0, async function (done) { 94bc03f14fSopenharmony_ci let startTime = new Date().getTime(); 95bc03f14fSopenharmony_ci funcWithOneparam(pasteboard.createHtmlData, htmlText, BASE_CONUT); 96bc03f14fSopenharmony_ci computeAverageTime(startTime, BASE_CONUT, 'createHtmlData_performance_test_001 averageTime:'); 97bc03f14fSopenharmony_ci done(); 98bc03f14fSopenharmony_ci }); 99bc03f14fSopenharmony_ci 100bc03f14fSopenharmony_ci /** 101bc03f14fSopenharmony_ci * @tc.name createWantData_performance_test_001 102bc03f14fSopenharmony_ci * @tc.desc createWantData interface performance test 103bc03f14fSopenharmony_ci * @tc.type PERF 104bc03f14fSopenharmony_ci * @tc.require I5YP4X 105bc03f14fSopenharmony_ci */ 106bc03f14fSopenharmony_ci it('createWantData_performance_test_001', 0, async function (done) { 107bc03f14fSopenharmony_ci let startTime = new Date().getTime(); 108bc03f14fSopenharmony_ci funcWithOneparam(pasteboard.createWantData, wantText, BASE_CONUT); 109bc03f14fSopenharmony_ci computeAverageTime(startTime, BASE_CONUT, 'createWantData_performance_test_001 averageTime:'); 110bc03f14fSopenharmony_ci done(); 111bc03f14fSopenharmony_ci }); 112bc03f14fSopenharmony_ci 113bc03f14fSopenharmony_ci /** 114bc03f14fSopenharmony_ci * @tc.name createPlainTextData_performance_test_001 115bc03f14fSopenharmony_ci * @tc.desc createPlainTextData interface performance test 116bc03f14fSopenharmony_ci * @tc.type PERF 117bc03f14fSopenharmony_ci * @tc.require I5YP4X 118bc03f14fSopenharmony_ci */ 119bc03f14fSopenharmony_ci it('createPlainTextData_performance_test_001', 0, async function (done) { 120bc03f14fSopenharmony_ci let startTime = new Date().getTime(); 121bc03f14fSopenharmony_ci funcWithOneparam(pasteboard.createPlainTextData, plainText, BASE_CONUT); 122bc03f14fSopenharmony_ci computeAverageTime(startTime, BASE_CONUT, 'createPlainTextData_performance_test_001 averageTime:'); 123bc03f14fSopenharmony_ci done(); 124bc03f14fSopenharmony_ci }); 125bc03f14fSopenharmony_ci 126bc03f14fSopenharmony_ci /** 127bc03f14fSopenharmony_ci * @tc.name createUriData_performance_test_001 128bc03f14fSopenharmony_ci * @tc.desc createUriData interface performance test 129bc03f14fSopenharmony_ci * @tc.type PERF 130bc03f14fSopenharmony_ci * @tc.require I5YP4X 131bc03f14fSopenharmony_ci */ 132bc03f14fSopenharmony_ci it('createUriData_performance_test_001', 0, async function (done) { 133bc03f14fSopenharmony_ci let startTime = new Date().getTime(); 134bc03f14fSopenharmony_ci funcWithOneparam(pasteboard.createUriData, uriText, BASE_CONUT); 135bc03f14fSopenharmony_ci computeAverageTime(startTime, BASE_CONUT, 'createUriData_performance_test_001 averageTime:'); 136bc03f14fSopenharmony_ci done(); 137bc03f14fSopenharmony_ci }); 138bc03f14fSopenharmony_ci 139bc03f14fSopenharmony_ci /** 140bc03f14fSopenharmony_ci * @tc.name createHtmlTextRecord_performance_test_001 141bc03f14fSopenharmony_ci * @tc.desc createHtmlTextRecord interface performance test 142bc03f14fSopenharmony_ci * @tc.type PERF 143bc03f14fSopenharmony_ci * @tc.require I5YP4X 144bc03f14fSopenharmony_ci */ 145bc03f14fSopenharmony_ci it('createHtmlTextRecord_performance_test_001', 0, async function (done) { 146bc03f14fSopenharmony_ci let startTime = new Date().getTime(); 147bc03f14fSopenharmony_ci funcWithOneparam(pasteboard.createHtmlTextRecord, htmlText, BASE_CONUT); 148bc03f14fSopenharmony_ci computeAverageTime(startTime, BASE_CONUT, 'createHtmlTextRecord_performance_test_001 averageTime:'); 149bc03f14fSopenharmony_ci done(); 150bc03f14fSopenharmony_ci }); 151bc03f14fSopenharmony_ci 152bc03f14fSopenharmony_ci /** 153bc03f14fSopenharmony_ci * @tc.name createWantRecord_performance_test_001 154bc03f14fSopenharmony_ci * @tc.desc createWantRecord interface performance test 155bc03f14fSopenharmony_ci * @tc.type PERF 156bc03f14fSopenharmony_ci * @tc.require I5YP4X 157bc03f14fSopenharmony_ci */ 158bc03f14fSopenharmony_ci it('createWantRecord_performance_test_001', 0, async function (done) { 159bc03f14fSopenharmony_ci let startTime = new Date().getTime(); 160bc03f14fSopenharmony_ci funcWithOneparam(pasteboard.createWantRecord, wantText, BASE_CONUT); 161bc03f14fSopenharmony_ci computeAverageTime(startTime, BASE_CONUT, 'createWantRecord_performance_test_001 averageTime:'); 162bc03f14fSopenharmony_ci done(); 163bc03f14fSopenharmony_ci }); 164bc03f14fSopenharmony_ci 165bc03f14fSopenharmony_ci /** 166bc03f14fSopenharmony_ci * @tc.name createPlainTextRecord_performance_test_001 167bc03f14fSopenharmony_ci * @tc.desc createPlainTextRecord interface performance test 168bc03f14fSopenharmony_ci * @tc.type PERF 169bc03f14fSopenharmony_ci * @tc.require I5YP4X 170bc03f14fSopenharmony_ci */ 171bc03f14fSopenharmony_ci it('createPlainTextRecord_performance_test_001', 0, async function (done) { 172bc03f14fSopenharmony_ci let startTime = new Date().getTime(); 173bc03f14fSopenharmony_ci funcWithOneparam(pasteboard.createPlainTextRecord, plainText, BASE_CONUT); 174bc03f14fSopenharmony_ci computeAverageTime(startTime, BASE_CONUT, 'createPlainTextRecord_performance_test_001 averageTime:'); 175bc03f14fSopenharmony_ci done(); 176bc03f14fSopenharmony_ci }); 177bc03f14fSopenharmony_ci 178bc03f14fSopenharmony_ci /** 179bc03f14fSopenharmony_ci * @tc.name createUriRecord_performance_test_001 180bc03f14fSopenharmony_ci * @tc.desc createUriRecord interface performance test 181bc03f14fSopenharmony_ci * @tc.type PERF 182bc03f14fSopenharmony_ci * @tc.require I5YP4X 183bc03f14fSopenharmony_ci */ 184bc03f14fSopenharmony_ci it('createUriRecord_performance_test_001', 0, async function (done) { 185bc03f14fSopenharmony_ci let startTime = new Date().getTime(); 186bc03f14fSopenharmony_ci funcWithOneparam(pasteboard.createUriRecord, uriText, BASE_CONUT); 187bc03f14fSopenharmony_ci computeAverageTime(startTime, BASE_CONUT, 'createUriRecord_performance_test_001 averageTime:'); 188bc03f14fSopenharmony_ci done(); 189bc03f14fSopenharmony_ci }); 190bc03f14fSopenharmony_ci 191bc03f14fSopenharmony_ci /** 192bc03f14fSopenharmony_ci * @tc.name addRecord_performance_test_001 193bc03f14fSopenharmony_ci * @tc.desc addRecord interface performance test 194bc03f14fSopenharmony_ci * @tc.type PERF 195bc03f14fSopenharmony_ci * @tc.require I5YP4X 196bc03f14fSopenharmony_ci */ 197bc03f14fSopenharmony_ci it('addRecord_performance_test_001', 0, async function (done) { 198bc03f14fSopenharmony_ci let pixelMap = await image.createPixelMap(pixelMapBuffer, opt); 199bc03f14fSopenharmony_ci let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_URI, uriText); 200bc03f14fSopenharmony_ci let startTime = new Date().getTime(); 201bc03f14fSopenharmony_ci funcWithTwoparam(pasteData.addRecord, pasteboard.MIMETYPE_PIXELMAP, pixelMap, BASE_CONUT); 202bc03f14fSopenharmony_ci computeAverageTime(startTime, BASE_CONUT, 'addRecord_performance_test_001 averageTime:'); 203bc03f14fSopenharmony_ci done(); 204bc03f14fSopenharmony_ci }); 205bc03f14fSopenharmony_ci 206bc03f14fSopenharmony_ci /** 207bc03f14fSopenharmony_ci * @tc.name getRecord_performance_test_001 208bc03f14fSopenharmony_ci * @tc.desc getRecord interface performance test 209bc03f14fSopenharmony_ci * @tc.type PERF 210bc03f14fSopenharmony_ci * @tc.require I5YP4X 211bc03f14fSopenharmony_ci */ 212bc03f14fSopenharmony_ci it('getRecord_performance_test_001', 0, async function (done) { 213bc03f14fSopenharmony_ci let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_URI, uriText); 214bc03f14fSopenharmony_ci let startTime = new Date().getTime(); 215bc03f14fSopenharmony_ci funcWithOneparam(pasteData.getRecord, 0, BASE_CONUT); 216bc03f14fSopenharmony_ci computeAverageTime(startTime, BASE_CONUT, 'getRecord_performance_test_001 averageTime:'); 217bc03f14fSopenharmony_ci done(); 218bc03f14fSopenharmony_ci }); 219bc03f14fSopenharmony_ci 220bc03f14fSopenharmony_ci /** 221bc03f14fSopenharmony_ci * @tc.name hasType_performance_test_001 222bc03f14fSopenharmony_ci * @tc.desc hasType interface performance test 223bc03f14fSopenharmony_ci * @tc.type PERF 224bc03f14fSopenharmony_ci * @tc.require I5YP4X 225bc03f14fSopenharmony_ci */ 226bc03f14fSopenharmony_ci it('hasType_performance_test_001', 0, async function (done) { 227bc03f14fSopenharmony_ci let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_URI, uriText); 228bc03f14fSopenharmony_ci let startTime = new Date().getTime(); 229bc03f14fSopenharmony_ci funcWithOneparam(pasteData.hasType, pasteboard.MIMETYPE_PIXELMAP, BASE_CONUT); 230bc03f14fSopenharmony_ci computeAverageTime(startTime, BASE_CONUT, 'hasType_performance_test_001 averageTime:'); 231bc03f14fSopenharmony_ci done(); 232bc03f14fSopenharmony_ci }); 233bc03f14fSopenharmony_ci 234bc03f14fSopenharmony_ci /** 235bc03f14fSopenharmony_ci * @tc.name removeRecord_performance_test_001 236bc03f14fSopenharmony_ci * @tc.desc removeRecord interface performance test 237bc03f14fSopenharmony_ci * @tc.type PERF 238bc03f14fSopenharmony_ci * @tc.require I5YP4X 239bc03f14fSopenharmony_ci */ 240bc03f14fSopenharmony_ci it('removeRecord_performance_test_001', 0, async function (done) { 241bc03f14fSopenharmony_ci let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_URI, uriText); 242bc03f14fSopenharmony_ci funcWithOneparam(pasteData.addHtmlRecord, htmlText, BASE_CONUT); 243bc03f14fSopenharmony_ci let startTime = new Date().getTime(); 244bc03f14fSopenharmony_ci funcWithOneparam(pasteData.removeRecord, 0, BASE_CONUT); 245bc03f14fSopenharmony_ci computeAverageTime(startTime, BASE_CONUT, 'removeRecord_performance_test_001 averageTime:'); 246bc03f14fSopenharmony_ci done(); 247bc03f14fSopenharmony_ci }); 248bc03f14fSopenharmony_ci 249bc03f14fSopenharmony_ci /** 250bc03f14fSopenharmony_ci * @tc.name replaceRecord_performance_test_001 251bc03f14fSopenharmony_ci * @tc.desc replaceRecord interface performance test 252bc03f14fSopenharmony_ci * @tc.type PERF 253bc03f14fSopenharmony_ci * @tc.require I5YP4X 254bc03f14fSopenharmony_ci */ 255bc03f14fSopenharmony_ci it('replaceRecord_performance_test_001', 0, async function (done) { 256bc03f14fSopenharmony_ci let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_URI, uriText); 257bc03f14fSopenharmony_ci let dataRecord = pasteboard.createRecord(pasteboard.MIMETYPE_TEXT_URI, uriText); 258bc03f14fSopenharmony_ci let startTime = new Date().getTime(); 259bc03f14fSopenharmony_ci funcWithTwoparam(pasteData.replaceRecord, 0, dataRecord, BASE_CONUT); 260bc03f14fSopenharmony_ci computeAverageTime(startTime, BASE_CONUT, 'replaceRecord_performance_test_001 averageTime:'); 261bc03f14fSopenharmony_ci done(); 262bc03f14fSopenharmony_ci }); 263bc03f14fSopenharmony_ci 264bc03f14fSopenharmony_ci /** 265bc03f14fSopenharmony_ci * @tc.name addHtmlRecord_performance_test_001 266bc03f14fSopenharmony_ci * @tc.desc addHtmlRecord interface performance test 267bc03f14fSopenharmony_ci * @tc.type PERF 268bc03f14fSopenharmony_ci * @tc.require I5YP4X 269bc03f14fSopenharmony_ci */ 270bc03f14fSopenharmony_ci it('addHtmlRecord_performance_test_001', 0, async function (done) { 271bc03f14fSopenharmony_ci let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_URI, uriText); 272bc03f14fSopenharmony_ci let startTime = new Date().getTime(); 273bc03f14fSopenharmony_ci funcWithOneparam(pasteData.addHtmlRecord, htmlText, BASE_CONUT); 274bc03f14fSopenharmony_ci computeAverageTime(startTime, BASE_CONUT, 'addHtmlRecord_performance_test_001 averageTime:'); 275bc03f14fSopenharmony_ci done(); 276bc03f14fSopenharmony_ci }); 277bc03f14fSopenharmony_ci 278bc03f14fSopenharmony_ci /** 279bc03f14fSopenharmony_ci * @tc.name addWantRecord_performance_test_001 280bc03f14fSopenharmony_ci * @tc.desc addWantRecord interface performance test 281bc03f14fSopenharmony_ci * @tc.type PERF 282bc03f14fSopenharmony_ci * @tc.require I5YP4X 283bc03f14fSopenharmony_ci */ 284bc03f14fSopenharmony_ci it('addWantRecord_performance_test_001', 0, async function (done) { 285bc03f14fSopenharmony_ci let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_URI, uriText); 286bc03f14fSopenharmony_ci let startTime = new Date().getTime(); 287bc03f14fSopenharmony_ci funcWithOneparam(pasteData.addWantRecord, wantText, BASE_CONUT); 288bc03f14fSopenharmony_ci computeAverageTime(startTime, BASE_CONUT, 'addWantRecord_performance_test_001 averageTime:'); 289bc03f14fSopenharmony_ci done(); 290bc03f14fSopenharmony_ci }); 291bc03f14fSopenharmony_ci 292bc03f14fSopenharmony_ci /** 293bc03f14fSopenharmony_ci * @tc.name addRecord_performance_test_002 294bc03f14fSopenharmony_ci * @tc.desc addRecord interface performance test 295bc03f14fSopenharmony_ci * @tc.type PERF 296bc03f14fSopenharmony_ci * @tc.require I5YP4X 297bc03f14fSopenharmony_ci */ 298bc03f14fSopenharmony_ci it('addRecord_performance_test_002', 0, async function (done) { 299bc03f14fSopenharmony_ci let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_URI, uriText); 300bc03f14fSopenharmony_ci let dataRecord = pasteboard.createRecord(pasteboard.MIMETYPE_TEXT_URI, uriText); 301bc03f14fSopenharmony_ci let startTime = new Date().getTime(); 302bc03f14fSopenharmony_ci funcWithOneparam(pasteData.addRecord, dataRecord, BASE_CONUT); 303bc03f14fSopenharmony_ci computeAverageTime(startTime, BASE_CONUT, 'addRecord_performance_test_002 averageTime:'); 304bc03f14fSopenharmony_ci done(); 305bc03f14fSopenharmony_ci }); 306bc03f14fSopenharmony_ci 307bc03f14fSopenharmony_ci /** 308bc03f14fSopenharmony_ci * @tc.name addTextRecord_performance_test_001 309bc03f14fSopenharmony_ci * @tc.desc addTextRecord interface performance test 310bc03f14fSopenharmony_ci * @tc.type PERF 311bc03f14fSopenharmony_ci * @tc.require I5YP4X 312bc03f14fSopenharmony_ci */ 313bc03f14fSopenharmony_ci it('addTextRecord_performance_test_001', 0, async function (done) { 314bc03f14fSopenharmony_ci let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_URI, uriText); 315bc03f14fSopenharmony_ci let startTime = new Date().getTime(); 316bc03f14fSopenharmony_ci funcWithOneparam(pasteData.addTextRecord, plainText, BASE_CONUT); 317bc03f14fSopenharmony_ci computeAverageTime(startTime, BASE_CONUT, 'addTextRecord_performance_test_001 averageTime:'); 318bc03f14fSopenharmony_ci done(); 319bc03f14fSopenharmony_ci }); 320bc03f14fSopenharmony_ci 321bc03f14fSopenharmony_ci /** 322bc03f14fSopenharmony_ci * @tc.name addUriRecord_performance_test_001 323bc03f14fSopenharmony_ci * @tc.desc addUriRecord interface performance test 324bc03f14fSopenharmony_ci * @tc.type PERF 325bc03f14fSopenharmony_ci * @tc.require I5YP4X 326bc03f14fSopenharmony_ci */ 327bc03f14fSopenharmony_ci it('addUriRecord_performance_test_001', 0, async function (done) { 328bc03f14fSopenharmony_ci let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_URI, uriText); 329bc03f14fSopenharmony_ci let startTime = new Date().getTime(); 330bc03f14fSopenharmony_ci funcWithOneparam(pasteData.addUriRecord, uriText, BASE_CONUT); 331bc03f14fSopenharmony_ci computeAverageTime(startTime, BASE_CONUT, 'addUriRecord_performance_test_001 averageTime:'); 332bc03f14fSopenharmony_ci done(); 333bc03f14fSopenharmony_ci }); 334bc03f14fSopenharmony_ci 335bc03f14fSopenharmony_ci /** 336bc03f14fSopenharmony_ci * @tc.name getMimeTypes_performance_test_001 337bc03f14fSopenharmony_ci * @tc.desc getMimeTypes interface performance test 338bc03f14fSopenharmony_ci * @tc.type PERF 339bc03f14fSopenharmony_ci * @tc.require I5YP4X 340bc03f14fSopenharmony_ci */ 341bc03f14fSopenharmony_ci it('getMimeTypes_performance_test_001', 0, async function (done) { 342bc03f14fSopenharmony_ci let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_URI, uriText); 343bc03f14fSopenharmony_ci let startTime = new Date().getTime(); 344bc03f14fSopenharmony_ci funcWithNoparam(pasteData.getMimeTypes, BASE_CONUT); 345bc03f14fSopenharmony_ci computeAverageTime(startTime, BASE_CONUT, 'getMimeTypes_performance_test_001 averageTime:'); 346bc03f14fSopenharmony_ci done(); 347bc03f14fSopenharmony_ci }); 348bc03f14fSopenharmony_ci 349bc03f14fSopenharmony_ci /** 350bc03f14fSopenharmony_ci * @tc.name getPrimaryHtml_performance_test_001 351bc03f14fSopenharmony_ci * @tc.desc getPrimaryHtml interface performance test 352bc03f14fSopenharmony_ci * @tc.type PERF 353bc03f14fSopenharmony_ci * @tc.require I5YP4X 354bc03f14fSopenharmony_ci */ 355bc03f14fSopenharmony_ci it('getPrimaryHtml_performance_test_001', 0, async function (done) { 356bc03f14fSopenharmony_ci let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_HTML, htmlText); 357bc03f14fSopenharmony_ci let startTime = new Date().getTime(); 358bc03f14fSopenharmony_ci funcWithNoparam(pasteData.getPrimaryHtml, BASE_CONUT); 359bc03f14fSopenharmony_ci computeAverageTime(startTime, BASE_CONUT, 'getPrimaryHtml_performance_test_001 averageTime:'); 360bc03f14fSopenharmony_ci done(); 361bc03f14fSopenharmony_ci }); 362bc03f14fSopenharmony_ci 363bc03f14fSopenharmony_ci /** 364bc03f14fSopenharmony_ci * @tc.name getPrimaryWant_performance_test_001 365bc03f14fSopenharmony_ci * @tc.desc getPrimaryWant interface performance test 366bc03f14fSopenharmony_ci * @tc.type PERF 367bc03f14fSopenharmony_ci * @tc.require I5YP4X 368bc03f14fSopenharmony_ci */ 369bc03f14fSopenharmony_ci it('getPrimaryWant_performance_test_001', 0, async function (done) { 370bc03f14fSopenharmony_ci let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_WANT, wantText); 371bc03f14fSopenharmony_ci let startTime = new Date().getTime(); 372bc03f14fSopenharmony_ci funcWithNoparam(pasteData.getPrimaryWant, BASE_CONUT); 373bc03f14fSopenharmony_ci computeAverageTime(startTime, BASE_CONUT, 'getPrimaryWant_performance_test_001 averageTime:'); 374bc03f14fSopenharmony_ci done(); 375bc03f14fSopenharmony_ci }); 376bc03f14fSopenharmony_ci 377bc03f14fSopenharmony_ci /** 378bc03f14fSopenharmony_ci * @tc.name getPrimaryMimeType_performance_test_001 379bc03f14fSopenharmony_ci * @tc.desc getPrimaryMimeType interface performance test 380bc03f14fSopenharmony_ci * @tc.type PERF 381bc03f14fSopenharmony_ci * @tc.require I5YP4X 382bc03f14fSopenharmony_ci */ 383bc03f14fSopenharmony_ci it('getPrimaryMimeType_performance_test_001', 0, async function (done) { 384bc03f14fSopenharmony_ci let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_WANT, wantText); 385bc03f14fSopenharmony_ci let startTime = new Date().getTime(); 386bc03f14fSopenharmony_ci funcWithNoparam(pasteData.getPrimaryMimeType, BASE_CONUT); 387bc03f14fSopenharmony_ci computeAverageTime(startTime, BASE_CONUT, 'getPrimaryMimeType_performance_test_001 averageTime:'); 388bc03f14fSopenharmony_ci done(); 389bc03f14fSopenharmony_ci }); 390bc03f14fSopenharmony_ci 391bc03f14fSopenharmony_ci /** 392bc03f14fSopenharmony_ci * @tc.name getPrimaryUri_performance_test_001 393bc03f14fSopenharmony_ci * @tc.desc getPrimaryUri interface performance test 394bc03f14fSopenharmony_ci * @tc.type PERF 395bc03f14fSopenharmony_ci * @tc.require I5YP4X 396bc03f14fSopenharmony_ci */ 397bc03f14fSopenharmony_ci it('getPrimaryUri_performance_test_001', 0, async function (done) { 398bc03f14fSopenharmony_ci let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_URI, uriText); 399bc03f14fSopenharmony_ci let startTime = new Date().getTime(); 400bc03f14fSopenharmony_ci funcWithNoparam(pasteData.getPrimaryUri, BASE_CONUT); 401bc03f14fSopenharmony_ci computeAverageTime(startTime, BASE_CONUT, 'getPrimaryUri_performance_test_001 averageTime:'); 402bc03f14fSopenharmony_ci done(); 403bc03f14fSopenharmony_ci }); 404bc03f14fSopenharmony_ci 405bc03f14fSopenharmony_ci /** 406bc03f14fSopenharmony_ci * @tc.name getPrimaryPixelMap_performance_test_001 407bc03f14fSopenharmony_ci * @tc.desc getPrimaryPixelMap interface performance test 408bc03f14fSopenharmony_ci * @tc.type PERF 409bc03f14fSopenharmony_ci * @tc.require I5YP4X 410bc03f14fSopenharmony_ci */ 411bc03f14fSopenharmony_ci it('getPrimaryPixelMap_performance_test_001', 0, async function (done) { 412bc03f14fSopenharmony_ci let pixelMap = await image.createPixelMap(pixelMapBuffer, opt); 413bc03f14fSopenharmony_ci let pasteData = pasteboard.createData(pasteboard.MIMETYPE_PIXELMAP, pixelMap); 414bc03f14fSopenharmony_ci let startTime = new Date().getTime(); 415bc03f14fSopenharmony_ci funcWithNoparam(pasteData.getPrimaryPixelMap, BASE_CONUT); 416bc03f14fSopenharmony_ci computeAverageTime(startTime, BASE_CONUT, 'getPrimaryPixelMap_performance_test_001 averageTime:'); 417bc03f14fSopenharmony_ci done(); 418bc03f14fSopenharmony_ci }); 419bc03f14fSopenharmony_ci 420bc03f14fSopenharmony_ci /** 421bc03f14fSopenharmony_ci * @tc.name getProperty_performance_test_001 422bc03f14fSopenharmony_ci * @tc.desc getProperty interface performance test 423bc03f14fSopenharmony_ci * @tc.type PERF 424bc03f14fSopenharmony_ci * @tc.require I5YP4X 425bc03f14fSopenharmony_ci */ 426bc03f14fSopenharmony_ci it('getProperty_performance_test_001', 0, async function (done) { 427bc03f14fSopenharmony_ci let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_URI, uriText); 428bc03f14fSopenharmony_ci let startTime = new Date().getTime(); 429bc03f14fSopenharmony_ci funcWithNoparam(pasteData.getProperty, BASE_CONUT); 430bc03f14fSopenharmony_ci computeAverageTime(startTime, BASE_CONUT, 'getProperty_performance_test_001 averageTime:'); 431bc03f14fSopenharmony_ci done(); 432bc03f14fSopenharmony_ci }); 433bc03f14fSopenharmony_ci 434bc03f14fSopenharmony_ci /** 435bc03f14fSopenharmony_ci * @tc.name setProperty_performance_test_001 436bc03f14fSopenharmony_ci * @tc.desc setProperty interface performance test 437bc03f14fSopenharmony_ci * @tc.type PERF 438bc03f14fSopenharmony_ci * @tc.require I5YP4X 439bc03f14fSopenharmony_ci */ 440bc03f14fSopenharmony_ci it('setProperty_performance_test_001', 0, async function (done) { 441bc03f14fSopenharmony_ci let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_URI, uriText); 442bc03f14fSopenharmony_ci let property = pasteData.getProperty(); 443bc03f14fSopenharmony_ci let startTime = new Date().getTime(); 444bc03f14fSopenharmony_ci funcWithOneparam(pasteData.setProperty, property, BASE_CONUT); 445bc03f14fSopenharmony_ci computeAverageTime(startTime, BASE_CONUT, 'setProperty_performance_test_001 averageTime:'); 446bc03f14fSopenharmony_ci done(); 447bc03f14fSopenharmony_ci }); 448bc03f14fSopenharmony_ci 449bc03f14fSopenharmony_ci /** 450bc03f14fSopenharmony_ci * @tc.name getRecordAt_performance_test_001 451bc03f14fSopenharmony_ci * @tc.desc getRecordAt interface performance test 452bc03f14fSopenharmony_ci * @tc.type PERF 453bc03f14fSopenharmony_ci * @tc.require I5YP4X 454bc03f14fSopenharmony_ci */ 455bc03f14fSopenharmony_ci it('getRecordAt_performance_test_001', 0, async function (done) { 456bc03f14fSopenharmony_ci let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_URI, uriText); 457bc03f14fSopenharmony_ci let startTime = new Date().getTime(); 458bc03f14fSopenharmony_ci funcWithOneparam(pasteData.getRecordAt, 0, BASE_CONUT); 459bc03f14fSopenharmony_ci computeAverageTime(startTime, BASE_CONUT, 'getRecordAt_performance_test_001 averageTime:'); 460bc03f14fSopenharmony_ci done(); 461bc03f14fSopenharmony_ci }); 462bc03f14fSopenharmony_ci 463bc03f14fSopenharmony_ci /** 464bc03f14fSopenharmony_ci * @tc.name getRecordCount_performance_test_001 465bc03f14fSopenharmony_ci * @tc.desc getRecordCount interface performance test 466bc03f14fSopenharmony_ci * @tc.type PERF 467bc03f14fSopenharmony_ci * @tc.require I5YP4X 468bc03f14fSopenharmony_ci */ 469bc03f14fSopenharmony_ci it('getRecordCount_performance_test_001', 0, async function (done) { 470bc03f14fSopenharmony_ci let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_URI, uriText); 471bc03f14fSopenharmony_ci let startTime = new Date().getTime(); 472bc03f14fSopenharmony_ci funcWithNoparam(pasteData.getRecordCount, BASE_CONUT); 473bc03f14fSopenharmony_ci computeAverageTime(startTime, BASE_CONUT, 'getRecordCount_performance_test_001 averageTime:'); 474bc03f14fSopenharmony_ci done(); 475bc03f14fSopenharmony_ci }); 476bc03f14fSopenharmony_ci 477bc03f14fSopenharmony_ci /** 478bc03f14fSopenharmony_ci * @tc.name hasMimeType_performance_test_001 479bc03f14fSopenharmony_ci * @tc.desc hasMimeType interface performance test 480bc03f14fSopenharmony_ci * @tc.type PERF 481bc03f14fSopenharmony_ci * @tc.require I5YP4X 482bc03f14fSopenharmony_ci */ 483bc03f14fSopenharmony_ci it('hasMimeType_performance_test_001', 0, async function (done) { 484bc03f14fSopenharmony_ci let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_URI, uriText); 485bc03f14fSopenharmony_ci let startTime = new Date().getTime(); 486bc03f14fSopenharmony_ci funcWithOneparam(pasteData.hasMimeType, pasteboard.MIMETYPE_TEXT_URI, BASE_CONUT); 487bc03f14fSopenharmony_ci computeAverageTime(startTime, BASE_CONUT, 'hasMimeType_performance_test_001 averageTime:'); 488bc03f14fSopenharmony_ci done(); 489bc03f14fSopenharmony_ci }); 490bc03f14fSopenharmony_ci 491bc03f14fSopenharmony_ci /** 492bc03f14fSopenharmony_ci * @tc.name removeRecordAt_performance_test_001 493bc03f14fSopenharmony_ci * @tc.desc removeRecordAt interface performance test 494bc03f14fSopenharmony_ci * @tc.type PERF 495bc03f14fSopenharmony_ci * @tc.require I5YP4X 496bc03f14fSopenharmony_ci */ 497bc03f14fSopenharmony_ci it('removeRecordAt_performance_test_001', 0, async function (done) { 498bc03f14fSopenharmony_ci let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_URI, uriText); 499bc03f14fSopenharmony_ci let startTime = new Date().getTime(); 500bc03f14fSopenharmony_ci funcWithOneparam(pasteData.removeRecordAt, 0, BASE_CONUT); 501bc03f14fSopenharmony_ci computeAverageTime(startTime, BASE_CONUT, 'removeRecordAt_performance_test_001 averageTime:'); 502bc03f14fSopenharmony_ci done(); 503bc03f14fSopenharmony_ci }); 504bc03f14fSopenharmony_ci 505bc03f14fSopenharmony_ci /** 506bc03f14fSopenharmony_ci * @tc.name replaceRecordAt_performance_test_001 507bc03f14fSopenharmony_ci * @tc.desc replaceRecordAt interface performance test 508bc03f14fSopenharmony_ci * @tc.type PERF 509bc03f14fSopenharmony_ci * @tc.require I5YP4X 510bc03f14fSopenharmony_ci */ 511bc03f14fSopenharmony_ci it('replaceRecordAt_performance_test_001', 0, async function (done) { 512bc03f14fSopenharmony_ci let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_URI, uriText); 513bc03f14fSopenharmony_ci let dataRecord = pasteboard.createRecord(pasteboard.MIMETYPE_TEXT_HTML, htmlText); 514bc03f14fSopenharmony_ci let startTime = new Date().getTime(); 515bc03f14fSopenharmony_ci funcWithTwoparam(pasteData.replaceRecordAt, 0, dataRecord, BASE_CONUT); 516bc03f14fSopenharmony_ci computeAverageTime(startTime, BASE_CONUT, 'replaceRecordAt_performance_test_001 averageTime:'); 517bc03f14fSopenharmony_ci done(); 518bc03f14fSopenharmony_ci }); 519bc03f14fSopenharmony_ci 520bc03f14fSopenharmony_ci /** 521bc03f14fSopenharmony_ci * @tc.name on_performance_test_001 522bc03f14fSopenharmony_ci * @tc.desc on interface performance test 523bc03f14fSopenharmony_ci * @tc.type PERF 524bc03f14fSopenharmony_ci * @tc.require I5YP4X 525bc03f14fSopenharmony_ci */ 526bc03f14fSopenharmony_ci it('on_performance_test_001', 0, async function (done) { 527bc03f14fSopenharmony_ci let systemPasteboard = pasteboard.getSystemPasteboard(); 528bc03f14fSopenharmony_ci let startTime = new Date().getTime(); 529bc03f14fSopenharmony_ci funcWithTwoparam(systemPasteboard.on, 'update', contentChanges, BASE_CONUT); 530bc03f14fSopenharmony_ci computeAverageTime(startTime, BASE_CONUT, 'on_performance_test_001 averageTime:'); 531bc03f14fSopenharmony_ci done(); 532bc03f14fSopenharmony_ci }); 533bc03f14fSopenharmony_ci 534bc03f14fSopenharmony_ci /** 535bc03f14fSopenharmony_ci * @tc.name off_performance_test_001 536bc03f14fSopenharmony_ci * @tc.desc off interface performance test 537bc03f14fSopenharmony_ci * @tc.type PERF 538bc03f14fSopenharmony_ci * @tc.require I5YP4X 539bc03f14fSopenharmony_ci */ 540bc03f14fSopenharmony_ci it('off_performance_test_001', 0, async function (done) { 541bc03f14fSopenharmony_ci let systemPasteboard = pasteboard.getSystemPasteboard(); 542bc03f14fSopenharmony_ci let startTime = new Date().getTime(); 543bc03f14fSopenharmony_ci funcWithTwoparam(systemPasteboard.off, 'update', contentChanges, BASE_CONUT); 544bc03f14fSopenharmony_ci computeAverageTime(startTime, BASE_CONUT, 'off_performance_test_001 averageTime:'); 545bc03f14fSopenharmony_ci done(); 546bc03f14fSopenharmony_ci }); 547bc03f14fSopenharmony_ci 548bc03f14fSopenharmony_ci function funcWithNoparam(func, count) { 549bc03f14fSopenharmony_ci for (let index = 0; index < count; index++) { 550bc03f14fSopenharmony_ci func(); 551bc03f14fSopenharmony_ci } 552bc03f14fSopenharmony_ci } 553bc03f14fSopenharmony_ci 554bc03f14fSopenharmony_ci function funcWithOneparam(func, param, count) { 555bc03f14fSopenharmony_ci for (let index = 0; index < count; index++) { 556bc03f14fSopenharmony_ci func(param); 557bc03f14fSopenharmony_ci } 558bc03f14fSopenharmony_ci } 559bc03f14fSopenharmony_ci 560bc03f14fSopenharmony_ci function funcWithTwoparam(func, paramOne, paramTwo, count) { 561bc03f14fSopenharmony_ci for (let index = 0; index < count; index++) { 562bc03f14fSopenharmony_ci func(paramOne, paramTwo); 563bc03f14fSopenharmony_ci } 564bc03f14fSopenharmony_ci } 565bc03f14fSopenharmony_ci 566bc03f14fSopenharmony_ci function computeAverageTime(startTime, baseCount, message) { 567bc03f14fSopenharmony_ci let endTime = new Date().getTime(); 568bc03f14fSopenharmony_ci let averageTime = ((endTime - startTime) * 1000) / baseCount; 569bc03f14fSopenharmony_ci console.info(message + averageTime); 570bc03f14fSopenharmony_ci } 571bc03f14fSopenharmony_ci 572bc03f14fSopenharmony_ci function contentChanges() { 573bc03f14fSopenharmony_ci console.info('#EVENT: The content is changed in the pasteboard'); 574bc03f14fSopenharmony_ci } 575bc03f14fSopenharmony_ci}); 576