uitest.test.ets 46.8 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
/**
 * Copyright (c) 2022 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
import abilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry';
17
import { UiDriver, BY, ResizeDirection, MatchPattern, WindowMode, DisplayRotation, PointerMatrix } from '@ohos.uitest'
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
import ability_featureAbility from '@ohos.ability.featureAbility';

const delegator = abilityDelegatorRegistry.getAbilityDelegator();
const bundleName = abilityDelegatorRegistry.getArguments().bundleName;
const waitUiReadyMs = 1000;

async function startAbility(bundleName: string, abilityName: string) {
  await delegator.executeShellCommand(`aa start -b ${bundleName} -a ${abilityName}`).then(result => {
    console.info(`UiTestCase, start abilityFinished: ${result}`)
  }).catch(err => {
    console.error(`UiTestCase, start abilityFailed: ${err}`)
  })
}

async function stopApplication(bundleName: string) {
  await delegator.executeShellCommand(`aa force-stop ${bundleName} `).then(result => {
    console.info(`UiTestCase, stop application finished: ${result}`)
  }).catch(err => {
    console.error(`UiTestCase,stop application failed: ${err}`)
  })
}

40
export default function UiTest() {
41
  describe('UiTest', function () {
42

43 44 45 46 47
    /*
     * @tc.number: uiTest_0100
     * @tc.name: testInputText
     * @tc.desc: inject text to the target UiComponent
     */
48
    it('testInputText', 0, async function () {
49
      await startAbility('com.uitestScene.acts', 'com.uitestScene.acts.MainAbility')
50 51 52 53 54 55 56 57
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
      let input = await driver.findComponent(BY.type('TextInput'))
      await input.inputText('123')
      await driver.delayMs(waitUiReadyMs)
      let input_new = await driver.findComponent(BY.type('TextInput'))
      let text = await input_new.getText()
      expect(text == '123').assertTrue()
58
      await stopApplication('com.uitestScene.acts')
59 60
    })

61 62 63 64 65
    /*
     * @tc.number: uiTest_0200
     * @tc.name: testClearText
     * @tc.desc: clear text of the target UiComponent
     */
66
    it('testClearText', 0, async function () {
67
      await startAbility('com.uitestScene.acts', 'com.uitestScene.acts.MainAbility')
68 69
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
70 71 72 73
      let input1 = await driver.findComponent(BY.type('TextInput'))
      await input1.inputText('abc')
      let input2 = await driver.findComponent(BY.type('TextInput'))
      await input2.clearText()
74 75 76 77
      await driver.delayMs(waitUiReadyMs)
      let input_new = await driver.findComponent(BY.type('TextInput'))
      let text = await input_new.getText()
      expect(text).assertEqual('')
78
      await stopApplication('com.uitestScene.acts')
79 80
    })

81 82 83 84 85
    /*
     * @tc.number: uiTest_0300
     * @tc.name: testCheckable
     * @tc.desc: find UiComponent by checkable attribute and get it's checkable attribute.
     */
86
    it('testCheckable', 0, async function () {
87
      await startAbility('com.uitestScene.acts', 'com.uitestScene.acts.MainAbility')
88 89 90 91
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
      let button = await driver.findComponent(BY.checkable(true).type('Checkbox'))
      let checkable = await button.isCheckable()
92
      expect(checkable == true).assertTrue()
93
      await stopApplication('com.uitestScene.acts')
94 95
    })

96 97 98 99 100
    /*
     * @tc.number: uiTest_0400
     * @tc.name: testChecked
     * @tc.desc: find UiComponent by checked attribute and get it's checked attribute.
     */
101
    it('testChecked', 0, async function () {
102
      await startAbility('com.uitestScene.acts', 'com.uitestScene.acts.MainAbility')
103 104 105 106
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
      let button = await driver.findComponent(BY.checked(false).type('Checkbox'))
      let checked = await button.isChecked()
107
      expect(checked == false).assertTrue()
108
      await stopApplication('com.uitestScene.acts')
109 110
    })

111 112 113 114 115 116
    /*
     * @tc.number: uiTest_0500
     * @tc.name: testMatchPattern
     * @tc.desc: specifies the string value match pattern.
     */
    it('testMatchPattern', 0, async function () {
117
      await startAbility('com.uitestScene.acts', 'com.uitestScene.acts.MainAbility')
118 119 120 121 122 123 124 125 126 127
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
      let Button1 = await driver.findComponent(BY.text('next page',MatchPattern.EQUALS))
      expect(await Button1.getText() == 'next page').assertTrue()
      let Button2 = await driver.findComponent(BY.text('next',MatchPattern.STARTS_WITH))
      expect(await Button2.getText() == 'next page').assertTrue()
      let Button3 = await driver.findComponent(BY.text('page',MatchPattern.ENDS_WITH))
      expect(await Button3.getText() == 'next page').assertTrue()
      let Button4 = await driver.findComponent(BY.text('ext',MatchPattern.CONTAINS))
      expect(await Button4.getText() == 'next page').assertTrue()
128
      await stopApplication('com.uitestScene.acts')
129 130
    })

131 132 133 134 135
    /*
     * @tc.number: uiTest_0600
     * @tc.name: testClick
     * @tc.desc: click in the specified location on the screen.
     */
136
    it('testClick', 0, async function () {
137
      await startAbility('com.uitestScene.acts', 'com.uitestScene.acts.MainAbility')
138 139
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
140 141 142
      let Button = await driver.findComponent(BY.text('next page'))
      let center = await Button.getBoundsCenter()
      await driver.click(center.X, center.Y)
143 144 145 146 147
      await driver.delayMs(waitUiReadyMs)
      let newButton = await driver.findComponent(BY.text('back to index'))
      let text = await newButton.getText()
      expect(text == 'back to index').assertTrue()
      await newButton.click()
148
      await stopApplication('com.uitestScene.acts')
149 150
    })

151 152 153 154 155
    /*
     * @tc.number: uiTest_0700
     * @tc.name: testDoubleClick
     * @tc.desc: doubleClick in the specified location on the screen.
     */
