提交 218a2e20 编写于 作者: X xialiangwei

增加UIExtension中XTS测试用例

Signed-off-by: Nxialiangwei <xialiangwei1@huawei.com>
Change-Id: Ifb40663431a9fba85dd0f3fac294db1c186b00f9
上级 71e11258
...@@ -17,9 +17,9 @@ group("actsuiextensiontest") { ...@@ -17,9 +17,9 @@ group("actsuiextensiontest") {
testonly = true testonly = true
if (is_standard_system) { if (is_standard_system) {
deps = [ deps = [
"actsabilityusertest:StartAbilityByUIContentSession",
"uiextensionprovider:UIExtensionProvider", "uiextensionprovider:UIExtensionProvider",
"uiextensiontest:UIExtensionTest", "uiextensiontest:UIExtensionTest",
"actsabilityusertest:StartAbilityByUIContentSession",
] ]
} }
} }
...@@ -15,28 +15,29 @@ ...@@ -15,28 +15,29 @@
import Ability from '@ohos.app.ability.UIAbility' import Ability from '@ohos.app.ability.UIAbility'
export default class MainAbility extends Ability { export default class MainAbility extends Ability {
onCreate(want, launchParam) { onCreate(want, launchParam) {
console.log('MainAbility onCreate') console.log('MainAbility onCreate');
} }
onDestroy() { onDestroy() {
console.log('MainAbility onDestroy') console.log('MainAbility onDestroy');
} }
onWindowStageCreate(windowStage) { onWindowStageCreate(windowStage) {
console.log('MainAbility onWindowStageCreate') console.log('MainAbility onWindowStageCreate');
windowStage.setUIContent(this.context, 'MainAbility/pages/index', null) windowStage.setUIContent(this.context, 'MainAbility/pages/index', null);
} }
onWindowStageDestroy() { onWindowStageDestroy() {
console.log('MainAbility onWindowStageDestroy') console.log('MainAbility onWindowStageDestroy');
} }
onForeground() { onForeground() {
console.log('MainAbility onForeground') console.log('MainAbility onForeground');
} }
onBackground() { onBackground() {
console.log('MainAbility onBackground') console.log('MainAbility onBackground');
} }
}; };
\ No newline at end of file
...@@ -12,13 +12,15 @@ ...@@ -12,13 +12,15 @@
* 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 Ability from '@ohos.app.ability.UIAbility' import Ability from '@ohos.app.ability.UIAbility';
import commonEventManager from '@ohos.commonEventManager' import commonEventManager from '@ohos.commonEventManager';
function PublishCallBackOne() { const sleepTimeOne = 1000;
console.log("====>Publish CallBack ACTS_StartAbility_0100_CommonEvent====>");
function publishCallBack() {
console.log('====>Publish CallBack ACTS_StartAbility_0100_CommonEvent====>');
globalThis.ability2Context.terminateSelf().then(()=>{ globalThis.ability2Context.terminateSelf().then(()=>{
console.log("====>terminateSelf success====>"); console.log('====>terminateSelf success====>');
}); });
} }
...@@ -29,43 +31,43 @@ function timeout() { ...@@ -29,43 +31,43 @@ function timeout() {
abilityName: 'TestAbility', abilityName: 'TestAbility',
} }
).then(()=>{ ).then(()=>{
console.log("====>start com.example.uiextensiontest.TestAbility finish====>") console.log('====>start com.example.uiextensiontest.TestAbility finish====>');
}); });
} }
export default class MainAbility2 extends Ability { export default class MainAbility2 extends Ability {
onCreate(want, launchParam) { onCreate(want, launchParam) {
console.log("MainAbility2 onCreate"); console.log('MainAbility2 onCreate');
} }
onDestroy() { onDestroy() {
// Ability is destroying, release resources for this ability // Ability is destroying, release resources for this ability
console.log("MainAbility2 onDestroy"); console.log('MainAbility2 onDestroy');
} }
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("MainAbility2 onWindowStageCreate"); console.log('MainAbility2 onWindowStageCreate');
windowStage.setUIContent(this.context, "pages/index2", null); windowStage.setUIContent(this.context, 'pages/index2', null);
} }
onWindowStageDestroy() { onWindowStageDestroy() {
// Main window is destroyed, release UI related resources // Main window is destroyed, release UI related resources
console.log("MainAbility2 onWindowStageDestroy"); console.log('MainAbility2 onWindowStageDestroy');
} }
onForeground() { onForeground() {
// Ability has brought to foreground // Ability has brought to foreground
console.log("MainAbility2 onForeground"); console.log('MainAbility2 onForeground');
globalThis.ability2Context = this.context; globalThis.ability2Context = this.context;
setTimeout(timeout, 1000); setTimeout(timeout, sleepTimeOne);
} }
onBackground() { onBackground() {
// Ability has back to background // Ability has back to background
console.log("MainAbility2 onBackground"); console.log('MainAbility2 onBackground');
let onResultEvent = 'ACTS_UIExtension_StartAbility_OnResult'; let onResultEvent = 'ACTS_UIExtension_StartAbility_OnResult';
commonEventManager.publish(onResultEvent, PublishCallBackOne); commonEventManager.publish(onResultEvent, publishCallBack);
} }
}; };
...@@ -12,60 +12,61 @@ ...@@ -12,60 +12,61 @@
* 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 Ability from '@ohos.app.ability.UIAbility' import Ability from '@ohos.app.ability.UIAbility';
const sleepTimeOne = 1000;
function timeout() { function timeout() {
globalThis.ability3Context.startAbility( globalThis.ability3Context.startAbility(
{ {
bundleName: 'com.example.uiextensiontest', bundleName: 'com.example.uiextensiontest',
abilityName: 'TestAbility', abilityName: 'TestAbility'
} }
).then(()=>{ ).then(()=>{
console.log("====>start com.example.uiextensiontest.TestAbility finish====>") console.log('====>start com.example.uiextensiontest.TestAbility finish====>');
}); });
} }
export default class MainAbility3 extends Ability { export default class MainAbility3 extends Ability {
onCreate(want, launchParam) { onCreate(want, launchParam) {
console.log("MainAbility3 onCreate"); console.log('MainAbility3 onCreate');
} }
onDestroy() { onDestroy() {
// Ability is destroying, release resources for this ability // Ability is destroying, release resources for this ability
console.log("MainAbility3 onDestroy"); console.log('MainAbility3 onDestroy');
} }
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("MainAbility3 onWindowStageCreate"); console.log('MainAbility3 onWindowStageCreate');
windowStage.setUIContent(this.context, "pages/index3", null); windowStage.setUIContent(this.context, 'pages/index3', null);
} }
onWindowStageDestroy() { onWindowStageDestroy() {
// Main window is destroyed, release UI related resources // Main window is destroyed, release UI related resources
console.log("MainAbility3 onWindowStageDestroy"); console.log('MainAbility3 onWindowStageDestroy');
} }
onForeground() { onForeground() {
// Ability has brought to foreground // Ability has brought to foreground
console.log("MainAbility3 onForeground"); console.log('MainAbility3 onForeground');
globalThis.ability3Context = this.context; globalThis.ability3Context = this.context;
setTimeout(timeout, 1000); setTimeout(timeout, sleepTimeOne);
} }
onBackground() { onBackground() {
// Ability has back to background // Ability has back to background
console.log("MainAbility3 onBackground"); console.log('MainAbility3 onBackground');
globalThis.ability3Context.terminateSelfWithResult( globalThis.ability3Context.terminateSelfWithResult(
{ {
resultCode:1, resultCode:1,
want:{ want:{
action:'ACTION' action:'ACTION'
} }
},()=>{ }, ()=>{
console.debug("====>terminateSelfWithResult success====>") console.debug('====>terminateSelfWithResult success====>');
}); });
} }
}; };
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册