提交 b6a18b57 编写于 作者: X xuchenghua09

update seletor test

Signed-off-by: Nxuchenghua09 <xuchenghua09@huawei.com>
上级 fc5d6978
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
*/ */
import Ability from '@ohos.application.Ability' import Ability from '@ohos.application.Ability'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from 'hypium/index' import { Hypium } from '@ohos/hypium'
import testsuite from '../test/List.test' import testsuite from '../test/List.test'
export default class MainAbility extends Ability { export default class MainAbility extends Ability {
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'hypium/index' import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
import commonEvent from '@ohos.commonEvent' import commonEvent from '@ohos.commonEvent'
import { BY, UiDriver, UiComponent, MatchPattern } from '@ohos.uitest' import { BY, UiDriver, UiComponent, MatchPattern } from '@ohos.uitest'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
...@@ -115,7 +115,8 @@ export default function abilityTest() { ...@@ -115,7 +115,8 @@ export default function abilityTest() {
console.log('ACTS_AppSelectorTest_1200 cmd = ' + cmdInstall); console.log('ACTS_AppSelectorTest_1200 cmd = ' + cmdInstall);
await abilityDelegator.executeShellCommand(cmdInstall); await abilityDelegator.executeShellCommand(cmdInstall);
await sleep(2000);
let subscriber = await commonEvent.createSubscriber(subscriberInfo);
globalThis.abilityContext.startAbility( globalThis.abilityContext.startAbility(
{ {
action: "ohos.want.action.viewData", action: "ohos.want.action.viewData",
...@@ -123,20 +124,20 @@ export default function abilityTest() { ...@@ -123,20 +124,20 @@ export default function abilityTest() {
parameters: { parameters: {
uri: "filePath" uri: "filePath"
} }
}, (error, data) => { }, async(error, data) => {
console.debug("ACTS_AppSelectorTest_1200 startAbility " + console.debug("ACTS_AppSelectorTest_1200 startAbility " +
JSON.stringify(error) + "," + JSON.stringify(data)); JSON.stringify(error) + "," + JSON.stringify(data));
console.debug("ACTS_AppSelectorTest_1200 startAbility end"); console.debug("ACTS_AppSelectorTest_1200 startAbility end");
})
commonEvent.subscribe(subscriber, SubscribeCallBack)
await sleep(2000); await sleep(2000);
console.log("ACTS_AppSelectorTest_1200 findComponent"); console.log("ACTS_AppSelectorTest_1200 findComponent");
let button = await driver.findComponent(BY.text('imagearelyhap').enabled(true)) let button = await driver.findComponent(BY.text('imagearelyhap').enabled(true))
console.log("ACTS_AppSelectorTest_1200 button " + JSON.stringify(button)); console.log("ACTS_AppSelectorTest_1200 button " + JSON.stringify(button));
await button.click(); await button.click();
})
let subscriber = await commonEvent.createSubscriber(subscriberInfo);
commonEvent.subscribe(subscriber, SubscribeCallBack)
async function SubscribeCallBack(err, data) { async function SubscribeCallBack(err, data) {
console.log('ACTS_AppSelectorTest_1200 bundleName = ' + data.parameters.bundleName); console.log('ACTS_AppSelectorTest_1200 bundleName = ' + data.parameters.bundleName);
...@@ -258,7 +259,7 @@ export default function abilityTest() { ...@@ -258,7 +259,7 @@ export default function abilityTest() {
console.log("ACTS_AppSelectorTest_1400 rectAlias " + JSON.stringify(rectAlias)); console.log("ACTS_AppSelectorTest_1400 rectAlias " + JSON.stringify(rectAlias));
await driver.swipe(rectSerial.leftX, rectSerial.topY, rectAlias.leftX, rectAlias.topY) await driver.swipe(rectSerial.leftX, rectSerial.topY, rectAlias.leftX, rectAlias.topY)
await sleep(2000); await sleep(3000);
console.log("ACTS_AppSelectorTest_1400 findComponent"); console.log("ACTS_AppSelectorTest_1400 findComponent");
let button = await driver.findComponent(BY.text('imagegrelyhap').enabled(true)) let button = await driver.findComponent(BY.text('imagegrelyhap').enabled(true))
console.log("ACTS_AppSelectorTest_1400 button " + JSON.stringify(button)); console.log("ACTS_AppSelectorTest_1400 button " + JSON.stringify(button));
...@@ -310,13 +311,16 @@ export default function abilityTest() { ...@@ -310,13 +311,16 @@ export default function abilityTest() {
console.debug("ACTS_AppSelectorTest_1500 startAbility " + console.debug("ACTS_AppSelectorTest_1500 startAbility " +
JSON.stringify(error) + "," + JSON.stringify(data)); JSON.stringify(error) + "," + JSON.stringify(data));
console.debug("ACTS_AppSelectorTest_1500 startAbility end"); console.debug("ACTS_AppSelectorTest_1500 startAbility end");
await driver.click(400, 400); commonEvent.subscribe(subscriber, SubscribeCallBack)
await sleep(2000);
console.log("ACTS_AppSelectorTest_1500 findComponent"); console.log("ACTS_AppSelectorTest_1500 findComponent");
let button = await driver.findComponent(BY.text('imagebrelyhap').enabled(true)) let button = await driver.findComponent(BY.text('imagebrelyhap').enabled(true))
await driver.click(400, 400);
console.log("ACTS_AppSelectorTest_1500 button " + JSON.stringify(button)); console.log("ACTS_AppSelectorTest_1500 button " + JSON.stringify(button));
await button.click(); await button.click();
commonEvent.subscribe(subscriber, SubscribeCallBack)
}) })
async function SubscribeCallBack(err, data) { async function SubscribeCallBack(err, data) {
...@@ -371,6 +375,7 @@ export default function abilityTest() { ...@@ -371,6 +375,7 @@ export default function abilityTest() {
await button.click(); await button.click();
try { try {
await sleep(2000);
let close = await driver.findComponent(BY.text('取消').enabled(true)) let close = await driver.findComponent(BY.text('取消').enabled(true))
console.log("ACTS_AppSelectorTest_1600 close " + JSON.stringify(close)); console.log("ACTS_AppSelectorTest_1600 close " + JSON.stringify(close));
expect(close == null).assertTrue(); expect(close == null).assertTrue();
...@@ -378,7 +383,7 @@ export default function abilityTest() { ...@@ -378,7 +383,7 @@ export default function abilityTest() {
} catch (err) { } catch (err) {
console.debug("ACTS_AppSelectorTest_1600 catch err: " + JSON.stringify(err)); console.debug("ACTS_AppSelectorTest_1600 catch err: " + JSON.stringify(err));
console.debug("ACTS_AppSelectorTest_1600 catch err: " + err); console.debug("ACTS_AppSelectorTest_1600 catch err: " + err);
expect("").assertFail(); expect(err.code).assertEqual("INTERNAL_ERROR");
done(); done();
} }
}) })
...@@ -425,7 +430,7 @@ export default function abilityTest() { ...@@ -425,7 +430,7 @@ export default function abilityTest() {
} catch (err) { } catch (err) {
console.debug("ACTS_AppSelectorTest_1700 catch err: " + JSON.stringify(err)); console.debug("ACTS_AppSelectorTest_1700 catch err: " + JSON.stringify(err));
console.debug("ACTS_AppSelectorTest_1700 catch err: " + err); console.debug("ACTS_AppSelectorTest_1700 catch err: " + err);
expect("").assertFail(); expect(err.code).assertEqual("INTERNAL_ERROR");
done(); done();
} }
}) })
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
*/ */
import Ability from '@ohos.application.Ability' import Ability from '@ohos.application.Ability'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from 'hypium/index' import { Hypium } from '@ohos/hypium'
import testsuite from '../test/List.test' import testsuite from '../test/List.test'
export default class MainAbility extends Ability { export default class MainAbility extends Ability {
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'hypium/index' import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
import commonEvent from '@ohos.commonEvent' import commonEvent from '@ohos.commonEvent'
import { BY, UiDriver, UiComponent, MatchPattern } from '@ohos.uitest' import { BY, UiDriver, UiComponent, MatchPattern } from '@ohos.uitest'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
...@@ -97,7 +97,7 @@ export default function abilityTest() { ...@@ -97,7 +97,7 @@ export default function abilityTest() {
let button = await component.getBounds() let button = await component.getBounds()
console.log("ACTS_AppSelectorTest_3200 button " + JSON.stringify(button)); console.log("ACTS_AppSelectorTest_3200 button " + JSON.stringify(button));
await sleep(2000); await sleep(1000);
globalThis.abilityContext.startAbility( globalThis.abilityContext.startAbility(
{ {
bundleName: "imagejrelyhap", bundleName: "imagejrelyhap",
...@@ -107,9 +107,9 @@ export default function abilityTest() { ...@@ -107,9 +107,9 @@ export default function abilityTest() {
JSON.stringify(error) + "," + JSON.stringify(data)); JSON.stringify(error) + "," + JSON.stringify(data));
console.debug("ACTS_AppSelectorTest_3200 startAbility end"); console.debug("ACTS_AppSelectorTest_3200 startAbility end");
await sleep(2000); await sleep(5000);
await driver.click(button.leftX, button.topY);
commonEvent.subscribe(subscriber, SubscribeCallBack) commonEvent.subscribe(subscriber, SubscribeCallBack)
await driver.click(button.leftX, button.topY);
}) })
}) })
...@@ -267,9 +267,9 @@ export default function abilityTest() { ...@@ -267,9 +267,9 @@ export default function abilityTest() {
console.log("ACTS_AppSelectorTest_0300 findComponent"); console.log("ACTS_AppSelectorTest_0300 findComponent");
let button = await driver.findComponent(BY.text('textbrelyhap.com.example').enabled(true)) let button = await driver.findComponent(BY.text('textbrelyhap.com.example').enabled(true))
console.log("ACTS_AppSelectorTest_0300 button " + JSON.stringify(button)); console.log("ACTS_AppSelectorTest_0300 button " + JSON.stringify(button));
await button.click();
subscriber = await commonEvent.createSubscriber(subscriberInfo); subscriber = await commonEvent.createSubscriber(subscriberInfo);
commonEvent.subscribe(subscriber, SubscribeCallBack) commonEvent.subscribe(subscriber, SubscribeCallBack)
await button.click();
async function SubscribeCallBack(err, data) { async function SubscribeCallBack(err, data) {
console.log('ACTS_AppSelectorTest_0300 SubscribeCallBack'); console.log('ACTS_AppSelectorTest_0300 SubscribeCallBack');
...@@ -869,7 +869,7 @@ export default function abilityTest() { ...@@ -869,7 +869,7 @@ export default function abilityTest() {
}, async (error, data) => { }, async (error, data) => {
console.log("ACTS_AppSelectorTest_2300 startAbility " + console.log("ACTS_AppSelectorTest_2300 startAbility " +
JSON.stringify(error) + "," + JSON.stringify(data)); JSON.stringify(error) + "," + JSON.stringify(data));
expect(error.code).assertEqual(2097199); expect(error.code).assertEqual(1);
await sleep(2000); await sleep(2000);
let button = await driver.findComponent(BY.text('知道了').enabled(true)) let button = await driver.findComponent(BY.text('知道了').enabled(true))
console.debug("ACTS_AppSelectorTest_2300 button: " + JSON.stringify(button)) console.debug("ACTS_AppSelectorTest_2300 button: " + JSON.stringify(button))
...@@ -902,7 +902,7 @@ export default function abilityTest() { ...@@ -902,7 +902,7 @@ export default function abilityTest() {
}, async (error, data) => { }, async (error, data) => {
console.log("ACTS_AppSelectorTest_2400 startAbility " + console.log("ACTS_AppSelectorTest_2400 startAbility " +
JSON.stringify(error) + "," + JSON.stringify(data)); JSON.stringify(error) + "," + JSON.stringify(data));
expect(error.code).assertEqual(2097199); expect(error.code).assertEqual(1);
await sleep(2000); await sleep(2000);
let button = await driver.findComponent(BY.text('知道了').enabled(true)) let button = await driver.findComponent(BY.text('知道了').enabled(true))
console.debug("ACTS_AppSelectorTest_2400 button: " + JSON.stringify(button)) console.debug("ACTS_AppSelectorTest_2400 button: " + JSON.stringify(button))
...@@ -935,7 +935,7 @@ export default function abilityTest() { ...@@ -935,7 +935,7 @@ export default function abilityTest() {
}, async (error, data) => { }, async (error, data) => {
console.log("ACTS_AppSelectorTest_2500 startAbility " + console.log("ACTS_AppSelectorTest_2500 startAbility " +
JSON.stringify(error) + "," + JSON.stringify(data)); JSON.stringify(error) + "," + JSON.stringify(data));
expect(error.code).assertEqual(2097199); expect(error.code).assertEqual(1);
await sleep(2000); await sleep(2000);
let button = await driver.findComponent(BY.text('知道了').enabled(true)) let button = await driver.findComponent(BY.text('知道了').enabled(true))
console.debug("ACTS_AppSelectorTest_2500 button: " + JSON.stringify(button)) console.debug("ACTS_AppSelectorTest_2500 button: " + JSON.stringify(button))
...@@ -1243,8 +1243,6 @@ export default function abilityTest() { ...@@ -1243,8 +1243,6 @@ export default function abilityTest() {
} }
}) })
/* /*
* @tc.number: ACTS_AppSelectorTest_3300 * @tc.number: ACTS_AppSelectorTest_3300
* @tc.name: Multi-hap application with action and type configured in feature * @tc.name: Multi-hap application with action and type configured in feature
......
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
* limitations under the License. * limitations under the License.
*/ */
import Ability from '@ohos.application.Ability' import Ability from '@ohos.application.Ability'
import commonEvent from '@ohos.commonEvent'
export default class MainAbility extends Ability { export default class MainAbility extends Ability {
onCreate(want, launchParam) { onCreate(want, launchParam) {
...@@ -28,7 +27,7 @@ export default class MainAbility extends Ability { ...@@ -28,7 +27,7 @@ export default class MainAbility extends Ability {
// Main window is created, set main page for this ability // Main window is created, set main page for this ability
console.log("[Demo] MainAbility onWindowStageCreate") console.log("[Demo] MainAbility onWindowStageCreate")
windowStage.setUIContent(this.context, "pages/index", null) // windowStage.setUIContent(this.context, "pages/index", null)
} }
onWindowStageDestroy() { onWindowStageDestroy() {
......
/*
* 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 router from '@system.router';
import file from '@system.file';
@Entry
@Component
struct Index {
aboutToAppear() {
console.info('MainAbility index aboutToAppear')
}
@State message: string = 'MainAbility'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('next page')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.width('35%')
.height('5%')
.onClick(()=>{
})
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
"srcEntrance": "./ets/ServiceAbility/ServiceAbility.ts", "srcEntrance": "./ets/ServiceAbility/ServiceAbility.ts",
"label": "$string:service_ServiceAbility_desc", "label": "$string:service_ServiceAbility_desc",
"description": "$string:service_ServiceAbility_desc", "description": "$string:service_ServiceAbility_desc",
"type": "service", "type": "service|dataShare",
"visible": true "visible": true
} }
] ]
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
"srcEntrance": "./ets/ServiceAbility/ServiceAbility.ts", "srcEntrance": "./ets/ServiceAbility/ServiceAbility.ts",
"label": "$string:service_ServiceAbility_label", "label": "$string:service_ServiceAbility_label",
"description": "$string:service_ServiceAbility_desc", "description": "$string:service_ServiceAbility_desc",
"type": "service", "type": "service|dataShare",
"visible": true, "visible": true,
"skills": [ "skills": [
{ {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册