156
    it('testDoubleClick', 0, async function () {
157
      await startAbility('com.uitestScene.acts', 'com.uitestScene.acts.MainAbility')
158 159 160 161 162 163 164 165 166 167
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
      let Button = await driver.findComponent(BY.text('Click twice'))
      let center = await Button.getBoundsCenter()
      await driver.doubleClick(center.X, center.Y)
      await driver.delayMs(waitUiReadyMs)
      let button = await driver.findComponent(BY.text('doubleClick'))
      let text = await button.getText()
      expect(text == 'doubleClick').assertTrue()
      await button.click()
168
      await stopApplication('com.uitestScene.acts')
169 170
    })

171 172 173 174 175
    /*
     * @tc.number: uiTest_0800
     * @tc.name: testLongClick
     * @tc.desc: longClick in the specified location on the screen.
     */
176
    it('testLongClick', 0, async function () {
177
      await startAbility('com.uitestScene.acts', 'com.uitestScene.acts.MainAbility')
178 179
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
180 181 182
      let Button = await driver.findComponent(BY.text('next page'))
      let center = await Button.getBoundsCenter()
      await driver.longClick(center.X, center.Y)
183 184 185 186 187
      await driver.delayMs(waitUiReadyMs)
      let newButton = await driver.findComponent(BY.text('longClick'))
      let text = await newButton.getText()
      expect(text == 'longClick').assertTrue()
      await newButton.click()
188
      await stopApplication('com.uitestScene.acts')
189 190
    })

191 192 193 194 195
    /*
     * @tc.number: uiTest_0900
     * @tc.name: testUiComponentClick
     * @tc.desc: click this UiComponentClick.
     */
196
    it('testUiComponentClick', 0, async function () {
197
      await startAbility('com.uitestScene.acts', 'com.uitestScene.acts.MainAbility')
198 199
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
200 201 202 203 204 205 206
      let button = await driver.findComponent(BY.text('next page'))
      await button.click()
      await driver.delayMs(waitUiReadyMs)
      let newButton = await driver.findComponent(BY.text('back to index'))
      let text = await newButton.getText()
      expect(text == 'back to index').assertTrue()
      await newButton.click()
207
      await stopApplication('com.uitestScene.acts')
208 209
    })

210 211 212 213 214
    /*
     * @tc.number: uiTest_1000
     * @tc.name: testUiComponentDoubleClick
     * @tc.desc: doubleClick this UiComponentClick.
     */
215
    it('testUiComponentDoubleClick', 0, async function () {
216
      await startAbility('com.uitestScene.acts', 'com.uitestScene.acts.MainAbility')
217 218
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
219 220
      let button = await driver.findComponent(BY.text('Click twice'))
      await button.doubleClick()
221
      await driver.delayMs(waitUiReadyMs)
222
      let newButton = await driver.findComponent(BY.text('doubleClick'))
223
      let text = await newButton.getText()
224
      expect(text == 'doubleClick').assertTrue()
225
      await newButton.click()
226
      await stopApplication('com.uitestScene.acts')
227 228
    })

229 230 231 232 233
    /*
     * @tc.number: uiTest_1100
     * @tc.name: testUiComponentLongClick
     * @tc.desc: longClick this UiComponentClick.
     */
234 235
    it('testUiComponentLongClick', 0, async function () {
      await startAbility('com.uitestScene.acts', 'com.uitestScene.acts.MainAbility')
236 237 238 239 240 241 242 243 244
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
      let button = await driver.findComponent(BY.text('next page'))
      await button.longClick()
      await driver.delayMs(waitUiReadyMs)
      let newButton = await driver.findComponent(BY.text('longClick'))
      let text = await newButton.getText()
      expect(text == 'longClick').assertTrue()
      await newButton.click()
245
      await stopApplication('com.uitestScene.acts')
246 247
    })

248 249 250 251 252
    /*
     * @tc.number: uiTest_1200
     * @tc.name: testKey
     * @tc.desc: find UiComponent by key attribute and get it's key attribute.
     */
253
    it('testKey', 0, async function () {
254
      await startAbility('com.uitestScene.acts', 'com.uitestScene.acts.MainAbility')
255 256
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
257 258
      let button = await driver.findComponent(BY.key('my-key'))
      expect(await button.getKey() == 'my-key').assertTrue()
259
      await stopApplication('com.uitestScene.acts')
260 261
    })

262 263 264 265 266
    /*
     * @tc.number: uiTest_1300
     * @tc.name: testId
     * @tc.desc: find UiComponent by id attribute and get it's id attribute.
     */
267
    it('testId', 0, async function () {
268
      await startAbility('com.uitestScene.acts', 'com.uitestScene.acts.MainAbility')
269 270 271
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
      let button = await driver.findComponent(BY.text('next page'))
272 273
      let id = await button.getId()
      let button2 = await driver.findComponent(BY.id(id))
274
      expect(await button2.getText() == 'next page').assertTrue()
275
      await stopApplication('com.uitestScene.acts')
276 277
    })

278 279 280 281 282 283
    /*
     * @tc.number: uiTest_1400
     * @tc.name: testType
     * @tc.desc: find UiComponent by type attribute and get it's type attribute.
     */
    it('testType', 0, async function () {
284
      await startAbility('com.uitestScene.acts', 'com.uitestScene.acts.MainAbility')
285 286 287 288 289
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
      let text = await driver.findComponent(BY.type('Text'))
      let type = await text.getType()
      expect(type == 'Text').assertTrue()
290
      await stopApplication('com.uitestScene.acts')
291 292
    })

293 294 295 296 297
    /*
     * @tc.number: uiTest_1500
     * @tc.name: testClickable
     * @tc.desc: find UiComponent by clickable attribute and get it's clickable attribute.
     */
298
    it('testClickable', 0, async function () {
299
      await startAbility('com.uitestScene.acts', 'com.uitestScene.acts.MainAbility')
300 301 302 303
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
      let button = await driver.findComponent(BY.text('next page').clickable(false))
      let clickable = await button.isClickable()
304
      expect(clickable == false).assertTrue()
305
      await stopApplication('com.uitestScene.acts')
306 307
    })

