uitest.test.ets 27.7 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 } 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('UiTestCase', function () {
42 43 44 45 46 47 48

   /*
    * @tc.number: uiTest_0100
    * @tc.name: testInputText
    * @tc.desc: inject text to the target UiComponent
    */
    it('testInputText', 0, async function () {
49 50 51 52 53 54 55 56 57 58
      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()
    })

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

77 78 79 80 81
    /*
     * @tc.number: uiTest_0300
     * @tc.name: testCheckable
     * @tc.desc: find UiComponent by checkable attribute and get it's checkable attribute.
     */
82
    it('testCheckable', 0, async function () {
83 84 85 86
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
      let button = await driver.findComponent(BY.checkable(true).type('Checkbox'))
      let checkable = await button.isCheckable()
87
      expect(checkable == true).assertTrue()
88 89
    })

90 91 92 93 94
    /*
     * @tc.number: uiTest_0400
     * @tc.name: testChecked
     * @tc.desc: find UiComponent by checked attribute and get it's checked attribute.
     */
95
    it('testChecked', 0, async function () {
96 97 98 99
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
      let button = await driver.findComponent(BY.checked(false).type('Checkbox'))
      let checked = await button.isChecked()
100 101 102
      expect(checked == false).assertTrue()
    })

103 104 105 106 107 108
    /*
     * @tc.number: uiTest_0500
     * @tc.name: testMatchPattern
     * @tc.desc: specifies the string value match pattern.
     */
    it('testMatchPattern', 0, async function () {
109 110 111 112 113 114 115 116 117 118
      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()
119 120
    })

121 122 123 124 125
    /*
     * @tc.number: uiTest_0600
     * @tc.name: testClick
     * @tc.desc: click in the specified location on the screen.
     */
126
    it('testClick', 0, async function () {
127 128
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
129 130 131
      let Button = await driver.findComponent(BY.text('next page'))
      let center = await Button.getBoundsCenter()
      await driver.click(center.X, center.Y)
132 133 134 135 136 137 138
      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()
    })

139 140 141 142 143
    /*
     * @tc.number: uiTest_0700
     * @tc.name: testDoubleClick
     * @tc.desc: doubleClick in the specified location on the screen.
     */
144 145 146 147 148 149 150 151 152 153 154 155 156
    it('testDoubleClick', 0, async function () {
      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()
    })

157 158 159 160 161
    /*
     * @tc.number: uiTest_0800
     * @tc.name: testLongClick
     * @tc.desc: longClick in the specified location on the screen.
     */
162
    it('testLongClick', 0, async function () {
163 164
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
165 166 167
      let Button = await driver.findComponent(BY.text('next page'))
      let center = await Button.getBoundsCenter()
      await driver.longClick(center.X, center.Y)
168 169 170 171 172 173 174
      await driver.delayMs(waitUiReadyMs)
      let newButton = await driver.findComponent(BY.text('longClick'))
      let text = await newButton.getText()
      expect(text == 'longClick').assertTrue()
      await newButton.click()
    })

175 176 177 178 179
    /*
     * @tc.number: uiTest_0900
     * @tc.name: testUiComponentClick
     * @tc.desc: click this UiComponentClick.
     */
180
    it('testUiComponentClick', 0, async function () {
181 182
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
183 184 185 186 187 188 189
      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()
190 191
    })

192 193 194 195 196
    /*
     * @tc.number: uiTest_1000
     * @tc.name: testUiComponentDoubleClick
     * @tc.desc: doubleClick this UiComponentClick.
     */
197
    it('testUiComponentDoubleClick', 0, async function () {
198 199
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
200 201
      let button = await driver.findComponent(BY.text('Click twice'))
      await button.doubleClick()
202
      await driver.delayMs(waitUiReadyMs)
203
      let newButton = await driver.findComponent(BY.text('doubleClick'))
204
      let text = await newButton.getText()
205
      expect(text == 'doubleClick').assertTrue()
206 207 208
      await newButton.click()
    })

209 210 211 212 213 214
    /*
     * @tc.number: uiTest_1100
     * @tc.name: testUiComponentLongClick
     * @tc.desc: longClick this UiComponentClick.
     */
      it('testUiComponentLongClick', 0, async function () {
215 216 217 218 219 220 221 222 223 224 225
      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()
    })

226 227 228 229 230
    /*
     * @tc.number: uiTest_1200
     * @tc.name: testKey
     * @tc.desc: find UiComponent by key attribute and get it's key attribute.
     */
231
    it('testKey', 0, async function () {
232 233
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
234 235
      let button = await driver.findComponent(BY.key('my-key'))
      expect(await button.getKey() == 'my-key').assertTrue()
236 237
    })

238 239 240 241 242
    /*
     * @tc.number: uiTest_1300
     * @tc.name: testId
     * @tc.desc: find UiComponent by id attribute and get it's id attribute.
     */
243
    it('testId', 0, async function () {
244 245 246
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
      let button = await driver.findComponent(BY.text('next page'))
247 248
      let id = await button.getId()
      let button2 = await driver.findComponent(BY.id(id))
249
      expect(await button2.getText() == 'next page').assertTrue()
250 251
    })

252 253 254 255 256 257
    /*
     * @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 () {
258 259 260 261 262 263 264
      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()
    })

265 266 267 268 269
    /*
     * @tc.number: uiTest_1500
     * @tc.name: testClickable
     * @tc.desc: find UiComponent by clickable attribute and get it's clickable attribute.
     */
270
    it('testClickable', 0, async function () {
271 272 273 274
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
      let button = await driver.findComponent(BY.text('next page').clickable(false))
      let clickable = await button.isClickable()
275
      expect(clickable == false).assertTrue()
276 277
    })

278 279 280 281 282
    /*
     * @tc.number: uiTest_1600
     * @tc.name: testLongClickable
     * @tc.desc: find UiComponent by longClickable attribute and get it's longClickable attribute.
     */
283
    it('testLongClickable', 0, async function () {
284 285 286 287
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
      let button = await driver.findComponent(BY.text('next page').longClickable(false))
      let longClickable = await button.isLongClickable()
288
      expect(longClickable== false).assertTrue()
289 290
    })

291 292 293 294 295
    /*
     * @tc.number: uiTest_1700
     * @tc.name: testScrollable
     * @tc.desc: find UiComponent by scrollable attribute and get it's scrollable attribute.
     */
296
    it('testScrollable', 0, async function () {
297 298 299 300
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
      let scrollBar = await driver.findComponent(BY.type('Scroll').scrollable(false))
      let scrollable = await scrollBar.isScrollable()
301
      expect(scrollable == false).assertTrue()
302 303
    })

304 305 306 307 308
    /*
     * @tc.number: uiTest_1800
     * @tc.name: testEnabled
     * @tc.desc: find UiComponent by enabled attribute and get it's enabled attribute.
     */
309
    it('testEnabled', 0, async function () {
310 311 312 313
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
      let button = await driver.findComponent(BY.text('next page').enabled(true))
      let enable = await button.isEnabled()
314
      expect(enable == true).assertTrue()
315 316
    })

317 318 319 320 321
    /*
     * @tc.number: uiTest_1900
     * @tc.name: testFocused
     * @tc.desc: find UiComponent by focused attribute and get it's focused attribute.
     */
322
    it('testFocused', 0, async function () {
323 324 325 326
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
      let button = await driver.findComponent(BY.text('next page').focused(false))
      let focused = await button.isFocused()
327
      expect(focused == false).assertTrue()
328 329
    })

330 331 332 333 334
    /*
     * @tc.number: uiTest_2000
     * @tc.name: testSelected
     * @tc.desc: find UiComponent by selected attribute and get it's selected attribute.
     */
335
    it('testSelected', 0, async function () {
336 337 338 339
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
      let button = await driver.findComponent(BY.text('next page').selected(false))
      let selected = await button.isSelected()
340
      expect(selected == false).assertTrue()
341 342
    })

343 344 345 346 347
    /*
     * @tc.number: uiTest_2100
     * @tc.name: testPressBack
     * @tc.desc: Press the BACK key.
     */
348
    it('testPressBack', 0, async function () {
349 350 351 352 353 354 355 356 357 358 359
      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()
    })

360 361 362 363 364
    /*
     * @tc.number: uiTest_2200
     * @tc.name: testFindComponents
     * @tc.desc: find all the matched UiComponents on current UI
     */
365
    it('testFindComponents', 0, async function () {
366 367 368 369 370 371
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
      let buttons = await driver.findComponents(BY.type('Button'))
      expect(await buttons[0].getText() != null).assertTrue()
    })

372 373 374 375 376
    /*
     * @tc.number: uiTest_2300
     * @tc.name: testTriggerKey
     * @tc.desc: press the specified key.
     */
377
    it('testTriggerKey', 0, async function () {
378 379 380 381 382
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
      let button = await driver.findComponent(BY.text('next page'))
      await button.click()
      await driver.delayMs(waitUiReadyMs)
383 384
      let keyBack = 2
      await driver.triggerKey(keyBack)
385 386 387 388 389
      await driver.delayMs(waitUiReadyMs)
      let button_ori = await driver.findComponent(BY.text('next page'))
      expect(await button_ori.getText() == 'next page').assertTrue()
    })

390 391 392 393 394
    /*
     * @tc.number: uiTest_2400
     * @tc.name: testGetUiComponentBounds
     * @tc.desc: get the bounds of this UiComponent.
     */
395
    it('testGetUiComponentBounds', 0, async function () {
396 397
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
398
      let text = await driver.findComponent(BY.text('next page'))
399 400 401 402 403 404 405
      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)
    })

406 407 408 409 410
    /*
     * @tc.number: uiTest_2500
     * @tc.name: testGetUiComponentBoundsCenter
     * @tc.desc: get the boundsCenter of this @link UiComponent.
     */
411
    it('testGetUiComponentBoundsCenter', 0, async function () {
412 413 414 415
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
      let button = await driver.findComponent(BY.text('next page'))
      let point = await button.getBoundsCenter()
416
      let bounds = await button.getBounds()
417
      expect(point!== null).assertTrue()
418 419
      expect(point.Y == (bounds.bottomY + bounds.topY)/2).assertTrue()
      expect(point.X == (bounds.rightX + bounds.leftX)/2).assertTrue()
420 421
    })

422 423 424 425 426
    /*
     * @tc.number: uiTest_2600
     * @tc.name: testWaitForComponent
     * @tc.desc: Find the first matched UiComponent on current UI during the time given.
     */
427
    it('testWaitForComponent', 0, async function () {
428 429 430 431 432 433
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
      let button = await driver.waitForComponent(BY.text('next page'), waitUiReadyMs)
      expect(button !== null).assertTrue()
    })

434 435 436 437 438
    /*
     * @tc.number: uiTest_2700
     * @tc.name: testScreenCap
     * @tc.desc: capture current screen.
     */
439 440 441 442 443 444 445 446
    it('testScreenCap', 0, async function () {
      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()
    })

447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462
    /*
     * @tc.number: uiTest_2800
     * @tc.name: testAssertComponentExist
     * @tc.desc:  Assert whether the matched UiComponent exists on current UI;.
     */
    it('testAssertComponentExist', 0, async function () {
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
      await driver.assertComponentExist(BY.text('next page'))
    })

    /*
     * @tc.number: uiTest_2900
     * @tc.name: testIsBefore
     * @tc.desc: find uiComponent which is before another UiComponent that specified by given.
     */
463
    it('testIsBefore', 0, async function () {
464 465
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
466 467
      let button = await driver.findComponent(BY.isBefore(BY.text('Click twice')).type('Button'))
      expect(await button.getType() == 'Button').assertTrue()
468 469
    })

470 471 472 473 474
    /*
     * @tc.number: uiTest_3000
     * @tc.name: testIsAfter
     * @tc.desc: find uiComponent which is after another UiComponent that specified by given.
     */
475
    it('testIsAfter', 0, async function () {
476 477
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
478 479
      let button = await driver.findComponent(BY.isAfter(BY.text('next page')).type('Text'))
      expect(await button.getText() == 'Click twice').assertTrue()
480 481
    })

482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500
    /*
     * @tc.number: uiTest_3100
     * @tc.name: testSwipe
     * @tc.desc: swipe on the screen between the specified points.
     */
    it('testSwipe', 0, async function () {
      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()
      await driver.swipe(300,300,300,600)
    })

    /*
     * @tc.number: uiTest_3200
     * @tc.name: testScrollSearch
     * @tc.desc: scroll on this UiComponent to find matched UiComponent.
     */
501
    it('testScrollSearch', 0, async function () {
502 503
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
504
      let scrollBar = await driver.findComponent(BY.type('Scroll'))
505 506
      let button = await scrollBar.scrollSearch(BY.text('next page'))
      expect(await button.getText() == 'next page').assertTrue()
507 508
    })

509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545
    /*
     * @tc.number: uiTest_3300
     * @tc.name: testScrollToBottom
     * @tc.desc: scroll on this UiComponent to the bottom.
     */
    it('testScrollToBottom', 0, async function () {
      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()
    })

    /*
     * @tc.number: uiTest_3400
     * @tc.name: testScrollToTop
     * @tc.desc: scroll on this UiComponent to the top.
     */
    it('testScrollToTop', 0, async function () {
      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()
    })

    /*
     * @tc.number: uiTest_3500
     * @tc.name: testGetWindowMode
     * @tc.desc: get the window mode of this UiWindow.
     */
546
    it('testGetWindowMode', 0, async function () {
547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565
      await startAbility('com.example.windows', 'MainAbility')
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
      let window1 = await driver.findWindow({bundleName:'com.example.windows'})
      let mode1 = await window1.getWindowMode()
      expect(mode1 == WindowMode.FULLSCREEN).assertTrue()
      let window2 = await driver.findWindow({bundleName:'com.example.windows'})
      await window2.resume()
      let mode2 = await window2.getWindowMode()
      expect(mode2 == WindowMode.FLOATING).assertTrue()
      await stopApplication('com.example.windows')
    })

    /*
     * @tc.number: uiTest_3600
     * @tc.name: testGetBundleName
     * @tc.desc: get the bundleName of this UiWindow.
     */
    it('testGetBundleName', 0, async function () {
566 567 568 569
      await startAbility('com.example.windows', 'MainAbility')
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
      let window = await driver.findWindow({bundleName:'com.example.windows'})
570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586
      let name = await window.getBundleName()
      expect(name == 'com.example.windows').assertTrue()
      await stopApplication('com.example.windows')
    })

    /*
     * @tc.number: uiTest_3700
     * @tc.name: testGetTitle
     * @tc.desc: get the title of this UiWindow.
     */
    it('testGetTitle', 0, async function () {
      await startAbility('com.example.windows', 'MainAbility')
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
      let window = await driver.findWindow({bundleName:'com.example.windows'})
      let title = await window.getTitle()
      expect(title == '').assertTrue()
587 588 589
      await stopApplication('com.example.windows')
    })

590 591 592 593 594
    /*
     * @tc.number: uiTest_3800
     * @tc.name: testWindowMoveTo
     * @tc.desc: move this UiWindow to the specified points.
     */
595
    it('testWindowMoveTo', 0, async function () {
596 597 598 599 600 601 602
      await startAbility('com.example.windows', 'MainAbility')
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
      let window = await driver.findWindow({bundleName:'com.example.windows'})
      await window.resume()
      await driver.delayMs(waitUiReadyMs)
      let window1 = await driver.findWindow({bundleName:'com.example.windows'})
603
      let bounds1 = await window1.getBounds()
604 605 606
      await window1.moveTo(100,100)
      await driver.delayMs(waitUiReadyMs)
      let window2 = await driver.findWindow({bundleName:'com.example.windows'})
607 608
      let bounds2 = await window2.getBounds()
      expect(bounds1 != bounds2).assertTrue()
609
      await stopApplication('com.example.windows')
610
    })
611

612 613 614 615 616
    /*
     * @tc.number: uiTest_3900
     * @tc.name: testWindowResize
     * @tc.desc: resize this UiWindow to the specified size for the specified direction.
     */
617
    it('testWindowResize', 0, async function () {
618 619 620 621
      await startAbility('com.example.windows', 'MainAbility')
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
      let window = await driver.findWindow({bundleName:'com.example.windows'})
622
      await window.resume()
623 624 625 626 627
      await driver.delayMs(waitUiReadyMs)
      let window1 = await driver.findWindow({bundleName:'com.example.windows'})
      let bounds1 = await window1.getBounds()
      await window1.resize(400,400,ResizeDirection.RIGHT_DOWN)
      await driver.delayMs(waitUiReadyMs)
628
      let window2 = await driver.findWindow({bundleName:'com.example.windows'})
629
      let bounds2 = await window2.getBounds()
630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662
      expect(bounds2 != bounds1).assertTrue()
      await window2.resize(500,500,ResizeDirection.RIGHT_UP)
      let window3 = await driver.findWindow({bundleName:'com.example.windows'})
      let bounds3= await window2.getBounds()
      expect(bounds3 != bounds2).assertTrue()
      await window3.resize(400,400,ResizeDirection.LEFT_DOWN)
      let window4 = await driver.findWindow({bundleName:'com.example.windows'})
      let bounds4= await window2.getBounds()
      expect(bounds4 != bounds3).assertTrue()
      await window4.resize(500,500,ResizeDirection.LEFT_DOWN)
      let window5 = await driver.findWindow({bundleName:'com.example.windows'})
      let bounds5= await window2.getBounds()
      expect(bounds5 != bounds4).assertTrue()
      await window5.resize(500,400,ResizeDirection.DOWN)
      let window6 = await driver.findWindow({bundleName:'com.example.windows'})
      let bounds6= await window2.getBounds()
      expect(bounds6 != bounds5).assertTrue()
      await window6.resize(500,500,ResizeDirection.UP)
      let window7 = await driver.findWindow({bundleName:'com.example.windows'})
      let bounds7 = await window2.getBounds()
      expect(bounds7 != bounds5).assertTrue()
      await window7.resize(500,500,ResizeDirection.UP)
      let window8 = await driver.findWindow({bundleName:'com.example.windows'})
      let bounds8 = await window2.getBounds()
      expect(bounds8 != bounds7).assertTrue()
      await window8.resize(400,500,ResizeDirection.LEFT)
      let window9 = await driver.findWindow({bundleName:'com.example.windows'})
      let bounds9 = await window2.getBounds()
      expect(bounds9 != bounds8).assertTrue()
      await window9.resize(400,500,ResizeDirection.RIGHT)
      let window10 = await driver.findWindow({bundleName:'com.example.windows'})
      let bounds10 = await window2.getBounds()
      expect(bounds10 != bounds9).assertTrue()
663
      await stopApplication('com.example.windows')
664 665
    })

666 667 668 669 670
    /*
     * @tc.number: uiTest_4000
     * @tc.name: testWindowFocus
     * @tc.desc: set the focused status of this UiWindow.
     */
671
    it('testWindowFocus', 0, async function () {
672 673 674 675
      await startAbility('com.example.windows', 'MainAbility')
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
      let window = await driver.findWindow({bundleName:'com.example.windows'})
676 677 678
      await window.focus()
      let IsActive = await window.focus()
      expect(IsActive == true).assertTrue()
679
      await stopApplication('com.example.windows')
680 681
    })

682 683 684 685 686
    /*
     * @tc.number: uiTest_4100
     * @tc.name: testWindowMaximize
     * @tc.desc: maximize this UiWindow.
     */
687
    it('testWindowMaximize', 0, async function () {
688 689 690 691
      await startAbility('com.example.windows', 'MainAbility')
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
      let window = await driver.findWindow({bundleName:'com.example.windows'})
692 693 694 695 696 697 698 699
      await window.resume()
      let window2 = await driver.findWindow({bundleName:'com.example.windows'})
      await window2.maximize()
      await driver.delayMs(waitUiReadyMs)
      let window3 = await driver.findWindow({bundleName:'com.example.windows'})
      let mode = await window3.getWindowMode()
      expect(mode == WindowMode.FULLSCREEN).assertTrue()
      await stopApplication('com.example.windows')
700 701
    })

702 703 704 705 706
    /*
     * @tc.number: uiTest_4200
     * @tc.name: testWindowMinimize
     * @tc.desc: minimize this UiWindow.
     */
707
    it('testWindowMinimize', 0, async function () {
708 709 710 711
      await startAbility('com.example.windows', 'MainAbility')
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
      let window = await driver.findWindow({bundleName:'com.example.windows'})
712 713 714 715
      await window.minimize()
      await driver.delayMs(waitUiReadyMs)
      let button = await driver.findComponent(BY.text('Clock'))
      expect(button != null).assertTrue()
716
      await stopApplication('com.example.windows')
717 718
    })

719 720 721 722 723
    /*
     * @tc.number: uiTest_4300
     * @tc.name: testWindowClose
     * @tc.desc: close this UiWindow.
     */
724 725 726 727 728 729 730 731 732
    it('testWindowClose', 0, async function () {
      await startAbility('com.example.windows', 'MainAbility')
      let driver = UiDriver.create()
      await driver.delayMs(waitUiReadyMs)
      let window = await driver.findWindow({bundleName:'com.example.windows'})
      await window.close()
      await driver.delayMs(waitUiReadyMs)
      let button = await driver.findComponent(BY.text('Clock'))
      expect(button != null).assertTrue()
733 734
    })

735
  })
736

737
}