未验证 提交 08096541 编写于 作者: O openharmony_ci 提交者: Gitee

!3911 XTS元能力测试套整改

Merge pull request !3911 from chengxingzhen/monthly_20220614
......@@ -32,6 +32,7 @@ group("ability_runtime") {
"amsdatauriutils:ActsAmsDataUriUtilsTest",
"amsdisplayIdtest:amsdisplayIdtest",
"amsgetabilityprocessinfo:amsgetabilityprocessinfo",
"apicover:apicover",
"context:context",
"fa:fa",
"featureability:featureability",
......
......@@ -210,7 +210,7 @@ export default function getHapModuleInfoJsunit() {
expect(data.descriptionId > 0).assertTrue();
expect(data.iconId > 0).assertTrue();
expect(data.moduleName).assertEqual("entry");
expect(data.process).assertEqual("");
expect(data.process).assertEqual("com.ohos.acecollaboration");
expect(data.targetAbility).assertEqual("");
expect(data.backgroundModes).assertEqual(0);
expect(data.isVisible).assertEqual(true);
......@@ -283,13 +283,13 @@ export default function getHapModuleInfoJsunit() {
expect(typeof (info.entryDir)).assertEqual("string");
expect(info.name).assertEqual("com.ohos.acecollaboration");
expect(info.description).assertEqual("$string:mainability_description");
expect(info.descriptionId > 0).assertTrue();
expect(info.description).assertEqual("");
expect(info.descriptionId).assertEqual(0);
expect(info.systemApp).assertEqual(true);
expect(info.enabled).assertEqual(true);
expect(info.label).assertEqual("$string:entry_MainAbility");
expect(info.icon).assertEqual("$media:icon");
expect(info.process).assertEqual("");
expect(info.process).assertEqual("com.ohos.acecollaboration");
expect(info.supportedModes).assertEqual(0);
expect(info.entryDir).assertEqual("/data/app/el1/bundle/public/" +
"com.ohos.acecollaboration/com.ohos.acecollaboration");
......@@ -330,4 +330,4 @@ export default function getHapModuleInfoJsunit() {
}
})
}
\ No newline at end of file
}
......@@ -211,7 +211,7 @@ export default function getHapModuleInfoJsunit() {
expect(data.description).assertEqual("$string:TestAbility_desc");
expect(data.icon).assertEqual("$media:icon");
expect(data.moduleName).assertEqual("entry");
expect(data.process).assertEqual("");
expect(data.process).assertEqual("com.ohos.acecollaboration");
expect(data.targetAbility).assertEqual("");
expect(data.backgroundModes).assertEqual(0);
expect(data.isVisible).assertEqual(true);
......
......@@ -13,7 +13,7 @@
* limitations under the License.
*/
import rpc from "@ohos.rpc";
import particleAbility from '@ohos.ability.particleability'
import particleAbility from '@ohos.ability.particleAbility'
import featureAbility from '@ohos.ability.featureAbility'
import commonEvent from '@ohos.commonEvent'
var serversecond_bundleName = "com.amsst.stserviceabilityserversecond";
......
......@@ -13,7 +13,7 @@
* limitations under the License.
*/
import rpc from "@ohos.rpc";
import particleAbility from '@ohos.ability.particleability'
import particleAbility from '@ohos.ability.particleAbility'
import featureAbility from '@ohos.ability.featureAbility'
import commonEvent from '@ohos.commonEvent'
var server_bundleName = "com.amsst.stserviceabilityserver";
......
/*
* Copyright (c) 2021 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 Ability from '@ohos.application.Ability'
import commonEvent from "@ohos.commonEvent"
export default class MainAbility2 extends Ability {
onCreate(want, launchParam) {
console.log("MainAbility2 onCreate");
globalThis.abilityContext = this.context
}
onDestroy() {
console.log("MainAbility2 onDestroy");
}
onWindowStageCreate(windowStage) {
console.log("MainAbility2 onWindowStageCreate");
windowStage.setUIContent(this.context, "pages/index/second", null);
commonEvent.publish("ACTS_InterfaceMultiUsersExtension_CommonEvent", () => {
console.log("publish Publish ACTS_InterfaceMultiUsersExtension_CommonEvent callback")
globalThis.abilityContext.terminateSelf().then(() => {
commonEvent.publish("ACTS_TerminateSelf_CommonEvent", ()=>{
console.log('terminateSelf promise');
});
});
})
}
onWindowStageDestroy() {
console.log("MainAbility2 onWindowStageDestroy");
}
onForeground() {
console.log("MainAbility2 onForeground");
}
onBackground() {
console.log("MainAbility2 onBackground");
}
};
/*
* Copyright (c) 2021 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 ServiceExtensionAbility from '@ohos.application.ServiceExtensionAbility'
import rpc from '@ohos.rpc';
class Stub extends rpc.RemoteObject {
constructor(des) {
super(des);
}
onRemoteRequest(code, data, reply, option) {
reply.writeNoException();
reply.writeString("success");
return true;
}
}
export default class ServiceAbility extends ServiceExtensionAbility {
onCreate(want) {
console.log('ServiceAbility onCreate');
}
onDestory(){
console.log('ServiceAbility onDestory');
}
onRequest(want,startId) {
console.log('ServiceAbility onRequest');
}
onConnect(want) {
console.log('ServiceAbility onConnect');
console.log('globalThis.startnum is' + globalThis.startnum);
switch (globalThis.startnum) {
case 1:
this.context.startAbility(
{
bundleName: 'com.acts.actsinterfacemultiusersextensiontest',
abilityName: 'com.acts.actsinterfacemultiusersextensiontest.MainAbility2'
},{
windowMode:0
}
).then((data) => {
console.debug("====>startAbility end====>");
console.debug("====>data is====>" + JSON.stringify(data));
})
break;
case 2:
this.context.startAbility(
{
bundleName: 'com.acts.error',
abilityName: 'com.acts.error.MainAbility2'
},{
windowMode:0
}).then(()=>{
console.debug("====>startAbility end====>");
})
console.debug("====>case 2 end====>");
var myStub1 = new Stub("com.acts.actsinterfacemultiusersextensiontest.MainAbility");
console.log('ThirdAbility onConnect before return:')
return myStub1;
break;
case 3:
this.context.startAbility(
{
bundleName: 'com.acts.actsinterfacemultiusersextensiontest',
abilityName: 'com.acts.actsinterfacemultiusersextensiontest.MainAbility2'
},{
windowMode:0
},(err,data) => {
console.debug("====>startAbility end====>" );
})
var myStub7 = new Stub("com.acts.actsinterfacemultiusersextensiontest.MainAbility");
console.log('ThirdAbility onConnect before return:')
return myStub7;
break;
case 4:
this.context.startAbility(
{
bundleName: 'com.acts.error',
abilityName: 'com.acts.error.MainAbility2'
},{
windowMode:0
},() => {
console.debug("====>startAbility end====>" );
})
var myStub2 = new Stub("com.acts.actsinterfacemultiusersextensiontest.MainAbility");
console.log('ThirdAbility onConnect before return:')
return myStub2;
break;
case 5:
this.context.startAbility(
{
bundleName: 'com.acts.actsinterfacemultiusersextensiontest',
abilityName: 'com.acts.actsinterfacemultiusersextensiontest.ServiceAbility2'
}).then((data)=>{
console.debug("====>startAbility end====>");
console.debug("====>data is====>" + JSON.stringify(data));
})
break;
case 6:
this.context.startAbility(
{
bundleName: 'com.acts.error',
abilityName: 'com.acts.error.ServiceAbility2'
}).then(()=>{
console.debug("====>startAbility end====>");
})
var myStub3 = new Stub("com.acts.actsinterfacemultiusersextensiontest.MainAbility");
console.log('ThirdAbility onConnect before return:')
return myStub3;
break;
case 7:
this.context.startAbility(
{
bundleName: 'com.acts.actsinterfacemultiusersextensiontest',
abilityName: 'com.acts.actsinterfacemultiusersextensiontest.ServiceAbility2'
},() => {
console.debug("====>startAbility end====>" );
})
var myStub8 = new Stub("com.acts.actsinterfacemultiusersextensiontest.MainAbility");
console.log('ThirdAbility onConnect before return:')
return myStub8;
break;
case 8:
this.context.startAbility(
{
bundleName: 'com.acts.error',
abilityName: 'com.acts.error.ServiceAbility2'
},() => {
console.debug("====>startAbility end====>" );
})
var myStub4 = new Stub("com.acts.actsinterfacemultiusersextensiontest.MainAbility");
console.log('ThirdAbility onConnect before return:')
return myStub4;
break;
case 9:
this.context.startAbility(
{
bundleName: 'com.acts.actsinterfacemultiusersextensiontest',
abilityName: 'com.acts.actsinterfacemultiusersextensiontest.ServiceAbility2'
}).then(()=>{
console.debug("====>startAbility end====>");
})
var myStub11 = new Stub("com.acts.actsinterfacemultiusersextensiontest.MainAbility");
console.log('ThirdAbility onConnect before return:')
return myStub11;
break;
case 10:
this.context.startAbility(
{
bundleName: 'com.acts.error',
abilityName: 'com.acts.error.ServiceAbility2'
}).then(()=>{
console.debug("====>startAbility end====>");
})
var myStub5 = new Stub("com.acts.actsinterfacemultiusersextensiontest.MainAbility");
console.log('ThirdAbility onConnect before return:')
return myStub5;
break;
case 11:
this.context.startAbility(
{
bundleName: 'com.acts.actsinterfacemultiusersextensiontest',
abilityName: 'com.acts.actsinterfacemultiusersextensiontest.ServiceAbility2'
}).then(()=>{
console.debug("====>startAbility end====>");
})
var myStub12 = new Stub("com.acts.actsinterfacemultiusersextensiontest.MainAbility");
console.log('ThirdAbility onConnect before return:')
return myStub12;
break;
case 12:
this.context.startAbility(
{
bundleName: 'com.acts.error',
abilityName: 'com.acts.error.ServiceAbility2'
},() => {
console.debug("====>startAbility end====>" );
})
var myStub6 = new Stub("com.acts.actsinterfacemultiusersextensiontest.MainAbility");
console.log('ThirdAbility onConnect before return:')
return myStub6;
break;
case 13:
this.context.startAbility(
{
bundleName: 'com.example.userservicesystemapi7',
abilityName: 'com.example.userservicesystemapi7.ServiceAbility'
}).then(() => {
console.debug("====>startAbility end====>" );
})
var myStub9 = new Stub("com.acts.actsinterfacemultiusersextensiontest.MainAbility");
console.log('ThirdAbility onConnect before return:')
return myStub9;
break;
case 14:
this.context.startAbility(
{
bundleName: 'com.example.userservicesystemapi7',
abilityName: 'com.example.userservicesystemapi7.ServiceAbility'
},() => {
console.debug("====>startAbility end====>" );
})
var myStub10 = new Stub("com.acts.actsinterfacemultiusersextensiontest.MainAbility");
console.log('ThirdAbility onConnect before return:')
return myStub10;
break;
default:
break;
}
}
onDisconnect(want) {
console.log('ServiceAbility onDisconnect');
}
onDestroy() {
console.log('ServiceAbility onDestroy');
}
}
\ No newline at end of file
/*
* Copyright (c) 2021 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 ServiceExtensionAbility from '@ohos.application.ServiceExtensionAbility'
import commonEvent from "@ohos.commonEvent"
import rpc from '@ohos.rpc';
export default class ServiceAbility2 extends ServiceExtensionAbility {
onCreate(want) {
console.log('ServiceAbility2 onCreate');
}
onDestory(){
console.log('ServiceAbility2 onDestory');
}
onRequest(want,startId) {
console.log('ServiceAbility2 onRequest');
commonEvent.publish("ACTS_InterfaceMultiUsersExtension_CommonEvent", () => {
console.log("publish Publish ACTS_InterfaceMultiUsersExtension_CommonEvent callback")
this.context.terminateSelf().then(() => {
commonEvent.publish("ACTS_TerminateSelf_CommonEvent", ()=>{
console.log('terminateSelf promise');
});
});
})
}
onConnect(want) {
console.log('ServiceAbility2 onConnect');
return new rpc.RemoteObject('connect');
}
onDisconnect(want) {
console.log('ServiceAbility2 onDisconnect, want:' + want.abilityName);
}
onDestroy() {
console.log('ServiceAbility2 onDestroy');
}
}
\ No newline at end of file
/*
* 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';
@Entry
@Component
struct Second {
private content: string = "Second Page"
build() {
Flex({ direction: FlexDirection.Column,alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text(`${this.content}`)
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('back to index')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.onClick(() => {
router.back()
})
}
.width('100%')
.height('100%')
}
}
\ No newline at end of file
{
"module": {
"name": "phone",
"type": "entry",
"srcEntrance": "./ets/Application/AbilityStage.ts",
"description": "$string:phone_entry_dsc",
"mainElement": "MainAbility",
"deviceTypes": [
"phone"
],
"deliveryWithInstall": true,
"installationFree": false,
"uiSyntax": "ets",
"pages": "$profile:main_pages",
"abilities": [
{
"name": "com.acts.actsinterfacemultiusersextensiontest.MainAbility",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:phone_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"orientation": "portrait",
"skills": [
{
"actions": [
"action.system.home"
],
"entities": [
"entity.system.home"
]
}
]
},
{
"name": "com.acts.actsinterfacemultiusersextensiontest.MainAbility2",
"srcEntrance": "./ets/MainAbility2/MainAbility2.ts",
"description": "$string:phone_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"orientation": "portrait"
}
],
"extensionAbilities": [
{
"srcEntrance": "./ets/ServiceAbility/ServiceAbility.ts",
"name": "com.acts.actsinterfacemultiusersextensiontest.ServiceAbility",
"icon": "$media:icon",
"srcLanguage": "ets",
"description": "$string:phone_entry_main",
"type": "service",
"visible": true
},
{
"srcEntrance": "./ets/ServiceAbility2/ServiceAbility2.ts",
"name": "com.acts.actsinterfacemultiusersextensiontest.ServiceAbility2",
"icon": "$media:icon",
"srcLanguage": "ets",
"description": "$string:phone_entry_main",
"type": "service",
"visible": true
}
],
"defPermissions": [
{
"availableScope": [],
"grantMode": "system_grant",
"name": "ohos.permission.MANAGE_LOCAL_ACCOUNTS"
},
{
"availableScope": [],
"grantMode": "system_grant",
"name": "ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION"
}
],
"requestPermissions": [
{
"name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED",
"reason": "need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
},
{
"name": "ohos.permission.GET_BUNDLE_INFO",
"reason": "need use ohos.permission.GET_BUNDLE_INFO"
},
{
"name": "ohos.permission.CHANGE_ABILITY_ENABLED_STATE",
"reason": "need use ohos.permission.CHANGE_ABILITY_ENABLED_STATE"
},
{
"name": "ohos.permission.REMOVE_CACHE_FILES",
"reason": "need use ohos.permission.REMOVE_CACHE_FILES"
},
{
"name": "ohos.permission.LISTEN_BUNDLE_CHANGE",
"reason": "need use ohos.permission.LISTEN_BUNDLE_CHANGE"
},
{
"name": "ohos.permission.INSTALL_BUNDLE",
"reason": "need use ohos.permission.INSTALL_BUNDLE"
},
{
"name": "ohos.permission.GET_RUNNING_INFO",
"reason": "need use ohos.permission.GET_RUNNING_INFO"
},
{
"name": "ohos.permission.CLEAN_BACKGROUND_PROCESSES",
"reason": "need use ohos.permission.CLEAN_BACKGROUND_PROCESSES"
},
{
"name": "ohos.permission.MANAGE_LOCAL_ACCOUNTS",
"reason": "need use ohos.permission.MANAGE_LOCAL_ACCOUNTS"
},
{
"name": "ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION",
"reason": "need use ohos.permission.MANAGE_LOCAL_ACCOUNTS"
}
]
}
}
......@@ -18,12 +18,10 @@ group("actsusers") {
if (is_standard_system) {
deps = [
"ActsAmsUsersApi7AppA:ActsAmsUsersApi7AppA",
"ActsAmsUsersExtensionSystemTest:ActsAmsUsersExtensionSystemTest",
"ActsAmsUsersKillProcessAppA:ActsAmsUsersKillProcessAppA",
"ActsAmsUsersKillProcessAppB:ActsAmsUsersKillProcessAppB",
"ActsAmsUsersKillProcessAppC:ActsAmsUsersKillProcessAppC",
"ActsAmsUsersSystemTest:ActsAmsUsersSystemTest",
"actsconnectabilitysystemabilitytest:ActsConnectAbilitySystemAbilityTest",
"actsextensionconnectabilitytest:ActsExtensionConnectAbilityTest",
"actsserviceabilityrelytest:actsServiceAbilityRelyHap",
]
......
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "120000",
"package": "com.example.actsconnectabilitysystemabilitytest",
"shell-timeout": "60000"
},
"kits": [
{
"type": "ShellKit",
"run-command": [
"acm create -n 101 -t normal",
"acm switch -i 101"
],
"teardown-command":[
"acm delete -i 101"
]
},
{
"test-file-name": [
"ActsConnectAbilitySystemAbilityTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
/*
* 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 AbilityStage from "@ohos.application.AbilityStage"
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("MyAbilityStage onCreate")
globalThis.stageOnCreateRun = 1;
globalThis.stageContext = this.context;
}
}
\ No newline at end of file
/*
* 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 commonEvent from '@ohos.commonEvent'
import Want from '@ohos.application.Want';
import rpc from '@ohos.rpc';
import ServiceExtensionAbility from '@ohos.application.ServiceExtensionAbility'
var conn = -1;
function publishCallBackOne () {
console.log("========Publish CallBack AMS_ConnectAbility_0100_commonEvent========");
}
function publishCallBackTwo () {
console.log("========Publish CallBack AMS_ConnectAbility_0200_commonEvent========");
}
function publishCallBackThree () {
console.log("========Publish CallBack AMS_ConnectAbility_0300_commonEvent========");
}
function publishCallBackFour () {
console.log("========Publish CallBack AMS_ConnectAbility_0400_commonEvent========");
}
function publishCallBackFive () {
console.log("========Publish CallBack AMS_ConnectAbility_0500_commonEvent========");
}
function publishCallBackSix () {
console.log("========Publish CallBack AMS_ConnectAbility_0600_commonEvent========");
}
function publishCallBackzero () {
console.log("========Publish CallBack AMSc_disonnectAbility_0100_commonEvent========");
}
function publishCallBackttwo () {
console.log("========Publish CallBack AMSc_disonnectAbility_0200_commonEvent========");
}
class Stub extends rpc.RemoteObject {
constructor(des) {
super(des);
}
onRemoteRequest(code, data, reply, option) {
reply.writeNoException();
reply.writeString("success");
return true;
}
}
function onConnectCallback(element) {
console.log('ACTS_ConnectAbility_0100 ConnectAbility onConnect element.bundleName : ' + element.bundleName)
console.log('ACTS_ConnectAbility_0100 ConnectAbility onConnect element.abilityName : ' + element.abilityName)
}
function onDisconnectCallback1(element) {
console.log('ACTS_ConnectAbility_0100 ConnectAbility onDisconnect element.bundleName : ' + element.bundleName)
console.log('ACTS_ConnectAbility_0100 ConnectAbility onDisconnect element.abilityName : ' + element.abilityName)
}
function onDisconnectCallback2(element) {
console.log('ACTS_ConnectAbility_0100 ConnectAbility onDisconnect element.bundleName : ' + element.bundleName)
console.log('ACTS_ConnectAbility_0100 ConnectAbility onDisconnect element.abilityName : ' + element.abilityName)
}
function onDisconnectCallback3(element) {
console.log('ACTS_ConnectAbility_0100 ConnectAbility onDisconnect element.bundleName : ' + element.bundleName)
console.log('ACTS_ConnectAbility_0100 ConnectAbility onDisconnect element.abilityName : ' + element.abilityName)
}
function onDisconnectCallback4(element) {
console.log('ACTS_ConnectAbility_0100 ConnectAbility onDisconnect element.bundleName : ' + element.bundleName)
console.log('ACTS_ConnectAbility_0100 ConnectAbility onDisconnect element.abilityName : ' + element.abilityName)
}
function onDisconnectCallback5(element) {
console.log('ACTS_ConnectAbility_0100 ConnectAbility onDisconnect element.bundleName : ' + element.bundleName)
console.log('ACTS_ConnectAbility_0100 ConnectAbility onDisconnect element.abilityName : ' + element.abilityName)
}
function onDisconnectCallback6(element) {
console.log('ACTS_ConnectAbility_0100 ConnectAbility onDisconnect element.bundleName : ' + element.bundleName)
console.log('ACTS_ConnectAbility_0100 ConnectAbility onDisconnect element.abilityName : ' + element.abilityName)
}
function onFailedCallback(code) {
console.log('ACTS_ConnectAbility_0100 ConnectAbility onFailed errCode : ' + code)
}
export default class ServiceAbility extends ServiceExtensionAbility {
onCreate(want) {
console.log('ServiceAbility onCreate, want: ' + want.abilityName);
}
onRequest(want, startId) {
console.log('ServiceAbility onRequest, want: ' + want.abilityName + ', startId: ' + startId);
console.log('ServiceAbility registerApplicationStateObserver begin');
console.log('ServiceAbility registerApplicationStateObserver end, conn: ' + conn);
}
onConnect(want) {
console.log('ServiceAbility onConnect, want:' + want.abilityName);
let extensionContext = this.context
if (want.action == "one") {
commonEvent.publish("AMS_ConnectAbility_0100_commonEvent", publishCallBackOne);
}
;
if (want.action == "two") {
commonEvent.publish("AMS_ConnectAbility_0200_commonEvent", publishCallBackTwo);
}
;
if (want.action == "Three") {
commonEvent.publish("AMS_ConnectAbility_0300_commonEvent", publishCallBackThree);
}
;
if (want.action == "Four") {
commonEvent.publish("AMS_ConnectAbility_0400_commonEvent", publishCallBackFour);
}
;
if (want.action == "Five") {
commonEvent.publish("AMS_ConnectAbility_0500_commonEvent", publishCallBackFive);
}
;
if (want.action == "Six") {
commonEvent.publish("AMS_ConnectAbility_0600_commonEvent", publishCallBackSix);
}
;
if (want.action == "Seven") {
extensionContext.connectAbility(
{
bundleName: "com.example.actsconnectabilitysystemabilitytest",
abilityName: "com.example.actsconnectabilitysystemabilitytest.ServiceAbility2",
},
{
onConnect: onConnectCallback,
onDisconnect: onDisconnectCallback1,
onFailed: onFailedCallback,
},
);
var myStub4 = new Stub("com.example.actsconnectabilitysystemabilitytest.MainAbility");
return myStub4;
};
if (want.action == "Eight") {
extensionContext.connectAbility(
{
bundleName: "com.example.actsconnectabilitysystemabilitytest",
abilityName: "com.example.actsconnectabilitysystemabilitytest.ServiceAbility3",
},
{
onConnect: onConnectCallback,
onDisconnect: onDisconnectCallback6,
onFailed: onFailedCallback,
},
);
var myStub1 = new Stub("com.example.actsconnectabilitysystemabilitytest.MainAbility");
return myStub1;
};
if (want.action == "Nine") {
console.log('connectAbility 111');
let num = extensionContext.connectAbility(
{
bundleName: 'com.example.actsconnectabilitysystemabilitytest',
abilityName: 'com.example.actsconnectabilitysystemabilitytest.ServiceAbility2'
},
{
onConnect: onConnectCallback,
onDisconnect: onDisconnectCallback2,
onFailed: onFailedCallback,
},)
setTimeout(()=>{
extensionContext.disconnectAbility(num).then(()=>{
console.log('in disconnectAbility');
})
},1000)
var myStub2 = new Stub("com.example.actsconnectabilitysystemabilitytest.MainAbility");
return myStub2;
};
if (want.action == "Ten") {
console.log('connectAbility 222');
let num = extensionContext.connectAbility(
{
bundleName: 'com.example.actsconnectabilitysystemabilitytest',
abilityName: 'com.example.actsconnectabilitysystemabilitytest.ServiceAbility2'
},
{
onConnect: onConnectCallback,
onDisconnect: onDisconnectCallback3,
onFailed: onFailedCallback,
},)
setTimeout(()=>{
extensionContext.disconnectAbility(num).then(()=>{
console.log('in disconnectAbility2');
})
},1000)
var myStub3 = new Stub("com.example.actsconnectabilitysystemabilitytest.MainAbility");
return myStub3;
};
if (want.action == "Ten one") {
console.log('connectAbility 333');
let num = extensionContext.connectAbility(
{
bundleName: 'com.example.actsconnectabilitysystemabilitytest',
abilityName: 'com.example.actsconnectabilitysystemabilitytest.ServiceAbility2'
},
{
onConnect: onConnectCallback,
onDisconnect: onDisconnectCallback4,
onFailed: onFailedCallback,
},)
setTimeout(()=>{
extensionContext.disconnectAbility(2222).then(()=>{
console.log('in disconnectAbility3');
})
},1000)
var myStub5 = new Stub("com.example.actsconnectabilitysystemabilitytest.MainAbility");
return myStub5;
};
if (want.action == "Ten two") {
console.log('connectAbility 444');
let num = extensionContext.connectAbility(
{
bundleName: 'com.example.actsconnectabilitysystemabilitytest',
abilityName: 'com.example.actsconnectabilitysystemabilitytest.ServiceAbility2'
},
{
onConnect: onConnectCallback,
onDisconnect: onDisconnectCallback5,
onFailed: onFailedCallback,
},)
setTimeout(()=>{
extensionContext.disconnectAbility(2222).then(()=>{
console.log('in disconnectAbility4');
})
},1000)
var myStub6 = new Stub("com.example.actsconnectabilitysystemabilitytest.MainAbility");
return myStub6;
};
}
onDisconnect(want) {
console.log('ServiceAbility onDisconnect, want:' + want.abilityName);
commonEvent.publish("AMSc_disonnectAbility_0100_commonEvent",publishCallBackzero);
commonEvent.publish("AMSc_disonnectAbility_0200_commonEvent",publishCallBackttwo);
}
onDestroy() {
console.log('ServiceAbility onDestroy');
}
}
/*
* 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.
*/
export default {
onStart() {
console.info('ServiceAbility onStart');
},
onStop() {
console.info('ServiceAbility onStop');
},
onCommand(want, startId) {
console.info('ServiceAbility onCommand');
}
};
\ No newline at end of file
/*
* Copyright (c) 2021 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 ServiceExtensionAbility from '@ohos.application.ServiceExtensionAbility'
import commonEvent from "@ohos.commonEvent"
import Want from '@ohos.application.Want';
import rpc from '@ohos.rpc';
export default class ServiceAbility2 extends ServiceExtensionAbility {
onCreate(want) {
console.log('ServiceAbility2 onCreate');
globalThis.abilityWant = want;
}
onDestory(){
console.log('ServiceAbility2 onDestory');
}
onRequest(want,startId) {
console.log('ServiceAbility2 onRequest');
}
onConnect(want: Want) {
console.log('ServiceAbility2 onConnect');
commonEvent.publish("AMS_ConnectAbility_0700_commonEvent", () => {
console.log("publish Publish AMS_ConnectAbility_0700_commonEvent callback");
})
commonEvent.publish("AMS_ConnectAbility_0900_commonEvent", () => {
console.log("publish Publish AMS_ConnectAbility_0900_commonEvent callback");
})
commonEvent.publish("AMS_ConnectAbility_1000_commonEvent", () => {
console.log("publish Publish AMS_ConnectAbility_1000_commonEvent callback");
})
commonEvent.publish("AMS_ConnectAbility_1100_commonEvent", () => {
console.log("publish Publish AMS_ConnectAbility_1100_commonEvent callback");
})
commonEvent.publish("AMS_ConnectAbility_1200_commonEvent", () => {
console.log("publish Publish AMS_ConnectAbility_1200_commonEvent callback");
})
return new rpc.RemoteObject('connect');
}
onDisconnect(want) {
console.log('ServiceAbility2 onDisconnect, want:' + want.abilityName);
}
onDestroy() {
console.log('ServiceAbility2 onDestroy');
}
}
\ No newline at end of file
/*
* 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';
@Entry
@Component
struct Second {
private content: string = "Second Page"
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text(`${this.content}`)
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('back to index')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.onClick(() => {
router.back()
})
}
.width('100%')
.height('100%')
}
}
\ No newline at end of file
{
"module": {
"name": "phone",
"type": "entry",
"srcEntrance": "./ets/Application/AbilityStage.ts",
"description": "$string:phone_entry_dsc",
"mainElement": "MainAbility",
"deviceTypes": [
"phone"
],
"deliveryWithInstall": true,
"installationFree": false,
"uiSyntax": "ets",
"pages": "$profile:main_pages",
"abilities": [
{
"name": "com.example.actsconnectabilitysystemabilitytest.MainAbility",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:phone_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"orientation": "portrait",
"skills": [
{
"actions": [
"action.system.home"
],
"entities": [
"entity.system.home"
]
}
]
}
],
"extensionAbilities": [
{
"srcEntrance": "./ets/ServiceAbility/ServiceAbility.ts",
"name": "com.example.actsconnectabilitysystemabilitytest.ServiceAbility",
"icon": "$media:icon",
"srcLanguage": "ets",
"description": "$string:phone_entry_main",
"type": "service",
"visible": true
},
{
"srcEntrance": "./ets/ServiceAbility2/ServiceAbility2.ts",
"name": "com.example.actsconnectabilitysystemabilitytest.ServiceAbility2",
"icon": "$media:icon",
"srcLanguage": "ets",
"description": "$string:phone_entry_main",
"type": "service",
"visible": true
}
],
"requestPermissions": [
{
"name":"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED",
"reason":"need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
},
{
"name":"ohos.permission.GET_BUNDLE_INFO",
"reason":"need use ohos.permission.GET_BUNDLE_INFO"
},
{
"name":"ohos.permission.CHANGE_ABILITY_ENABLED_STATE",
"reason":"need use ohos.permission.CHANGE_ABILITY_ENABLED_STATE"
},
{
"name":"ohos.permission.REMOVE_CACHE_FILES",
"reason":"need use ohos.permission.REMOVE_CACHE_FILES"
},
{
"name": "ohos.permission.MANAGE_LOCAL_ACCOUNTS",
"reason": "ceshi"
},
{
"name": "ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION",
"reason": "ceshi"
},
{
"name":"ohos.permission.LISTEN_BUNDLE_CHANGE",
"reason":"need use ohos.permission.LISTEN_BUNDLE_CHANGE"
},
{
"name":"ohos.permission.INSTALL_BUNDLE",
"reason":"need use ohos.permission.INSTALL_BUNDLE"
},
{
"name":"ohos.permission.MANAGE_MISSIONS",
"reason":"need use ohos.permission.MANAGE_MISSIONS"
},
{
"name":"ohos.permission.GET_RUNNING_INFO",
"reason":"need use ohos.permission.GET_RUNNING_INFO"
},
{
"name":"ohos.permission.CLEAN_BACKGROUND_PROCESSES",
"reason":"need use ohos.permission.CLEAN_BACKGROUND_PROCESSES"
},
{
"name":"ohos.permission.CLEAN_APPLICATION_DATA",
"reason":"need use ohos.permission.CLEAN_APPLICATION_DATA"
}
]
}
}
{
"string": [
{
"name": "phone_entry_dsc",
"value": "i am an entry for phone"
},
{
"name": "phone_entry_main",
"value": "the phone entry ability"
},
{
"name": "entry_label",
"value": "ActsContextTest"
},
{
"name": "form_description",
"value": "my form"
},
{
"name": "serviceability_description",
"value": "my whether"
},
{
"name": "description_application",
"value": "demo for test"
},
{
"name": "app_name",
"value": "Demo"
}
]
}
\ No newline at end of file
......@@ -23,22 +23,6 @@ struct Index {
aboutToAppear(){
console.info("start run testcase!!!!")
const core = Core.getInstance()
const expectExtend = new ExpectExtend({
'id': 'extend'
})
core.addService('expect', expectExtend)
const reportExtend = new ReportExtend(file)
core.addService('report', reportExtend)
core.init()
core.subscribeEvent('task', reportExtend)
const configService = core.getDefaultService('config')
console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters))
globalThis.abilityWant.parameters.timeout = 70000;
configService.setConfig(globalThis.abilityWant.parameters)
testsuite(globalThis.abilityContext)
core.execute()
}
build() {
......
......@@ -28,7 +28,7 @@ const MAX_MISSION_NUM = 1024;
function sleep(time) {
return new Promise((resove, reject) => {
setTimeout(() => {
resove();
resove("time arrived");
}, time)
})
}
......
# Copyright (c) 2021 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("//test/xts/tools/build/suite.gni")
group("apicover") {
testonly = true
if (is_standard_system) {
deps = [
"apicoverhaptest:ApiCoverhapTest",
"fasupplement:FaSupplement",
"formmodule:FormModule",
"stagesupplement:StageSupplement",
]
}
}
{
"app": {
"bundleName": "com.acts.actsinterfacemultiusersextensiontest",
"bundleName": "com.example.apicoverhaptest",
"vendor": "huawei",
"versionCode": 1000000,
"versionName": "1.0.0",
"debug": false,
"icon" : "$media:icon",
"label" : "$string:app_name",
"description" : "$string:description_application",
"distributedNotificationEnabled": true,
"keepAlive" : true,
"icon": "$media:icon",
"label": "$string:app_name",
"description": "$string:description_application",
"distributedNotificationEnabled": true,
"keepAlive": true,
"singleUser": true,
"minAPIVersion": 8,
"targetAPIVersion": 8,
"minAPIVersion": 9,
"targetAPIVersion": 9,
"car": {
"apiCompatibleVersion": 8,
"apiCompatibleVersion": 9,
"singleUser": false
}
}
}
}
\ No newline at end of file
}
{
"string":[
{
"name":"app_name",
"value":"LifecycleTest"
}
]
}
\ No newline at end of file
# Copyright (c) 2021 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("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ApiCoverhapTest") {
hap_profile = "entry/src/main/module.json"
js_build_mode = "debug"
deps = [
":apicoverhaptest_js_assets",
":apicoverhaptest_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ApiCoverhapTest"
}
ohos_app_scope("apicoverhaptest_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("apicoverhaptest_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("apicoverhaptest_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":apicoverhaptest_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
......@@ -2,25 +2,20 @@
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "300000",
"package": "com.acts.actsinterfacemultiusersextensiontest",
"shell-timeout": "300000"
"test-timeout": "180000",
"package": "com.example.apicoverhaptest",
"shell-timeout": "600000"
},
"kits": [
{
"type": "ShellKit",
"run-command": [
"acm create -n user101 -t normal",
"acm switch -i 101"
]
},
{
"test-file-name": [
"ActsAmsUsersExtensionSystemTest.hap",
"ActsAmsUsersApi7AppA.hap"
"ApiCoverhapTest.hap",
"FaSupplement.hap",
"StageSupplement.hap",
"FormModule.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
\ No newline at end of file
]
}
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Copyright (c) 2021 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
......@@ -12,12 +12,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import AbilityStage from "@ohos.application.AbilityStage"
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("MyAbilityStage onCreate")
globalThis.stageOnCreateRun = 1;
globalThis.stageContext = this.context;
console.log("[Demo] MyAbilityStage onCreate")
globalThis.stageContext = this.context;
}
}
}
\ No newline at end of file
import commonEvent from '@ohos.commonEvent';
import FormExtension from '@ohos.application.FormExtension';
import formBindingData from '@ohos.application.formBindingData';
import formInfo from '@ohos.application.formInfo';
var extensionInfo_config_direction
export default class FormAbility extends FormExtension {
onCreate(want) {
// Called to return a FormBindingData object.
let formData = {};
let extensionInfo_currentInfo_name = this.context.currentHapModuleInfo.name
let extensionInfo_currentInfo_description = this.context.currentHapModuleInfo.description
this.context.resourceManager.getConfiguration((err, data) => {
if (err.code != 0 ) {
console.error(`Ability: getConfiguration failed: ${JSON.stringify(err)}`);
} else {
console.log(`Ability: getConfiguration success: ${JSON.stringify(data)}`);
extensionInfo_config_direction = data.direction
}
})
var CommonEventPublishData = {
parameters: {
"extensionInfo_currentInfo_name": extensionInfo_currentInfo_name,
"extensionInfo_currentInfo_description": extensionInfo_currentInfo_description,
"extensionInfo_config_direction": extensionInfo_config_direction,
"key":"value"
}
}
commonEvent.publish("FormAbility_OnCreate", CommonEventPublishData, (err) => {
console.log('FormAbility_OnCreate');
});
console.info("FormAbility onCreate")
return formBindingData.createFormBindingData(formData);
}
onCastToNormal(formId) {
// Called when the form provider is notified that a temporary form is successfully
// converted to a normal form.
}
onUpdate(formId) {
// Called to notify the form provider to update a specified form.
}
onVisibilityChange(newStatus) {
// Called when the form provider receives form events from the system.
}
onEvent(formId, message) {
// Called when a specified message event defined by the form provider is triggered.
}
onDestroy(formId) {
// Called to notify the form provider that a specified form has been destroyed.
}
onAcquireFormState(want) {
// Called to return a {@link FormState} object.
return formInfo.FormState.READY;
}
};
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Copyright (c) 2021 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
......@@ -15,36 +15,35 @@
import Ability from '@ohos.application.Ability'
export default class MainAbility extends Ability {
onCreate(want,launchParam){
// Ability is creating, initialize resources for this ability
console.log("MainAbility onCreate")
onCreate(want, launchParam) {
console.log("[Demo] MainAbility onCreate")
globalThis.abilityWant = want;
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("MainAbility onDestroy")
console.log("[Demo] MainAbility onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("MainAbility onWindowStageCreate")
globalThis.abilityContext = this.context
windowStage.setUIContent(this.context, "pages/index/index", null)
console.log("[Demo] MainAbility onWindowStageCreate")
globalThis.abilityContext = this.context;
windowStage.setUIContent(this.context, "pages/MainAbility_pages", null)
}
onWindowStageDestroy() {
//Main window is destroyed, release UI related resources
console.log("MainAbility onWindowStageDestroy")
// Main window is destroyed, release UI related resources
console.log("[Demo] MainAbility onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("MainAbility onForeground")
console.log("[Demo] MainAbility onForeground")
}
onBackground() {
// Ability has back to background
console.log("MainAbility onBackground")
console.log("[Demo] MainAbility onBackground")
}
};
\ No newline at end of file
};
// @ts-nocheck
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
......@@ -14,10 +15,13 @@
*/
import file from '@system.file';
import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index"
import testsuite from "../../test/List.test.ets"
import list from '../test/ListTest'
@Entry
@Component
struct Index {
@State message: string = 'MainAbility'
aboutToAppear() {
console.info("start run testcase!!!!")
const core = Core.getInstance()
......@@ -29,22 +33,25 @@ struct Index {
core.addService('report', reportExtend)
core.init()
globalThis.abilityWant.parameters.timeout = 20000;
core.subscribeEvent('task', reportExtend)
console.info("subscribeEvent run !!!!")
const configService = core.getDefaultService('config')
globalThis.abilityWant.parameters['timeout'] = 10000
console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters))
configService.setConfig(globalThis.abilityWant.parameters)
testsuite(globalThis.abilityContext)
console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters))
list(globalThis.abilityContext)
core.execute()
}
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text('MainAbility')
.fontSize(50)
.fontWeight(FontWeight.Bold)
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
}
.width('100%')
.height('100%')
}
}
\ No newline at end of file
/*
* 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 "deccjsunit/index"
import formProvider from '@ohos.application.formProvider';
import FormInfo from '@ohos.application.formInfo';
import formError from '@ohos.application.formError';
var EXTENSION_INFO_ERR = 2097152
var USERID_ERR = 2097177
var trueInfo;
var array = new Array();
function sleep(time) {
return new Promise((resolve)=>setTimeout(resolve,time));
}
export default function ApiCoverTest(abilityContext) {
describe('ApiCoverTestTest', function () {
/*
* @tc.number SUB_AA_ABILITY_Extension_API_001
* @tc.name StartServiceExtensionAbility with incorrect abilityName.
* @tc.desc Function test
* @tc.level 3
*/
it('SUB_AA_ABILITY_Extension_API_001', 0, async function (done) {
await sleep(2000);
let want = {
bundleName: "com.example.extensionapitest",
abilityName: "FirstExtension1"
};
await abilityContext.startServiceExtensionAbility(want).then((data) => {
console.log('Ability: startServiceExtensionAbility success:' + JSON.stringify(data));
expect("case execute failed").assertEqual(data);
}).catch((error) => {
console.error(`Ability: startServiceExtensionAbility failed: ${JSON.stringify(error)}`);
expect(EXTENSION_INFO_ERR).assertEqual(error.code);
})
done()
})
/*
* @tc.number SUB_AA_ABILITY_Extension_API_002
* @tc.name StopServiceExtensionAbility with incorrect bundleName.
* @tc.desc Function test
* @tc.level 3
*/
it('SUB_AA_ABILITY_Extension_API_002', 0, async function (done) {
await sleep(2000);
let want = {
bundleName: "com.example.extensionapitest1",
abilityName: "FirstExtension"
};
await abilityContext.stopServiceExtensionAbility(want).then((data) => {
console.log(`Ability: stopServiceExtensionAbility success: ${JSON.stringify(data)}`);
expect("case execute failed").assertEqual(data);
}).catch((error) => {
console.error(`Ability: stopServiceExtensionAbility failed: ${JSON.stringify(error)}`);
expect(EXTENSION_INFO_ERR).assertEqual(error.code);
})
done()
})
/*
* @tc.number SUB_AA_ABILITY_Extension_API_003
* @tc.name startServiceExtensionAbilityWithAccount with incorrect userId.
* @tc.desc Function test
* @tc.level 3
*/
it('SUB_AA_ABILITY_Extension_API_003', 0, async function (done) {
await sleep(2000);
let want = {
bundleName: "com.example.extensionapitest",
abilityName: "FirstExtension"
};
await abilityContext.startServiceExtensionAbilityWithAccount(want, 999).then((data) => {
console.log(`Ability: startServiceExtensionAbilityWithAccount success: ${JSON.stringify(data)}`);
expect("case execute failed").assertEqual("data");
}).catch((error) => {
console.error(`Ability: startServiceExtensionAbilityWithAccount failed: ${JSON.stringify(error)}`);
expect(USERID_ERR).assertEqual(error.code);
})
done()
})
/*
* @tc.number SUB_AA_ABILITY_Extension_API_004
* @tc.name stopServiceExtensionAbilityWithAccount with incorrect userId.
* @tc.desc Function test
* @tc.level 3
*/
it('SUB_AA_ABILITY_Extension_API_004', 0, async function (done) {
await sleep(2000);
let want = {
bundleName: "com.example.extensionapitest",
abilityName: "FirstExtension"
};
await abilityContext.stopServiceExtensionAbilityWithAccount(want, 999).then((data) => {
console.log(`Ability: stopServiceExtensionAbilityWithAccount success: ${JSON.stringify(data)}`);
expect("case execute failed").assertEqual(data);
}).catch((error) => {
console.error(`Ability: stopServiceExtensionAbilityWithAccount failed: ${JSON.stringify(error)}`);
expect(USERID_ERR).assertEqual(error.code);
})
done()
})
/*
* @tc.number SUB_AA_ABILITY_Extension_API_005
* @tc.name StartServiceExtensionAbility with incorrect abilityName.
* @tc.desc Function test
* @tc.level 3
*/
it('SUB_AA_ABILITY_Extension_API_005', 0, async function (done) {
await sleep(2000);
let want = {
bundleName: "com.example.extensionapitest",
abilityName: "FirstExtension1"
}
await abilityContext.startServiceExtensionAbility(want, (err, data) => {
if (err.code) {
console.error(`Ability: startServiceExtensionAbility failed: ${JSON.stringify(err)}`);
expect(EXTENSION_INFO_ERR).assertEqual(err.code);
} else {
console.log(`Ability: startServiceExtensionAbility success: ${JSON.stringify(data)}`);
expect("case execute failed").assertEqual(data);
}
done()
})
})
/*
* @tc.number SUB_AA_ABILITY_Extension_API_006
* @tc.name StopServiceExtensionAbility with incorrect bundleName.
* @tc.desc Function test
* @tc.level 3
*/
it('SUB_AA_ABILITY_Extension_API_006', 0, async function (done) {
await sleep(2000);
let want = {
bundleName: "com.example.extensionapitest1",
abilityName: "FirstExtension"
};
await abilityContext.stopServiceExtensionAbility(want, (err, data) => {
if (err.code) {
console.error(`Ability: stopServiceExtensionAbility failed: ${JSON.stringify(err)}`);
expect(EXTENSION_INFO_ERR).assertEqual(err.code);
} else {
console.log(`Ability: stopServiceExtensionAbility success: ${JSON.stringify(data)}`);
expect("case execute failed").assertEqual(data);
}
done()
})
done()
})
/*
* @tc.number SUB_AA_ABILITY_Extension_API_007
* @tc.name startServiceExtensionAbilityWithAccount with incorrect userId.
* @tc.desc Function test
* @tc.level 3
*/
it('SUB_AA_ABILITY_Extension_API_007', 0, async function (done) {
await sleep(2000);
let want = {
bundleName: "com.example.extensionapitest",
abilityName: "FirstExtension"
};
await abilityContext.startServiceExtensionAbilityWithAccount(want, 999, (err, data) => {
if (err.code) {
console.error(`Ability: startServiceExtensionAbilityWithAccount failed: ${JSON.stringify(err)}`);
expect(USERID_ERR).assertEqual(err.code);
} else {
console.log(`Ability: startServiceExtensionAbilityWithAccount success: ${JSON.stringify(data)}`);
expect("case execute failed").assertEqual(data);
}
done()
})
})
/*
* @tc.number SUB_AA_ABILITY_Extension_API_008
* @tc.name stopServiceExtensionAbilityWithAccount with incorrect userId.
* @tc.desc Function test
* @tc.level 3
*/
it('SUB_AA_ABILITY_Extension_API_008', 0, async function (done) {
await sleep(2000);
let want = {
bundleName: "com.example.extensionapitest",
abilityName: "FirstExtension"
};
abilityContext.stopServiceExtensionAbilityWithAccount(want, 999, (err, data) => {
if (err.code) {
console.error(`Ability: stopServiceExtensionAbilityWithAccount failed: ${JSON.stringify(err)}`);
expect(USERID_ERR).assertEqual(err.code);
} else {
console.log(`Ability: stopServiceExtensionAbilityWithAccount success: ${JSON.stringify(data)}`);
expect("case execute failed").assertEqual(data);
}
done()
})
})
/*
* @tc.number SUB_AA_AMS_Context_0100
* @tc.name Get the resource and path of the context.
* @tc.desc Function test
* @tc.level 3
*/
it('SUB_AA_AMS_Context_0100', 0, async function (done) {
expect("/data/storage/el2/base/haps/phone/cache").assertEqual(abilityContext.cacheDir)
expect("/data/storage/el2/base/haps/phone/temp").assertEqual(abilityContext.tempDir)
expect("/data/storage/el2/base/haps/phone/files").assertEqual(abilityContext.filesDir)
expect("/data/storage/el2/database/phone").assertEqual(abilityContext.databaseDir)
expect("/data/storage/el2/base/haps/phone/preferences").assertEqual(abilityContext.preferencesDir)
expect("/data/storage/el1/bundle").assertEqual(abilityContext.bundleCodeDir)
expect("/data/storage/el2/distributedfiles").assertEqual(abilityContext.distributedFilesDir)
expect(1).assertEqual(abilityContext.area)
abilityContext.resourceManager.getConfiguration((err, data) => {
if (err.code != 0 ) {
console.error(`Ability: getConfiguration failed: ${JSON.stringify(err)}`);
expect(USERID_ERR).assertEqual(err.code);
done()
} else {
console.log(`Ability: getConfiguration success: ${JSON.stringify(data)}`);
expect(1).assertEqual(data.direction)
done()
}
})
let moduleContext = abilityContext.createModuleContext("module1")
expect("/data/storage/el2/base/cache").assertEqual(moduleContext.cacheDir)
done()
})
/*
* @tc.number SUB_AA_Form_provider_getFormsInfo_0100
* @tc.name The provider calls the getFormsInfo interface to obtain form information.
* @tc.desc Function test
* @tc.level 3
*/
it('SUB_AA_Form_provider_getFormsInfo_0100', 0, async function (done) {
console.info("SUB_AA_Form_provider_getFormsInfo_0100");
formProvider.getFormsInfo((err, value) => {
console.info("formProvider::GetFormsInfoTest err: " + JSON.stringify(err));
console.info("formProvider::GetFormsInfoTest value: " + JSON.stringify(value));
if (err.code != 0) {
expect(0).assertEqual(2)
} else {
for(let i = 0; i < value.length; i++){
if(value[i].bundleName == "com.example.extensionapitest" && value[i].name == "widget"){
trueInfo = value[i]
console.info("formProvider::GetFormsInfoTest trueInfo: " + JSON.stringify(trueInfo));
}
}
}
checkFormInfo(trueInfo)
done()
})
done()
})
/*
* @tc.number SUB_AA_Form_provider_getFormsInfo_0200
* @tc.name The provider calls the getFormsInfo interface to obtain form information in the module1.
* @tc.desc Function test
* @tc.level 3
*/
it('SUB_AA_Form_provider_getFormsInfo_0200', 0, async function (done) {
console.info("SUB_AA_Form_provider_getFormsInfo_0200");
const filter: formInfo.FormInfoFilter = {
moduleName: "module1"
};
formProvider.getFormsInfo(filter, (err, value) => {
console.info("formProvider::GetFormsInfoTest err: " + JSON.stringify(err));
console.info("formProvider::GetFormsInfoTest value: " + JSON.stringify(value));
if (err.code != 0) {
expect(0).assertEqual(2)
} else {
if(value.length == 0){
expect(1).assertEqual(0)
}else{
for(let i = 0; i < value.length; i++){
if(value[i].bundleName == "com.example.extensionapitest" && value[i].name == "widget1"){
trueInfo = value[i]
console.info("formProvider::GetFormsInfoTest trueInfo: " + JSON.stringify(trueInfo));
}
}
}
}
checkFormInfoModule1(trueInfo)
done();
})
done()
})
/*
* @tc.number SUB_AA_Form_provider_TestFormErr_0100
* @tc.name Get all FormError types.
* @tc.desc Function test
* @tc.level 3
*/
it('SUB_AA_Form_provider_TestFormErr_0100', 0, async function (done) {
console.info("SUB_AA_Form_provider_TestFormErr_0100");
expect(7).assertEqual(formError.FormError.ERR_ADD_INVALID_PARAM)
expect(10).assertEqual(formError.FormError.ERR_BIND_PROVIDER_FAILED)
expect(8).assertEqual(formError.FormError.ERR_CFG_NOT_MATCH_ID)
expect(1).assertEqual(formError.FormError.ERR_COMMON)
expect(31).assertEqual(formError.FormError.ERR_FORM_DUPLICATE_ADDED)
expect(20).assertEqual(formError.FormError.ERR_FORM_FA_NOT_INSTALLED)
expect(18).assertEqual(formError.FormError.ERR_FORM_NO_SUCH_ABILITY)
expect(19).assertEqual(formError.FormError.ERR_FORM_NO_SUCH_DIMENSION)
expect(17).assertEqual(formError.FormError.ERR_FORM_NO_SUCH_MODULE)
expect(5).assertEqual(formError.FormError.ERR_GET_BUNDLE_FAILED)
expect(4).assertEqual(formError.FormError.ERR_GET_INFO_FAILED)
expect(6).assertEqual(formError.FormError.ERR_GET_LAYOUT_FAILED)
expect(36).assertEqual(formError.FormError.ERR_IN_RECOVERY)
expect(15).assertEqual(formError.FormError.ERR_MAX_FORMS_PER_CLIENT)
expect(12).assertEqual(formError.FormError.ERR_MAX_INSTANCES_PER_FORM)
expect(11).assertEqual(formError.FormError.ERR_MAX_SYSTEM_FORMS)
expect(16).assertEqual(formError.FormError.ERR_MAX_SYSTEM_TEMP_FORMS)
expect(9).assertEqual(formError.FormError.ERR_NOT_EXIST_ID)
expect(13).assertEqual(formError.FormError.ERR_OPERATION_FORM_NOT_SELF)
expect(2).assertEqual(formError.FormError.ERR_PERMISSION_DENY)
expect(14).assertEqual(formError.FormError.ERR_PROVIDER_DEL_FAIL)
expect(30).assertEqual(formError.FormError.ERR_SYSTEM_RESPONSES_FAILED)
done()
})
/*
* @tc.number SUB_AA_Form_provider_TestFormInfo_0100
* @tc.name Get all FormInfo types
* @tc.desc Function test
* @tc.level 3
*/
it('SUB_AA_Form_provider_TestFormInfo_0100', 0, async function (done) {
console.info("SUB_AA_Form_provider_TestFormInfo_0100");
expect("ohos.extra.param.key.form_dimension").assertEqual(FormInfo.FormParam.DIMENSION_KEY)
expect("ohos.extra.param.key.form_height").assertEqual(FormInfo.FormParam.HEIGHT_KEY)
expect("ohos.extra.param.key.module_name").assertEqual(FormInfo.FormParam.MODULE_NAME_KEY)
expect("ohos.extra.param.key.form_name").assertEqual(FormInfo.FormParam.NAME_KEY)
expect("ohos.extra.param.key.form_temporary").assertEqual(FormInfo.FormParam.TEMPORARY_KEY)
expect("ohos.extra.param.key.form_width").assertEqual(FormInfo.FormParam.WIDTH_KEY)
expect(0).assertEqual(FormInfo.FormState.DEFAULT)
expect(1).assertEqual(FormInfo.FormState.READY)
expect(-1).assertEqual(FormInfo.FormState.UNKNOWN)
expect(0).assertEqual(FormInfo.ColorMode.MODE_DARK)
expect(1).assertEqual(FormInfo.ColorMode.MODE_LIGHT)
done();
});
})
}
function checkFormInfoModule1(formInfo){
console.info("formProvider::GetFormsInfoTest value: " + JSON.stringify(formInfo));
expect("com.example.extensionapitest").assertEqual(formInfo.bundleName)
expect("module1").assertEqual(formInfo.moduleName)
expect("FormAbility").assertEqual(formInfo.abilityName)
expect("widget1").assertEqual(formInfo.name)
expect("This is a service widget.").assertEqual(formInfo.description)
expect(FormInfo.FormType.JS).assertEqual(formInfo.type)
expect(FormInfo.ColorMode.MODE_DARK).assertEqual(formInfo.colorMode)
expect(1).assertEqual(formInfo.isDefault)
expect(1).assertEqual(formInfo.updateEnabled)
expect(0).assertEqual(formInfo.formVisibleNotify)
expect(undefined).assertEqual(formInfo.relatedBundleName)
expect("ability://xxxxx").assertEqual(formInfo.formConfigAbility)
expect(1).assertEqual(formInfo.updateDuration)
expect(2).assertEqual(formInfo.defaultDimension)
expect(2).assertEqual(formInfo.supportDimensions[0])
}
function checkFormInfo(formInfo){
console.info("formProvider::GetFormsInfoTest formInfo: " + JSON.stringify(formInfo));
expect("com.example.extensionapitest").assertEqual(formInfo.bundleName)
expect("entry").assertEqual(formInfo.moduleName)
expect("FormAbility").assertEqual(formInfo.abilityName)
expect("widget").assertEqual(formInfo.name)
expect("This is a service widget.").assertEqual(formInfo.description)
expect(FormInfo.FormType.JS).assertEqual(formInfo.type)
expect(FormInfo.ColorMode.MODE_AUTO).assertEqual(formInfo.colorMode)
expect(1).assertEqual(formInfo.isDefault)
expect(1).assertEqual(formInfo.updateEnabled)
expect(0).assertEqual(formInfo.formVisibleNotify)
expect(undefined).assertEqual(formInfo.relatedBundleName)
expect("ability://xxxxx").assertEqual(formInfo.formConfigAbility)
expect(1).assertEqual(formInfo.updateDuration)
expect(2).assertEqual(formInfo.defaultDimension)
expect(2).assertEqual(formInfo.supportDimensions[0])
}
\ No newline at end of file
......@@ -12,9 +12,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import abilityTest from './Ability.test.ets'
import verificationTest from './VerificationTest'
import apiCoverAbility from './ApiCoverAbility.test'
export default function testsuite(context) {
console.debug("====>in list.test====>");
abilityTest(context)
export default function List(context) {
verificationTest(context)
apiCoverAbility(context)
}
\ No newline at end of file
#wrapper {
flex-direction: column;
}
#div1 {
width: 100%;
height: 100%;
justify-content: center;
align-items: center;
background-color: white;
}
#text1 {
height: 45px;
width: 150px;
font-size: 16px;
text-align: center;
}
<div>
<div id="wrapper">
<div id="div1">
<text id="text1">{{title}}</text>
</div>
</div>
</div>
\ No newline at end of file
{
"actions": {},
"data": {
"title": "Hello World"
}
}
\ No newline at end of file
{
"module": {
"name": "phone",
"type": "entry",
"srcEntrance": "./ets/Application/AbilityStage.ts",
"description": "$string:phone_entry_dsc",
"mainElement": "MainAbility",
"deviceTypes": [
"phone"
],
"deliveryWithInstall": true,
"installationFree": false,
"pages": "$profile:main_pages",
"uiSyntax": "ets",
"abilities": [
{
"name": "com.example.apicoverhaptest.MainAbility",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:phone_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"startWindowIcon": "$media:icon",
"startWindowBackground": "$color:white",
"visible": true,
"orientation": "portrait",
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
]
}
],
"extensionAbilities": [
{
"name": "FormAbility",
"srcEntrance": "./ets/FormAbility/FormAbility.ts",
"label": "$string:MainAbility_label",
"description": "$string:MainAbility_desc",
"type": "form",
"metadata": [
{
"name": "ohos.extension.form",
"resource": "$profile:form_config"
}
]
}
]
}
}
\ No newline at end of file
{
"color": [
{
"name": "white",
"value": "#FFFFFF"
}
]
}
\ No newline at end of file
......@@ -10,23 +10,27 @@
},
{
"name": "entry_label",
"value": "ActsContextTest"
"value": "ActsLifecycleMultihapTest"
},
{
"name": "form_description",
"value": "my form"
},
{
"name": "serviceability_description",
"value": "my whether"
"name": "description_application",
"value": "demo for test"
},
{
"name": "description_application",
"value": "demo for test"
"name": "entry_desc",
"value": "description"
},
{
"name": "app_name",
"value": "Demo"
"name": "MainAbility_desc",
"value": "description"
},
{
"name": "MainAbility_label",
"value": "label"
}
]
}
\ No newline at end of file
}
{
"forms": [
{
"isDefault": true,
"src": "./js/widget/pages/index/index",
"scheduledUpdateTime": "10:30",
"defaultDimension": "2*2",
"name": "widget",
"description": "This is a service widget.",
"colorMode": "auto",
"window": {
"designWidth": 720,
"autoDesignWidth": true
},
"formConfigAbility": "ability://xxxxx",
"supportDimensions": [
"2*2"
],
"updateEnabled": true,
"updateDuration": 1
}
]
}
\ No newline at end of file
# Copyright (c) 2021 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("//test/xts/tools/build/suite.gni")
ohos_hap("FaSupplement") {
hap_profile = "entry/src/main/config.json"
hap_name = "FaSupplement"
subsystem_name = XTS_SUITENAME
final_hap_path =
"${SUITES_OUTPUT_ROOT}/${XTS_SUITENAME}/testcases/${hap_name}.hap"
testonly = true
deps = [
":fasupplement_resources",
":fasupplement_ts_assets",
]
certificate_profile = "signature/openharmony_sx.p7b"
}
ohos_js_assets("fasupplement_ts_assets") {
source_dir = "entry/src/main/ets"
hap_profile = "entry/src/main/config.json"
ets2abc = true
}
ohos_resources("fasupplement_resources") {
sources = [ "entry/src/main/resources" ]
hap_profile = "entry/src/main/config.json"
}
{
"app": {
"vendor": "example",
"bundleName": "ohos.acts.aafwk.test.fasupplement",
"version": {
"code": 1000000,
"name": "1.0.0"
},
"apiVersion": {
"compatible": 9,
"target": 9
}
},
"deviceConfig": {},
"module": {
"mainAbility": ".MainAbility",
"deviceType": [
"phone"
],
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"orientation": "unspecified",
"visible": true,
"srcPath": "MainAbility",
"name": ".MainAbility",
"srcLanguage": "ets",
"icon": "$media:icon",
"description": "$string:MainAbility_desc",
"formsEnabled": false,
"label": "$string:MainAbility_label",
"type": "page",
"launchType": "singleton"
},
{
"orientation": "unspecified",
"visible": true,
"srcPath": "MainAbility2",
"name": ".MainAbility2",
"srcLanguage": "ets",
"icon": "$media:icon",
"description": "$string:MainAbility2_desc",
"formsEnabled": false,
"label": "$string:MainAbility2_label",
"type": "page",
"launchType": "singleton"
}
],
"distro": {
"moduleType": "entry",
"installationFree": false,
"deliveryWithInstall": true,
"moduleName": "entry"
},
"package": "ohos.acts.aafwk.test.fasupplement",
"srcPath": "",
"name": ".entry",
"js": [
{
"mode": {
"syntax": "ets",
"type": "pageAbility"
},
"pages": [
"pages/index"
],
"name": ".MainAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
},
{
"mode": {
"syntax": "ets",
"type": "pageAbility"
},
"pages": [
"pages/index"
],
"name": ".MainAbility2",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
]
}
}
\ No newline at end of file
/*
* 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 ability_featureAbility from '@ohos.ability.featureAbility';
import commonEvent from '@ohos.commonEvent';
var printLog1 = "Fa:MainAbility:";
var listPush1 = "Fa_MainAbility_";
export default {
onCreate() {
console.info(printLog1 + 'onCreate');
},
onDestroy() {
console.info(printLog1 + 'onDestroy');
commonEvent.publish(listPush1 + "onDestroy", (err) => {
console.info(printLog1 + listPush1 + "onDestroy");
});
},
onActive() {
console.info(printLog1 + 'onActive');
ability_featureAbility.hasWindowFocus().then((data) => {
console.info(printLog1 + "hasWindowFocus data = " + data);
var CommonEventPublishData = {
parameters: {
hasWindowFocus: data
}
}
commonEvent.publish(listPush1 + "HasWindowFocus", CommonEventPublishData, (err) => {
console.info(printLog1 + listPush1 + "HasWindowFocus");
});
setTimeout(()=>{
ability_featureAbility.terminateSelf().then((data) => {
console.info(printLog1 + "terminateSelf data = " + JSON.stringify(data));
}).catch((err) => {
console.info(printLog1 + "terminateSelf err = " + JSON.stringify(err));
});
}, 3000)
}).catch((err) => {
console.info(printLog1 + "hasWindowFocus err = " + JSON.stringify(err));
});
},
onInactive() {
console.info(printLog1 + 'onInactive');
},
onShow() {
console.info(printLog1 + 'onShow');
},
onHide() {
console.info(printLog1 + 'onHide');
}
}
\ No newline at end of file
......@@ -12,17 +12,20 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@Entry
@Component
struct MyComponent {
struct Index {
@State message: string = 'Hello World Test Fa'
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text('Hello World1111111')
.fontSize(50)
.fontWeight(FontWeight.Bold)
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
}
.width('100%')
.height('100%')
}
}
\ No newline at end of file
/*
* 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 ability_featureAbility from '@ohos.ability.featureAbility';
import commonEvent from '@ohos.commonEvent';
var printLog1 = "Fa:MainAbility2:";
var listPush1 = "Fa_MainAbility2_";
export default {
onCreate() {
console.info(printLog1 + 'onCreate');
let list = ["ohos.permission.CAMERA"]
ability_featureAbility.getContext().requestPermissionsFromUser(list, 1).then((permissionRequestResult) => {
console.info(printLog1 + "requestPermissionsFromUser data = " + JSON.stringify(permissionRequestResult));
var CommonEventPublishData = {
parameters: {
permissionRequestResult: permissionRequestResult
}
}
commonEvent.publish(listPush1 + "onCreate", CommonEventPublishData, (err) => {
console.info(printLog1 + listPush1 + "onCreate");
});
}).catch((err) => {
console.info(printLog1 + "requestPermissionsFromUser err = " + JSON.stringify(err));
});
setTimeout(()=>{
ability_featureAbility.terminateSelf().then((data) => {
console.info(printLog1 + "terminateSelf data = " + JSON.stringify(data));
}).catch((err) => {
console.info(printLog1 + "terminateSelf err = " + JSON.stringify(err));
});
}, 3000)
},
onDestroy() {
console.info(printLog1 + 'onDestroy');
commonEvent.publish(listPush1 + "onDestroy", (err) => {
console.info(printLog1 + listPush1 + "onDestroy");
});
},
onActive() {
console.info(printLog1 + 'onActive');
},
onInactive() {
console.info(printLog1 + 'onInactive');
},
onShow() {
console.info(printLog1 + 'onShow');
},
onHide() {
console.info(printLog1 + 'onHide');
}
}
\ No newline at end of file
/*
* 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.
*/
@Entry
@Component
struct Index {
@State message: string = 'Hello World Test Fa 2'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
{
"string": [
{
"name": "entry_desc",
"value": "description"
},
{
"name": "MainAbility_desc",
"value": "description"
},
{
"name": "MainAbility_label",
"value": "FaSupplement"
},
{
"name": "MainAbility2_desc",
"value": "description"
},
{
"name": "MainAbility2_label",
"value": "label"
},
{
"name": "MainAbility3_desc",
"value": "description"
},
{
"name": "MainAbility3_label",
"value": "label"
},
{
"name": "PageAbility_desc",
"value": "description"
},
{
"name": "PageAbility_label",
"value": "label"
},
{
"name": "DataAbility_desc",
"value": "hap sample empty provider"
}
]
}
\ No newline at end of file
[ZoneTransfer]
ZoneId=0
ReferrerUrl=vscode-file://vscode-app/d:/Software/Microsoft%20VS%20Code/resources/app/out/vs/code/electron-browser/workbench/workbench.html
HostUrl=file:///d%3A/OpenHarmony/Xts/xts_acts-master/aafwk/aafwk_standard/newwant/actsnewwantbrelyhap/signature/openharmony_sx.p7b
{
"app": {
"bundleName": "com.example.actsconnectabilitysystemabilitytest",
"app":{
"bundleName": "com.example.apicoverhaptest",
"vendor": "huawei",
"versionCode": 1000000,
"versionName": "1.0.0",
"debug": false,
"icon" : "$media:icon",
"label" : "$string:app_name",
"description" : "$string:description_application",
"distributedNotificationEnabled": true,
"keepAlive" : true,
"icon": "$media:icon",
"label": "$string:app_name",
"description": "$string:description_application",
"distributedNotificationEnabled": true,
"keepAlive": true,
"singleUser": true,
"minAPIVersion": 8,
"targetAPIVersion": 8,
"car": {
"apiCompatibleVersion": 8,
"minAPIVersion": 9,
"targetAPIVersion": 9,
"car":{
"apiCompatibleVersion": 9,
"singleUser": false
}
}
}
}
\ No newline at end of file
}
{
"string":[
{
"name":"app_name",
"value":"ohosProject"
}
]
}
\ No newline at end of file
import AbilityStage from "@ohos.application.AbilityStage"
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("[Demo] MyAbilityStage onCreate")
}
}
\ No newline at end of file
#wrapper {
flex-direction: column;
}
#div1 {
width: 100%;
height: 100%;
justify-content: center;
align-items: center;
background-color: white;
}
#text1 {
height: 45px;
width: 150px;
font-size: 16px;
text-align: center;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册