308 309 310 311 312
    /*
     * @tc.number: uiTest_1600
     * @tc.name: testLongClickable
     * @tc.desc: find UiComponent by longClickable attribute and get it's longClickable attribute.
     */
313
    it('testLongClickable', 0, async function () {
314
      await startAbility('com.uitestScene.acts', 'com.uitestScene.acts.MainAbility')
315 316 317 318
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
      let button = await driver.findComponent(BY.text('next page').longClickable(false))
      let longClickable = await button.isLongClickable()
319
      expect(longClickable== false).assertTrue()
320
      await stopApplication('com.uitestScene.acts')
321 322
    })

323 324 325 326 327
    /*
     * @tc.number: uiTest_1700
     * @tc.name: testScrollable
     * @tc.desc: find UiComponent by scrollable attribute and get it's scrollable attribute.
     */
328
    it('testScrollable', 0, async function () {
329
      await startAbility('com.uitestScene.acts', 'com.uitestScene.acts.MainAbility')
330 331 332 333
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
      let scrollBar = await driver.findComponent(BY.type('Scroll').scrollable(false))
      let scrollable = await scrollBar.isScrollable()
334
      expect(scrollable == false).assertTrue()
335
      await stopApplication('com.uitestScene.acts')
336 337
    })

338 339 340 341 342
    /*
     * @tc.number: uiTest_1800
     * @tc.name: testEnabled
     * @tc.desc: find UiComponent by enabled attribute and get it's enabled attribute.
     */
343
    it('testEnabled', 0, async function () {
344
      await startAbility('com.uitestScene.acts', 'com.uitestScene.acts.MainAbility')
345 346 347 348
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
      let button = await driver.findComponent(BY.text('next page').enabled(true))
      let enable = await button.isEnabled()
349
      expect(enable == true).assertTrue()
350
      await stopApplication('com.uitestScene.acts')
351 352
    })

353 354 355 356 357
    /*
     * @tc.number: uiTest_1900
     * @tc.name: testFocused
     * @tc.desc: find UiComponent by focused attribute and get it's focused attribute.
     */
358
    it('testFocused', 0, async function () {
359
      await startAbility('com.uitestScene.acts', 'com.uitestScene.acts.MainAbility')
360 361 362 363
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
      let button = await driver.findComponent(BY.text('next page').focused(false))
      let focused = await button.isFocused()
364
      expect(focused == false).assertTrue()
365
      await stopApplication('com.uitestScene.acts')
366 367
    })

368 369 370 371 372
    /*
     * @tc.number: uiTest_2000
     * @tc.name: testSelected
     * @tc.desc: find UiComponent by selected attribute and get it's selected attribute.
     */
373
    it('testSelected', 0, async function () {
374
      await startAbility('com.uitestScene.acts', 'com.uitestScene.acts.MainAbility')
375 376 377 378
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
      let button = await driver.findComponent(BY.text('next page').selected(false))
      let selected = await button.isSelected()
379
      expect(selected == false).assertTrue()
380
      await stopApplication('com.uitestScene.acts')
381 382
    })

383 384 385 386 387
    /*
     * @tc.number: uiTest_2100
     * @tc.name: testPressBack
     * @tc.desc: Press the BACK key.
     */
388
    it('testPressBack', 0, async function () {
389
      await startAbility('com.uitestScene.acts', 'com.uitestScene.acts.MainAbility')
390 391 392 393 394 395 396 397 398
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
      let button = await driver.findComponent(BY.text('next page'))
      await button.click()
      await driver.delayMs(waitUiReadyMs)
      await driver.pressBack()
      await driver.delayMs(waitUiReadyMs)
      let button_ori = await driver.findComponent(BY.text('next page'))
      expect(await button_ori.getText() == 'next page').assertTrue()
399
      await stopApplication('com.uitestScene.acts')
400 401
    })

402 403 404 405 406
    /*
     * @tc.number: uiTest_2200
     * @tc.name: testFindComponents
     * @tc.desc: find all the matched UiComponents on current UI
     */
407
    it('testFindComponents', 0, async function () {
408
      await startAbility('com.uitestScene.acts', 'com.uitestScene.acts.MainAbility')
409 410 411 412
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
      let buttons = await driver.findComponents(BY.type('Button'))
      expect(await buttons[0].getText() != null).assertTrue()
413
      await stopApplication('com.uitestScene.acts')
414 415
    })

416 417 418 419 420
    /*
     * @tc.number: uiTest_2300
     * @tc.name: testTriggerKey
     * @tc.desc: press the specified key.
     */
421
    it('testTriggerKey', 0, async function () {
422
      await startAbility('com.uitestScene.acts', 'com.uitestScene.acts.MainAbility')
423 424 425 426 427
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
      let button = await driver.findComponent(BY.text('next page'))
      await button.click()
      await driver.delayMs(waitUiReadyMs)
428 429
      let keyBack = 2
      await driver.triggerKey(keyBack)
430 431 432
      await driver.delayMs(waitUiReadyMs)
      let button_ori = await driver.findComponent(BY.text('next page'))
      expect(await button_ori.getText() == 'next page').assertTrue()
433
      await stopApplication('com.uitestScene.acts')
434 435
    })

436 437
    /*
     * @tc.number: uiTest_2400
438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460
     * @tc.name: testTriggerCombineKeys
     * @tc.desc: press two or three key combinations
     */
    it('testTriggerCombineKeys', 0, async function () {
      await startAbility('com.uitestScene.acts', 'com.uitestScene.acts.MainAbility')
      let driver = UiDriver.create()
      await driver.delayMs(2000)
      let text = await driver.findComponent(BY.type('TextInput'))
      let center = await text.getBoundsCenter()
      await text.inputText('123')
      await driver.click(center.X, center.Y)
      await driver.delayMs(waitUiReadyMs)
      await driver.triggerCombineKeys(2072, 2017)
      await driver.delayMs(waitUiReadyMs)
      await driver.triggerCombineKeys(2072, 2019)
      await driver.triggerCombineKeys(2072, 2038)
      let text2 = await driver.findComponent(BY.type('TextInput'))
      expect(await text2.getText() == '123123').assertTrue()
      await stopApplication('com.uitestScene.acts')
    })

    /*
     * @tc.number: uiTest_2500
461 462 463
     * @tc.name: testGetUiComponentBounds
     * @tc.desc: get the bounds of this UiComponent.
     */
