提交 1d123860 编写于 作者: C chengxingzhen

元能力用例优化

Signed-off-by: Nchengxingzhen <chengxingzhen@huawei.com>
上级 5c3e32cc
...@@ -13,12 +13,23 @@ ...@@ -13,12 +13,23 @@
* limitations under the License. * limitations under the License.
*/ */
import Ability from '@ohos.application.Ability' import Ability from '@ohos.application.Ability'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
import testsuite from '../test/List.test'
export default class MainAbility extends Ability { export default class MainAbility extends Ability {
onCreate(want,launchParam){ onCreate(want,launchParam){
// Ability is creating, initialize resources for this ability // Ability is creating, initialize resources for this ability
console.log("AbilityMultiInstanceTest onCreate") console.log("AbilityMultiInstanceTest onCreate")
globalThis.abilityWant = want; globalThis.abilityWant = want;
globalThis.abilityContext = this.context
let abilityDelegator: any
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
let abilityDelegatorArguments: any
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
} }
onDestroy() { onDestroy() {
...@@ -29,7 +40,7 @@ export default class MainAbility extends Ability { ...@@ -29,7 +40,7 @@ export default class MainAbility extends Ability {
onWindowStageCreate(windowStage) { onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability // Main window is created, set main page for this ability
console.log("AbilityMultiInstanceTest onWindowStageCreate") console.log("AbilityMultiInstanceTest onWindowStageCreate")
globalThis.abilityContext = this.context
windowStage.setUIContent(this.context, "pages/index/index", null) windowStage.setUIContent(this.context, "pages/index/index", null)
console.log("AbilityMultiInstanceTest onWindowStageCreate finish") console.log("AbilityMultiInstanceTest onWindowStageCreate finish")
} }
......
...@@ -13,20 +13,11 @@ ...@@ -13,20 +13,11 @@
* limitations under the License. * limitations under the License.
*/ */
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
import testsuite from '../../test/List.test'
@Entry @Entry
@Component @Component
struct Index { struct Index {
aboutToAppear(){ aboutToAppear(){
let abilityDelegator: any
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
let abilityDelegatorArguments: any
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
} }
build() { build() {
......
...@@ -91,6 +91,25 @@ async function startAbilityProcess(abilityContext, parameters) { ...@@ -91,6 +91,25 @@ async function startAbilityProcess(abilityContext, parameters) {
export default function abilityTest(abilityContext) { export default function abilityTest(abilityContext) {
describe('ActsAbilityTest', function () { describe('ActsAbilityTest', function () {
let TAG1 = "ACTS_AbilityMultiInstance_Single == ";
afterEach(async (done) => {
console.log(TAG1 + "afterEach called");
let wantInfo = {
bundleName: "com.example.abilitymultiinstance",
abilityName: "com.example.abilitymultiinstance.MainAbility"
}
await abilityContext.startAbility(wantInfo).then((data) => {
console.log(TAG1 + "startAbility data : " + JSON.stringify(data));
}).catch((err) => {
console.log(TAG1 + "startAbility err : " + JSON.stringify(err));
})
setTimeout(function () {
console.log(TAG1 + "afterEach end");
done();
}, 500);
})
/* /*
* @tc.number: ACTS_AbilityMultiInstance_Multi_0100 * @tc.number: ACTS_AbilityMultiInstance_Multi_0100
* @tc.name: Connects a service ability, which is used to start a cloned page ability. * @tc.name: Connects a service ability, which is used to start a cloned page ability.
......
...@@ -17,15 +17,39 @@ import { BY,UiDriver,UiComponent } from '@ohos.uitest'; ...@@ -17,15 +17,39 @@ import { BY,UiDriver,UiComponent } from '@ohos.uitest';
import commonEvent from '@ohos.commonEvent'; import commonEvent from '@ohos.commonEvent';
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'; import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry';
import power from '@ohos.power'; import power from '@ohos.power';
import backgroundTaskManager from '@ohos.backgroundTaskManager';
export default function OnAndOffScreenTest() { export default function OnAndOffScreenTest() {
describe('OnAndOffScreenTest', function () { describe('OnAndOffScreenTest', function () {
let TAG = ""; let TAG = "";
let TAG1 = "SUB_AA_OpenHarmony == "; let TAG1 = "SUB_AA_OpenHarmony == OnAndOffScreenTest : ";
let sleepTimeOne = 1000; let sleepTimeOne = 1000;
let abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); let abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
let id = undefined;
beforeAll(async (done) => {
console.log(TAG1 + "beforeAll called");
let myReason = 'test FaShowOnLockTest';
let delayInfo = backgroundTaskManager.requestSuspendDelay(myReason, () => {
console.log(TAG1 + "Request suspension delay will time out.");
})
id = delayInfo.requestId;
console.log(TAG1 + "requestId is : " + id);
setTimeout(function () {
console.log(TAG1 + "beforeAll end");
done();
}, sleepTimeOne);
})
afterAll(async (done) => {
console.log(TAG1 + "afterAll called");
backgroundTaskManager.cancelSuspendDelay(id);
setTimeout(function () {
console.log(TAG1 + "afterAll end");
done();
}, sleepTimeOne);
})
async function slideScreen(TAG) { async function slideScreen(TAG) {
console.log(TAG + "slideScreen start"); console.log(TAG + "slideScreen start");
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
"startWindowIcon": "$media:icon", "startWindowIcon": "$media:icon",
"startWindowBackground": "$color:white", "startWindowBackground": "$color:white",
"visible": true, "visible": true,
"launchType": "singleton",
"skills": [ "skills": [
{ {
"entities": [ "entities": [
......
...@@ -29,6 +29,16 @@ export default function FaSetDisplayOrientationTest() { ...@@ -29,6 +29,16 @@ export default function FaSetDisplayOrientationTest() {
afterEach(async (done) => { afterEach(async (done) => {
console.log(TAG1 + "afterEach called"); console.log(TAG1 + "afterEach called");
let wantInfo = {
bundleName: "com.example.supportfunctionhaptest",
abilityName: "MainAbility"
}
await globalThis.abilityTestContext.startAbility(wantInfo).then((data) => {
console.log(TAG1 + "startAbility data : " + JSON.stringify(data));
}).catch((err) => {
console.log(TAG1 + "startAbility err : " + JSON.stringify(err));
})
let cmd1 = "aa force-stop ohos.acts.aafwk.test.fasupportfunction"; let cmd1 = "aa force-stop ohos.acts.aafwk.test.fasupportfunction";
let cmd2 = "aa force-stop ohos.acts.aafwk.test.fasupportfunctionthree"; let cmd2 = "aa force-stop ohos.acts.aafwk.test.fasupportfunctionthree";
......
...@@ -16,6 +16,7 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from ...@@ -16,6 +16,7 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'; import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry';
import commonEvent from '@ohos.commonEvent'; import commonEvent from '@ohos.commonEvent';
import power from '@ohos.power'; import power from '@ohos.power';
import backgroundTaskManager from '@ohos.backgroundTaskManager';
export default function FaShowOnLockTest() { export default function FaShowOnLockTest() {
...@@ -26,6 +27,30 @@ export default function FaShowOnLockTest() { ...@@ -26,6 +27,30 @@ export default function FaShowOnLockTest() {
let sleepTimeOne = 1000; let sleepTimeOne = 1000;
let sleepTimeTwo = 2000; let sleepTimeTwo = 2000;
let abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); let abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
let id = undefined;
beforeAll(async (done) => {
console.log(TAG1 + "beforeAll called");
let myReason = 'test FaShowOnLockTest';
let delayInfo = backgroundTaskManager.requestSuspendDelay(myReason, () => {
console.log(TAG1 + "Request suspension delay will time out.");
})
id = delayInfo.requestId;
console.log(TAG1 + "requestId is : " + id);
setTimeout(function () {
console.log(TAG1 + "beforeAll end");
done();
}, sleepTimeOne);
})
afterAll(async (done) => {
console.log(TAG1 + "afterAll called");
backgroundTaskManager.cancelSuspendDelay(id);
setTimeout(function () {
console.log(TAG1 + "afterAll end");
done();
}, sleepTimeOne);
})
beforeEach(async (done) => { beforeEach(async (done) => {
console.log(TAG1 + "beforeEach called"); console.log(TAG1 + "beforeEach called");
let status = undefined; let status = undefined;
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
"startWindowIcon": "$media:icon", "startWindowIcon": "$media:icon",
"startWindowBackground": "$color:white", "startWindowBackground": "$color:white",
"visible": true, "visible": true,
"launchType": "singleton",
"skills": [ "skills": [
{ {
"entities": [ "entities": [
......
...@@ -16,6 +16,7 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from " ...@@ -16,6 +16,7 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "
import commonEvent from '@ohos.commonEvent' import commonEvent from '@ohos.commonEvent'
import appManager from '@ohos.application.appManager' import appManager from '@ohos.application.appManager'
import osaccount from '@ohos.account.osAccount' import osaccount from '@ohos.account.osAccount'
import backgroundTaskManager from '@ohos.backgroundTaskManager';
var subscriberInfo_MainAbility = { var subscriberInfo_MainAbility = {
events: ["ACTS_InterfaceMultiUsers_0100_Start_CommonEvent","ACTS_TerminateSelf_CommonEvent"] events: ["ACTS_InterfaceMultiUsers_0100_Start_CommonEvent","ACTS_TerminateSelf_CommonEvent"]
...@@ -39,6 +40,31 @@ export default function abilityTest() { ...@@ -39,6 +40,31 @@ export default function abilityTest() {
// }) // })
// }) // })
// }) // })
let id = undefined;
beforeAll(async (done) => {
console.log("ACTS_InterfaceMultiUsers beforeAll called");
let myReason = 'test FaShowOnLockTest';
let delayInfo = backgroundTaskManager.requestSuspendDelay(myReason, () => {
console.log("ACTS_InterfaceMultiUsers Request suspension delay will time out.");
})
id = delayInfo.requestId;
console.log("ACTS_InterfaceMultiUsers requestId is : " + id);
setTimeout(function () {
console.log("ACTS_InterfaceMultiUsers beforeAll end");
done();
}, 1000);
})
afterAll(async (done) => {
console.log("ACTS_InterfaceMultiUsers afterAll called");
backgroundTaskManager.cancelSuspendDelay(id);
setTimeout(function () {
console.log("ACTS_InterfaceMultiUsers afterAll end");
done();
}, 1000);
})
console.debug("====>in ACTS_InterfaceMultiUsers====>"); console.debug("====>in ACTS_InterfaceMultiUsers====>");
/* /*
* @tc.number : ACTS_startAbility_0100 * @tc.number : ACTS_startAbility_0100
......
...@@ -84,7 +84,7 @@ describe('ActsFeatureAbilityTest', function () { ...@@ -84,7 +84,7 @@ describe('ActsFeatureAbilityTest', function () {
console.info('beforeEach called') console.info('beforeEach called')
}) })
afterEach(function() { afterEach(async function(done) {
/* /*
* @tc.teardown: teardown invoked after each testcases * @tc.teardown: teardown invoked after each testcases
...@@ -94,6 +94,22 @@ describe('ActsFeatureAbilityTest', function () { ...@@ -94,6 +94,22 @@ describe('ActsFeatureAbilityTest', function () {
setTimeout(() => {}, 500); setTimeout(() => {}, 500);
backgroundTaskManager.stopBackgroundRunning(featureAbility.getContext()); backgroundTaskManager.stopBackgroundRunning(featureAbility.getContext());
setTimeout(() => {}, 500); setTimeout(() => {}, 500);
let wantInfo = {
want: {
bundleName: "com.example.actsfeatureabilitytest",
abilityName: "com.example.actsfeatureabilitytest.TestAbility"
}
}
await featureAbility.startAbility(wantInfo).then((data) => {
console.log("ACTS_wantConstant startAbility data : " + JSON.stringify(data));
}).catch((err) => {
console.log("ACTS_wantConstant startAbility err : " + JSON.stringify(err));
})
setTimeout(function () {
console.log("ACTS_wantConstant afterEach end");
done();
}, 500);
}) })
/** /**
......
...@@ -23,6 +23,24 @@ const errCode1 = 202; ...@@ -23,6 +23,24 @@ const errCode1 = 202;
export default function startAbilityTest() { export default function startAbilityTest() {
describe('StartAbilityTest', function () { describe('StartAbilityTest', function () {
afterEach(async function(done) {
let wantInfo = {
want: {
bundleName: "com.example.actsfeatureabilitytest",
abilityName: "com.example.actsfeatureabilitytest.TestAbility"
}
}
await featureAbility.startAbility(wantInfo).then((data) => {
console.log("SUB_AA_JsApi_StartAbility startAbility data : " + JSON.stringify(data));
}).catch((err) => {
console.log("SUB_AA_JsApi_StartAbility startAbility err : " + JSON.stringify(err));
})
setTimeout(function () {
console.log("SUB_AA_JsApi_StartAbility afterEach end");
done();
}, 500);
})
/* /*
* @tc.number: SUB_AA_JsApi_StartAbility_0100 * @tc.number: SUB_AA_JsApi_StartAbility_0100
* @tc.name: testAbility0100. * @tc.name: testAbility0100.
......
...@@ -57,6 +57,18 @@ export default function test() { ...@@ -57,6 +57,18 @@ export default function test() {
commonEvent.unsubscribe(subscriberOnAcquired, () => unsubscribeCallback("afterEach unsubscribe subscriberOnAcquired")); commonEvent.unsubscribe(subscriberOnAcquired, () => unsubscribeCallback("afterEach unsubscribe subscriberOnAcquired"));
commonEvent.unsubscribe(subscriberCast, () => unsubscribeCallback("afterEach unsubscribe subscriberCast")); commonEvent.unsubscribe(subscriberCast, () => unsubscribeCallback("afterEach unsubscribe subscriberCast"));
commonEvent.unsubscribe(subscriberSupply, () => unsubscribeCallback("afterEach unsubscribe subscriberSupply")); commonEvent.unsubscribe(subscriberSupply, () => unsubscribeCallback("afterEach unsubscribe subscriberSupply"));
let wantInfo = {
want: {
bundleName: "com.ohos.st.formacquiretest",
abilityName: "com.ohos.st.formacquiretest.TestAbility"
}
}
await featureAbility.startAbility(wantInfo).then((data) => {
console.log("FMS_acquireForm startAbility data : " + JSON.stringify(data));
}).catch((err) => {
console.log("FMS_acquireForm startAbility err : " + JSON.stringify(err));
})
await sleep(1000); await sleep(1000);
}) })
......
...@@ -60,6 +60,18 @@ export default function test() { ...@@ -60,6 +60,18 @@ export default function test() {
commonEvent.unsubscribe(subscriberOnAcquired, () => unsubscribeCallback("afterEach unsubscribe subscriberOnAcquired")); commonEvent.unsubscribe(subscriberOnAcquired, () => unsubscribeCallback("afterEach unsubscribe subscriberOnAcquired"));
commonEvent.unsubscribe(subscriberCast, () => unsubscribeCallback("afterEach unsubscribe subscriberCast")); commonEvent.unsubscribe(subscriberCast, () => unsubscribeCallback("afterEach unsubscribe subscriberCast"));
commonEvent.unsubscribe(subscriberSupply, () => unsubscribeCallback("afterEach unsubscribe subscriberSupply")); commonEvent.unsubscribe(subscriberSupply, () => unsubscribeCallback("afterEach unsubscribe subscriberSupply"));
let wantInfo = {
want: {
bundleName: "com.ohos.st.formacquiretest2",
abilityName: "com.ohos.st.formacquiretest2.TestAbility"
}
}
await featureAbility.startAbility(wantInfo).then((data) => {
console.log("FMS_acquireForm2 startAbility data : " + JSON.stringify(data));
}).catch((err) => {
console.log("FMS_acquireForm2 startAbility err : " + JSON.stringify(err));
})
await sleep(1000); await sleep(1000);
}) })
......
...@@ -16,7 +16,8 @@ ...@@ -16,7 +16,8 @@
import featureAbility from '@ohos.ability.featureAbility'; import featureAbility from '@ohos.ability.featureAbility';
import commonEvent from '@ohos.commonEvent'; import commonEvent from '@ohos.commonEvent';
import systemTime from '@ohos.systemTime'; import systemTime from '@ohos.systemTime';
import { beforeEach, afterEach, describe, expect, it } from '@ohos/hypium' import { beforeAll, afterAll, beforeEach, afterEach, describe, expect, it } from '@ohos/hypium'
import backgroundTaskManager from '@ohos.backgroundTaskManager';
const onAcquiredForm_Event = { const onAcquiredForm_Event = {
events: ["FMS_FormOnAcquired_commonEvent"], events: ["FMS_FormOnAcquired_commonEvent"],
...@@ -45,6 +46,30 @@ let subscriberSupply; ...@@ -45,6 +46,30 @@ let subscriberSupply;
export default function test() { export default function test() {
describe(`FmsDeleteFormTest`, () => { describe(`FmsDeleteFormTest`, () => {
let id = undefined;
beforeAll(async (done) => {
console.log("FMS_deleteForm beforeAll called");
let myReason = 'test FaShowOnLockTest';
let delayInfo = backgroundTaskManager.requestSuspendDelay(myReason, () => {
console.log("FMS_deleteForm Request suspension delay will time out.");
})
id = delayInfo.requestId;
console.log("FMS_deleteForm requestId is : " + id);
setTimeout(function () {
console.log("FMS_deleteForm beforeAll end");
done();
}, 1000);
})
afterAll(async (done) => {
console.log("FMS_deleteForm afterAll called");
backgroundTaskManager.cancelSuspendDelay(id);
setTimeout(function () {
console.log("FMS_deleteForm afterAll end");
done();
}, 1000);
})
beforeEach(async () => { beforeEach(async () => {
subscriberOnAcquired = await commonEvent.createSubscriber(onAcquiredForm_Event); subscriberOnAcquired = await commonEvent.createSubscriber(onAcquiredForm_Event);
subscriberOnReleased = await commonEvent.createSubscriber(onReleasedFormEvent); subscriberOnReleased = await commonEvent.createSubscriber(onReleasedFormEvent);
......
...@@ -60,6 +60,18 @@ export default function test() { ...@@ -60,6 +60,18 @@ export default function test() {
commonEvent.unsubscribe(subscriberOnDeleted, () => unsubscribeCallback("afterEach unsubscribe subscriberOnDeleted")); commonEvent.unsubscribe(subscriberOnDeleted, () => unsubscribeCallback("afterEach unsubscribe subscriberOnDeleted"));
commonEvent.unsubscribe(subscriberOnRefresh, () => unsubscribeCallback("afterEach unsubscribe subscriberOnRefresh")); commonEvent.unsubscribe(subscriberOnRefresh, () => unsubscribeCallback("afterEach unsubscribe subscriberOnRefresh"));
commonEvent.unsubscribe(subscriberSupply, () => unsubscribeCallback("afterEach unsubscribe subscriberSupply")); commonEvent.unsubscribe(subscriberSupply, () => unsubscribeCallback("afterEach unsubscribe subscriberSupply"));
let wantInfo = {
want: {
bundleName: "com.ohos.st.formdynamicrefreshtest",
abilityName: "com.ohos.st.formdynamicrefreshtest.TestAbility"
}
}
await featureAbility.startAbility(wantInfo).then((data) => {
console.log("FMS_timedRefresh startAbility data : " + JSON.stringify(data));
}).catch((err) => {
console.log("FMS_timedRefresh startAbility err : " + JSON.stringify(err));
})
await sleep(1000); await sleep(1000);
}) })
......
...@@ -56,6 +56,18 @@ export default function test() { ...@@ -56,6 +56,18 @@ export default function test() {
commonEvent.unsubscribe(subscriberOnAcquired, () => unsubscribeCallback("afterEach unsubscribe subscriberOnAcquired")); commonEvent.unsubscribe(subscriberOnAcquired, () => unsubscribeCallback("afterEach unsubscribe subscriberOnAcquired"));
commonEvent.unsubscribe(subscriberOnDeleted, () => unsubscribeCallback("afterEach unsubscribe subscriberOnDeleted")); commonEvent.unsubscribe(subscriberOnDeleted, () => unsubscribeCallback("afterEach unsubscribe subscriberOnDeleted"));
commonEvent.unsubscribe(subscriberOnReleased, () => unsubscribeCallback("afterEach unsubscribe subscriberOnReleased")); commonEvent.unsubscribe(subscriberOnReleased, () => unsubscribeCallback("afterEach unsubscribe subscriberOnReleased"));
let wantInfo = {
want: {
bundleName: "com.ohos.st.formreleasetest",
abilityName: "com.ohos.st.formreleasetest.TestAbility"
}
}
await featureAbility.startAbility(wantInfo).then((data) => {
console.log("FMS_releaseForm startAbility data : " + JSON.stringify(data));
}).catch((err) => {
console.log("FMS_releaseForm startAbility err : " + JSON.stringify(err));
})
await sleep(1000); await sleep(1000);
}) })
......
...@@ -15,7 +15,8 @@ ...@@ -15,7 +15,8 @@
import featureAbility from "@ohos.ability.featureAbility"; import featureAbility from "@ohos.ability.featureAbility";
import commonEvent from '@ohos.commonEvent'; import commonEvent from '@ohos.commonEvent';
import { beforeAll, beforeEach, afterEach, describe, expect, it } from '@ohos/hypium' import { beforeAll, afterAll, beforeEach, afterEach, describe, expect, it } from '@ohos/hypium'
import backgroundTaskManager from '@ohos.backgroundTaskManager';
var onAcquiredForm_Event = { var onAcquiredForm_Event = {
events: ["FMS_FormOnAcquired_commonEvent"], events: ["FMS_FormOnAcquired_commonEvent"],
...@@ -47,8 +48,28 @@ var subscriberSupply; ...@@ -47,8 +48,28 @@ var subscriberSupply;
export default function test() { export default function test() {
describe(`FmsStateFormTest`, () => { describe(`FmsStateFormTest`, () => {
let id = undefined;
beforeAll(async (done) => { beforeAll(async (done) => {
done(); console.log("FMS_disableFormsUpdate beforeAll called");
let myReason = 'test FaShowOnLockTest';
let delayInfo = backgroundTaskManager.requestSuspendDelay(myReason, () => {
console.log("FMS_disableFormsUpdate Request suspension delay will time out.");
})
id = delayInfo.requestId;
console.log("FMS_disableFormsUpdate requestId is : " + id);
setTimeout(function () {
console.log("FMS_disableFormsUpdate beforeAll end");
done();
}, 1000);
})
afterAll(async (done) => {
console.log("FMS_disableFormsUpdate afterAll called");
backgroundTaskManager.cancelSuspendDelay(id);
setTimeout(function () {
console.log("FMS_disableFormsUpdate afterAll end");
done();
}, 1000);
}) })
beforeEach(async () => { beforeEach(async () => {
......
...@@ -15,7 +15,8 @@ ...@@ -15,7 +15,8 @@
import featureAbility from "@ohos.ability.featureAbility"; import featureAbility from "@ohos.ability.featureAbility";
import commonEvent from '@ohos.commonEvent'; import commonEvent from '@ohos.commonEvent';
import { beforeAll, beforeEach, afterEach, describe, expect, it } from '@ohos/hypium' import { beforeAll, afterAll, beforeEach, afterEach, describe, expect, it } from '@ohos/hypium'
import backgroundTaskManager from '@ohos.backgroundTaskManager';
var onAcquiredForm_Event = { var onAcquiredForm_Event = {
events: ["FMS_FormOnAcquired_commonEvent"], events: ["FMS_FormOnAcquired_commonEvent"],
...@@ -47,8 +48,28 @@ var subscriberSupply; ...@@ -47,8 +48,28 @@ var subscriberSupply;
export default function test() { export default function test() {
describe(`FmsStateFormTest`, () => { describe(`FmsStateFormTest`, () => {
let id = undefined;
beforeAll(async (done) => { beforeAll(async (done) => {
done(); console.log("FMS_enableFormsUpdate beforeAll called");
let myReason = 'test FaShowOnLockTest';
let delayInfo = backgroundTaskManager.requestSuspendDelay(myReason, () => {
console.log("FMS_enableFormsUpdate Request suspension delay will time out.");
})
id = delayInfo.requestId;
console.log("FMS_enableFormsUpdate requestId is : " + id);
setTimeout(function () {
console.log("FMS_enableFormsUpdate beforeAll end");
done();
}, 1000);
})
afterAll(async (done) => {
console.log("FMS_enableFormsUpdate afterAll called");
backgroundTaskManager.cancelSuspendDelay(id);
setTimeout(function () {
console.log("FMS_enableFormsUpdate afterAll end");
done();
}, 1000);
}) })
beforeEach(async () => { beforeEach(async () => {
......
...@@ -60,6 +60,18 @@ export default function test() { ...@@ -60,6 +60,18 @@ export default function test() {
commonEvent.unsubscribe(subscriberDel, () => unsubscribeCallback("afterEach unsubscribe subscriberDel")); commonEvent.unsubscribe(subscriberDel, () => unsubscribeCallback("afterEach unsubscribe subscriberDel"));
commonEvent.unsubscribe(subscriberOnState, () => unsubscribeCallback("afterEach unsubscribe subscriberOnState")); commonEvent.unsubscribe(subscriberOnState, () => unsubscribeCallback("afterEach unsubscribe subscriberOnState"));
commonEvent.unsubscribe(subscriberSupply, () => unsubscribeCallback("afterEach unsubscribe subscriberSupply")); commonEvent.unsubscribe(subscriberSupply, () => unsubscribeCallback("afterEach unsubscribe subscriberSupply"));
let wantInfo = {
want: {
bundleName: "com.ohos.st.formstatenotifyinvisibletest",
abilityName: "com.ohos.st.formstatenotifyinvisibletest.TestAbility"
}
}
await featureAbility.startAbility(wantInfo).then((data) => {
console.log("FMS_notifyInvisibleForms startAbility data : " + JSON.stringify(data));
}).catch((err) => {
console.log("FMS_notifyInvisibleForms startAbility err : " + JSON.stringify(err));
})
await sleep(1000); await sleep(1000);
}) })
/** /**
......
...@@ -54,6 +54,18 @@ export default function test() { ...@@ -54,6 +54,18 @@ export default function test() {
commonEvent.unsubscribe(subscriberOnAcquired, () => unsubscribeCallback("afterEach unsubscribe subscriberOnAcquired")); commonEvent.unsubscribe(subscriberOnAcquired, () => unsubscribeCallback("afterEach unsubscribe subscriberOnAcquired"));
commonEvent.unsubscribe(subscriberOnState, () => unsubscribeCallback("afterEach unsubscribe subscriberOnState")); commonEvent.unsubscribe(subscriberOnState, () => unsubscribeCallback("afterEach unsubscribe subscriberOnState"));
commonEvent.unsubscribe(subscriberSupply, () => unsubscribeCallback("afterEach unsubscribe subscriberSupply")); commonEvent.unsubscribe(subscriberSupply, () => unsubscribeCallback("afterEach unsubscribe subscriberSupply"));
let wantInfo = {
want: {
bundleName: "com.ohos.st.formstatenotifyinvisibletest2",
abilityName: "com.ohos.st.formstatenotifyinvisibletest2.TestAbility"
}
}
await featureAbility.startAbility(wantInfo).then((data) => {
console.log("FMS_notifyInvisibleForms2 startAbility data : " + JSON.stringify(data));
}).catch((err) => {
console.log("FMS_notifyInvisibleForms2 startAbility err : " + JSON.stringify(err));
})
await sleep(1000); await sleep(1000);
}) })
/** /**
......
...@@ -57,6 +57,18 @@ export default function test() { ...@@ -57,6 +57,18 @@ export default function test() {
commonEvent.unsubscribe(subscriberOnAcquired, () => unsubscribeCallback("afterEach unsubscribe subscriberOnAcquired")); commonEvent.unsubscribe(subscriberOnAcquired, () => unsubscribeCallback("afterEach unsubscribe subscriberOnAcquired"));
commonEvent.unsubscribe(subscriberOnState, () => unsubscribeCallback("afterEach unsubscribe subscriberOnState")); commonEvent.unsubscribe(subscriberOnState, () => unsubscribeCallback("afterEach unsubscribe subscriberOnState"));
commonEvent.unsubscribe(subscriberSupply, () => unsubscribeCallback("afterEach unsubscribe subscriberSupply")); commonEvent.unsubscribe(subscriberSupply, () => unsubscribeCallback("afterEach unsubscribe subscriberSupply"));
let wantInfo = {
want: {
bundleName: "com.ohos.st.formstatenotifyvisibletest",
abilityName: "com.ohos.st.formstatenotifyvisibletest.TestAbility"
}
}
await featureAbility.startAbility(wantInfo).then((data) => {
console.log("FMS_notifyVisibleForms startAbility data : " + JSON.stringify(data));
}).catch((err) => {
console.log("FMS_notifyVisibleForms startAbility err : " + JSON.stringify(err));
})
await sleep(1000); await sleep(1000);
}) })
/** /**
......
...@@ -13,6 +13,9 @@ ...@@ -13,6 +13,9 @@
* limitations under the License. * limitations under the License.
*/ */
import Ability from '@ohos.application.Ability' import Ability from '@ohos.application.Ability'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
import testsuite from '../test/List.test'
export default class MainAbility extends Ability { export default class MainAbility extends Ability {
...@@ -20,6 +23,14 @@ export default class MainAbility extends Ability { ...@@ -20,6 +23,14 @@ export default class MainAbility extends Ability {
// Ability is creating, initialize resources for this ability // Ability is creating, initialize resources for this ability
console.log("MainAbility onCreate") console.log("MainAbility onCreate")
globalThis.abilityWant = want; globalThis.abilityWant = want;
globalThis.abilityContext = this.context
console.info("start run testcase!!!!")
var abilityDelegator: any
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments: any
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
} }
onDestroy() { onDestroy() {
...@@ -30,7 +41,7 @@ export default class MainAbility extends Ability { ...@@ -30,7 +41,7 @@ export default class MainAbility extends Ability {
onWindowStageCreate(windowStage) { onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability // Main window is created, set main page for this ability
console.log("MainAbility onWindowStageCreate") console.log("MainAbility onWindowStageCreate")
globalThis.abilityContext = this.context
windowStage.setUIContent(this.context, "MainAbility/pages/index/index", null) windowStage.setUIContent(this.context, "MainAbility/pages/index/index", null)
} }
......
...@@ -13,20 +13,10 @@ ...@@ -13,20 +13,10 @@
* limitations under the License. * limitations under the License.
*/ */
import router from '@ohos.router'; import router from '@ohos.router';
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
import testsuite from '../../../test/List.test'
@Entry @Entry
@Component @Component
struct Index { struct Index {
aboutToAppear() { aboutToAppear() {
console.info("start run testcase!!!!")
var abilityDelegator: any
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments: any
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
} }
build() { build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
......
...@@ -42,6 +42,22 @@ export default function killProcessWithAccountTest() { ...@@ -42,6 +42,22 @@ export default function killProcessWithAccountTest() {
}) })
}) })
afterEach(async (done) => {
console.log("ACTS_KillProcessWithAccount afterEach called");
let wantInfo = {
bundleName: "com.acts.killprocesswithaccount",
abilityName: "com.acts.killprocesswithaccount.MainAbility"
}
await globalThis.abilityContext.startAbility(wantInfo).then((data) => {
console.log("ACTS_KillProcessWithAccount startAbility data : " + JSON.stringify(data));
}).catch((err) => {
console.log("ACTS_KillProcessWithAccount startAbility err : " + JSON.stringify(err));
})
setTimeout(function () {
console.log("ACTS_KillProcessWithAccount afterEach end");
done();
}, 500);
})
beforeEach(async (done) => { beforeEach(async (done) => {
console.log('======>beforeEach killProcessWithAccountTest<=======' + flag); console.log('======>beforeEach killProcessWithAccountTest<=======' + flag);
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
"label": "$string:entry_label", "label": "$string:entry_label",
"visible": true, "visible": true,
"orientation": "portrait", "orientation": "portrait",
"launchType": "singleton",
"skills": [ "skills": [
{ {
"actions": [ "actions": [
......
...@@ -13,12 +13,24 @@ ...@@ -13,12 +13,24 @@
* limitations under the License. * limitations under the License.
*/ */
import Ability from '@ohos.application.Ability' import Ability from '@ohos.application.Ability'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
import testsuite from '../test/List.test'
export default class MainAbility extends Ability { export default class MainAbility extends Ability {
onCreate(want,launchParam){ onCreate(want,launchParam){
// Ability is creating, initialize resources for this ability // Ability is creating, initialize resources for this ability
console.log("MainAbility onCreate") console.log("MainAbility onCreate")
globalThis.abilityWant = want; globalThis.abilityWant = want;
globalThis.abilityContext = this.context
console.info("start run testcase!!!!")
var abilityDelegator: any
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments: any
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
} }
onDestroy() { onDestroy() {
...@@ -29,7 +41,7 @@ export default class MainAbility extends Ability { ...@@ -29,7 +41,7 @@ export default class MainAbility extends Ability {
onWindowStageCreate(windowStage) { onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability // Main window is created, set main page for this ability
console.log("MainAbility onWindowStageCreate") console.log("MainAbility onWindowStageCreate")
globalThis.abilityContext = this.context
windowStage.setUIContent(this.context, "MainAbility/pages/index/index", null) windowStage.setUIContent(this.context, "MainAbility/pages/index/index", null)
} }
......
...@@ -13,9 +13,6 @@ ...@@ -13,9 +13,6 @@
* limitations under the License. * limitations under the License.
*/ */
import router from '@ohos.router'; import router from '@ohos.router';
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
import testsuite from '../../../test/List.test'
@Entry @Entry
...@@ -23,13 +20,6 @@ import testsuite from '../../../test/List.test' ...@@ -23,13 +20,6 @@ import testsuite from '../../../test/List.test'
struct Index { struct Index {
aboutToAppear(){ aboutToAppear(){
console.info("start run testcase!!!!")
var abilityDelegator: any
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments: any
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
} }
build() { build() {
......
...@@ -43,7 +43,20 @@ export default function abilityTest() { ...@@ -43,7 +43,20 @@ export default function abilityTest() {
await appManager.killProcessesByBundleName("com.example.multiinstancehapa"); await appManager.killProcessesByBundleName("com.example.multiinstancehapa");
await appManager.killProcessesByBundleName("com.example.multiinstancehapb"); await appManager.killProcessesByBundleName("com.example.multiinstancehapb");
done(); let wantInfo = {
bundleName: "com.example.processmultiinstance",
abilityName: "com.example.processmultiinstance.MainAbility"
}
await globalThis.abilityContext.startAbility(wantInfo).then((data) => {
console.log("ACTS_Process_MultiInstance startAbility data: " + JSON.stringify(data));
}).catch((err) => {
console.log("ACTS_Process_MultiInstance startAbility err: " + JSON.stringify(err));
})
setTimeout(function () {
console.log("ACTS_Process_MultiInstance afterEach end");
done();
}, 500);
}) })
/** /**
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
"label": "$string:entry_label", "label": "$string:entry_label",
"visible": true, "visible": true,
"orientation": "portrait", "orientation": "portrait",
"launchType": "singleton",
"skills": [ "skills": [
{ {
"actions": [ "actions": [
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册