diff --git a/arkXtest/uitest/Test.json b/arkXtest/uitest/Test.json index 551e5894a3de45ab7bf58e9a6fd53d35642c7c6b..817de6e701a8fdd02601a5c6bef60cb95ff53a8e 100644 --- a/arkXtest/uitest/Test.json +++ b/arkXtest/uitest/Test.json @@ -20,11 +20,17 @@ "type": "ShellKit", "run-command": [ "param set persist.ace.testmode.enabled 1", + "param set persist.sys.suspend_manager_enabled 0", + "reboot", "power-shell wakeup", "hilog -Q pidoff", "hilog -b DEBUG", "uinput -T -d 300 600 -m 300 600 300 100 -u 300 100", "power-shell setmode 602" + ], + "teardown-command": [ + "param set persist.sys.suspend_manager_enabled 1", + "reboot" ] } ] diff --git a/arkXtest/uitest/src/main/ets/test/uitest.test.ets b/arkXtest/uitest/src/main/ets/test/uitest.test.ets index 73be999832f47ef52b3c5953f90d791285c86b39..159012fe1f1babc3535fd5077ed59d6c2a800286 100644 --- a/arkXtest/uitest/src/main/ets/test/uitest.test.ets +++ b/arkXtest/uitest/src/main/ets/test/uitest.test.ets @@ -70,7 +70,7 @@ export default function UiTest() { 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)) + let Button3 = await driver.findComponent(BY.text('xt 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() @@ -476,7 +476,7 @@ export default function UiTest() { expect(await Button1.getText() == 'next page').assertTrue() let Button2 = await driver.findComponent(ON.text('next',MatchPattern.STARTS_WITH)) expect(await Button2.getText() == 'next page').assertTrue() - let Button3 = await driver.findComponent(ON.text('page',MatchPattern.ENDS_WITH)) + let Button3 = await driver.findComponent(ON.text('xt page',MatchPattern.ENDS_WITH)) expect(await Button3.getText() == 'next page').assertTrue() let Button4 = await driver.findComponent(ON.text('ext',MatchPattern.CONTAINS)) expect(await Button4.getText() == 'next page').assertTrue() @@ -1372,25 +1372,49 @@ export default function UiTest() { await startAbility('com.uitestScene.acts', 'com.uitestScene.acts.MainAbility') let driver = Driver.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) + let rotation = await driver.getDisplayRotation() + if (rotation == DisplayRotation.ROTATION_180) { + console.info('The device is displayed in vertical on default') + await driver.setDisplayRotation(DisplayRotation.ROTATION_90) + await driver.delayMs(waitUiReadyMs) + let rotation1 = await driver.getDisplayRotation() + expect(rotation1 == DisplayRotation.ROTATION_90) + await driver.setDisplayRotation(DisplayRotation.ROTATION_180) + await driver.delayMs(waitUiReadyMs) + let rotation2 = await driver.getDisplayRotation() + expect(rotation2 == DisplayRotation.ROTATION_180) + await driver.setDisplayRotation(DisplayRotation.ROTATION_270) + await driver.delayMs(waitUiReadyMs) + let rotation3 = await driver.getDisplayRotation() + expect(rotation3 == DisplayRotation.ROTATION_270) + await driver.setDisplayRotation(DisplayRotation.ROTATION_0) + await driver.delayMs(waitUiReadyMs) + let rotation4 = await driver.getDisplayRotation() + expect(rotation4 == DisplayRotation.ROTATION_0) + } else if (rotation == DisplayRotation.ROTATION_270) { + console.info('The device is displayed in horizontal on default') + await driver.setDisplayRotation(DisplayRotation.ROTATION_90) + await driver.delayMs(waitUiReadyMs) + let rotation1 = await driver.getDisplayRotation() + expect(rotation1 == DisplayRotation.ROTATION_0) - 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_180) + await driver.delayMs(waitUiReadyMs) + let rotation2 = await driver.getDisplayRotation() + expect(rotation2 == DisplayRotation.ROTATION_270) + + await driver.setDisplayRotation(DisplayRotation.ROTATION_270) + await driver.delayMs(waitUiReadyMs) + let rotation3 = await driver.getDisplayRotation() + expect(rotation3 == DisplayRotation.ROTATION_180) - await driver.setDisplayRotation(DisplayRotation.ROTATION_0) - let rotation4 = await driver.getDisplayRotation() - expect(rotation4== DisplayRotation.ROTATION_0).assertTrue() + await driver.setDisplayRotation(DisplayRotation.ROTATION_0) + await driver.delayMs(waitUiReadyMs) + let rotation4 = await driver.getDisplayRotation() + expect(rotation4 == DisplayRotation.ROTATION_90) + await driver.setDisplayRotation(DisplayRotation.ROTATION_90) + } await stopApplication('com.uitestScene.acts') }) @@ -1402,14 +1426,20 @@ export default function UiTest() { it('testSetDisplayRotationEnabled', 0, async function () { await startAbility('com.uitestScene.acts', 'com.uitestScene.acts.MainAbility') let driver = Driver.create() - await driver.setDisplayRotationEnabled(false) await driver.setDisplayRotation(DisplayRotation.ROTATION_180) - await driver.delayMs(waitUiReadyMs) + let rotation = await driver.getDisplayRotation() await driver.setDisplayRotationEnabled(true) await driver.setDisplayRotation(DisplayRotation.ROTATION_90) + await driver.delayMs(waitUiReadyMs) let rotation2 = await driver.getDisplayRotation() - expect(rotation2 == DisplayRotation.ROTATION_90).assertTrue() - await driver.setDisplayRotation(DisplayRotation.ROTATION_0) + if (rotation == DisplayRotation.ROTATION_180) { + console.info('The device is displayed in vertical on default') + expect(rotation2 == DisplayRotation.ROTATION_90) + await driver.setDisplayRotation(DisplayRotation.ROTATION_0) + } else { + expect(rotation2 == DisplayRotation.ROTATION_0) + console.info('The device is displayed in horizontal on default') + } await stopApplication('com.uitestScene.acts') })