464
    it('testGetUiComponentBounds', 0, async function () {
465
      await startAbility('com.uitestScene.acts', 'com.uitestScene.acts.MainAbility')
466 467
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
468
      let text = await driver.findComponent(BY.text('next page'))
469 470 471 472 473
      expect(text !== null).assertTrue()
      let bounds = await text.getBounds();
      expect(bounds !== null).assertTrue()
      expect(bounds.rightX).assertLarger(bounds.leftX)
      expect(bounds.bottomY).assertLarger(bounds.topY)
474
      await stopApplication('com.uitestScene.acts')
475 476
    })

477
    /*
478
     * @tc.number: uiTest_2600
479 480 481
     * @tc.name: testGetUiComponentBoundsCenter
     * @tc.desc: get the boundsCenter of this @link UiComponent.
     */
482
    it('testGetUiComponentBoundsCenter', 0, async function () {
483
      await startAbility('com.uitestScene.acts', 'com.uitestScene.acts.MainAbility')
484 485 486 487
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
      let button = await driver.findComponent(BY.text('next page'))
      let point = await button.getBoundsCenter()
488
      let bounds = await button.getBounds()
489
      expect(point!== null).assertTrue()
490 491
      expect(point.Y == (bounds.bottomY + bounds.topY)/2).assertTrue()
      expect(point.X == (bounds.rightX + bounds.leftX)/2).assertTrue()
492
      await stopApplication('com.uitestScene.acts')
493 494
    })

495
    /*
496
     * @tc.number: uiTest_2700
497 498 499
     * @tc.name: testWaitForComponent
     * @tc.desc: Find the first matched UiComponent on current UI during the time given.
     */
500
    it('testWaitForComponent', 0, async function () {
501
      await startAbility('com.uitestScene.acts', 'com.uitestScene.acts.MainAbility')
502 503 504 505
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
      let button = await driver.waitForComponent(BY.text('next page'), waitUiReadyMs)
      expect(button !== null).assertTrue()
506
      await stopApplication('com.uitestScene.acts')
507 508
    })

509
    /*
510
     * @tc.number: uiTest_2800
511 512 513
     * @tc.name: testScreenCap
     * @tc.desc: capture current screen.
     */
514
    it('testScreenCap', 0, async function () {
515
      await startAbility('com.uitestScene.acts', 'com.uitestScene.acts.MainAbility')
516 517 518 519 520
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
      let savePath = '/data/local/tmp/1.png'
      let success = await driver.screenCap(savePath)
      expect(success == true).assertTrue()
521
      await stopApplication('com.uitestScene.acts')
522 523
    })

524
    /*
525
     * @tc.number: uiTest_2900
526 527 528 529
     * @tc.name: testAssertComponentExist
     * @tc.desc:  Assert whether the matched UiComponent exists on current UI;.
     */
    it('testAssertComponentExist', 0, async function () {
530
      await startAbility('com.uitestScene.acts', 'com.uitestScene.acts.MainAbility')
531 532 533
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
      await driver.assertComponentExist(BY.text('next page'))
534
      await stopApplication('com.uitestScene.acts')
535 536 537
    })

    /*
538
     * @tc.number: uiTest_3000
539 540 541
     * @tc.name: testIsBefore
     * @tc.desc: find uiComponent which is before another UiComponent that specified by given.
     */
542
    it('testIsBefore', 0, async function () {
543
      await startAbility('com.uitestScene.acts', 'com.uitestScene.acts.MainAbility')
544 545
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
546 547
      let button = await driver.findComponent(BY.isBefore(BY.text('Click twice')).type('Button'))
      expect(await button.getType() == 'Button').assertTrue()
548
      await stopApplication('com.uitestScene.acts')
549 550
    })

551
    /*
552
     * @tc.number: uiTest_3100
553 554 555
     * @tc.name: testIsAfter
     * @tc.desc: find uiComponent which is after another UiComponent that specified by given.
     */
556
    it('testIsAfter', 0, async function () {
557
      await startAbility('com.uitestScene.acts', 'com.uitestScene.acts.MainAbility')
558 559
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
560 561
      let button = await driver.findComponent(BY.isAfter(BY.text('next page')).type('Text'))
      expect(await button.getText() == 'Click twice').assertTrue()
562
      await stopApplication('com.uitestScene.acts')
563 564
    })

565
    /*
566
     * @tc.number: uiTest_3200
567 568 569 570
     * @tc.name: testSwipe
     * @tc.desc: swipe on the screen between the specified points.
     */
    it('testSwipe', 0, async function () {
571
      await startAbility('com.uitestScene.acts', 'com.uitestScene.acts.MainAbility')
572 573 574 575 576
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
      await driver.swipe(300,600,300,300)
      let text = await driver.findComponent(BY.text('next page'))
      expect(text == null).assertTrue()
577 578 579
      let scrollBar = await driver.findComponent(BY.type('Scroll'))
      await scrollBar.scrollToTop()
      await stopApplication('com.uitestScene.acts')
580 581 582
    })

    /*
583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600
     * @tc.number: uiTest_3300
     * @tc.name: testFling
     * @tc.desc: inject fling on the device display.
     */
    it('testFling', 0, async function () {
      await startAbility('com.uitestScene.acts', 'com.uitestScene.acts.MainAbility')
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
      await driver.fling({X:300, Y:600},{X:300, Y:300}, 20, 600)
      let text = await driver.findComponent(BY.text('next page'))
      expect(text == null).assertTrue()
      let scrollBar = await driver.findComponent(BY.type('Scroll'))
      await scrollBar.scrollToTop()
      await stopApplication('com.uitestScene.acts')
    })

    /*
     * @tc.number: uiTest_3400
601 602 603
     * @tc.name: testScrollSearch
     * @tc.desc: scroll on this UiComponent to find matched UiComponent.
     */
