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

!3910 XTS元能力测试套整改

Merge pull request !3910 from chengxingzhen/master
......@@ -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";
......
{
"app": {
"bundleName": "com.acts.actsinterfacemultiusersextensiontest",
"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,
"singleUser": true,
"minAPIVersion": 8,
"targetAPIVersion": 8,
"car": {
"apiCompatibleVersion": 8,
"singleUser": 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("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsAmsUsersExtensionSystemTest") {
hap_profile = "entry/src/main/module.json"
js_build_mode = "debug"
deps = [
":actsamsusersextensionsystemtest_js_assets",
":actsamsusersextensionsystemtest_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsAmsUsersExtensionSystemTest"
}
ohos_app_scope("actsamsusersextensionsystemtest_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("actsamsusersextensionsystemtest_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("actsamsusersextensionsystemtest_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":actsamsusersextensionsystemtest_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "300000",
"package": "com.acts.actsinterfacemultiusersextensiontest",
"shell-timeout": "300000"
},
"kits": [
{
"type": "ShellKit",
"run-command": [
"acm create -n user101 -t normal",
"acm switch -i 101"
]
},
{
"test-file-name": [
"ActsAmsUsersExtensionSystemTest.hap",
"ActsAmsUsersApi7AppA.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
\ 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 AbilityStage from "@ohos.application.AbilityStage"
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("MyAbilityStage onCreate")
globalThis.stageOnCreateRun = 1;
globalThis.stageContext = this.context;
}
}
/*
* 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 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")
globalThis.abilityWant = want;
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("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)
}
onWindowStageDestroy() {
//Main window is destroyed, release UI related resources
console.log("MainAbility onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("MainAbility onForeground")
}
onBackground() {
// Ability has back to background
console.log("MainAbility onBackground")
}
};
\ 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 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) 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 file from '@system.file';
import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index"
import testsuite from "../../test/List.test.ets"
@Entry
@Component
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)
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)
core.execute()
}
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text('MainAbility')
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.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 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
/*
* 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 abilityTest from './Ability.test.ets'
export default function testsuite(context) {
console.debug("====>in list.test====>");
abilityTest(context)
}
\ 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"
}
]
}
}
{
"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
......@@ -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",
]
......
{
"app": {
"bundleName": "com.example.actsconnectabilitysystemabilitytest",
"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,
"singleUser": true,
"minAPIVersion": 8,
"targetAPIVersion": 8,
"car": {
"apiCompatibleVersion": 8,
"singleUser": 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("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsConnectAbilitySystemAbilityTest") {
hap_profile = "entry/src/main/module.json"
js_build_mode = "debug"
deps = [
":actsconnectabilitysystemabilitytest_js_assets",
":actsconnectabilitysystemabilitytest_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsConnectAbilitySystemAbilityTest"
}
ohos_app_scope("actsconnectabilitysystemabilitytest_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("actsconnectabilitysystemabilitytest_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("actsconnectabilitysystemabilitytest_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":actsconnectabilitysystemabilitytest_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
{
"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
import Ability from '@ohos.application.Ability'
// import commonEvent from '@ohos.commonEvent'
export default class MainAbility extends Ability {
onCreate(want, launchParam) {
// Ability is creating, initialize resources for this ability
console.log("AbilityMultiInstanceTest onCreate")
globalThis.abilityWant = want;
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("AbilityMultiInstanceTest onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("AbilityMultiInstanceTest onWindowStageCreate")
globalThis.abilityContext = this.context
windowStage.setUIContent(this.context, "pages/index/index", null)
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("AbilityMultiInstanceTest onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("AbilityMultiInstanceTest onForeground")
}
onBackground() {
// Ability has back to background
console.log("AbilityMultiInstanceTest onBackground")
}
};
/*
* 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.
*/
export default {
onStart() {
console.info('ServiceAbility2 onStart');
},
onStop() {
console.info('ServiceAbility2 onStop');
},
onCommand(want, startId) {
console.info('ServiceAbility2 onCommand');
}
};
\ 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 MyComponent {
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text('Hello World1111111')
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.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 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
/*
* 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 abilityTest from './manyusersabilitytest.test.ets'
export default function testsuite(context) {
abilityTest(context)
}
\ 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)
})
}
......
......@@ -75,7 +75,7 @@ struct Index {
console.info("!!!====>formsystemhost deleteCallBack end ====>");
}
private aboutToAppear() {
aboutToAppear() {
commonEvent.createSubscriber(this.subscriberFormDeleteEvent).then(async (data) => {
console.info("====>formsystemhost Subscriber FormDelete data:====>", JSON.stringify(data));
this.subscriberDel = data;
......
......@@ -70,7 +70,7 @@ struct Index {
console.info("!!!====>formsystemhost deleteCallBack end ====>");
}
private aboutToAppear() {
aboutToAppear() {
commonEvent.createSubscriber(this.subscriberFormDeleteEvent).then(async (data) => {
console.info("====>formsystemhost Subscriber FormDelete data:====>", JSON.stringify(data));
this.subscriberDle = data;
......
......@@ -124,7 +124,7 @@ struct Index {
private fill(value: number): string {
return (value > 9 ? "" : "0") + value;
}
private aboutToAppear() {
aboutToAppear() {
commonEvent.createSubscriber(this.subscriberFormDeleteEvent).then(async (data) => {
console.info("====>[FormComponent] Subscriber FormDelete data:====>", JSON.stringify(data));
this.subscriberDel = data;
......@@ -191,7 +191,7 @@ struct Index {
console.log("[FormComponent.host] sendCastForm start");
setTimeout(() => {
let commonEventPublishData = {
data: sendCastFormMsg,
data: this.sendCastFormMsg,
parameters: {
"formId" : ""
}
......
......@@ -83,7 +83,7 @@ struct Index {
console.info("!!!====>formsystemhost deleteCallBack end ====>");
}
private aboutToAppear() {
aboutToAppear() {
commonEvent.createSubscriber(this.subscriberFormDeleteEvent).then(async (data) => {
console.info("====>formsystemhost Subscriber FormDelete data:====>", JSON.stringify(data));
this.subscriberDel = data;
......
......@@ -89,7 +89,7 @@ struct Index {
console.info("!!!====>formsystemhost deleteCallBack end ====>");
}
private aboutToAppear() {
aboutToAppear() {
commonEvent.createSubscriber(this.subscriberFormDeleteEvent).then(async (data) => {
console.info("====>formsystemhost Subscriber FormDelete data:====>", JSON.stringify(data));
this.subscriberDel = data;
......
......@@ -90,7 +90,7 @@ struct Index {
console.info("!!!====>formsystemhost deleteCallBack end ====>");
}
private aboutToAppear() {
aboutToAppear() {
commonEvent.createSubscriber(this.subscriberFormDeleteEvent).then(async (data) => {
console.info("====>formsystemhost Subscriber FormDelete data:====>", JSON.stringify(data));
this.subscriberDel = data;
......
......@@ -78,7 +78,7 @@ struct Index {
console.info("!!!====>[FormComponent.host] deleteCallBack end ====>");
}
private aboutToAppear() {
aboutToAppear() {
commonEvent.createSubscriber(this.subscriberFormDeleteEvent).then(async (data) => {
console.info("====>[FormComponent.host] Subscriber FormDelete data:====>", JSON.stringify(data));
this.subscriberDel = data;
......
......@@ -70,7 +70,7 @@ struct Index {
console.info("!!!====>formsystemhost deleteCallBack end ====>");
}
private aboutToAppear() {
aboutToAppear() {
commonEvent.createSubscriber(this.subscriberFormDeleteEvent).then(async (data) => {
console.info("====>formsystemhost Subscriber FormDelete data:====>", JSON.stringify(data));
this.subscriberDel = data;
......
......@@ -70,7 +70,7 @@ struct Index {
console.info("!!!====>formsystemhostj deleteCallBack end ====>");
}
private aboutToAppear() {
aboutToAppear() {
commonEvent.createSubscriber(this.subscriberFormDeleteEvent).then(async (data) => {
console.info("====>formsystemhostj Subscriber FormDelete data:====>", JSON.stringify(data));
this.subscriberDel = data;
......
......@@ -87,7 +87,7 @@ struct Index {
console.info(`${this.TAG} unSubscribeDeleteCallback`);
}
private async aboutToAppear() {
async aboutToAppear() {
const onDeleteEventSubscriber = await commonEvent.createSubscriber(this.subscriberFormDeleteEvent);
const onTerminateEventSubscriber = await commonEvent.createSubscriber(this.subscriberFormTerminateEvent);
commonEvent.subscribe(onDeleteEventSubscriber, async (err, data) => {
......
......@@ -54,7 +54,7 @@ struct Index {
console.info(`${this.TAG} unSubscribeDeleteCallback====>`);
}
private async aboutToAppear() {
async aboutToAppear() {
const onDeleteEventSubscriber = await commonEvent.createSubscriber(this.subscriberFormDeleteEvent);
commonEvent.subscribe(onDeleteEventSubscriber, async (err, data) => {
console.info(`${this.TAG} deleteCallBack start:====> ${JSON.stringify(data)}`);
......
......@@ -153,7 +153,7 @@ struct Index {
console.debug("====> [FormComponent] formsystemhostn optType unSubscribeCastFormCallback CallBack====>");
}
private aboutToAppear() {
aboutToAppear() {
commonEvent.createSubscriber(this.subscriberFormDeleteEvent).then(async (data) => {
console.info("====>[FormComponent] formsystemhostn Subscriber FormDelete data:====>", JSON.stringify(data));
this.subscriberDel = data;
......
......@@ -52,7 +52,7 @@ struct Index {
console.debug("====>formOnErrorEvent Publish CallBack ====>");
}
private aboutToAppear() {
aboutToAppear() {
console.error('[FormComponent] getWant');
featureAbility.getWant()
.then((want: any) => {
......
......@@ -152,7 +152,7 @@ struct Index {
console.debug("====> [FormComponent] formsystemhosto optType unSubscribeCastFormCallback CallBack====>");
}
private aboutToAppear() {
aboutToAppear() {
const TAG = "[FormComponent.hosto]";
commonEvent.createSubscriber(this.subscriberFormDeleteEvent).then(async (data) => {
......
......@@ -144,7 +144,7 @@ struct Index {
console.info("!!!====> [FormComponent] formsystemhostp optType deleteCallBack end ====>");
}
private aboutToAppear() {
aboutToAppear() {
commonEvent.createSubscriber(this.subscriberFormDeleteEvent).then(async (data) => {
console.info("====>[FormComponent] formsystemhostp Subscriber FormDelete data:====>", JSON.stringify(data));
this.subscriberDel = data;
......
......@@ -15,13 +15,13 @@
import featureAbility from "@ohos.ability.featureAbility";
import formBindingData from "@ohos.application.formBindingData";
import formManager from '@ohos.ability.formManager';
import formManager from '@ohos.application.formProvider';
import commonEvent from '@ohos.commonEvent';
@Entry
@Component
struct Index {
@State formId: number = 0;
@State formId: string = "0";
@State opt : string = "updateForm";
@State formData: {[key: string]: any} = {temperature: "14c", "time": "12:00"};
@State nextTime: number = 5;
......@@ -36,12 +36,12 @@ struct Index {
console.debug("====>formsystemhostc formOnDynamicRefreshEventk ====>");
}
private aboutToAppear() {
aboutToAppear() {
console.log(`form supply B aboutToAppear start`);
console.error('form supply B getWant');
featureAbility.getWant()
.then((want: any) => {
this.formId = parseInt(want.parameters.formId);
this.formId = want.parameters.formId;
this.opt = want.parameters.opt;
if(want.parameters.formData) {
this.formData = want.parameters.formData;
......@@ -64,9 +64,9 @@ struct Index {
.then((data) => {
console.info('form supply B updateForm result:' + data);
let commonEventPublishData = {
data: data.toString(),
data: JSON.stringify(data),
parameters: {
"formId" : this.formId.toString()
"formId" : this.formId
}
};
commonEvent.publish(this.formUpdateFormEvent, commonEventPublishData, this.publishUpdateFormCallBack);
......@@ -81,9 +81,9 @@ struct Index {
.then((data) => {
console.info('form supply B setNextRefreshTime result:' + data);
let commonEventPublishData = {
data: data.toString(),
data: JSON.stringify(data),
parameters: {
"formId" : this.formId.toString()
"formId" : this.formId
}
};
commonEvent.publish(this.formOnDynamicRefreshEvent, commonEventPublishData, this.formOnDynamicRefreshCallBack);
......
......@@ -15,13 +15,13 @@
import featureAbility from "@ohos.ability.featureAbility";
import formBindingData from "@ohos.application.formBindingData";
import formManager from '@ohos.ability.formManager';
import formManager from '@ohos.application.formProvider';
import commonEvent from '@ohos.commonEvent';
@Entry
@Component
struct Index {
@State formId: number = 0;
@State formId: string = "0";
@State opt : string = "updateForm";
@State formData: {[key: string]: any} = {temperature: "14c", "time": "12:00"};
@State nextTime: number = 5;
......@@ -36,12 +36,12 @@ struct Index {
console.debug("====>formsystemhostc formOnDynamicRefreshEventk ====>");
}
private aboutToAppear() {
aboutToAppear() {
console.log(`form supply B aboutToAppear start`);
console.error('form supply B getWant');
featureAbility.getWant()
.then((want: any) => {
this.formId = parseInt(want.parameters.formId);
this.formId = want.parameters.formId;
this.opt = want.parameters.opt;
if(want.parameters.formData) {
this.formData = want.parameters.formData;
......@@ -64,9 +64,9 @@ struct Index {
.then((data) => {
console.info('form supply B updateForm result:' + data);
let commonEventPublishData = {
data: data.toString(),
data: JSON.stringify(data),
parameters: {
"formId" : this.formId.toString()
"formId" : this.formId
}
};
commonEvent.publish(this.formUpdateFormEvent, commonEventPublishData, this.publishUpdateFormCallBack);
......@@ -81,9 +81,9 @@ struct Index {
.then((data) => {
console.info('form supply B setNextRefreshTime result:' + data);
let commonEventPublishData = {
data: data.toString(),
data: JSON.stringify(data),
parameters: {
"formId" : this.formId.toString()
"formId" : this.formId
}
};
commonEvent.publish(this.formOnDynamicRefreshEvent, commonEventPublishData, this.formOnDynamicRefreshCallBack);
......
......@@ -15,13 +15,13 @@
import featureAbility from "@ohos.ability.featureAbility";
import formBindingData from "@ohos.application.formBindingData";
import formManager from '@ohos.ability.formManager';
import formManager from '@ohos.application.formProvider';
import commonEvent from '@ohos.commonEvent';
@Entry
@Component
struct Index {
@State formId: number = 0;
@State formId: string = "0";
@State opt : string = "updateForm";
@State formData: {[key: string]: any} = {temperature: "14c", "time": "12:00"};
@State nextTime: number = 5;
......@@ -36,12 +36,12 @@ struct Index {
console.debug("====>formsystemhostc formOnDynamicRefreshEventk ====>");
}
private aboutToAppear() {
aboutToAppear() {
console.log(`form supply B aboutToAppear start`);
console.error('form supply B getWant');
featureAbility.getWant()
.then((want: any) => {
this.formId = parseInt(want.parameters.formId);
this.formId = want.parameters.formId;
this.opt = want.parameters.opt;
if(want.parameters.formData) {
this.formData = want.parameters.formData;
......@@ -64,9 +64,9 @@ struct Index {
.then((data) => {
console.info('form supply B updateForm result:' + data);
let commonEventPublishData = {
data: data.toString(),
data: JSON.stringify(data),
parameters: {
"formId" : this.formId.toString()
"formId" : this.formId
}
};
commonEvent.publish(this.formUpdateFormEvent, commonEventPublishData, this.publishUpdateFormCallBack);
......@@ -81,9 +81,9 @@ struct Index {
.then((data) => {
console.info('form supply B setNextRefreshTime result:' + data);
let commonEventPublishData = {
data: data.toString(),
data: JSON.stringify(data),
parameters: {
"formId" : this.formId.toString()
"formId" : this.formId
}
};
commonEvent.publish(this.formOnDynamicRefreshEvent, commonEventPublishData, this.formOnDynamicRefreshCallBack);
......
......@@ -1541,27 +1541,8 @@ export default function test() {
console.info(`FMS_acquireForm_2600 featureAbility.startAbility again end`);
}
function onSupplyCallBack(_, data) {
if (data.parameters.kind == "onCastToNormal") {
console.info("====>FMS_acquireForm_2600 onSupplyCallBack====>" + JSON.stringify(data));
commonEvent.unsubscribe(subscriberSupply, () => unsubscribeSupplyCallback("FMS_acquireForm_2600"));
formId2 = data.parameters.parameters;
if (formId1 && formId2) {
expect(formId1).assertEqual(formId2);
let commonEventPublishData = {
data: formId1
};
commonEvent.publish(deleteForm_Event, commonEventPublishData, () =>
publishCallback1("FMS_acquireForm_2600"));
done()
}
}
}
commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack);
commonEvent.subscribe(subscriberCast, onCastCallBack);
commonEvent.subscribe(subscriberSupply, onSupplyCallBack);
console.info(`FMS_acquireForm_2600 featureAbility.startAbility start`);
await featureAbility.startAbility({
......
......@@ -1134,7 +1134,7 @@ const changeTime = async (hour, min, second) => {
console.info(`FMS_deleteForm changeTime s: ${s}`);
try {
await systemTiem.setTime(s);
await systemTime.setTime(s);
console.info(`FMS_deleteForm set time success: ${formatTime}`);
} catch (error) {
console.info(`FMS_deleteForm set time failure: ${error}`);
......
......@@ -15,6 +15,11 @@
import formHost from '@ohos.application.formHost';
import { describe, expect, it } from 'deccjsunit/index';
import FormInfo from '@ohos.application.formInfo';
function sleep(time) {
return new Promise((resolve)=>setTimeout(resolve,time));
}
export const getAllFormsInfoTest = (describeName, filterParameter) => {
const ERR_OK_CODE = 0;
......@@ -23,48 +28,8 @@ export const getAllFormsInfoTest = (describeName, filterParameter) => {
describe(`${describeName}`, () => {
const callbackName = `FMS_getFormsInfo_0500 callback`;
const promiseName = `FMS_getFormsInfo_0500 promise`;
const expectDataB = {
bundleName: 'com.ohos.st.formsystemproviderb',
moduleName: 'form_module_b',
abilityName: 'com.ohos.st.formsystemproviderb.MainAbility',
name: 'FormB_Js001',
description: 'form_description_FormB_Js001',
descriptionId: 20,
type: 1,
jsComponentName: 'card_b',
colorMode: -1,
isDefault: 1,
updateEnabled: 1,
formVisibleNotify: 1,
formConfigAbility: 'abilityb',
updateDuration: 3,
scheduledUpdateTime: '10:30',
defaultDimension: 2,
supportDimensions: [1, 2],
metaData: { customizeData: [{ name: 'originWidgetNameB', value: 'valueB' }] },
};
const expectDataC = {
bundleName: 'com.ohos.st.formsystemproviderc',
moduleName: 'form_module_c',
abilityName: 'com.ohos.st.formsystemproviderc.MainAbility',
name: 'FormC_Js001',
description: 'form_description_FormC_Js001',
descriptionId: 30,
type: 1,
jsComponentName: 'card_c',
colorMode: 1,
isDefault: 1,
updateEnabled: 1,
formVisibleNotify: 1,
formConfigAbility: 'abilityc',
updateDuration: 4,
scheduledUpdateTime: '15:30',
defaultDimension: 3,
supportDimensions: [3, 4],
metaData: { customizeData: [{ name: 'originWidgetNameC', value: 'valueC' }] },
};
var tempDataB = undefined;
var tempDataC = undefined;
/**
* @tc.name: getFormsInfo
......@@ -92,13 +57,17 @@ export const getAllFormsInfoTest = (describeName, filterParameter) => {
expect(dataB.length).assertEqual(1);
expect(dataC.length).assertEqual(1);
expect(JSON.stringify(dataB[0])).assertEqual(JSON.stringify(expectDataB));
expect(JSON.stringify(dataC[0])).assertEqual(JSON.stringify(expectDataC));
tempDataB = dataB[0];
tempDataC = dataC[0];
expect(error.code).assertEqual(ERR_OK_CODE);
expect(error.message).assertEqual(ERR_OK);
done();
console.log(`==========${callbackName} ${describeName} end==========`);
});
await sleep(2000)
checkDataB(tempDataB)
checkDataC(tempDataC)
} catch (error) {
console.log(`${callbackName} exception caught: ${JSON.stringify(error)})`);
console.log(`${callbackName} should not reach here`);
......@@ -132,8 +101,9 @@ export const getAllFormsInfoTest = (describeName, filterParameter) => {
expect(dataB.length).assertEqual(1);
expect(dataC.length).assertEqual(1);
expect(JSON.stringify(dataB[0])).assertEqual(JSON.stringify(expectDataB));
expect(JSON.stringify(dataC[0])).assertEqual(JSON.stringify(expectDataC));
tempDataB = dataB[0];
tempDataC = dataC[0];
done();
console.log(`==========${promiseName} ${describeName} end==========`);
} catch (error) {
......@@ -142,5 +112,49 @@ export const getAllFormsInfoTest = (describeName, filterParameter) => {
expect().assertFail();
}
});
function checkDataB(formInfo){
expect("com.ohos.st.formsystemproviderb").assertEqual(formInfo.bundleName)
expect("form_module_b").assertEqual(formInfo.moduleName)
expect("com.ohos.st.formsystemproviderb.MainAbility").assertEqual(formInfo.abilityName)
expect("FormB_Js001").assertEqual(formInfo.name)
expect("form_description_FormB_Js001").assertEqual(formInfo.description)
expect(FormInfo.FormType.JS).assertEqual(formInfo.type)
expect('card_b').assertEqual(formInfo.jsComponentName)
expect(FormInfo.ColorMode.MODE_AUTO).assertEqual(formInfo.colorMode)
expect(1).assertEqual(formInfo.isDefault)
expect(1).assertEqual(formInfo.updateEnabled)
expect(1).assertEqual(formInfo.formVisibleNotify)
expect(undefined).assertEqual(formInfo.relatedBundleName)
expect("abilityb").assertEqual(formInfo.formConfigAbility)
expect(3).assertEqual(formInfo.updateDuration)
expect(2).assertEqual(formInfo.defaultDimension)
expect('10:30').assertEqual(formInfo.scheduledUpdateTime)
expect(1).assertEqual(formInfo.supportDimensions[0])
expect(2).assertEqual(formInfo.supportDimensions[1])
expect('originWidgetNameB').assertEqual(formInfo.metaData.customizeData[0].name)
expect('valueB').assertEqual(formInfo.metaData.customizeData[0].value)
}
function checkDataC(formInfo){
expect("com.ohos.st.formsystemproviderc").assertEqual(formInfo.bundleName)
expect("form_module_c").assertEqual(formInfo.moduleName)
expect("com.ohos.st.formsystemproviderc.MainAbility").assertEqual(formInfo.abilityName)
expect("FormC_Js001").assertEqual(formInfo.name)
expect("form_description_FormC_Js001").assertEqual(formInfo.description)
expect(FormInfo.FormType.JS).assertEqual(formInfo.type)
expect('card_c').assertEqual(formInfo.jsComponentName)
expect(FormInfo.ColorMode.MODE_LIGHT).assertEqual(formInfo.colorMode)
expect(1).assertEqual(formInfo.isDefault)
expect(1).assertEqual(formInfo.updateEnabled)
expect(1).assertEqual(formInfo.formVisibleNotify)
expect(undefined).assertEqual(formInfo.relatedBundleName)
expect("abilityc").assertEqual(formInfo.formConfigAbility)
expect(4).assertEqual(formInfo.updateDuration)
expect('15:30').assertEqual(formInfo.scheduledUpdateTime)
expect(3).assertEqual(formInfo.defaultDimension)
expect(3).assertEqual(formInfo.supportDimensions[0])
expect(4).assertEqual(formInfo.supportDimensions[1])
expect('originWidgetNameC').assertEqual(formInfo.metaData.customizeData[0].name)
expect('valueC').assertEqual(formInfo.metaData.customizeData[0].value)
}
});
};
......@@ -15,6 +15,7 @@
import formHost from '@ohos.application.formHost';
import { describe, expect, it } from 'deccjsunit/index';
import FormInfo from '@ohos.application.formInfo';
export const getFormsInfoTest = (describeName, filterParameter) => {
const ERR_OK_CODE = 0;
......@@ -23,6 +24,9 @@ export const getFormsInfoTest = (describeName, filterParameter) => {
const ERR_GET_BUNDLE_FAILED = `failed to obtain the bundle information`;
const ERR_ADD_INVALID_PARAM_CODE = 7;
const ERR_ADD_INVALID_PARAM = `invalid input parameter during form operation`;
function sleep(time) {
return new Promise((resolve)=>setTimeout(resolve,time));
}
describe(`${describeName}`, () => {
const callbackName = `FMS_getFormsInfo_0900 callback`;
......@@ -130,27 +134,7 @@ export const getFormsInfoTest = (describeName, filterParameter) => {
const callbackName = `FMS_getFormsInfo_1100 callback`;
const promiseName = `FMS_getFormsInfo_1100 promise`;
const bundleName = `com.ohos.st.formsystemproviderb`;
const expectDataB = {
bundleName: 'com.ohos.st.formsystemproviderb',
moduleName: 'form_module_b',
abilityName: 'com.ohos.st.formsystemproviderb.MainAbility',
name: 'FormB_Js001',
description: 'form_description_FormB_Js001',
descriptionId: 20,
type: 1,
jsComponentName: 'card_b',
colorMode: -1,
isDefault: 1,
updateEnabled: 1,
formVisibleNotify: 1,
formConfigAbility: 'abilityb',
updateDuration: 3,
scheduledUpdateTime: '10:30',
defaultDimension: 2,
supportDimensions: [1, 2],
metaData: { customizeData: [{ name: 'originWidgetNameB', value: 'valueB' }] },
};
var tempDataB = undefined;
/**
* @tc.name: getFormsInfo
......@@ -173,12 +157,15 @@ export const getFormsInfoTest = (describeName, filterParameter) => {
expect(data.length).assertEqual(1);
expect(dataB.length).assertEqual(1);
expect(JSON.stringify(dataB[0])).assertEqual(JSON.stringify(expectDataB));
tempDataB = dataB[0]
expect(error.code).assertEqual(ERR_OK_CODE);
expect(error.message).assertEqual(ERR_OK);
done();
console.log(`==========${callbackName} ${describeName} end==========`);
});
await sleep(2000)
checkDataB(tempDataB)
done()
} catch (error) {
console.log(`${callbackName} exception caught: ${JSON.stringify(error)})`);
console.log(`${callbackName} should not reach here`);
......@@ -207,7 +194,8 @@ export const getFormsInfoTest = (describeName, filterParameter) => {
expect(data.length).assertEqual(1);
expect(dataB.length).assertEqual(1);
expect(JSON.stringify(dataB[0])).assertEqual(JSON.stringify(expectDataB));
tempDataB = dataB[0]
checkDataB(tempDataB)
done();
console.log(`==========${promiseName} ${describeName} end==========`);
} catch (error) {
......@@ -216,6 +204,28 @@ export const getFormsInfoTest = (describeName, filterParameter) => {
expect().assertFail();
}
});
function checkDataB(formInfo){
expect("com.ohos.st.formsystemproviderb").assertEqual(formInfo.bundleName)
expect("form_module_b").assertEqual(formInfo.moduleName)
expect("com.ohos.st.formsystemproviderb.MainAbility").assertEqual(formInfo.abilityName)
expect("FormB_Js001").assertEqual(formInfo.name)
expect("form_description_FormB_Js001").assertEqual(formInfo.description)
expect(FormInfo.FormType.JS).assertEqual(formInfo.type)
expect('card_b').assertEqual(formInfo.jsComponentName)
expect(FormInfo.ColorMode.MODE_AUTO).assertEqual(formInfo.colorMode)
expect(1).assertEqual(formInfo.isDefault)
expect(1).assertEqual(formInfo.updateEnabled)
expect(1).assertEqual(formInfo.formVisibleNotify)
expect(undefined).assertEqual(formInfo.relatedBundleName)
expect("abilityb").assertEqual(formInfo.formConfigAbility)
expect(3).assertEqual(formInfo.updateDuration)
expect(2).assertEqual(formInfo.defaultDimension)
expect('10:30').assertEqual(formInfo.scheduledUpdateTime)
expect(1).assertEqual(formInfo.supportDimensions[0])
expect(2).assertEqual(formInfo.supportDimensions[1])
expect('originWidgetNameB').assertEqual(formInfo.metaData.customizeData[0].name)
expect('valueB').assertEqual(formInfo.metaData.customizeData[0].value)
}
});
describe(`${describeName}`, () => {
......@@ -431,6 +441,7 @@ export const getFormsInfoTest = (describeName, filterParameter) => {
const promiseName = `FMS_getFormsInfo_1800 promise`;
const bundleName = `com.ohos.st.formsystemproviderc`;
const moduleName = `form_module_c`;
var tempDataC = undefined;
const expectDataC = {
bundleName: 'com.ohos.st.formsystemproviderc',
......@@ -444,6 +455,8 @@ export const getFormsInfoTest = (describeName, filterParameter) => {
colorMode: 1,
isDefault: 1,
updateEnabled: 1,
isStatic:true,
window:{"autoDesignWidth":false,"designWidth":720},
formVisibleNotify: 1,
formConfigAbility: 'abilityc',
updateDuration: 4,
......@@ -471,15 +484,18 @@ export const getFormsInfoTest = (describeName, filterParameter) => {
});
console.log(`${callbackName} form dataC: ${JSON.stringify(dataC)}`);
console.log(`${callbackName} formC amount: ${dataC.length}`);
tempDataC = dataC[0];
expect(data.length).assertEqual(1);
expect(dataC.length).assertEqual(1);
expect(JSON.stringify(dataC[0])).assertEqual(JSON.stringify(expectDataC));
//expect(JSON.stringify(dataC[0])).assertEqual(JSON.stringify(expectDataC));
expect(error.code).assertEqual(ERR_OK_CODE);
expect(error.message).assertEqual(ERR_OK);
done();
console.log(`==========${callbackName} ${describeName} end==========`);
});
await sleep(2000)
checkDataC(tempDataC)
tempDataC = undefined;
done();
} catch (error) {
console.log(`${callbackName} exception caught: ${JSON.stringify(error)})`);
console.log(`${callbackName} should not reach here`);
......@@ -508,14 +524,38 @@ export const getFormsInfoTest = (describeName, filterParameter) => {
expect(data.length).assertEqual(1);
expect(dataC.length).assertEqual(1);
expect(JSON.stringify(dataC[0])).assertEqual(JSON.stringify(expectDataC));
done();
//expect(JSON.stringify(dataC[0])).assertEqual(JSON.stringify(expectDataC));
tempDataC = dataC[0];
console.log(`==========${promiseName} ${describeName} end==========`);
checkDataC(tempDataC)
done()
} catch (error) {
console.log(`${promiseName} exception caught: ${JSON.stringify(error)})`);
console.log(`${promiseName} should not reach here`);
expect().assertFail();
}
});
function checkDataC(formInfo){
expect("com.ohos.st.formsystemproviderc").assertEqual(formInfo.bundleName)
expect("form_module_c").assertEqual(formInfo.moduleName)
expect("com.ohos.st.formsystemproviderc.MainAbility").assertEqual(formInfo.abilityName)
expect("FormC_Js001").assertEqual(formInfo.name)
expect("form_description_FormC_Js001").assertEqual(formInfo.description)
expect(FormInfo.FormType.JS).assertEqual(formInfo.type)
expect('card_c').assertEqual(formInfo.jsComponentName)
expect(FormInfo.ColorMode.MODE_LIGHT).assertEqual(formInfo.colorMode)
expect(1).assertEqual(formInfo.isDefault)
expect(1).assertEqual(formInfo.updateEnabled)
expect(1).assertEqual(formInfo.formVisibleNotify)
expect(undefined).assertEqual(formInfo.relatedBundleName)
expect("abilityc").assertEqual(formInfo.formConfigAbility)
expect(4).assertEqual(formInfo.updateDuration)
expect(3).assertEqual(formInfo.defaultDimension)
expect(3).assertEqual(formInfo.supportDimensions[0])
expect(4).assertEqual(formInfo.supportDimensions[1])
expect('originWidgetNameC').assertEqual(formInfo.metaData.customizeData[0].name)
expect('valueC').assertEqual(formInfo.metaData.customizeData[0].value)
}
});
};
......@@ -15,7 +15,12 @@
import formHost from '@ohos.application.formHost';
import { describe, expect, it } from 'deccjsunit/index';
import FormInfo from '@ohos.application.formInfo';
function sleep(time) {
return new Promise((resolve)=>setTimeout(resolve,time));
}
export const getAllFormsInfoTest = (describeName, filterParameter) => {
const ERR_OK_CODE = 0;
const ERR_OK = `success`;
......@@ -23,69 +28,9 @@ export const getAllFormsInfoTest = (describeName, filterParameter) => {
describe(`${describeName}`, () => {
const callbackName = `FMS_getFormsInfo_0600 callback`;
const promiseName = `FMS_getFormsInfo_0600 promise`;
const expectDataA01 = {
bundleName: 'com.ohos.st.formsystemprovidera',
moduleName: 'form_module_a',
abilityName: 'com.ohos.st.formsystemprovidera.MainAbility',
name: 'FormA_Js001',
description: 'form_description_FormA_Js001',
descriptionId: 0,
type: 1,
jsComponentName: 'card_a01',
colorMode: 0,
isDefault: 1,
updateEnabled: 1,
formVisibleNotify: 1,
formConfigAbility: 'abilitya01',
updateDuration: 1,
scheduledUpdateTime: '5:30',
defaultDimension: 1,
supportDimensions: [1, 3],
metaData: { customizeData: [{ name: 'originWidgetNameA01', value: 'valueA01' }] },
};
const expectDataA02 = {
bundleName: 'com.ohos.st.formsystemprovidera',
moduleName: 'form_module_a',
abilityName: 'com.ohos.st.formsystemprovidera.MainAbility',
name: 'FormA_Js002',
description: 'form_description_FormA_Js002',
descriptionId: 10,
type: 1,
jsComponentName: 'card_a02',
colorMode: 1,
isDefault: 0,
updateEnabled: 0,
formVisibleNotify: 0,
formConfigAbility: 'abilitya02',
updateDuration: 2,
scheduledUpdateTime: '20:30',
defaultDimension: 4,
supportDimensions: [1, 2, 3, 4],
metaData: { customizeData: [{ name: 'originWidgetNameA02', value: 'valueA02' }] },
};
const expectDataB = {
bundleName: 'com.ohos.st.formsystemproviderb',
moduleName: 'form_module_b',
abilityName: 'com.ohos.st.formsystemproviderb.MainAbility',
name: 'FormB_Js001',
description: 'form_description_FormB_Js001',
descriptionId: 20,
type: 1,
jsComponentName: 'card_b',
colorMode: -1,
isDefault: 1,
updateEnabled: 1,
formVisibleNotify: 1,
formConfigAbility: 'abilityb',
updateDuration: 3,
scheduledUpdateTime: '10:30',
defaultDimension: 2,
supportDimensions: [1, 2],
metaData: { customizeData: [{ name: 'originWidgetNameB', value: 'valueB' }] },
};
var tempDataA1 = undefined;
var tempDataA2 = undefined;
var tempDataB = undefined;
/**
* @tc.name: getFormsInfo
......@@ -113,14 +58,18 @@ export const getAllFormsInfoTest = (describeName, filterParameter) => {
expect(dataA.length).assertEqual(2);
expect(dataB.length).assertEqual(1);
expect(JSON.stringify(dataA[0])).assertEqual(JSON.stringify(expectDataA01));
expect(JSON.stringify(dataA[1])).assertEqual(JSON.stringify(expectDataA02));
expect(JSON.stringify(dataB[0])).assertEqual(JSON.stringify(expectDataB));
tempDataA1 = dataA[0]
tempDataA2 = dataA[1]
tempDataB = dataB[0]
expect(error.code).assertEqual(ERR_OK_CODE);
expect(error.message).assertEqual(ERR_OK);
done();
console.log(`==========${callbackName} ${describeName} end==========`);
});
await sleep(2000)
checkDataA1(tempDataA1)
checkDataA2(tempDataA2)
checkDataB(tempDataB)
done()
} catch (error) {
console.log(`${callbackName} exception caught: ${JSON.stringify(error)})`);
console.log(`${callbackName} should not reach here`);
......@@ -154,9 +103,12 @@ export const getAllFormsInfoTest = (describeName, filterParameter) => {
expect(dataA.length).assertEqual(2);
expect(dataB.length).assertEqual(1);
expect(JSON.stringify(dataA[0])).assertEqual(JSON.stringify(expectDataA01));
expect(JSON.stringify(dataA[1])).assertEqual(JSON.stringify(expectDataA02));
expect(JSON.stringify(dataB[0])).assertEqual(JSON.stringify(expectDataB));
tempDataA1 = dataA[0]
tempDataA2 = dataA[1]
tempDataB = dataB[0]
checkDataA1(tempDataA1)
checkDataA2(tempDataA2)
checkDataB(tempDataB)
done();
console.log(`==========${promiseName} ${describeName} end==========`);
} catch (error) {
......@@ -165,5 +117,76 @@ export const getAllFormsInfoTest = (describeName, filterParameter) => {
expect().assertFail();
}
});
function checkDataB(formInfo){
expect("com.ohos.st.formsystemproviderb").assertEqual(formInfo.bundleName)
expect("form_module_b").assertEqual(formInfo.moduleName)
expect("com.ohos.st.formsystemproviderb.MainAbility").assertEqual(formInfo.abilityName)
expect("FormB_Js001").assertEqual(formInfo.name)
expect("form_description_FormB_Js001").assertEqual(formInfo.description)
expect(FormInfo.FormType.JS).assertEqual(formInfo.type)
expect('card_b').assertEqual(formInfo.jsComponentName)
expect(FormInfo.ColorMode.MODE_AUTO).assertEqual(formInfo.colorMode)
expect(1).assertEqual(formInfo.isDefault)
expect(1).assertEqual(formInfo.updateEnabled)
expect(1).assertEqual(formInfo.formVisibleNotify)
expect(undefined).assertEqual(formInfo.relatedBundleName)
expect("abilityb").assertEqual(formInfo.formConfigAbility)
expect(3).assertEqual(formInfo.updateDuration)
expect(2).assertEqual(formInfo.defaultDimension)
expect('10:30').assertEqual(formInfo.scheduledUpdateTime)
expect(1).assertEqual(formInfo.supportDimensions[0])
expect(2).assertEqual(formInfo.supportDimensions[1])
expect('originWidgetNameB').assertEqual(formInfo.metaData.customizeData[0].name)
expect('valueB').assertEqual(formInfo.metaData.customizeData[0].value)
}
function checkDataA1(formInfo){
expect("com.ohos.st.formsystemprovidera").assertEqual(formInfo.bundleName)
expect("form_module_a").assertEqual(formInfo.moduleName)
expect("com.ohos.st.formsystemprovidera.MainAbility").assertEqual(formInfo.abilityName)
expect("FormA_Js001").assertEqual(formInfo.name)
expect("form_description_FormA_Js001").assertEqual(formInfo.description)
expect(FormInfo.FormType.JS).assertEqual(formInfo.type)
expect('card_a01').assertEqual(formInfo.jsComponentName)
expect(FormInfo.ColorMode.MODE_DARK).assertEqual(formInfo.colorMode)
expect(1).assertEqual(formInfo.isDefault)
expect(1).assertEqual(formInfo.updateEnabled)
expect(1).assertEqual(formInfo.formVisibleNotify)
expect(undefined).assertEqual(formInfo.relatedBundleName)
expect("abilitya01").assertEqual(formInfo.formConfigAbility)
expect(1).assertEqual(formInfo.updateDuration)
expect(1).assertEqual(formInfo.defaultDimension)
expect('5:30').assertEqual(formInfo.scheduledUpdateTime)
expect(1).assertEqual(formInfo.supportDimensions[0])
expect(3).assertEqual(formInfo.supportDimensions[1])
expect('originWidgetNameA01').assertEqual(formInfo.metaData.customizeData[0].name)
expect('valueA01').assertEqual(formInfo.metaData.customizeData[0].value)
}
function checkDataA2(formInfo){
expect("com.ohos.st.formsystemprovidera").assertEqual(formInfo.bundleName)
expect("form_module_a").assertEqual(formInfo.moduleName)
expect("com.ohos.st.formsystemprovidera.MainAbility").assertEqual(formInfo.abilityName)
expect("FormA_Js002").assertEqual(formInfo.name)
expect("form_description_FormA_Js002").assertEqual(formInfo.description)
expect(FormInfo.FormType.JS).assertEqual(formInfo.type)
expect('card_a02').assertEqual(formInfo.jsComponentName)
expect(FormInfo.ColorMode.MODE_LIGHT).assertEqual(formInfo.colorMode)
expect(0).assertEqual(formInfo.isDefault)
expect(0).assertEqual(formInfo.updateEnabled)
expect(0).assertEqual(formInfo.formVisibleNotify)
expect(undefined).assertEqual(formInfo.relatedBundleName)
expect("abilitya02").assertEqual(formInfo.formConfigAbility)
expect(2).assertEqual(formInfo.updateDuration)
expect(4).assertEqual(formInfo.defaultDimension)
expect('20:30').assertEqual(formInfo.scheduledUpdateTime)
expect(1).assertEqual(formInfo.supportDimensions[0])
expect(2).assertEqual(formInfo.supportDimensions[1])
expect(3).assertEqual(formInfo.supportDimensions[2])
expect(4).assertEqual(formInfo.supportDimensions[3])
expect('originWidgetNameA02').assertEqual(formInfo.metaData.customizeData[0].name)
expect('valueA02').assertEqual(formInfo.metaData.customizeData[0].value)
}
});
};
......@@ -15,6 +15,7 @@
import formHost from '@ohos.application.formHost';
import { describe, expect, it } from 'deccjsunit/index';
import FormInfo from '@ohos.application.formInfo';
export const getAllFormsInfoTest = (describeName, filterParameter) => {
const ERR_OK_CODE = 0;
......@@ -23,27 +24,7 @@ export const getAllFormsInfoTest = (describeName, filterParameter) => {
describe(`${describeName}`, () => {
const callbackName = `FMS_getFormsInfo_0400 callback`;
const promiseName = `FMS_getFormsInfo_0400 promise`;
const expectDataB = {
bundleName: 'com.ohos.st.formsystemproviderb',
moduleName: 'form_module_b',
abilityName: 'com.ohos.st.formsystemproviderb.MainAbility',
name: 'FormB_Js001',
description: 'form_description_FormB_Js001',
descriptionId: 20,
type: 1,
jsComponentName: 'card_b',
colorMode: -1,
isDefault: 1,
updateEnabled: 1,
formVisibleNotify: 1,
formConfigAbility: 'abilityb',
updateDuration: 3,
scheduledUpdateTime: '10:30',
defaultDimension: 2,
supportDimensions: [1, 2],
metaData: { customizeData: [{ name: 'originWidgetNameB', value: 'valueB' }] },
};
var tempDataB = undefined;
/**
* @tc.name: getFormsInfo
......@@ -71,13 +52,15 @@ export const getAllFormsInfoTest = (describeName, filterParameter) => {
expect(dataB.length).assertEqual(1);
expect(dataD.length).assertEqual(0);
expect(JSON.stringify(dataB[0])).assertEqual(JSON.stringify(expectDataB));
tempDataB = dataB[0]
expect(JSON.stringify(dataD)).assertEqual(`[]`);
expect(error.code).assertEqual(ERR_OK_CODE);
expect(error.message).assertEqual(ERR_OK);
done();
console.log(`==========${callbackName} ${describeName} end==========`);
});
await sleep(2000)
checkDataB(tempDataB)
done()
} catch (error) {
console.log(`${callbackName} exception caught: ${JSON.stringify(error)})`);
console.log(`${callbackName} should not reach here`);
......@@ -111,7 +94,8 @@ export const getAllFormsInfoTest = (describeName, filterParameter) => {
expect(dataB.length).assertEqual(1);
expect(dataD.length).assertEqual(0);
expect(JSON.stringify(dataB[0])).assertEqual(JSON.stringify(expectDataB));
tempDataB = dataB[0]
checkDataB(tempDataB)
expect(JSON.stringify(dataD)).assertEqual(`[]`);
done();
console.log(`==========${promiseName} ${describeName} end==========`);
......@@ -121,5 +105,27 @@ export const getAllFormsInfoTest = (describeName, filterParameter) => {
expect().assertFail();
}
});
function checkDataB(formInfo){
expect("com.ohos.st.formsystemproviderb").assertEqual(formInfo.bundleName)
expect("form_module_b").assertEqual(formInfo.moduleName)
expect("com.ohos.st.formsystemproviderb.MainAbility").assertEqual(formInfo.abilityName)
expect("FormB_Js001").assertEqual(formInfo.name)
expect("form_description_FormB_Js001").assertEqual(formInfo.description)
expect(FormInfo.FormType.JS).assertEqual(formInfo.type)
expect('card_b').assertEqual(formInfo.jsComponentName)
expect(FormInfo.ColorMode.MODE_AUTO).assertEqual(formInfo.colorMode)
expect(1).assertEqual(formInfo.isDefault)
expect(1).assertEqual(formInfo.updateEnabled)
expect(1).assertEqual(formInfo.formVisibleNotify)
expect(undefined).assertEqual(formInfo.relatedBundleName)
expect("abilityb").assertEqual(formInfo.formConfigAbility)
expect(3).assertEqual(formInfo.updateDuration)
expect(2).assertEqual(formInfo.defaultDimension)
expect('10:30').assertEqual(formInfo.scheduledUpdateTime)
expect(1).assertEqual(formInfo.supportDimensions[0])
expect(2).assertEqual(formInfo.supportDimensions[1])
expect('originWidgetNameB').assertEqual(formInfo.metaData.customizeData[0].name)
expect('valueB').assertEqual(formInfo.metaData.customizeData[0].value)
}
});
};
......@@ -14,7 +14,7 @@
*/
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index"
import appManager from '@ohos.application.AppManager';
import appManager from '@ohos.application.appManager';
import osaccount from '@ohos.account.osAccount'
const NULL_ACCOUNT_ID = 102;
......
......@@ -636,374 +636,5 @@ export default function abilityTest(abilityContext) {
done();
}
})
/*
* @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 globalThis.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 globalThis.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 globalThis.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 globalThis.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 globalThis.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 globalThis.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 globalThis.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"
};
globalThis.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/entry_test/cache").assertEqual(globalThis.AbilityContext.cacheDir)
expect("/data/storage/el2/base/haps/entry_test/temp").assertEqual(globalThis.AbilityContext.tempDir)
expect("/data/storage/el2/base/haps/entry_test/files").assertEqual(globalThis.AbilityContext.filesDir)
expect("/data/storage/el2/database/entry_test").assertEqual(globalThis.AbilityContext.databaseDir)
expect("/data/storage/el2/base/haps/entry_test/preferences").assertEqual(globalThis.AbilityContext.preferencesDir)
expect("/data/storage/el1/bundle").assertEqual(globalThis.AbilityContext.bundleCodeDir)
expect("/data/storage/el2/distributedfiles").assertEqual(globalThis.AbilityContext.distributedFilesDir)
expect(1).assertEqual(globalThis.AbilityContext.area)
globalThis.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 = globalThis.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
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册