1/* 2 * Copyright (C) 2022 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 16import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium' 17import pasteboard from '@ohos.pasteboard' 18import image from '@ohos.multimedia.image'; 19 20let opt = { 21 size: { height: 3, width: 5 }, 22 pixelFormat: 3, 23 editable: true, 24 alphaType: 1, 25 scaleMode: 1 26} 27 28let error = undefined 29 30const color = new ArrayBuffer(128); 31 32const WANT = { 33 bundleName: "com.acts.distributeddatamgr.pasteboardtest", 34 abilityName: "com.acts.distributeddatamgr.pasteboardtest.MainAbility" 35}; 36 37const ARRAY_BUFFER = new ArrayBuffer(256) 38export default function pasteBoardTest(){ 39 describe('pasteBoardTest', function() { 40 console.info('start################################start'); 41 42 beforeEach(function() { 43 error = undefined; 44 }) 45 /** 46 * @tc.number SUB_Pasteboard_Local_SDK_PasteDataSetQueryProperty_0900 47 * @tc.name Adds one record(s) 48 * @tc.desc Test pasteBoard SetProperty API functionality. 49 * @tc.size : MEDIUM 50 * @tc.type : Function 51 * @tc.level : Level 2 52 */ 53 it('SUB_PASTEBOARD_FUNCTION_ETS_TEST_1100', 0, async function (done) { 54 var pasteData = pasteboard.createHtmlData('application/xml'); 55 console.info("SUB_PASTEBOARD_FUNCTION_ETS_TEST_1100 start") 56 var systemPasteBoard = pasteboard.getSystemPasteboard(); 57 await systemPasteBoard.clear().then(async () => { 58 let prop = pasteData.getProperty(); 59 prop.shareOption = pasteboard.ShareOption.INAPP; 60 pasteData.setProperty(prop); 61 var property = pasteData.getProperty(); 62 expect(0).assertEqual(property.shareOption) 63 console.info("SUB_PASTEBOARD_FUNCTION_ETS_TEST_1100 end") 64 }) 65 done(); 66 }) 67 /** 68 * @tc.number SUB_Pasteboard_Local_SDK_PasteDataSetQueryProperty_1000 69 * @tc.name Adds one record(s) 70 * @tc.desc Test pasteBoard SetProperty API functionality. 71 * @tc.size : MEDIUM 72 * @tc.type : Function 73 * @tc.level : Level 2 74 */ 75 it('SUB_PASTEBOARD_FUNCTION_ETS_TEST_1200', 0, async function (done) { 76 var pasteData = pasteboard.createPlainTextData("hello"); 77 console.info("SUB_PASTEBOARD_FUNCTION_ETS_TEST_1200 start") 78 var systemPasteBoard = pasteboard.getSystemPasteboard(); 79 await systemPasteBoard.clear().then(async () => { 80 let prop = pasteData.getProperty(); 81 prop.shareOption = pasteboard.ShareOption.LOCALDEVICE; 82 pasteData.setProperty(prop); 83 var property = pasteData.getProperty(); 84 expect(1).assertEqual(property.shareOption) 85 console.info("SUB_PASTEBOARD_FUNCTION_ETS_TEST_1200 end") 86 }) 87 done(); 88 }) 89 /** 90 * @tc.number SUB_Pasteboard_Local_SDK_PasteDataSetQueryProperty_0700 91 * @tc.name Adds one record(s) 92 * @tc.desc Test pasteBoard SetProperty API functionality. 93 * @tc.size : MEDIUM 94 * @tc.type : Function 95 * @tc.level : Level 2 96 */ 97 it('SUB_PASTEBOARD_FUNCTION_ETS_TEST_1300', 0, async function (done) { 98 var pasteData = pasteboard.createPlainTextData("hello"); 99 console.info("SUB_PASTEBOARD_FUNCTION_ETS_TEST_1300 start") 100 var systemPasteBoard = pasteboard.getSystemPasteboard(); 101 await systemPasteBoard.clear().then(async () => { 102 let prop = pasteData.getProperty(); 103 prop.shareOption = pasteboard.ShareOption.CROSSDEVICE; 104 pasteData.setProperty(prop); 105 var property = pasteData.getProperty(); 106 expect(2).assertEqual(property.shareOption) 107 console.info("SUB_PASTEBOARD_FUNCTION_ETS_TEST_1300 end") 108 }) 109 done(); 110 }) 111 /** 112 * @tc.number SUB_Pasteboard_Local_SDK_PasteDataSetQueryProperty_0800 113 * @tc.name Adds one record(s) 114 * @tc.desc Test pasteBoard SetProperty API functionality. 115 * @tc.size : MEDIUM 116 * @tc.type : Function 117 * @tc.level : Level 2 118 */ 119 it('SUB_PASTEBOARD_FUNCTION_ETS_TEST_1400', 0, async function (done) { 120 var pasteData = pasteboard.createPlainTextData("hello"); 121 console.info("SUB_PASTEBOARD_FUNCTION_ETS_TEST_1400 start") 122 var systemPasteBoard = pasteboard.getSystemPasteboard(); 123 await systemPasteBoard.clear().then(async () => { 124 let prop = pasteData.getProperty(); 125 pasteData.setProperty(prop); 126 var property = pasteData.getProperty(); 127 expect(2).assertEqual(property.shareOption) 128 console.info("SUB_PASTEBOARD_FUNCTION_ETS_TEST_1400 end") 129 }) 130 done(); 131 }) 132 133 /** 134 * @tc.number SUB_Pasteboard_Local_SDK_PasteDataSetQueryProperty_0100 135 * @tc.name setProperty 136 * @tc.desc Test pasteBoard setProperty error,type of parameter "property" is string 137 * @tc.size : MEDIUM 138 * @tc.type : Function 139 * @tc.level : Level 2 140 */ 141 it('SUB_PASTEBOARD_FUNCTION_ETS_SETPROPERTY_0100', 0, async function (done) { 142 console.info("SUB_PASTEBOARD_FUNCTION_ETS_SETPROPERTY_0100 start") 143 let pasteData = pasteboard.createData("string",ARRAY_BUFFER) 144 function setProperty(property){ 145 pasteData.setProperty(property) 146 } 147 try{ 148 setProperty("property"); 149 }catch(err){ 150 console.info("Set property error, err code is: " + err.code) 151 error = err 152 expect(err.code).assertEqual("401") 153 } 154 expect(error != undefined).assertTrue(); 155 console.info("SUB_PASTEBOARD_FUNCTION_ETS_SETPROPERTY_0100 end") 156 done(); 157 }) 158 159 /** 160 * @tc.number SUB_Pasteboard_Local_SDK_PasteDataSetQueryProperty_0400 161 * @tc.name setProperty 162 * @tc.desc Test pasteBoard setProperty error,parameter "property" is null; 163 * @tc.size : MEDIUM 164 * @tc.type : Function 165 * @tc.level : Level 2 166 */ 167 it('SUB_PASTEBOARD_FUNCTION_ETS_SETPROPERTY_0200', 0, async function (done) { 168 console.info("SUB_PASTEBOARD_FUNCTION_ETS_SETPROPERTY_0200 start") 169 let pasteData = pasteboard.createData("string",ARRAY_BUFFER) 170 try{ 171 pasteData.setProperty(null); 172 }catch(err){ 173 console.info("Set property error, err code is: " + err.code) 174 error = err 175 expect(err.code).assertEqual("401") 176 } 177 expect(error != undefined).assertTrue(); 178 console.info("SUB_PASTEBOARD_FUNCTION_ETS_SETPROPERTY_0200 end") 179 done(); 180 }) 181 182 /** 183 * @tc.number SUB_Pasteboard_Local_SDK_PasteDataSetQueryProperty_0600 184 * @tc.name setProperty 185 * @tc.desc Test pasteBoard setProperty error without parameters 186 * @tc.size : MEDIUM 187 * @tc.type : Function 188 * @tc.level : Level 2 189 */ 190 it('SUB_PASTEBOARD_FUNCTION_ETS_SETPROPERTY_0300', 0, async function (done) { 191 console.info("SUB_PASTEBOARD_FUNCTION_ETS_SETPROPERTY_0300 start") 192 let pasteData = pasteboard.createData("string",ARRAY_BUFFER) 193 function setProperty(func, property){ 194 func() 195 } 196 try{ 197 setProperty(pasteData.setProperty,"prop"); 198 }catch(err){ 199 console.info("Set property error, err code is: " + err.code) 200 error = err 201 expect(err.code).assertEqual("401") 202 } 203 expect(error != undefined).assertTrue(); 204 console.info("SUB_PASTEBOARD_FUNCTION_ETS_SETPROPERTY_0300 end") 205 done(); 206 }) 207 208 /** 209 * @tc.number SUB_Pasteboard_Local_SDK_PasteDataConvert_0300 210 * @tc.name toPlainText 211 * @tc.desc Successfully cast string record to text 212 * @tc.size : MEDIUM 213 * @tc.type : Function 214 * @tc.level : Level 2 215 */ 216 it('SUB_PASTEBOARD_FUNCTION_ETS_TOPLAINTEXT_0100', 0, async function (done) { 217 console.info("SUB_PASTEBOARD_FUNCTION_ETS_TOPLAINTEXT_0100 start") 218 let pasteDataRecord = pasteboard.createRecord(pasteboard.MIMETYPE_TEXT_PLAIN,"valueType") 219 var str = await pasteDataRecord.toPlainText(); 220 expect(str).assertEqual("valueType") 221 console.info("SUB_PASTEBOARD_FUNCTION_ETS_TOPLAINTEXT_0100 end") 222 done(); 223 }) 224 225 /** 226 * @tc.number SUB_Pasteboard_Local_SDK_PasteDataConvert_0200 227 * @tc.name toPlainText 228 * @tc.desc Successfully cast pixelMap record to text 229 * @tc.size : MEDIUM 230 * @tc.type : Function 231 * @tc.level : Level 2 232 */ 233 it('SUB_PASTEBOARD_FUNCTION_ETS_TOPLAINTEXT_0200', 0, async function (done) { 234 console.info("SUB_PASTEBOARD_FUNCTION_ETS_TOPLAINTEXT_0200 start") 235 let pasteDataRecord = undefined; 236 await image.createPixelMap(color, opt).then((pixelMap) => { 237 pasteDataRecord = pasteboard.createRecord(pasteboard.MIMETYPE_PIXELMAP,pixelMap); 238 }) 239 var str = await pasteDataRecord.toPlainText(); 240 expect(str).assertEqual(""); 241 console.info("SUB_PASTEBOARD_FUNCTION_ETS_TOPLAINTEXT_0200 end") 242 done(); 243 }) 244 245 /** 246 * @tc.number SUB_Pasteboard_Local_SDK_PasteDataConvert_0500 247 * @tc.name toPlainText 248 * @tc.desc Successfully cast want record to text 249 * @tc.size : MEDIUM 250 * @tc.type : Function 251 * @tc.level : Level 2 252 */ 253 it('SUB_PASTEBOARD_FUNCTION_ETS_TOPLAINTEXT_0300', 0, async function (done) { 254 console.info("SUB_PASTEBOARD_FUNCTION_ETS_TOPLAINTEXT_0300 start") 255 let pasteDataRecord = pasteboard.createRecord(pasteboard.MIMETYPE_TEXT_WANT,WANT) 256 var str = await pasteDataRecord.toPlainText(); 257 expect(str).assertEqual(""); 258 console.info("SUB_PASTEBOARD_FUNCTION_ETS_TOPLAINTEXT_0300 end") 259 done(); 260 }) 261 262 /** 263 * @tc.number SUB_Pasteboard_Local_SDK_PasteDataConvert_0100 264 * @tc.name toPlainText 265 * @tc.desc Successfully cast arrayBuffer record to text 266 * @tc.size : MEDIUM 267 * @tc.type : Function 268 * @tc.level : Level 2 269 */ 270 it('SUB_PASTEBOARD_FUNCTION_ETS_TOPLAINTEXT_0400', 0, async function (done) { 271 console.info("SUB_PASTEBOARD_FUNCTION_ETS_TOPLAINTEXT_0400 start") 272 let pasteDataRecord = pasteboard.createRecord("ArrayBuffer",ARRAY_BUFFER) 273 var str = await pasteDataRecord.toPlainText(); 274 expect(str).assertEqual("") 275 console.info("SUB_PASTEBOARD_FUNCTION_ETS_TOPLAINTEXT_0400 end") 276 done(); 277 }) 278 279 /** 280 * @tc.number SUB_Pasteboard_Local_SDK_PasteDataSetQueryType_0700 281 * @tc.name getRecord 282 * @tc.desc Get specified record success 283 * @tc.size : MEDIUM 284 * @tc.type : Function 285 * @tc.level : Level 2 286 */ 287 it('SUB_PASTEBOARD_FUNCTION_ETS_GETRECORDAT_0100', 0, async function (done) { 288 console.info("SUB_PASTEBOARD_FUNCTION_ETS_GETRECORDAT_0100 start") 289 var uri = "www.baidu.com" 290 let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_URI,uri) 291 expect(pasteData.getRecord(0).uri).assertEqual(uri) 292 done(); 293 }) 294 295 /** 296 * @tc.number SUB_Pasteboard_Local_SDK_PasteDataSetQueryType_0100 297 * @tc.name getRecord 298 * @tc.desc Get specified record failed,type of parameter "index" is string. 299 * @tc.size : MEDIUM 300 * @tc.type : Function 301 * @tc.level : Level 2 302 */ 303 it('SUB_PASTEBOARD_FUNCTION_ETS_GETRECORDAT_0200', 0, async function (done) { 304 console.info("SUB_PASTEBOARD_FUNCTION_ETS_GETRECORDAT_0200 start") 305 let pasteData = pasteboard.createData("string",ARRAY_BUFFER) 306 function getRecord(index){ 307 pasteData.getRecord(index) 308 } 309 try{ 310 getRecord("0") 311 }catch(err){ 312 console.info("Get specified record failed,error code is: " + err.code) 313 error = err 314 expect(err.code).assertEqual("401") 315 } 316 expect(error != undefined).assertTrue(); 317 console.info("SUB_PASTEBOARD_FUNCTION_ETS_GETRECORDAT_0200 end") 318 done(); 319 }) 320 321 /** 322 * @tc.number SUB_Pasteboard_Local_SDK_PasteDataSetQueryType_0200 323 * @tc.name getRecord 324 * @tc.desc Get specified record failed,index out of range 325 * @tc.size : MEDIUM 326 * @tc.type : Function 327 * @tc.level : Level 2 328 */ 329 it('SUB_PASTEBOARD_FUNCTION_ETS_GETRECORDAT_0300', 0, async function (done) { 330 console.info("SUB_PASTEBOARD_FUNCTION_ETS_GETRECORDAT_0300 start") 331 let pasteData = pasteboard.createData("arraybuffer",ARRAY_BUFFER) 332 try{ 333 pasteData.getRecord(1) 334 }catch(err){ 335 console.info("Get specified record failed,error code is: " + err.code) 336 error = err 337 expect(err.code).assertEqual("12900001") 338 } 339 expect(error != undefined).assertTrue(); 340 console.info("SUB_PASTEBOARD_FUNCTION_ETS_GETRECORDAT_0300 end") 341 done(); 342 }) 343 344 /** 345 * @tc.number SUB_Pasteboard_Local_SDK_PasteDataSetQueryType_0400 346 * @tc.name hasType 347 * @tc.desc Check whether the pasteData contains the specified data type success 348 * @tc.size : MEDIUM 349 * @tc.type : Function 350 * @tc.level : Level 2 351 */ 352 it('SUB_PASTEBOARD_FUNCTION_ETS_HASTYPE_0100', 0, async function (done) { 353 console.info("SUB_PASTEBOARD_FUNCTION_ETS_HASTYPE_0100 start") 354 let pasteData = pasteboard.createData("string",ARRAY_BUFFER) 355 let result = pasteData.hasType("string") 356 expect(result).assertTrue(); 357 console.info("SUB_PASTEBOARD_FUNCTION_ETS_HASTYPE_0100 end") 358 done(); 359 }) 360 361 /** 362 * @tc.number SUB_Pasteboard_Local_SDK_PasteDataSetQueryType_0300 363 * @tc.name hasType 364 * @tc.desc Check whether the pasteData contains the specified data type success 365 * @tc.size : MEDIUM 366 * @tc.type : Function 367 * @tc.level : Level 2 368 */ 369 it('SUB_PASTEBOARD_FUNCTION_ETS_HASTYPE_0200', 0, async function (done) { 370 console.info("SUB_PASTEBOARD_FUNCTION_ETS_HASTYPE_0200 start") 371 let pasteData = pasteboard.createData("string",ARRAY_BUFFER) 372 let result = pasteData.hasType("arrayBuffer") 373 expect(result).assertEqual(false); 374 console.info("SUB_PASTEBOARD_FUNCTION_ETS_HASTYPE_0200 end") 375 done(); 376 }) 377 378 /** 379 * @tc.number SUB_Pasteboard_Local_SDK_PasteDataSetQueryType_0600 380 * @tc.name hasType 381 * @tc.desc Check whether the pasteData contains the specified data type failed,type of parameter "mimeType" is number 382 * @tc.size : MEDIUM 383 * @tc.type : Function 384 * @tc.level : Level 2 385 */ 386 it('SUB_PASTEBOARD_FUNCTION_ETS_HASTYPE_0300', 0, async function (done) { 387 console.info("SUB_PASTEBOARD_FUNCTION_ETS_HASTYPE_0300 start") 388 let pasteData = pasteboard.createData("string",ARRAY_BUFFER) 389 let result 390 function check(mimeType){ 391 pasteData.hasType(mimeType) 392 } 393 try{ 394 check(0) 395 }catch(err){ 396 console.info("Check fail,error code is: " + err.code) 397 error = err 398 expect(err.code).assertEqual("401") 399 } 400 expect(error != undefined).assertTrue(); 401 console.info("SUB_PASTEBOARD_FUNCTION_ETS_HASTYPE_0300 end") 402 done(); 403 }) 404 405 /** 406 * @tc.number SUB_Pasteboard_Local_SDK_PasteDataSetQueryType_0500 407 * @tc.name hasType 408 * @tc.desc Check whether the pasteData contains the specified data type failed without parameters 409 * @tc.size : MEDIUM 410 * @tc.type : Function 411 * @tc.level : Level 2 412 */ 413 it('SUB_PASTEBOARD_FUNCTION_ETS_HASTYPE_0400', 0, async function (done) { 414 console.info("SUB_PASTEBOARD_FUNCTION_ETS_HASTYPE_0400 start") 415 let pasteData = pasteboard.createData("string",ARRAY_BUFFER) 416 let result 417 function check(func,mimeType){ 418 func() 419 } 420 try{ 421 check(pasteData.hasType,"string") 422 }catch(err){ 423 console.info("Check fail,error code is: " + err.code) 424 error = err 425 expect(err.code).assertEqual("401") 426 } 427 expect(error != undefined).assertTrue(); 428 console.info("SUB_PASTEBOARD_FUNCTION_ETS_HASTYPE_0400 end") 429 done(); 430 }) 431 432 /** 433 * @tc.number SUB_Pasteboard_Local_SDK_PasteDataRemoveOrReplace_1300 434 * @tc.name removeRecord 435 * @tc.desc Remove specified record from pasteData successful 436 * @tc.size : MEDIUM 437 * @tc.type : Function 438 * @tc.level : Level 2 439 */ 440 it('SUB_PASTEBOARD_FUNCTION_ETS_REMOVERECORD_0100', 0, async function (done) { 441 console.info("SUB_PASTEBOARD_FUNCTION_ETS_REMOVERECORD_0100 start") 442 let pasteData = pasteboard.createData("string",ARRAY_BUFFER) 443 pasteData.removeRecord(0) 444 let result = pasteData.hasType("string") 445 expect(result == false).assertTrue(); 446 console.info("SUB_PASTEBOARD_FUNCTION_ETS_REMOVERECORD_0100 end") 447 done(); 448 }) 449 450 /** 451 * @tc.number SUB_Pasteboard_Local_SDK_PasteDataRemoveOrReplace_0300 452 * @tc.name removeRecord 453 * @tc.desc Remove specified record from pasteData failed,index out of range 454 * @tc.size : MEDIUM 455 * @tc.type : Function 456 * @tc.level : Level 2 457 */ 458 it('SUB_PASTEBOARD_FUNCTION_ETS_REMOVERECORD_0200', 0, async function (done) { 459 console.info("SUB_PASTEBOARD_FUNCTION_ETS_REMOVERECORD_0200 start") 460 let pasteData = pasteboard.createData("string",ARRAY_BUFFER) 461 try{ 462 pasteData.removeRecord(1) 463 }catch(err){ 464 console.info("Remove specified record fail,error code is: " + err.code) 465 error = err 466 expect(err.code).assertEqual("12900001") 467 } 468 expect(error != undefined).assertTrue(); 469 console.info("SUB_PASTEBOARD_FUNCTION_ETS_REMOVERECORD_0200 end") 470 done(); 471 }) 472 473 /** 474 * @tc.number SUB_Pasteboard_Local_SDK_PasteDataRemoveOrReplace_0500 475 * @tc.name removeRecord 476 * @tc.desc Remove specified record from pasteData failed,type of parameter "index" is string 477 * @tc.size : MEDIUM 478 * @tc.type : Function 479 * @tc.level : Level 2 480 */ 481 it('SUB_PASTEBOARD_FUNCTION_ETS_REMOVERECORD_0300', 0, async function (done) { 482 console.info("SUB_PASTEBOARD_FUNCTION_ETS_REMOVERECORD_0300 start") 483 let pasteData = pasteboard.createData("string",ARRAY_BUFFER) 484 function remove(index){ 485 pasteData.removeRecord(index) 486 } 487 try{ 488 remove("0") 489 }catch(err){ 490 console.info("Remove specified record fail,error code is: " + err.code) 491 error = err 492 expect(err.code).assertEqual("401") 493 } 494 expect(error != undefined).assertTrue(); 495 console.info("SUB_PASTEBOARD_FUNCTION_ETS_REMOVERECORD_0300 end") 496 done(); 497 }) 498 499 /** 500 * @tc.number SUB_Pasteboard_Local_SDK_PasteDataRemoveOrReplace_0100 501 * @tc.name removeRecord 502 * @tc.desc Remove specified record from pasteData failed without parameters 503 * @tc.size : MEDIUM 504 * @tc.type : Function 505 * @tc.level : Level 2 506 */ 507 it('SUB_PASTEBOARD_FUNCTION_ETS_REMOVERECORD_0400', 0, async function (done) { 508 console.info("SUB_PASTEBOARD_FUNCTION_ETS_REMOVERECORD_0400 start") 509 let pasteData = pasteboard.createData("string",ARRAY_BUFFER) 510 function remove(func, index){ 511 func() 512 } 513 try{ 514 remove(pasteData.removeRecord,1) 515 }catch(err){ 516 console.info("Remove specified record fail,error code is: " + err.code) 517 error = err 518 expect(err.code).assertEqual("401") 519 } 520 expect(error != undefined).assertTrue(); 521 console.info("SUB_PASTEBOARD_FUNCTION_ETS_REMOVERECORD_0400 end") 522 done(); 523 }) 524 525 /** 526 * @tc.number SUB_Pasteboard_Local_SDK_PasteDataRemoveOrReplace_2000 527 * @tc.name replaceRecord 528 * @tc.desc Remove specified record from pasteData failed without parameters 529 * @tc.size : MEDIUM 530 * @tc.type : Function 531 * @tc.level : Level 2 532 */ 533 it('SUB_PASTEBOARD_FUNCTION_ETS_REPLACERECORD_0100', 0, async function (done) { 534 console.info("SUB_PASTEBOARD_FUNCTION_ETS_REPLACERECORD_0100 start") 535 let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_PLAIN,"valueType") 536 let pasteDataRecord = pasteboard.createRecord("arrayBuffer",ARRAY_BUFFER) 537 pasteData.replaceRecord(0,pasteDataRecord) 538 let result = pasteData.hasType("arrayBuffer") 539 expect(result).assertTrue(); 540 console.info("SUB_PASTEBOARD_FUNCTION_ETS_REPLACERECORD_0100 end") 541 done(); 542 }) 543 544 /** 545 * @tc.number SUB_Pasteboard_Local_SDK_PasteDataRemoveOrReplace_0400 546 * @tc.name replaceRecord 547 * @tc.desc Remove specified record from pasteData failed,index out of range; 548 * @tc.size : MEDIUM 549 * @tc.type : Function 550 * @tc.level : Level 2 551 */ 552 it('SUB_PASTEBOARD_FUNCTION_ETS_REPLACERECORD_0200', 0, async function (done) { 553 console.info("SUB_PASTEBOARD_FUNCTION_ETS_REPLACERECORD_0200 start") 554 let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_PLAIN,"valueType") 555 let pasteDataRecord = pasteboard.createRecord("arrayBuffer",ARRAY_BUFFER) 556 try{ 557 pasteData.replaceRecord(1,pasteDataRecord) 558 }catch(err){ 559 console.info("Replace specified record fail,error code is: " + err.code) 560 error = err 561 expect(err.code).assertEqual("12900001") 562 } 563 expect(error != undefined).assertTrue(); 564 console.info("SUB_PASTEBOARD_FUNCTION_ETS_REPLACERECORD_0200 end") 565 done(); 566 }) 567 568 /** 569 * @tc.number SUB_Pasteboard_Local_SDK_PasteDataRemoveOrReplace_0600 570 * @tc.name replaceRecord 571 * @tc.desc Remove specified record from pasteData failed,type of parameter "index" is string 572 * @tc.size : MEDIUM 573 * @tc.type : Function 574 * @tc.level : Level 2 575 */ 576 it('SUB_PASTEBOARD_FUNCTION_ETS_REPLACERECORD_0300', 0, async function (done) { 577 console.info("SUB_PASTEBOARD_FUNCTION_ETS_REPLACERECORD_0300 start") 578 let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_PLAIN,"valueType") 579 let pasteDataRecord = pasteboard.createRecord("arrayBuffer",ARRAY_BUFFER) 580 function replace(index, record){ 581 pasteData.replaceRecord(index, record) 582 } 583 try{ 584 replace("0",pasteDataRecord) 585 }catch(err){ 586 console.info("Replace specified record fail,error code is: " + err.code) 587 error = err 588 expect(err.code).assertEqual("401") 589 } 590 expect(error != undefined).assertTrue(); 591 console.info("SUB_PASTEBOARD_FUNCTION_ETS_REPLACERECORD_0300 end") 592 done(); 593 }) 594 595 /** 596 * @tc.number SUB_Pasteboard_Local_SDK_PasteDataRemoveOrReplace_1900 597 * @tc.name replaceRecord 598 * @tc.desc Remove specified record from pasteData failed,type of parameter "record" is string 599 * @tc.size : MEDIUM 600 * @tc.type : Function 601 * @tc.level : Level 2 602 */ 603 it('SUB_PASTEBOARD_FUNCTION_ETS_REPLACERECORD_0400', 0, async function (done) { 604 console.info("SUB_PASTEBOARD_FUNCTION_ETS_REPLACERECORD_0400 start") 605 let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_PLAIN,"valueType") 606 let pasteDataRecord = pasteboard.createRecord("arrayBuffer",ARRAY_BUFFER) 607 function replace(index, record){ 608 pasteData.replaceRecord(index, record) 609 } 610 try{ 611 replace(0,"pasteDataRecord") 612 }catch(err){ 613 console.info("Replace specified record fail,error code is: " + err.code) 614 error = err 615 expect(err.code).assertEqual("401") 616 } 617 expect(error != undefined).assertTrue(); 618 console.info("SUB_PASTEBOARD_FUNCTION_ETS_REPLACERECORD_0400 end") 619 done(); 620 }) 621 622 /** 623 * @tc.number SUB_Pasteboard_Local_SDK_PasteDataRemoveOrReplace_0200 624 * @tc.name replaceRecord 625 * @tc.desc Remove specified record from pasteData failed without parameters 626 * @tc.size : MEDIUM 627 * @tc.type : Function 628 * @tc.level : Level 2 629 */ 630 it('SUB_PASTEBOARD_FUNCTION_ETS_REPLACERECORD_0500', 0, async function (done) { 631 console.info("SUB_PASTEBOARD_FUNCTION_ETS_REPLACERECORD_0500 start") 632 let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_PLAIN,"valueType") 633 let pasteDataRecord = pasteboard.createRecord("arrayBuffer",ARRAY_BUFFER) 634 function replace(func, index, record){ 635 func() 636 } 637 try{ 638 replace(pasteData.replaceRecord, 0, "record") 639 }catch(err){ 640 console.info("Replace specified record fail,error code is: " + err.code) 641 error = err 642 expect(err.code).assertEqual("401") 643 } 644 expect(error != undefined).assertTrue(); 645 console.info("SUB_PASTEBOARD_FUNCTION_ETS_REPLACERECORD_0500 end") 646 done(); 647 }) 648 649 }); 650}