604
    it('testScrollSearch', 0, async function () {
605
      await startAbility('com.uitestScene.acts', 'com.uitestScene.acts.MainAbility')
606 607
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
608
      let scrollBar = await driver.findComponent(BY.type('Scroll'))
609 610
      let button = await scrollBar.scrollSearch(BY.text('next page'))
      expect(await button.getText() == 'next page').assertTrue()
611
      await stopApplication('com.uitestScene.acts')
612 613
    })

614
    /*
615
     * @tc.number: uiTest_3500
616 617 618 619
     * @tc.name: testScrollToBottom
     * @tc.desc: scroll on this UiComponent to the bottom.
     */
    it('testScrollToBottom', 0, async function () {
620
      await startAbility('com.uitestScene.acts', 'com.uitestScene.acts.MainAbility')
621 622 623 624 625 626 627 628
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
      let scrollBar = await driver.findComponent(BY.type('Scroll'))
      expect(scrollBar != null).assertTrue()
      await scrollBar.scrollToBottom()
      let button = await driver.findComponent(BY.text('bottom'))
      expect(await button.getText() == 'bottom').assertTrue()
      await scrollBar.scrollToTop()
629
      await stopApplication('com.uitestScene.acts')
630 631 632
    })

    /*
633
     * @tc.number: uiTest_3600
634 635 636 637
     * @tc.name: testScrollToTop
     * @tc.desc: scroll on this UiComponent to the top.
     */
    it('testScrollToTop', 0, async function () {
638
      await startAbility('com.uitestScene.acts', 'com.uitestScene.acts.MainAbility')
639 640 641 642 643 644 645 646
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
      let scrollBar = await driver.findComponent(BY.type('Scroll'))
      expect(scrollBar !== null).assertTrue()
      await scrollBar.scrollToBottom()
      await scrollBar.scrollToTop()
      let button = await driver.findComponent(BY.text('next page'))
      expect(await button.getText() == 'next page').assertTrue()
647
      await stopApplication('com.uitestScene.acts')
648 649 650
    })

    /*
651 652 653 654 655 656 657 658 659 660
     * @tc.number: uiTest_3700
     * @tc.name: testPinch
     * @tc.desc: pinch enlarge this UiComponent to the target scale.
     */
    it('testPinch', 0, async function () {
      await startAbility('com.uitestScene.acts', 'com.uitestScene.acts.MainAbility')
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
      let button = await driver.findComponent(BY.text('jump'))
      await button.click()
661
      await driver.delayMs(waitUiReadyMs)
662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687
      let image1 = await driver.findComponent(BY.type('Image'))
      let bounds1 = await image1.getBounds()
      await image1.pinchIn(0.5);
      await driver.delayMs(waitUiReadyMs)
      let image2 = await driver.findComponent(BY.type('Image'))
      let bounds2 = await image2.getBounds()
      expect(bounds2 != bounds1).assertTrue()
      await image2.pinchOut(1.2);
      let image3 = await driver.findComponent(BY.type('Image'))
      let bounds3 = await image3.getBounds()
      expect(bounds3 != bounds2).assertTrue()
      await driver.pressBack()
      await stopApplication('com.uitestScene.acts')
    })

    /*
     * @tc.number: uiTest_3800
     * @tc.name: testInjectMultiPointerAction
     * @tc.desc: inject multi-pointer action on the device display.
     */
    it('testInjectMultiPointerAction', 0, async function () {
      await startAbility('com.uitestScene.acts', 'com.uitestScene.acts.MainAbility')
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
      let button = await driver.findComponent(BY.text('jump'))
      await button.click()
688
      await driver.delayMs(waitUiReadyMs)
689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724
      let image1 = await driver.findComponent(BY.type('Image'))
      let bounds1 = await image1.getBounds()
      let pointer = PointerMatrix.create(2,11)
      await driver.delayMs(300)
      pointer.setPoint(0,0,{X:245,Y:480})
      pointer.setPoint(0,1,{X:250,Y:480})
      pointer.setPoint(0,2,{X:255,Y:480})
      pointer.setPoint(0,3,{X:260,Y:480})
      pointer.setPoint(0,4,{X:265,Y:480})
      pointer.setPoint(0,5,{X:270,Y:480})
      pointer.setPoint(0,6,{X:275,Y:480})
      pointer.setPoint(0,7,{X:280,Y:480})
      pointer.setPoint(0,8,{X:285,Y:480})
      pointer.setPoint(0,9,{X:290,Y:480})
      pointer.setPoint(0,10,{X:295,Y:480})
      pointer.setPoint(1,0,{X:505,Y:480})
      pointer.setPoint(1,1,{X:500,Y:480})
      pointer.setPoint(1,2,{X:495,Y:480})
      pointer.setPoint(1,3,{X:490,Y:480})
      pointer.setPoint(1,4,{X:485,Y:480})
      pointer.setPoint(1,5,{X:480,Y:480})
      pointer.setPoint(1,6,{X:475,Y:480})
      pointer.setPoint(1,7,{X:470,Y:480})
      pointer.setPoint(1,8,{X:465,Y:480})
      pointer.setPoint(1,9,{X:460,Y:480})
      pointer.setPoint(1,10,{X:455,Y:480})
      await driver.injectMultiPointerAction(pointer, 600)
      let image2 = await driver.findComponent(BY.type('Image'))
      let bounds2= await image1.getBounds()
      expect(bounds2 != bounds1).assertTrue()
      await driver.pressBack()
      await stopApplication('com.uitestScene.acts')
    })

    /*
     * @tc.number: uiTest_3900
725 726 727
     * @tc.name: testGetWindowMode
     * @tc.desc: get the window mode of this UiWindow.
     */
