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

!4493 Adapt to the new framework_part23

Merge pull request !4493 from jiyong/local-20220722-0002
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
# distributed under the License is distributed on an "AS IS" BASIS, # distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import("//test/xts/tools/build/suite.gni") import("//test/xts/tools/build/suite.gni")
......
...@@ -9,13 +9,13 @@ ...@@ -9,13 +9,13 @@
# distributed under the License is distributed on an "AS IS" BASIS, # distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import("//test/xts/tools/build/suite.gni") import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsServiceAbilityClientTest") { ohos_js_hap_suite("ActsServiceAbilityClientTest") {
hap_name = "ActsServiceAbilityClientTest" hap_name = "ActsServiceAbilityClientTest"
hap_profile = "./entry/src/main/config.json" hap_profile = "./src/main/config.json"
deps = [ deps = [
":hjs_demo_js_assets", ":hjs_demo_js_assets",
":hjs_demo_resources", ":hjs_demo_resources",
...@@ -23,9 +23,11 @@ ohos_js_hap_suite("ActsServiceAbilityClientTest") { ...@@ -23,9 +23,11 @@ ohos_js_hap_suite("ActsServiceAbilityClientTest") {
certificate_profile = "./signature/openharmony_sx.p7b" certificate_profile = "./signature/openharmony_sx.p7b"
} }
ohos_js_assets("hjs_demo_js_assets") { ohos_js_assets("hjs_demo_js_assets") {
source_dir = "./entry/src/main/js/default" js2abc = true
hap_profile = "./src/main/config.json"
source_dir = "./src/main/js"
} }
ohos_resources("hjs_demo_resources") { ohos_resources("hjs_demo_resources") {
sources = [ "./entry/src/main/js/resources" ] sources = [ "./src/main/resources" ]
hap_profile = "./entry/src/main/config.json" hap_profile = "./src/main/config.json"
} }
{ {
"description": "Configuration for hjunit demo Tests", "description": "Configuration for hjunit demo Tests",
"driver": { "driver": {
"type": "JSUnitTest", "type": "OHJSUnitTest",
"test-timeout": "180000", "test-timeout": "600000",
"package": "com.amsst.stserviceabilityclient", "bundle-name": "com.amsst.stserviceabilityclient",
"shell-timeout": "60000" "package-name": "com.amsst.stserviceabilityclient",
}, "shell-timeout": "600000",
"kits": [ "testcase-timeout": 30000
{ },
"test-file-name": [ "kits": [
"ActsServiceAbilityClientTest.hap", {
"ActsServiceAbilityServerRelyHap.hap", "test-file-name": [
"ActsServiceAbilityServerSecondRelyHap.hap" "ActsServiceAbilityClientTest.hap",
], "ActsServiceAbilityServerRelyHap.hap",
"type": "AppInstallKit", "ActsServiceAbilityServerSecondRelyHap.hap"
"cleanup-apps": true ],
} "type": "AppInstallKit",
] "cleanup-apps": true
} }
]
}
{ {
"app": { "app": {
"bundleName": "com.amsst.stserviceabilityclient", "bundleName": "com.amsst.stserviceabilityclient",
"vendor": "amsst", "vendor": "amsst",
"version": { "version": {
"code": 1, "code": 1,
"name": "1.0" "name": "1.0"
}, },
"apiVersion": { "apiVersion": {
"compatible": 4, "compatible": 4,
"target": 5, "target": 5,
"releaseType": "Beta1" "releaseType": "Beta1"
} }
}, },
"deviceConfig": {}, "deviceConfig": {},
"module": { "module": {
"package": "com.amsst.stserviceabilityclient", "package": "com.amsst.stserviceabilityclient",
"name": ".MyApplication", "name": ".entry",
"deviceType": [ "mainAbility": ".MainAbility",
"phone" "srcPath":"",
], "deviceType": [
"distro": { "phone"
"deliveryWithInstall": true, ],
"moduleName": "entry", "distro": {
"moduleType": "entry" "deliveryWithInstall": true,
}, "moduleName": "entry",
"abilities": [ "moduleType": "entry"
{ },
"skills": [ "abilities": [
{ {
"entities": [ "skills": [
"entity.system.home" {
], "entities": [
"actions": [ "entity.system.home"
"action.system.home" ],
] "actions": [
} "action.system.home"
], ]
"name": "com.amsst.stserviceabilityclient.MainAbility", }
"icon": "$media:icon", ],
"description": "$string:mainability_description", "orientation": "unspecified",
"label": "$string:app_name", "formsEnabled": false,
"type": "page", "name": ".MainAbility",
"launchType": "standard", "srcLanguage": "js",
"visible": true "srcPath": "MainAbility",
} "icon": "$media:icon",
], "description": "$string:MainAbility_desc",
"reqPermissions": [ "label": "$string:MainAbility_label",
{ "type": "page",
"name": "ohos.permission.INSTALL_BUNDLE", "visible": true,
"reason": "need use ohos.permission.INSTALL_BUNDLE" "launchType": "standard"
}, },
{ {
"name":"ohos.permission.GET_BUNDLE_INFO", "orientation": "unspecified",
"reason":"need use ohos.permission.GET_BUNDLE_INFO" "formsEnabled": false,
}, "name": ".TestAbility",
{ "srcLanguage": "js",
"name":"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", "srcPath": "TestAbility",
"reason":"need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" "icon": "$media:icon",
}, "description": "$string:TestAbility_desc",
{ "label": "$string:TestAbility_label",
"name":"ohos.permission.CHANGE_ABILITY_ENABLED_STATE", "type": "page",
"reason":"need use ohos.permission.CHANGE_ABILITY_ENABLED_STATE" "visible": true,
}, "launchType": "standard"
{ }
"name":"ohos.permission.REMOVE_CACHE_FILES", ],
"reason":"need use ohos.permission.REMOVE_CACHE_FILES" "reqPermissions": [
}, {
{ "name": "ohos.permission.INSTALL_BUNDLE",
"name":"ohos.permission.LISTEN_BUNDLE_CHANGE", "reason": "need use ohos.permission.INSTALL_BUNDLE"
"reason":"need use ohos.permission.LISTEN_BUNDLE_CHANGE" },
}, {
{ "name":"ohos.permission.GET_BUNDLE_INFO",
"name":"ohos.permission.MANAGE_LOCAL_ACCOUNTS", "reason":"need use ohos.permission.GET_BUNDLE_INFO"
"reason":"need use ohos.permission.MANAGE_LOCAL_ACCOUNTS" },
} {
], "name":"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED",
"js": [ "reason":"need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
{ },
"pages": [ {
"pages/index/index" "name":"ohos.permission.CHANGE_ABILITY_ENABLED_STATE",
], "reason":"need use ohos.permission.CHANGE_ABILITY_ENABLED_STATE"
"name": "default", },
"window": { {
"designWidth": 720, "name":"ohos.permission.REMOVE_CACHE_FILES",
"autoDesignWidth": false "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.MANAGE_LOCAL_ACCOUNTS",
"reason":"need use ohos.permission.MANAGE_LOCAL_ACCOUNTS"
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
},
{
"pages": [
"pages/index/index"
],
"name": ".TestAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
],
"testRunner": {
"name": "OpenHarmonyTestRunner",
"srcPath": "TestRunner"
}
}
}
\ No newline at end of file
/* /*
* Copyright (c) 2021 Huawei Device Co., Ltd. * Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
export default {
export default { onCreate() {
onCreate() { console.info('AceApplication onCreate');
console.info('AceApplication onCreate'); },
}, onDestroy() {
onDestroy() { console.info('AceApplication onDestroy');
console.info('AceApplication onDestroy'); }
} };
};
.container { .container {
flex-direction: column; flex-direction: column;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
} }
.title { .title {
font-size: 100px; font-size: 100px;
} }
.titleST { .titleST {
font-size: 32px; font-size: 32px;
} }
<div class="container"> <div class="container">
<text class="title"> <text class="title">
{{ $t('strings.hello') }} {{ title }} {{ $t('strings.hello') }} {{ title }}
</text> </text>
<text class="titleST"> <text class="titleST">
StServiceAbilityClient StServiceAbilityClient
</text> </text>
</div> </div>
/* /*
* Copyright (C) 2021 Huawei Device Co., Ltd. * Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import file from '@system.file' import file from '@system.file'
import app from '@system.app' import app from '@system.app'
import {Core, ExpectExtend, ReportExtend} from 'deccjsunit/index' import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
export default { import testsuite from '../../../test/List.test'
data: {
title: "" export default {
}, data: {
onInit() { title: ""
this.title = this.$t('strings.world'); },
}, onInit() {
onShow() { this.title = this.$t('strings.world');
console.info('====onShow finish====<') },
const core = Core.getInstance() onShow() {
const expectExtend = new ExpectExtend({ console.info('====onShow finish====<')
'id': 'extend' var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
}) var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
const reportExtend = new ReportExtend(file) console.info('start run testcase!!!')
core.addService('expect', expectExtend) Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
core.addService('report', reportExtend) },
core.init() onReady() {
const configService = core.getDefaultService('config') },
configService.setConfig(this)
require('../../../test/List.test')
core.execute()
},
onReady() {
},
} }
\ No newline at end of file
/* /*
* Copyright (c) 2021 Huawei Device Co., Ltd. * Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
export default {
onCreate() { export default {
console.info('AceApplication onCreate'); onCreate() {
}, console.info('AceApplication onCreate');
onDestroy() { },
console.info('AceApplication onDestroy'); onDestroy() {
} console.info('AceApplication onDestroy');
}; }
};
{
"strings": {
"hello": "Hello",
"world": "World"
},
"Files": {
}
}
\ No newline at end of file
{
"strings": {
"hello": "您好",
"world": "世界"
},
"Files": {
}
}
\ No newline at end of file
.container {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
left: 0px;
top: 0px;
width: 100%;
height: 100%;
}
.title {
font-size: 60px;
text-align: center;
width: 100%;
height: 40%;
margin: 10px;
}
@media screen and (device-type: phone) and (orientation: landscape) {
.title {
font-size: 60px;
}
}
@media screen and (device-type: tablet) and (orientation: landscape) {
.title {
font-size: 100px;
}
}
\ No newline at end of file
<div class="container"> <div class="container">
<text class="title"> <text class="title">
{{ $t('strings.hello') }} {{ title }} {{ $t('strings.hello') }} {{ title }}
</text> </text>
</div> </div>
/*
* 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 {
data: {
title: ""
},
onInit() {
this.title = this.$t('strings.world');
}
}
/*
* 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 AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
function translateParamsToString(parameters) {
const keySet = new Set([
'-s class', '-s notClass', '-s suite', '-s itName',
'-s level', '-s testType', '-s size', '-s timeout',
'-s package', '-s dryRun'
])
let targetParams = '';
for (const key in parameters) {
if (keySet.has(key)) {
targetParams += ' ' + key + ' ' + parameters[key]
}
}
return targetParams.trim()
}
export default {
onPrepare() {
console.info('OpenHarmonyTestRunner OnPrepare')
},
onRun() {
console.log('OpenHarmonyTestRunner onRun run')
var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.MainAbility'
var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName
cmd += ' ' + translateParamsToString(abilityDelegatorArguments.parameters)
var debug = abilityDelegatorArguments.parameters["-D"]
console.info('debug value : '+debug)
if (debug == 'true')
{
cmd += ' -D'
}
console.info('cmd : '+cmd)
abilityDelegator.executeShellCommand(cmd, (err, data) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
console.info('executeShellCommand : data : ' + data.stdResult);
console.info('executeShellCommand : data : ' + data.exitCode);
})
}
};
/* /*
* Copyright (c) 2021 Huawei Device Co., Ltd. * Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
require('./StServiceAbilityClient.test.js')
\ No newline at end of file import ActsStServiceAbilityTest from './StServiceAbilityClient.test.js'
export default function testsuite() {
ActsStServiceAbilityTest()
}
\ No newline at end of file
{ {
"string": [ "string": [
{ {
"name": "app_name", "name": "app_name",
"value": "StSeAbClient" "value": "StSeAbClient"
}, },
{ {
"name": "mainability_description", "name": "mainability_description",
"value": "JS_Phone_Empty Feature Ability" "value": "JS_Phone_Empty Feature Ability"
} },
] {
"name": "MainAbility_desc",
"value": "description"
},
{
"name": "MainAbility_label",
"value": "label"
},
{
"name": "TestAbility_desc",
"value": "description"
},
{
"name": "TestAbility_label",
"value": "label"
}
]
} }
\ No newline at end of file
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
# distributed under the License is distributed on an "AS IS" BASIS, # distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import("//test/xts/tools/build/suite.gni") import("//test/xts/tools/build/suite.gni")
......
{ {
"app": { "app": {
"bundleName": "com.amsst.stserviceabilityserver", "bundleName": "com.amsst.stserviceabilityserver",
"vendor": "test", "vendor": "test",
"version": { "version": {
"code": 1000110, "code": 1000110,
"name": "1.1.1" "name": "1.1.1"
}, },
"apiVersion": { "apiVersion": {
"compatible": 9, "compatible": 9,
"target": 9 "target": 9
} }
}, },
"deviceConfig": {}, "deviceConfig": {},
"module": { "module": {
"package": "com.amsst.stserviceabilityserver", "package": "com.amsst.stserviceabilityserver",
"name": ".MyApplication", "name": ".MyApplication",
"mainAbility": ".MainAbility", "mainAbility": ".MainAbility",
"srcPath": "", "srcPath": "",
"deviceType": [ "deviceType": [
"phone" "phone"
], ],
"distro": { "distro": {
"deliveryWithInstall": true, "deliveryWithInstall": true,
"moduleName": "entry", "moduleName": "entry",
"moduleType": "entry", "moduleType": "entry",
"installationFree": false "installationFree": false
}, },
"abilities": [ "abilities": [
{ {
"skills": [ "skills": [
{ {
"entities": [ "entities": [
"entity.system.home" "entity.system.home"
], ],
"actions": [ "actions": [
"action.system.home" "action.system.home"
] ]
} }
], ],
"orientation": "unspecified", "orientation": "unspecified",
"visible": true, "visible": true,
"srcPath": "MainAbility", "srcPath": "MainAbility",
"name": ".MainAbility", "name": ".MainAbility",
"srcLanguage": "ets", "srcLanguage": "ets",
"icon": "$media:icon", "icon": "$media:icon",
"description": "$string:description_mainability", "description": "$string:description_mainability",
"formsEnabled": false, "formsEnabled": false,
"label": "$string:entry_MainAbility", "label": "$string:entry_MainAbility",
"type": "page", "type": "page",
"launchType": "standard" "launchType": "standard"
}, },
{ {
"srcPath": "ServiceAbility", "srcPath": "ServiceAbility",
"name": ".ServiceAbility", "name": ".ServiceAbility",
"icon": "$media:icon", "icon": "$media:icon",
"srcLanguage": "ets", "srcLanguage": "ets",
"description": "$string:description_serviceability", "description": "$string:description_serviceability",
"visible": true, "visible": true,
"type": "service" "type": "service"
} }
], ],
"js": [ "js": [
{ {
"mode": { "mode": {
"syntax": "ets", "syntax": "ets",
"type": "pageAbility" "type": "pageAbility"
}, },
"pages": [ "pages": [
"pages/index", "pages/index",
"pages/second" "pages/second"
], ],
"name": ".MainAbility", "name": ".MainAbility",
"window": { "window": {
"designWidth": 720, "designWidth": 720,
"autoDesignWidth": false "autoDesignWidth": false
} }
} }
], ],
"defPermissions": [ "defPermissions": [
{ {
"name": "com.ohos.screenlock.DataAbilityShellProvider.PROVIDER" "name": "com.ohos.screenlock.DataAbilityShellProvider.PROVIDER"
} }
] ]
} }
} }
/* /*
* Copyright (C) 2022 Huawei Device Co., Ltd. * Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import AbilityStage from "@ohos.application.AbilityStage" import AbilityStage from "@ohos.application.AbilityStage"
export default class MyAbilityStage extends AbilityStage { export default class MyAbilityStage extends AbilityStage {
onCreate() { onCreate() {
console.log("MyAbilityStage onCreate"); console.log("MyAbilityStage onCreate");
} }
} }
\ No newline at end of file
/* /*
* Copyright (C) 2022 Huawei Device Co., Ltd. * Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import Ability from '@ohos.application.Ability' import Ability from '@ohos.application.Ability'
export default class MainAbility extends Ability { export default class MainAbility extends Ability {
onCreate(want, launchParam) { onCreate(want, launchParam) {
console.log("jws onCreate"); console.log("jws onCreate");
} }
onDestroy() { onDestroy() {
console.log("jws onDestroy"); console.log("jws onDestroy");
} }
onWindowStageCreate(windowStage) { onWindowStageCreate(windowStage) {
console.log("jws onWindowStageCreate"); console.log("jws onWindowStageCreate");
} }
onWindowStageDestroy() { onWindowStageDestroy() {
console.log("jws onWindowStageDestroy"); console.log("jws onWindowStageDestroy");
} }
onForeground() { onForeground() {
console.log("jws onForeground"); console.log("jws onForeground");
} }
onBackground() { onBackground() {
console.log("jws onBackground"); console.log("jws onBackground");
} }
call(){ call(){
} }
} }
\ No newline at end of file
/* /*
* Copyright (C) 2022 Huawei Device Co., Ltd. * Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
export default { export default {
onCreate() { onCreate() {
console.info('Application onCreate') console.info('Application onCreate')
}, },
onDestroy() { onDestroy() {
console.info('Application onDestroy') console.info('Application onDestroy')
}, },
} }
\ No newline at end of file
/* /*
* Copyright (C) 2022 Huawei Device Co., Ltd. * Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import {Core} from 'deccjsunit/index' import {Core} from 'deccjsunit/index'
@Entry @Entry
@Component @Component
struct Index { struct Index {
aboutToAppear() { aboutToAppear() {
console.info('onShow finish') console.info('onShow finish')
const core = Core.getInstance() const core = Core.getInstance()
core.init() core.init()
const configService = core.getDefaultService('config') const configService = core.getDefaultService('config')
configService.setConfig(this) configService.setConfig(this)
core.execute() core.execute()
} }
build() { build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text('Hello World') Text('Hello World')
.fontSize(50) .fontSize(50)
.fontWeight(FontWeight.Bold) .fontWeight(FontWeight.Bold)
} }
.width('100%') .width('100%')
.height('100%') .height('100%')
} }
} }
\ No newline at end of file
/* /*
* Copyright (C) 2022 Huawei Device Co., Ltd. * Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import router from '@system.router'; import router from '@system.router';
@Entry @Entry
@Component @Component
struct Second { struct Second {
private content: string = "Second Page" private content: string = "Second Page"
build() { build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text(`${this.content}`) Text(`${this.content}`)
.fontSize(50) .fontSize(50)
.fontWeight(FontWeight.Bold) .fontWeight(FontWeight.Bold)
Button() { Button() {
Text('back to index') Text('back to index')
.fontSize(20) .fontSize(20)
.fontWeight(FontWeight.Bold) .fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule) }.type(ButtonType.Capsule)
.margin({ .margin({
top: 20 top: 20
}) })
.backgroundColor('#0D9FFB') .backgroundColor('#0D9FFB')
.onClick(() => { .onClick(() => {
router.back() router.back()
}) })
} }
.width('100%') .width('100%')
.height('100%') .height('100%')
} }
} }
\ No newline at end of file
/* /*
* Copyright (C) 2022 Huawei Device Co., Ltd. * Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import rpc from "@ohos.rpc"; import rpc from "@ohos.rpc";
import particleAbility from '@ohos.ability.particleAbility' import particleAbility from '@ohos.ability.particleAbility'
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
import commonEvent from '@ohos.commonEvent' import commonEvent from '@ohos.commonEvent'
var serversecond_bundleName = "com.amsst.stserviceabilityserversecond"; var serversecond_bundleName = "com.amsst.stserviceabilityserversecond";
var serversecond_abilityName = "com.amsst.stserviceabilityserversecond.ServiceAbility"; var serversecond_abilityName = "com.amsst.stserviceabilityserversecond.ServiceAbility";
var mConnIdJs; var mConnIdJs;
class StubTest extends rpc.RemoteObject { class StubTest extends rpc.RemoteObject {
constructor(des) { constructor(des) {
console.info('ACTS_SerivceAbilityServer ====< des = ' + des); console.info('ACTS_SerivceAbilityServer ====< des = ' + des);
if (typeof des === 'string') { if (typeof des === 'string') {
console.info('ACTS_ super'); console.info('ACTS_ super');
super(des); super(des);
} else { } else {
return null; return null;
} }
} }
onRemoteRequest(code, data, reply, option) { onRemoteRequest(code, data, reply, option) {
if (code === 1) { if (code === 1) {
console.info("ACTS_SerivceAbilityServer ====< onRemoteRequest code = 1"); console.info("ACTS_SerivceAbilityServer ====< onRemoteRequest code = 1");
let token = data.readInterfaceToken(); let token = data.readInterfaceToken();
console.log('ACTS_SerivceAbilityServer ====< onRemoteRequest token:' + token); console.log('ACTS_SerivceAbilityServer ====< onRemoteRequest token:' + token);
let num = data.readInt(); let num = data.readInt();
console.log('ACTS_SerivceAbilityServer ====< onRemoteRequest num:' + num); console.log('ACTS_SerivceAbilityServer ====< onRemoteRequest num:' + num);
this.method(); this.method();
num = num + 777; num = num + 777;
reply.writeInt(num); reply.writeInt(num);
} else { } else {
console.info("ACTS_SerivceAbilityServer ====< onRemoteRequest code not 1"); console.info("ACTS_SerivceAbilityServer ====< onRemoteRequest code not 1");
} }
return true; return true;
} }
method() { method() {
console.log('ACTS_SerivceAbilityServer ====< method called.') console.log('ACTS_SerivceAbilityServer ====< method called.')
} }
} }
export default { export default {
onStart(want) { onStart(want) {
console.debug('ACTS_SerivceAbilityServer 0425 ====>onStart .ts 0851 =' console.debug('ACTS_SerivceAbilityServer 0425 ====>onStart .ts 0851 ='
+ want + " , JSON." + JSON.stringify(want)); + want + " , JSON." + JSON.stringify(want));
commonEvent.publish("ACTS_SerivceAbilityServer_onStart", (err) => { }); commonEvent.publish("ACTS_SerivceAbilityServer_onStart", (err) => { });
}, },
onStop() { onStop() {
console.debug('ACTS_SerivceAbilityServer ====<onStop'); console.debug('ACTS_SerivceAbilityServer ====<onStop');
commonEvent.publish("ACTS_SerivceAbilityServer_onStop", (err) => { }); commonEvent.publish("ACTS_SerivceAbilityServer_onStop", (err) => { });
featureAbility.terminateSelf(); featureAbility.terminateSelf();
}, },
onCommand(want, restart, startId) { onCommand(want, restart, startId) {
console.debug('ACTS_SerivceAbilityServer ====>onCommand=' console.debug('ACTS_SerivceAbilityServer ====>onCommand='
+ "JSON(want)=" + JSON.stringify(want) + "JSON(want)=" + JSON.stringify(want)
+ " ,restart=" + restart + " ,startId=" + startId); + " ,restart=" + restart + " ,startId=" + startId);
if (want.action == 'ServiceStartService_0900') { if (want.action == 'ServiceStartService_0900') {
particleAbility.startAbility( particleAbility.startAbility(
{ {
want: want:
{ {
bundleName: serversecond_bundleName, bundleName: serversecond_bundleName,
abilityName: serversecond_abilityName, abilityName: serversecond_abilityName,
action: "ServiceStartService_0900", action: "ServiceStartService_0900",
}, },
} }
); );
featureAbility.terminateSelf(); featureAbility.terminateSelf();
} else if (want.action == 'ServiceStartService_1000') { } else if (want.action == 'ServiceStartService_1000') {
particleAbility.startAbility( particleAbility.startAbility(
{ {
want: want:
{ {
bundleName: serversecond_bundleName, bundleName: serversecond_bundleName,
abilityName: serversecond_abilityName, abilityName: serversecond_abilityName,
action: "ServiceStartService_1000", action: "ServiceStartService_1000",
}, },
}, (err, data) => { }, (err, data) => {
console.debug('ACTS_SerivceAbilityServer start Ability 1000 callback=====' console.debug('ACTS_SerivceAbilityServer start Ability 1000 callback====='
+ err + ', data= ' + data + " , JSON." + JSON.stringify(data)); + err + ', data= ' + data + " , JSON." + JSON.stringify(data));
featureAbility.terminateSelf(); featureAbility.terminateSelf();
} }
); );
} else { } else {
commonEvent.publish("ACTS_SerivceAbilityServer_onCommand" + "_" + want.action, (err) => { commonEvent.publish("ACTS_SerivceAbilityServer_onCommand" + "_" + want.action, (err) => {
if (!err.code) { if (!err.code) {
if (want.action == 'PageStartService_0100' || want.action == 'PageStartService_0200' if (want.action == 'PageStartService_0100' || want.action == 'PageStartService_0200'
|| want.action == 'PageStartService_0301' || want.action == 'PageStartService_0401') { || want.action == 'PageStartService_0301' || want.action == 'PageStartService_0401') {
console.debug('ACTS_SerivceAbilityServer_onCommand 100 200 301 401.terminateSelf()=====>' console.debug('ACTS_SerivceAbilityServer_onCommand 100 200 301 401.terminateSelf()=====>'
+ want.action); + want.action);
featureAbility.terminateSelf(); featureAbility.terminateSelf();
} }
} else { } else {
console.debug('ACTS_SerivceAbilityServer_onCommand publish err=====>' + err); console.debug('ACTS_SerivceAbilityServer_onCommand publish err=====>' + err);
} }
}); });
} }
}, },
onConnect(want) { onConnect(want) {
console.info('ACTS_SerivceAbilityServer ====< onConnect'); console.info('ACTS_SerivceAbilityServer ====< onConnect');
try { try {
console.debug('ACTS_SerivceAbilityServer ====>onConnect=' console.debug('ACTS_SerivceAbilityServer ====>onConnect='
+ want + " , JSON." + JSON.stringify(want)); + want + " , JSON." + JSON.stringify(want));
function onConnectCallback(element, remote) { function onConnectCallback(element, remote) {
console.debug('ACTS_SerivceAbilityServer_onConnectCallback ====> mConnIdJs=' console.debug('ACTS_SerivceAbilityServer_onConnectCallback ====> mConnIdJs='
+ JSON.stringify(mConnIdJs) + " , " + mConnIdJs); + JSON.stringify(mConnIdJs) + " , " + mConnIdJs);
console.debug('ACTS_SerivceAbilityServer_onConnectCallback ====> element=' console.debug('ACTS_SerivceAbilityServer_onConnectCallback ====> element='
+ JSON.stringify(element) + " , " + element); + JSON.stringify(element) + " , " + element);
console.debug('ACTS_SerivceAbilityServer_onConnectCallback ====> remote=' console.debug('ACTS_SerivceAbilityServer_onConnectCallback ====> remote='
+ JSON.stringify(remote) + " , " + remote); + JSON.stringify(remote) + " , " + remote);
} }
function onDisconnectCallback(element) { function onDisconnectCallback(element) {
console.debug('ACTS_SerivceAbilityServer_onDisconnectCallback ====> element=' console.debug('ACTS_SerivceAbilityServer_onDisconnectCallback ====> element='
+ JSON.stringify(element) + " , " + element); + JSON.stringify(element) + " , " + element);
} }
function onFailedCallback(code) { function onFailedCallback(code) {
console.debug('ACTS_SerivceAbilityServer_onFailedCallback ====> code=' console.debug('ACTS_SerivceAbilityServer_onFailedCallback ====> code='
+ JSON.stringify(code) + " , " + code) + JSON.stringify(code) + " , " + code)
} }
if (want.action == 'ServiceConnectService_1300' || want.action == 'ServiceConnectService_1400' if (want.action == 'ServiceConnectService_1300' || want.action == 'ServiceConnectService_1400'
|| want.action == 'ServiceConnectService_1500' || want.action == 'ServiceConnectService_1600') { || want.action == 'ServiceConnectService_1500' || want.action == 'ServiceConnectService_1600') {
mConnIdJs = particleAbility.connectAbility( mConnIdJs = particleAbility.connectAbility(
{ {
bundleName: serversecond_bundleName, bundleName: serversecond_bundleName,
abilityName: serversecond_abilityName, abilityName: serversecond_abilityName,
action: want.action, action: want.action,
}, },
{ {
onConnect: onConnectCallback, onConnect: onConnectCallback,
onDisconnect: onDisconnectCallback, onDisconnect: onDisconnectCallback,
onFailed: onFailedCallback, onFailed: onFailedCallback,
}, },
) )
} else { } else {
commonEvent.publish("ACTS_SerivceAbilityServer_onConnect" + "_" + want.action, (err) => { }); commonEvent.publish("ACTS_SerivceAbilityServer_onConnect" + "_" + want.action, (err) => { });
} }
} catch (err) { } catch (err) {
console.log("ACTS_SerivceAbilityServer ====< error:" + err) console.log("ACTS_SerivceAbilityServer ====< error:" + err)
} }
console.info('ACTS_SerivceAbilityServer ====< onConnect end'); console.info('ACTS_SerivceAbilityServer ====< onConnect end');
return new StubTest("connect-test"); return new StubTest("connect-test");
}, },
onDisconnect(want) { onDisconnect(want) {
console.debug('ACTS_SerivceAbilityServer ====>onDisConnect=' console.debug('ACTS_SerivceAbilityServer ====>onDisConnect='
+ want + " , JSON." + JSON.stringify(want)); + want + " , JSON." + JSON.stringify(want));
commonEvent.publish("ACTS_SerivceAbilityServer_onDisConnect", (err) => { commonEvent.publish("ACTS_SerivceAbilityServer_onDisConnect", (err) => {
if (err.code) { if (err.code) {
console.debug('ACTS_SerivceAbilityServer_onDisConnect publish err=====>' + err); console.debug('ACTS_SerivceAbilityServer_onDisConnect publish err=====>' + err);
} else { } else {
console.debug('ACTS_SerivceAbilityServer_onDisConnect featureAbility.terminateSelf()=====<' console.debug('ACTS_SerivceAbilityServer_onDisConnect featureAbility.terminateSelf()=====<'
+ want.action); + want.action);
if (want.action == 'ServiceConnectService_1300' || want.action == 'ServiceConnectService_1400' if (want.action == 'ServiceConnectService_1300' || want.action == 'ServiceConnectService_1400'
|| want.action == 'ServiceConnectService_1500' || want.action == 'ServiceConnectService_1501' || want.action == 'ServiceConnectService_1500' || want.action == 'ServiceConnectService_1501'
|| want.action == 'ServiceConnectService_1600' || want.action == 'ServiceConnectService_1601' || want.action == 'ServiceConnectService_1600' || want.action == 'ServiceConnectService_1601'
) { ) {
particleAbility.disconnectAbility(mConnIdJs, (err) => { particleAbility.disconnectAbility(mConnIdJs, (err) => {
console.debug("=ACTS_SerivceAbilityServer_onDisConnect 13 14 15 16 err====>" console.debug("=ACTS_SerivceAbilityServer_onDisConnect 13 14 15 16 err====>"
+ ("json err=") + JSON.stringify(err) + " , " + want.action); + ("json err=") + JSON.stringify(err) + " , " + want.action);
}) })
} }
featureAbility.terminateSelf(); featureAbility.terminateSelf();
} }
}); });
}, },
onReady() { onReady() {
console.debug('ACTS_SerivceAbilityServer ====<onReady'); console.debug('ACTS_SerivceAbilityServer ====<onReady');
}, },
onReconnect(want) { onReconnect(want) {
console.debug('ACTS_SerivceAbilityServer ====>onReconnect=' console.debug('ACTS_SerivceAbilityServer ====>onReconnect='
+ want + " , JSON." + JSON.stringify(want)); + want + " , JSON." + JSON.stringify(want));
commonEvent.publish("ACTS_SerivceAbilityServer_onReconnect" + "_" + want.action, (err) => { }); commonEvent.publish("ACTS_SerivceAbilityServer_onReconnect" + "_" + want.action, (err) => { });
}, },
OnAbilityConnectDone(element, remoteObject, resultCode) { OnAbilityConnectDone(element, remoteObject, resultCode) {
console.debug('ACTS_SerivceAbilityServer ====>OnAbilityConnectDone=' console.debug('ACTS_SerivceAbilityServer ====>OnAbilityConnectDone='
+ element + " , JSON." + JSON.stringify(element) + element + " , JSON." + JSON.stringify(element)
+ remoteObject + " , JSON." + JSON.stringify(remoteObject) + remoteObject + " , JSON." + JSON.stringify(remoteObject)
+ resultCode + " , JSON." + JSON.stringify(resultCode) + resultCode + " , JSON." + JSON.stringify(resultCode)
); );
commonEvent.publish("ACTS_SerivceAbilityServer_OnAbilityConnectDone", (err) => { }); commonEvent.publish("ACTS_SerivceAbilityServer_OnAbilityConnectDone", (err) => { });
}, },
}; };
\ No newline at end of file
{ {
"string": [ "string": [
{ {
"name": "entry_MainAbility", "name": "entry_MainAbility",
"value": "ServiceExtAbility" "value": "ServiceExtAbility"
}, },
{ {
"name": "description_mainability", "name": "description_mainability",
"value": "eTS_Empty Ability" "value": "eTS_Empty Ability"
}, },
{ {
"name": "description_serviceability", "name": "description_serviceability",
"value": "hap sample empty service" "value": "hap sample empty service"
}, },
{ {
"name": "description_dataability", "name": "description_dataability",
"value": "hap sample empty provider" "value": "hap sample empty provider"
}, },
{ {
"name": "description_mainability2", "name": "description_mainability2",
"value": "eTS_Empty Ability" "value": "eTS_Empty Ability"
}, },
{ {
"name": "entry_MainAbility2", "name": "entry_MainAbility2",
"value": "entry_MainAbility2" "value": "entry_MainAbility2"
}, },
{ {
"name": "description_testdataability", "name": "description_testdataability",
"value": "hap sample empty provider" "value": "hap sample empty provider"
}, },
{ {
"name": "permreason_dataability", "name": "permreason_dataability",
"value": "request dataability premission" "value": "request dataability premission"
} }
] ]
} }
\ No newline at end of file
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
# distributed under the License is distributed on an "AS IS" BASIS, # distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import("//test/xts/tools/build/suite.gni") import("//test/xts/tools/build/suite.gni")
......
{ {
"app": { "app": {
"bundleName": "com.amsst.stserviceabilityserversecond", "bundleName": "com.amsst.stserviceabilityserversecond",
"vendor": "test", "vendor": "test",
"version": { "version": {
"code": 1000110, "code": 1000110,
"name": "1.1.1" "name": "1.1.1"
}, },
"apiVersion": { "apiVersion": {
"compatible": 9, "compatible": 9,
"target": 9 "target": 9
} }
}, },
"deviceConfig": {}, "deviceConfig": {},
"module": { "module": {
"package": "com.amsst.stserviceabilityserversecond", "package": "com.amsst.stserviceabilityserversecond",
"name": ".MyApplication", "name": ".MyApplication",
"mainAbility": ".MainAbility", "mainAbility": ".MainAbility",
"srcPath": "", "srcPath": "",
"deviceType": [ "deviceType": [
"phone" "phone"
], ],
"distro": { "distro": {
"deliveryWithInstall": true, "deliveryWithInstall": true,
"moduleName": "entry", "moduleName": "entry",
"moduleType": "entry", "moduleType": "entry",
"installationFree": false "installationFree": false
}, },
"abilities": [ "abilities": [
{ {
"skills": [ "skills": [
{ {
"entities": [ "entities": [
"entity.system.home" "entity.system.home"
], ],
"actions": [ "actions": [
"action.system.home" "action.system.home"
] ]
} }
], ],
"orientation": "unspecified", "orientation": "unspecified",
"visible": true, "visible": true,
"srcPath": "MainAbility", "srcPath": "MainAbility",
"name": ".MainAbility", "name": ".MainAbility",
"srcLanguage": "ets", "srcLanguage": "ets",
"icon": "$media:icon", "icon": "$media:icon",
"description": "$string:description_mainability", "description": "$string:description_mainability",
"formsEnabled": false, "formsEnabled": false,
"label": "$string:entry_MainAbility", "label": "$string:entry_MainAbility",
"type": "page", "type": "page",
"launchType": "standard" "launchType": "standard"
}, },
{ {
"srcPath": "ServiceAbility", "srcPath": "ServiceAbility",
"name": ".ServiceAbility", "name": ".ServiceAbility",
"icon": "$media:icon", "icon": "$media:icon",
"srcLanguage": "ets", "srcLanguage": "ets",
"description": "$string:description_serviceability", "description": "$string:description_serviceability",
"visible": true, "visible": true,
"type": "service" "type": "service"
} }
], ],
"js": [ "js": [
{ {
"mode": { "mode": {
"syntax": "ets", "syntax": "ets",
"type": "pageAbility" "type": "pageAbility"
}, },
"pages": [ "pages": [
"pages/index", "pages/index",
"pages/second" "pages/second"
], ],
"name": ".MainAbility", "name": ".MainAbility",
"window": { "window": {
"designWidth": 720, "designWidth": 720,
"autoDesignWidth": false "autoDesignWidth": false
} }
} }
], ],
"defPermissions": [ "defPermissions": [
{ {
"name": "com.ohos.screenlock.DataAbilityShellProvider.PROVIDER" "name": "com.ohos.screenlock.DataAbilityShellProvider.PROVIDER"
} }
] ]
} }
} }
/* /*
* Copyright (C) 2022 Huawei Device Co., Ltd. * Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import AbilityStage from "@ohos.application.AbilityStage" import AbilityStage from "@ohos.application.AbilityStage"
export default class MyAbilityStage extends AbilityStage { export default class MyAbilityStage extends AbilityStage {
onCreate() { onCreate() {
console.log("MyAbilityStage onCreate"); console.log("MyAbilityStage onCreate");
} }
} }
\ No newline at end of file
import Ability from '@ohos.application.Ability' import Ability from '@ohos.application.Ability'
export default class MainAbility extends Ability { export default class MainAbility extends Ability {
onCreate(want, launchParam) { onCreate(want, launchParam) {
console.log("jws onCreate"); console.log("jws onCreate");
} }
onDestroy() { onDestroy() {
console.log("jws onDestroy"); console.log("jws onDestroy");
} }
onWindowStageCreate(windowStage) { onWindowStageCreate(windowStage) {
console.log("jws onWindowStageCreate"); console.log("jws onWindowStageCreate");
} }
onWindowStageDestroy() { onWindowStageDestroy() {
console.log("jws onWindowStageDestroy"); console.log("jws onWindowStageDestroy");
} }
onForeground() { onForeground() {
console.log("jws onForeground"); console.log("jws onForeground");
} }
onBackground() { onBackground() {
console.log("jws onBackground"); console.log("jws onBackground");
} }
call(){ call(){
} }
} }
\ No newline at end of file
/* /*
* Copyright (C) 2022 Huawei Device Co., Ltd. * Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
export default { export default {
onCreate() { onCreate() {
console.info('Application onCreate') console.info('Application onCreate')
}, },
onDestroy() { onDestroy() {
console.info('Application onDestroy') console.info('Application onDestroy')
}, },
} }
\ No newline at end of file
/* /*
* Copyright (C) 2022 Huawei Device Co., Ltd. * Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import {Core} from 'deccjsunit/index' import {Core} from 'deccjsunit/index'
@Entry @Entry
@Component @Component
struct Index { struct Index {
aboutToAppear() { aboutToAppear() {
console.info('onShow finish') console.info('onShow finish')
const core = Core.getInstance() const core = Core.getInstance()
core.init() core.init()
const configService = core.getDefaultService('config') const configService = core.getDefaultService('config')
configService.setConfig(this) configService.setConfig(this)
core.execute() core.execute()
} }
build() { build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text('Hello World') Text('Hello World')
.fontSize(50) .fontSize(50)
.fontWeight(FontWeight.Bold) .fontWeight(FontWeight.Bold)
} }
.width('100%') .width('100%')
.height('100%') .height('100%')
} }
} }
\ No newline at end of file
/* /*
* Copyright (C) 2022 Huawei Device Co., Ltd. * Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import router from '@system.router'; import router from '@system.router';
@Entry @Entry
@Component @Component
struct Second { struct Second {
private content: string = "Second Page" private content: string = "Second Page"
build() { build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text(`${this.content}`) Text(`${this.content}`)
.fontSize(50) .fontSize(50)
.fontWeight(FontWeight.Bold) .fontWeight(FontWeight.Bold)
Button() { Button() {
Text('back to index') Text('back to index')
.fontSize(20) .fontSize(20)
.fontWeight(FontWeight.Bold) .fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule) }.type(ButtonType.Capsule)
.margin({ .margin({
top: 20 top: 20
}) })
.backgroundColor('#0D9FFB') .backgroundColor('#0D9FFB')
.onClick(() => { .onClick(() => {
router.back() router.back()
}) })
} }
.width('100%') .width('100%')
.height('100%') .height('100%')
} }
} }
\ No newline at end of file
/* /*
* Copyright (C) 2022 Huawei Device Co., Ltd. * Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import rpc from "@ohos.rpc"; import rpc from "@ohos.rpc";
import particleAbility from '@ohos.ability.particleAbility' import particleAbility from '@ohos.ability.particleAbility'
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
import commonEvent from '@ohos.commonEvent' import commonEvent from '@ohos.commonEvent'
var server_bundleName = "com.amsst.stserviceabilityserver"; var server_bundleName = "com.amsst.stserviceabilityserver";
var server_abilityName = "com.amsst.stserviceabilityserver.ServiceAbility"; var server_abilityName = "com.amsst.stserviceabilityserver.ServiceAbility";
var mConnIdJs; var mConnIdJs;
class StubTest extends rpc.RemoteObject { class StubTest extends rpc.RemoteObject {
constructor(des) { constructor(des) {
console.info('ACTS_SerivceAbilityServerSecond ====< des = ' + des); console.info('ACTS_SerivceAbilityServerSecond ====< des = ' + des);
if (typeof des === 'string') { if (typeof des === 'string') {
console.info('ACTS_ super'); console.info('ACTS_ super');
super(des); super(des);
} else { } else {
return null; return null;
} }
} }
onRemoteRequest(code, data, reply, option) { onRemoteRequest(code, data, reply, option) {
if (code === 1) { if (code === 1) {
console.info("ACTS_SerivceAbilityServerSecond ====< onRemoteRequest code = 1"); console.info("ACTS_SerivceAbilityServerSecond ====< onRemoteRequest code = 1");
let token = data.readInterfaceToken(); let token = data.readInterfaceToken();
console.log('ACTS_SerivceAbilityServerSecond ====< onRemoteRequest token:' + token); console.log('ACTS_SerivceAbilityServerSecond ====< onRemoteRequest token:' + token);
let num = data.readInt(); let num = data.readInt();
console.log('ACTS_SerivceAbilityServerSecond ====< onRemoteRequest num:' + num); console.log('ACTS_SerivceAbilityServerSecond ====< onRemoteRequest num:' + num);
this.method(); this.method();
num = num + 777; num = num + 777;
reply.writeInt(num); reply.writeInt(num);
} else { } else {
console.info("ACTS_SerivceAbilityServerSecond ====< onRemoteRequest code not 1"); console.info("ACTS_SerivceAbilityServerSecond ====< onRemoteRequest code not 1");
} }
return true; return true;
} }
method() { method() {
console.log('ACTS_SerivceAbilityServerSecond ====< method called.') console.log('ACTS_SerivceAbilityServerSecond ====< method called.')
} }
} }
export default { export default {
onStart(want) { onStart(want) {
console.debug('ACTS_SerivceAbilityServerSecond ====>onStart=' console.debug('ACTS_SerivceAbilityServerSecond ====>onStart='
+ want + " , JSON." + JSON.stringify(want)); + want + " , JSON." + JSON.stringify(want));
commonEvent.publish("ACTS_SerivceAbilityServerSecond_onStart", (err) => { }); commonEvent.publish("ACTS_SerivceAbilityServerSecond_onStart", (err) => { });
}, },
onStop() { onStop() {
console.debug('ACTS_SerivceAbilityServerSecond ====<onStop'); console.debug('ACTS_SerivceAbilityServerSecond ====<onStop');
commonEvent.publish("ACTS_SerivceAbilityServerSecond_onStop", (err) => { }); commonEvent.publish("ACTS_SerivceAbilityServerSecond_onStop", (err) => { });
featureAbility.terminateSelf(); featureAbility.terminateSelf();
}, },
onCommand(want, restart, startId) { onCommand(want, restart, startId) {
console.debug('ACTS_SerivceAbilityServerSecond ====>onCommand=' console.debug('ACTS_SerivceAbilityServerSecond ====>onCommand='
+ "JSON(want)=" + JSON.stringify(want) + "JSON(want)=" + JSON.stringify(want)
+ " ,restart=" + restart + " ,startId=" + startId); + " ,restart=" + restart + " ,startId=" + startId);
commonEvent.publish("ACTS_SerivceAbilityServerSecond_onCommand" + "_" + want.action, (err) => { }); commonEvent.publish("ACTS_SerivceAbilityServerSecond_onCommand" + "_" + want.action, (err) => { });
featureAbility.terminateSelf(); featureAbility.terminateSelf();
}, },
onConnect(want) { onConnect(want) {
console.info('ACTS_SerivceAbilityServerSecond ====< onConnect'); console.info('ACTS_SerivceAbilityServerSecond ====< onConnect');
try { try {
console.debug('ACTS_SerivceAbilityServerSecond ====>onConnect=' console.debug('ACTS_SerivceAbilityServerSecond ====>onConnect='
+ want + " , JSON." + JSON.stringify(want)); + want + " , JSON." + JSON.stringify(want));
function onConnectCallback(element, remote) { function onConnectCallback(element, remote) {
console.debug('ACTS_SerivceAbilityServerSecond_onConnectCallback ====> want.action=' console.debug('ACTS_SerivceAbilityServerSecond_onConnectCallback ====> want.action='
+ JSON.stringify(want.action) + " , " + want.action); + JSON.stringify(want.action) + " , " + want.action);
console.debug('ACTS_SerivceAbilityServerSecond_onConnectCallback ====> element=' console.debug('ACTS_SerivceAbilityServerSecond_onConnectCallback ====> element='
+ JSON.stringify(element) + " , " + element); + JSON.stringify(element) + " , " + element);
console.debug('ACTS_SerivceAbilityServerSecond_onConnectCallback ====> remote=' console.debug('ACTS_SerivceAbilityServerSecond_onConnectCallback ====> remote='
+ JSON.stringify(remote) + " , " + remote); + JSON.stringify(remote) + " , " + remote);
if (want.action == 'ServiceConnectService_1500' || want.action == 'ServiceConnectService_1600') { if (want.action == 'ServiceConnectService_1500' || want.action == 'ServiceConnectService_1600') {
commonEvent.publish("ACTS_SerivceAbilityServerSecond_onConnect" + "_" + want.action, (err) => { commonEvent.publish("ACTS_SerivceAbilityServerSecond_onConnect" + "_" + want.action, (err) => {
console.debug("publish = ACTS_SerivceAbilityServerSecond_onConnect" + "_" + want.action); console.debug("publish = ACTS_SerivceAbilityServerSecond_onConnect" + "_" + want.action);
}); });
} }
} }
function onDisconnectCallback(element) { function onDisconnectCallback(element) {
console.debug('ACTS_SerivceAbilityServerSecond_onDisconnectCallback ====> element=' console.debug('ACTS_SerivceAbilityServerSecond_onDisconnectCallback ====> element='
+ JSON.stringify(element) + " , " + element); + JSON.stringify(element) + " , " + element);
} }
function onFailedCallback(code) { function onFailedCallback(code) {
console.debug('ACTS_SerivceAbilityServerSecond_onFailedCallback ====> code=' console.debug('ACTS_SerivceAbilityServerSecond_onFailedCallback ====> code='
+ JSON.stringify(code) + " , " + code) + JSON.stringify(code) + " , " + code)
} }
if (want.action == 'ServiceConnectService_1500') { if (want.action == 'ServiceConnectService_1500') {
mConnIdJs = particleAbility.connectAbility( mConnIdJs = particleAbility.connectAbility(
{ {
bundleName: server_bundleName, bundleName: server_bundleName,
abilityName: server_abilityName, abilityName: server_abilityName,
action: "ServiceConnectService_1501", action: "ServiceConnectService_1501",
}, },
{ {
onConnect: onConnectCallback, onConnect: onConnectCallback,
onDisconnect: onDisconnectCallback, onDisconnect: onDisconnectCallback,
onFailed: onFailedCallback, onFailed: onFailedCallback,
}, },
) )
} else if (want.action == 'ServiceConnectService_1600') { } else if (want.action == 'ServiceConnectService_1600') {
mConnIdJs = particleAbility.connectAbility( mConnIdJs = particleAbility.connectAbility(
{ {
bundleName: server_bundleName, bundleName: server_bundleName,
abilityName: server_abilityName, abilityName: server_abilityName,
action: "ServiceConnectService_1601", action: "ServiceConnectService_1601",
}, },
{ {
onConnect: onConnectCallback, onConnect: onConnectCallback,
onDisconnect: onDisconnectCallback, onDisconnect: onDisconnectCallback,
onFailed: onFailedCallback, onFailed: onFailedCallback,
}, },
) )
} else if (want.action == 'ServiceConnectService_1590') { } else if (want.action == 'ServiceConnectService_1590') {
mConnIdJs = particleAbility.connectAbility( mConnIdJs = particleAbility.connectAbility(
{ {
bundleName: server_bundleName, bundleName: server_bundleName,
abilityName: server_abilityName, abilityName: server_abilityName,
action: "ServiceConnectService_1591", action: "ServiceConnectService_1591",
}, },
{ {
onConnect: onConnectCallback, onConnect: onConnectCallback,
onDisconnect: onDisconnectCallback, onDisconnect: onDisconnectCallback,
onFailed: onFailedCallback, onFailed: onFailedCallback,
}, },
) )
} else { } else {
commonEvent.publish("ACTS_SerivceAbilityServerSecond_onConnect" + "_" + want.action, (err) => { }); commonEvent.publish("ACTS_SerivceAbilityServerSecond_onConnect" + "_" + want.action, (err) => { });
} }
} catch (err) { } catch (err) {
console.log("ACTS_SerivceAbilityServerSecond ====< error:" + err) console.log("ACTS_SerivceAbilityServerSecond ====< error:" + err)
} }
console.info('ACTS_SerivceAbilityServerSecond ====< onConnect end'); console.info('ACTS_SerivceAbilityServerSecond ====< onConnect end');
return new StubTest("connect-test"); return new StubTest("connect-test");
}, },
onDisconnect(want) { onDisconnect(want) {
console.debug('ACTS_SerivceAbilityServerSecond ====>onDisConnect=' console.debug('ACTS_SerivceAbilityServerSecond ====>onDisConnect='
+ want + " , JSON." + JSON.stringify(want)); + want + " , JSON." + JSON.stringify(want));
commonEvent.publish("ACTS_SerivceAbilityServerSecond_onDisConnect", (err) => { commonEvent.publish("ACTS_SerivceAbilityServerSecond_onDisConnect", (err) => {
if (err.code) { if (err.code) {
console.debug('ACTS_SerivceAbilityServerSecond_onDisConnect publish err=====>' + err); console.debug('ACTS_SerivceAbilityServerSecond_onDisConnect publish err=====>' + err);
} else { } else {
console.debug('ACTS_SerivceAbilityServerSecond_onDisConnect featureAbility.terminateSelf()=====<' console.debug('ACTS_SerivceAbilityServerSecond_onDisConnect featureAbility.terminateSelf()=====<'
+ want.action); + want.action);
if (want.action == 'ServiceConnectService_1500' || want.action == 'ServiceConnectService_1501' if (want.action == 'ServiceConnectService_1500' || want.action == 'ServiceConnectService_1501'
|| want.action == 'ServiceConnectService_1600' || want.action == 'ServiceConnectService_1601' || want.action == 'ServiceConnectService_1600' || want.action == 'ServiceConnectService_1601'
|| want.action == 'ServiceConnectService_1590') { || want.action == 'ServiceConnectService_1590') {
particleAbility.disconnectAbility(mConnIdJs, (err) => { particleAbility.disconnectAbility(mConnIdJs, (err) => {
console.debug("=ACTS_SerivceAbilityServerSecond_onDisConnect err====>" console.debug("=ACTS_SerivceAbilityServerSecond_onDisConnect err====>"
+ ("json err=") + JSON.stringify(err) + " , " + want.action); + ("json err=") + JSON.stringify(err) + " , " + want.action);
}) })
} }
featureAbility.terminateSelf(); featureAbility.terminateSelf();
} }
}); });
}, },
onReady() { onReady() {
console.debug('ACTS_SerivceAbilityServerSecond ====<onReady'); console.debug('ACTS_SerivceAbilityServerSecond ====<onReady');
}, },
onReconnect(want) { onReconnect(want) {
console.debug('ACTS_SerivceAbilityServerSecond ====>onReconnect=' console.debug('ACTS_SerivceAbilityServerSecond ====>onReconnect='
+ want + " , JSON." + JSON.stringify(want)); + want + " , JSON." + JSON.stringify(want));
}, },
OnAbilityConnectDone(element, remoteObject, resultCode) { OnAbilityConnectDone(element, remoteObject, resultCode) {
console.debug('ACTS_SerivceAbilityServerSecond ====>OnAbilityConnectDone=' console.debug('ACTS_SerivceAbilityServerSecond ====>OnAbilityConnectDone='
+ element + " , JSON." + JSON.stringify(element) + element + " , JSON." + JSON.stringify(element)
+ remoteObject + " , JSON." + JSON.stringify(remoteObject) + remoteObject + " , JSON." + JSON.stringify(remoteObject)
+ resultCode + " , JSON." + JSON.stringify(resultCode) + resultCode + " , JSON." + JSON.stringify(resultCode)
); );
commonEvent.publish("ACTS_SerivceAbilityServerSecond_OnAbilityConnectDone", (err) => { }); commonEvent.publish("ACTS_SerivceAbilityServerSecond_OnAbilityConnectDone", (err) => { });
}, },
}; };
{ {
"string": [ "string": [
{ {
"name": "entry_MainAbility", "name": "entry_MainAbility",
"value": "ServiceExtAbility" "value": "ServiceExtAbility"
}, },
{ {
"name": "description_mainability", "name": "description_mainability",
"value": "eTS_Empty Ability" "value": "eTS_Empty Ability"
}, },
{ {
"name": "description_serviceability", "name": "description_serviceability",
"value": "hap sample empty service" "value": "hap sample empty service"
}, },
{ {
"name": "description_dataability", "name": "description_dataability",
"value": "hap sample empty provider" "value": "hap sample empty provider"
}, },
{ {
"name": "description_mainability2", "name": "description_mainability2",
"value": "eTS_Empty Ability" "value": "eTS_Empty Ability"
}, },
{ {
"name": "entry_MainAbility2", "name": "entry_MainAbility2",
"value": "entry_MainAbility2" "value": "entry_MainAbility2"
}, },
{ {
"name": "description_testdataability", "name": "description_testdataability",
"value": "hap sample empty provider" "value": "hap sample empty provider"
}, },
{ {
"name": "permreason_dataability", "name": "permreason_dataability",
"value": "request dataability premission" "value": "request dataability premission"
} }
] ]
} }
\ No newline at end of file
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
# distributed under the License is distributed on an "AS IS" BASIS, # distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import("//test/xts/tools/build/suite.gni") import("//test/xts/tools/build/suite.gni")
......
...@@ -9,12 +9,12 @@ ...@@ -9,12 +9,12 @@
# distributed under the License is distributed on an "AS IS" BASIS, # distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import("//test/xts/tools/build/suite.gni") import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsGetWantAllTest") { ohos_js_hap_suite("ActsGetWantAllTest") {
hap_profile = "./entry/src/main/config.json" hap_profile = "./src/main/config.json"
deps = [ deps = [
":hjs_demo_js_assets", ":hjs_demo_js_assets",
":hjs_demo_resources", ":hjs_demo_resources",
...@@ -23,9 +23,11 @@ ohos_js_hap_suite("ActsGetWantAllTest") { ...@@ -23,9 +23,11 @@ ohos_js_hap_suite("ActsGetWantAllTest") {
hap_name = "ActsGetWantAllTest" hap_name = "ActsGetWantAllTest"
} }
ohos_js_assets("hjs_demo_js_assets") { ohos_js_assets("hjs_demo_js_assets") {
source_dir = "./entry/src/main/js/default" js2abc = true
hap_profile = "./src/main/config.json"
source_dir = "./src/main/js"
} }
ohos_resources("hjs_demo_resources") { ohos_resources("hjs_demo_resources") {
sources = [ "./entry/src/main/js/resources" ] sources = [ "./src/main/resources" ]
hap_profile = "./entry/src/main/config.json" hap_profile = "./src/main/config.json"
} }
{ {
"description": "Configuration for hjunit demo Tests", "description": "Configuration for hjunit demo Tests",
"driver": { "driver": {
"type": "JSUnitTest", "type": "OHJSUnitTest",
"test-timeout": "600000", "test-timeout": "600000",
"package": "com.example.actsgetwantalltest", "bundle-name": "com.example.actsgetwantalltest",
"shell-timeout": "600000" "package-name": "com.example.actsgetwantalltest",
}, "shell-timeout": "600000"
"kits": [ },
{ "kits": [
"test-file-name": [ {
"ActsGetWantAllTest.hap", "test-file-name": [
"ActsGetWantAllTestHap.hap" "ActsGetWantAllTest.hap",
], "ActsGetWantAllTestHap.hap"
"type": "AppInstallKit", ],
"cleanup-apps": true "type": "AppInstallKit",
} "cleanup-apps": true
] }
} ]
}
{
"app": {
"bundleName": "com.example.actsgetwantalltest",
"vendor": "example",
"version": {
"code": 1,
"name": "1.0"
},
"apiVersion": {
"compatible": 4,
"target": 5,
"releaseType": "Beta1"
}
},
"deviceConfig": {},
"module": {
"package": "com.example.actsgetwantalltest",
"name": ".MyApplication",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"visible": true,
"name": "com.example.actsgetwantalltest.MainAbility",
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "$string:app_name",
"type": "page",
"launchType": "standard"
}
],
"reqPermissions": [
{
"name": "ohos.permission.INSTALL_BUNDLE",
"reason": "need use ohos.permission.INSTALL_BUNDLE"
},
{
"name":"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED",
"reason":"need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
},
{
"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"
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
]
}
}
\ No newline at end of file
{
"app": {
"bundleName": "com.example.actsgetwantalltest",
"vendor": "example",
"version": {
"code": 1,
"name": "1.0"
},
"apiVersion": {
"compatible": 4,
"target": 5,
"releaseType": "Beta1"
}
},
"deviceConfig": {},
"module": {
"package": "com.example.actsgetwantalltest",
"name": ".entry",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"orientation": "unspecified",
"formsEnabled": false,
"name": ".MainAbility",
"srcLanguage": "js",
"srcPath": "MainAbility",
"icon": "$media:icon",
"description": "$string:MainAbility_desc",
"label": "$string:MainAbility_label",
"type": "page",
"visible": true,
"launchType": "standard"
},
{
"orientation": "unspecified",
"formsEnabled": false,
"name": ".TestAbility",
"srcLanguage": "js",
"srcPath": "TestAbility",
"icon": "$media:icon",
"description": "$string:TestAbility_desc",
"label": "$string:TestAbility_label",
"type": "page",
"visible": true,
"launchType": "standard"
}
],
"reqPermissions": [
{
"name": "ohos.permission.INSTALL_BUNDLE",
"reason": "need use ohos.permission.INSTALL_BUNDLE"
},
{
"name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED",
"reason": "need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
},
{
"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"
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
},
{
"pages": [
"pages/index/index"
],
"name": ".TestAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
],
"testRunner": {
"name": "OpenHarmonyTestRunner",
"srcPath": "TestRunner"
},
"mainAbility": ".MainAbility",
"srcPath": ""
}
}
\ 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.
*/
export default {
onCreate() {
console.info('TestApplication onCreate')
},
onDestroy() {
console.info("TestApplication onDestroy");
}
};
.container { .container {
flex-direction: column; flex-direction: column;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
} }
.title { .title {
font-size: 100px; font-size: 100px;
} }
<div class="container">
<text class="title">
{{ $t('strings.hello') }} {{ title }}
</text>
</div>
/* /*
* Copyright (c) 2021 Huawei Device Co., Ltd. * Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import {Core, ExpectExtend} from 'deccjsunit/index' import { Hypium } from '@ohos/hypium'
import testsuite from '../../../test/List.test'
const injectRef = Object.getPrototypeOf(global) || global const injectRef = Object.getPrototypeOf(global) || global
injectRef.regeneratorRuntime = require('@babel/runtime/regenerator') injectRef.regeneratorRuntime = require('@babel/runtime/regenerator')
let once = true let once = true
export default { export default {
data: { data: {
title: '' title: ''
}, },
onInit() { onInit() {
this.title = this.$t('strings.world'); this.title = this.$t('strings.world');
}, },
onShow() { onShow() {
if (once) { if (once) {
once = false once = false
console.info('onShow finish') console.info('onShow finish')
const core = Core.getInstance() var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
const expectExtend = new ExpectExtend({ var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
id: 'extend' console.info('start run testcase!!!')
}) Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
core.addService('expect', expectExtend) }
core.init() },
onReady() {
const configService = core.getDefaultService('config') console.info('onReady');
configService.setConfig(this) },
}
require('../../../test/List.test')
core.execute()
}
},
onReady() {
console.info('onReady');
},
}
/*
* 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 {
onCreate() {
console.info('AceApplication onCreate');
},
onDestroy() {
console.info('AceApplication onDestroy');
}
};
{
"strings": {
"hello": "Hello",
"world": "World"
},
"Files": {
}
}
\ No newline at end of file
{
"strings": {
"hello": "您好",
"world": "世界"
},
"Files": {
}
}
\ No newline at end of file
.container {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
left: 0px;
top: 0px;
width: 100%;
height: 100%;
}
.title {
font-size: 60px;
text-align: center;
width: 100%;
height: 40%;
margin: 10px;
}
@media screen and (device-type: phone) and (orientation: landscape) {
.title {
font-size: 60px;
}
}
@media screen and (device-type: tablet) and (orientation: landscape) {
.title {
font-size: 100px;
}
}
\ No newline at end of file
<div class="container">
<text class="title">
{{ $t('strings.hello') }} {{ title }}
</text>
</div>
/*
* 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 {
data: {
title: ""
},
onInit() {
this.title = this.$t('strings.world');
}
}
/*
* 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 AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
function translateParamsToString(parameters) {
const keySet = new Set([
'-s class', '-s notClass', '-s suite', '-s itName',
'-s level', '-s testType', '-s size', '-s timeout',
'-s package', '-s dryRun'
])
let targetParams = '';
for (const key in parameters) {
if (keySet.has(key)) {
targetParams += ' ' + key + ' ' + parameters[key]
}
}
return targetParams.trim()
}
export default {
onPrepare() {
console.info('OpenHarmonyTestRunner OnPrepare')
},
onRun() {
console.log('OpenHarmonyTestRunner onRun run')
var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.MainAbility'
var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName
cmd += ' ' + translateParamsToString(abilityDelegatorArguments.parameters)
var debug = abilityDelegatorArguments.parameters["-D"]
console.info('debug value : '+debug)
if (debug == 'true')
{
cmd += ' -D'
}
console.info('cmd : '+cmd)
abilityDelegator.executeShellCommand(cmd, (err, data) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
console.info('executeShellCommand : data : ' + data.stdResult);
console.info('executeShellCommand : data : ' + data.exitCode);
})
}
};
/* /*
* Copyright (c) 2021 Huawei Device Co., Ltd. * Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import ActsGetWantTest from './ActsGetWantAllTest.js'
require('./ActsGetWantAllTest.js')
\ No newline at end of file export default function testsuite() {
ActsGetWantTest()
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册