728
    it('testGetWindowMode', 0, async function () {
729
      await startAbility('com.uitestScene.acts', 'com.uitestScene.acts.MainAbility')
730 731
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
732
      let window1 = await driver.findWindow({bundleName:'com.uitestScene.acts'})
733 734
      let mode1 = await window1.getWindowMode()
      expect(mode1 == WindowMode.FULLSCREEN).assertTrue()
735 736 737 738 739 740 741
      try {
        await window1.resume()
        let window2 = await driver.findWindow({bundleName:'com.uitestScene.acts'})
        let mode2 = await window2.getWindowMode()
        expect(mode2 == WindowMode.FLOATING).assertTrue()
        await stopApplication('com.uitestScene.acts')
      }
742 743 744 745 746 747
      catch (err) {
        if (err.message == 'this device can not support this action') {
          expect(window1 != null).assertTrue()
        } else {
          expect(false).assertTrue()
        }
748
      }
749 750 751
    })

    /*
752
     * @tc.number: uiTest_4000
753 754 755 756
     * @tc.name: testGetBundleName
     * @tc.desc: get the bundleName of this UiWindow.
     */
    it('testGetBundleName', 0, async function () {
757
      await startAbility('com.uitestScene.acts', 'com.uitestScene.acts.MainAbility')
758 759
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
760
      let window = await driver.findWindow({bundleName:'com.uitestScene.acts'})
761
      let name = await window.getBundleName()
762 763
      expect(name == 'com.uitestScene.acts').assertTrue()
      await stopApplication('com.uitestScene.acts')
764 765 766
    })

    /*
767
     * @tc.number: uiTest_4100
768 769 770 771
     * @tc.name: testGetTitle
     * @tc.desc: get the title of this UiWindow.
     */
    it('testGetTitle', 0, async function () {
772
      await startAbility('com.uitestScene.acts', 'com.uitestScene.acts.MainAbility')
773 774
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
775
      let window = await driver.findWindow({bundleName:'com.uitestScene.acts'})
776 777
      let title = await window.getTitle()
      expect(title == '').assertTrue()
778
      await stopApplication('com.uitestScene.acts')
779 780
    })

781
    /*
782
     * @tc.number: uiTest_4200
783 784 785
     * @tc.name: testWindowMoveTo
     * @tc.desc: move this UiWindow to the specified points.
     */
786
    it('testWindowMoveTo', 0, async function () {
787
      await startAbility('com.uitestScene.acts', 'com.uitestScene.acts.MainAbility')
788 789
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
790
      let window = await driver.findWindow({bundleName:'com.uitestScene.acts'})
791 792 793 794 795 796 797 798 799 800 801 802
      try{
        await window.resume()
        await driver.delayMs(waitUiReadyMs)
        let window1 = await driver.findWindow({bundleName:'com.uitestScene.acts'})
        let bounds1 = await window1.getBounds()
        await window1.moveTo(100,100)
        await driver.delayMs(waitUiReadyMs)
        let window2 = await driver.findWindow({bundleName:'com.uitestScene.acts'})
        let bounds2 = await window2.getBounds()
        expect(bounds1 != bounds2).assertTrue()
        await stopApplication('com.uitestScene.acts')
      }
803 804 805 806 807 808
      catch (err) {
        if (err.message == 'this device can not support this action') {
          expect(window != null).assertTrue()
        } else {
          expect(false).assertTrue()
        }
809
      }
810
    })
811

812
    /*
813
     * @tc.number: uiTest_4300
814 815 816
     * @tc.name: testWindowResize
     * @tc.desc: resize this UiWindow to the specified size for the specified direction.
     */
817 818
    it('testWindowResizeA', 0, async function () {
      await startAbility('com.uitestScene.acts', 'com.uitestScene.acts.MainAbility')
819 820
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
821
      let window = await driver.findWindow({bundleName:'com.uitestScene.acts'})
822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848
      try{
        await window.resume()
        await driver.delayMs(waitUiReadyMs)

        let window1 = await driver.findWindow({bundleName:'com.uitestScene.acts'})
        let bounds1 = await window1.getBounds()
        await window1.resize(600,600,ResizeDirection.RIGHT_DOWN)
        await driver.delayMs(waitUiReadyMs)
        let window2 = await driver.findWindow({bundleName:'com.uitestScene.acts'})
        let bounds2 = await window2.getBounds()
        expect(bounds2 != bounds1).assertTrue()

        await window2.resize(400,400,ResizeDirection.RIGHT_UP)
        let window3 = await driver.findWindow({bundleName:'com.uitestScene.acts'})
        let bounds3= await window3.getBounds()
        expect(bounds3 != bounds2).assertTrue()
        await window3.resize(300,300,ResizeDirection.LEFT_DOWN)
        let window4 = await driver.findWindow({bundleName:'com.uitestScene.acts'})
        let bounds4= await window4.getBounds()
        expect(bounds4 != bounds3).assertTrue()

        await window4.resize(500,500,ResizeDirection.LEFT_UP)
        let window5 = await driver.findWindow({bundleName:'com.uitestScene.acts'})
        let bounds5= await window5.getBounds()
        expect(bounds5 != bounds4).assertTrue()
        await stopApplication('com.uitestScene.acts')
      }
849 850 851 852 853 854
      catch (err) {
        if (err.message == 'this device can not support this action') {
          expect(window != null).assertTrue()
        } else {
          expect(false).assertTrue()
        }
855
      }
856 857 858 859 860 861 862
    })

    it('testWindowResizeB', 0, async function () {
      await startAbility('com.uitestScene.acts', 'com.uitestScene.acts.MainAbility')
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
      let window = await driver.findWindow({bundleName:'com.uitestScene.acts'})
863 864 865
      try{
        await window.resume()
        await driver.delayMs(waitUiReadyMs)
866

867 868 869 870 871 872
        let window5 = await driver.findWindow({bundleName:'com.uitestScene.acts'})
        let bounds5= await window5.getBounds()
        await window5.resize(bounds5.rightX - bounds5.leftX,300,ResizeDirection.DOWN)
        let window6 = await driver.findWindow({bundleName:'com.uitestScene.acts'})
        let bounds6= await window6.getBounds()
        expect(bounds6 != bounds5).assertTrue()
873

874 875 876 877
        await window6.resize(bounds6.rightX - bounds6.leftX,500,ResizeDirection.UP)
        let window7 = await driver.findWindow({bundleName:'com.uitestScene.acts'})
        let bounds7 = await window7.getBounds()
        expect(bounds7 != bounds6).assertTrue()
878

879 880 881 882
        await window7.resize(300,bounds7.bottomY - bounds7.topY,ResizeDirection.LEFT)
        let window8 = await driver.findWindow({bundleName:'com.uitestScene.acts'})
        let bounds8 = await window8.getBounds()
        expect(bounds8 != bounds7).assertTrue()
883

884 885 886 887
        await window8.resize(500,bounds8.bottomY - bounds8.topY,ResizeDirection.RIGHT)
        let window9 = await driver.findWindow({bundleName:'com.uitestScene.acts'})
        let bounds9 = await window9.getBounds()
        expect(bounds9 != bounds8).assertTrue()
888

889 890
        await stopApplication('com.uitestScene.acts')
      }
891 892 893 894 895 896
      catch (err) {
        if (err.message == 'this device can not support this action') {
          expect(window != null).assertTrue()
        } else {
          expect(false).assertTrue()
        }
897
      }
898 899
    })

900
    /*
901
     * @tc.number: uiTest_4400
902
     * @tc.name: testWindowAttr
903 904
     * @tc.desc: set the focused status of this UiWindow.
     */
905
    it('testWindowAttr', 0, async function () {
906
      await startAbility('com.uitestScene.acts', 'com.uitestScene.acts.MainAbility')
907 908
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
909
      let window = await driver.findWindow({bundleName:'com.uitestScene.acts',focused:true,actived:true})
910
      await window.focus()
911
      let isFocused = await window.isFocused()
912
      let isActived = await window.isActived()
913
      expect(isFocused == true).assertTrue()
914
      expect(isActived == true).assertTrue()
915
      await stopApplication('com.uitestScene.acts')
916 917
    })

918
    /*
919
     * @tc.number: uiTest_4500
920 921 922
     * @tc.name: testWindowMaximize
     * @tc.desc: maximize this UiWindow.
     */
923
    it('testWindowMaximize', 0, async function () {
924
      await startAbility('com.uitestScene.acts', 'com.uitestScene.acts.MainAbility')
925 926
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
927
      let window = await driver.findWindow({bundleName:'com.uitestScene.acts'})
928 929 930 931 932 933 934 935 936 937
      try{
        await window.resume()
        let window2 = await driver.findWindow({bundleName:'com.uitestScene.acts'})
        await window2.maximize()
        await driver.delayMs(waitUiReadyMs)
        let window3 = await driver.findWindow({bundleName:'com.uitestScene.acts'})
        let mode = await window3.getWindowMode()
        expect(mode == WindowMode.FULLSCREEN).assertTrue()
        await stopApplication('com.uitestScene.acts')
      }
938 939 940 941 942 943
      catch (err) {
        if (err.message == 'this device can not support this action') {
          expect(window != null).assertTrue()
        } else {
          expect(false).assertTrue()
        }
944
      }
945 946
    })

947
    /*
948
     * @tc.number: uiTest_4600
949 950 951
     * @tc.name: testWindowMinimize
     * @tc.desc: minimize this UiWindow.
     */
952
    it('testWindowMinimize', 0, async function () {
953
      await startAbility('com.uitestScene.acts', 'com.uitestScene.acts.MainAbility')
954 955
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
956
      let window = await driver.findWindow({bundleName:'com.uitestScene.acts'})
957
      try{
958
      await window.minimize()
959 960 961 962 963
        await driver.delayMs(waitUiReadyMs)
        let window1 = await driver.findWindow({bundleName:'com.uitestScene.acts'})
        expect(window1 == null).assertTrue()
        await stopApplication('com.uitestScene.acts')
      }
964 965 966 967 968 969
      catch (err) {
        if (err.message == 'this device can not support this action') {
          expect(window != null).assertTrue()
        } else {
          expect(false).assertTrue()
        }
970
      }
971 972
    })

973
    /*
974
     * @tc.number: uiTest_4700
975 976 977
     * @tc.name: testWindowClose
     * @tc.desc: close this UiWindow.
     */
978
    it('testWindowClose', 0, async function () {
979
      await startAbility('com.uitestScene.acts', 'com.uitestScene.acts.MainAbility')
980 981
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
982
      let window = await driver.findWindow({bundleName:'com.uitestScene.acts'})
983 984 985 986 987 988
      try{
        await window.close()
        await driver.delayMs(waitUiReadyMs)
        let window1 = await driver.findWindow({bundleName:'com.uitestScene.acts'})
        expect(window1 == null).assertTrue()
      }
989 990 991 992 993 994
      catch (err) {
        if (err.message == 'this device can not support this action') {
          expect(window != null).assertTrue()
        } else {
          expect(false).assertTrue()
        }
995
      }
996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102
    })

    /*
     * @tc.number: uiTest_4800
     * @tc.name: testGetDisplaySize
     * @tc.desc: get the size of the device display.
     */
    it('testGetDisplaySize', 0, async function () {
      await startAbility('com.uitestScene.acts', 'com.uitestScene.acts.MainAbility')
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
      let s = await driver.getDisplaySize()
      expect(s.X != 0).assertTrue()
      expect(s.Y != 0).assertTrue()
      await stopApplication('com.uitestScene.acts')
    })

    /*
     * @tc.number: uiTest_4900
     * @tc.name: testGetDisplayDensity
     * @tc.desc: get the density of the device display.
     */
    it('testGetDisplayDensity', 0, async function () {
      await startAbility('com.uitestScene.acts', 'com.uitestScene.acts.MainAbility')
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
      let s = await driver.getDisplayDensity()
      expect(s.X != 0).assertTrue()
      expect(s.Y != 0).assertTrue()
      await stopApplication('com.uitestScene.acts')
    })

    /*
     * @tc.number: uiTest_5000
     * @tc.name: testDisplayRotation
     * @tc.desc: get the rotation of the device display and set it.
     */
    it('testDisplayRotation', 0, async function () {
      await startAbility('com.uitestScene.acts', 'com.uitestScene.acts.MainAbility')
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
      await driver.delayMs(waitUiReadyMs)
      await driver.setDisplayRotation(DisplayRotation.ROTATION_90)
      let rotation1 = await driver.getDisplayRotation()
      expect(rotation1 == DisplayRotation.ROTATION_90).assertTrue()
      await driver.delayMs(waitUiReadyMs)

      await driver.setDisplayRotation(DisplayRotation.ROTATION_180)
      let rotation2 = await driver.getDisplayRotation()
      expect(rotation2 == DisplayRotation.ROTATION_180).assertTrue()
      await driver.delayMs(waitUiReadyMs)

      await driver.setDisplayRotation(DisplayRotation.ROTATION_270)
      let rotation3 = await driver.getDisplayRotation()
      expect(rotation3 == DisplayRotation.ROTATION_270).assertTrue()
      await driver.delayMs(waitUiReadyMs)

      await driver.setDisplayRotation(DisplayRotation.ROTATION_0)
      let rotation4 = await driver.getDisplayRotation()
      expect(rotation4== DisplayRotation.ROTATION_0).assertTrue()
      await stopApplication('com.uitestScene.acts')
    })

    /*
     * @tc.number: uiTest_5100
     * @tc.name: testSetDisplayRotationEnabled
     * @tc.desc: enable/disable the rotation of device display.
     */
    it('testSetDisplayRotationEnabled', 0, async function () {
      await startAbility('com.uitestScene.acts', 'com.uitestScene.acts.MainAbility')
      let driver = UiDriver.create()
      await driver.setDisplayRotationEnabled(false)
      await driver.setDisplayRotation(DisplayRotation.ROTATION_180)
      await driver.delayMs(waitUiReadyMs)
      let rotation3 = await driver.getDisplayRotation()
      await driver.setDisplayRotationEnabled(true)
      await driver.setDisplayRotation(DisplayRotation.ROTATION_90)
      let rotation2 = await driver.getDisplayRotation()
      expect(rotation2 == DisplayRotation.ROTATION_90).assertTrue()
      await driver.setDisplayRotation(DisplayRotation.ROTATION_0)
      await stopApplication('com.uitestScene.acts')
    })

    /*
     * @tc.number: uiTest_5200
     * @tc.name: testWakeUpDisplay
     * @tc.desc: wake up the device display.
     */
    it('testWakeUpDisplay', 0, async function () {
      await startAbility('com.uitestScene.acts', 'com.uitestScene.acts.MainAbility')
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
      await driver.wakeUpDisplay()
      await stopApplication('com.uitestScene.acts')
    })

    /*
     * @tc.number: uiTest_5300
     * @tc.name: testPressHome
     * @tc.desc: press the home key.
     */
    it('testPressHome', 0, async function () {
      await startAbility('com.uitestScene.acts', 'com.uitestScene.acts.MainAbility')
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
      await driver.pressHome()
      let button = await driver.findComponent(BY.text('next page'))
1103
      expect(button != null).assertTrue()
1104
      await stopApplication('com.uitestScene.acts')
1105 1106
    })

1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119
    /*
     * @tc.number: uiTest_5400
     * @tc.name: testWaitForIdle
     * @tc.desc: wait for the UI become idle.
     */
    it('testWaitForIdle', 0, async function () {
      await startAbility('com.uitestScene.acts', 'com.uitestScene.acts.MainAbility')
      let driver = UiDriver.create()
      await driver.delayMs(2000)
      let idled = await driver.waitForIdle(4000,5000)
      expect(idled = true).assertTrue()
      await stopApplication('com.uitestScene.acts')
    })
1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163

    /*
     * @tc.number: uiTest_5600
     * @tc.name: testDrag
     * @tc.desc: drag on the screen between the specified points.
     */
    it('testDrag', 0, async function () {
      await startAbility('com.uitestScene.acts', 'com.uitestScene.acts.MainAbility')
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
      let button = await driver.findComponent(BY.text('jump'))
      await button.longClick()
      await driver.delayMs(waitUiReadyMs)
      let text1 = await driver.findComponent(BY.text('orange'))
      let text2 = await driver.findComponent(BY.text('one'))
      let point1 = await text1.getBoundsCenter()
      let point2 = await text2.getBoundsCenter()
      await driver.drag(point1.X, point1.Y, point2.X, point2.Y)
      await driver.delayMs(waitUiReadyMs)
      let text = await driver.findComponent(BY.text('four'))
      expect(text == null).assertTrue()
      await stopApplication('com.uitestScene.acts')
    })

    /*
     * @tc.number: uiTest_5700
     * @tc.name: testDragTos  
     * @tc.desc: drag this UiComponent to the bounds rect of target UiComponent.
     */
    it('testDragTo', 0, async function () {
      await startAbility('com.uitestScene.acts', 'com.uitestScene.acts.MainAbility')
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
      let button = await driver.findComponent(BY.text('jump'))
      await button.longClick()
      await driver.delayMs(waitUiReadyMs)
      let text1 = await driver.findComponent(BY.text('orange'))
      let text2 = await driver.findComponent(BY.text('one'))
      await text1.dragTo(text2)
      await driver.delayMs(waitUiReadyMs)
      let text = await driver.findComponent(BY.text('four'))
      expect(text == null).assertTrue()
      await stopApplication('com.uitestScene.acts')
    })
1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189

    /*
     * @tc.number: uiTest_5800
     * @tc.name: testSplit 
     * @tc.desc: change this UiWindow into split screen mode.
     */
    it('testSplit', 0, async function () {
      await startAbility('com.uitestScene.acts', 'com.uitestScene.acts.MainAbility')
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
      let window1 = await driver.findWindow({bundleName:'com.uitestScene.acts'})
      try {
        await window1.split()
        await driver.delayMs(waitUiReadyMs)
        let window2 = await driver.findWindow({bundleName:'com.ohos.systemui'})
        expect(window2 == null).assertTrue()
      }
      catch (err) {
        if (err.message == 'this device can not support this action') {
          expect(window1 != null).assertTrue()
        } else {
          expect(false).assertTrue()
        }
      }
      await stopApplication('com.uitestScene.acts')
    })
1190 1191
  })
}