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

!1860 【增强特性】提供定制框架js接口

Merge pull request !1860 from huangke11/master
# Copyright (C) 2021 Huawei Device Co., Ltd.
# 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
......@@ -17,6 +17,7 @@ group("global") {
testonly = true
if (is_standard_system) {
deps = [
"cust/custjs:custjs_test",
"i18n_standard/intljs:intljs_test",
"resmgr_standard/resmgrjs:resmgrjs_test",
]
......
# 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("custjs_test") {
hap_profile = "./src/main/config.json"
deps = [
":custjs_assets",
":custjs_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsCustJsTest"
}
ohos_js_assets("custjs_assets") {
source_dir = "./src/main/js/default"
}
ohos_resources("custjs_resources") {
sources = [ "./src/main/resources" ]
hap_profile = "./src/main/config.json"
}
{
"description": "Configuration for cust js api Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "300000",
"package": "ohos.cust.test",
"shell-timeout": "60000"
},
"kits": [
{
"test-file-name": [
"ActsCustJsTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
},
{
"type": "ShellKit",
"run-command": [
"mkdir -p /system/etc/custxmltest/",
"mkdir -p /sys-prod/etc/custxmltest/",
"touch /system/etc/custxmltest/system.xml",
"touch /system/etc/custxmltest/both.xml",
"touch /sys-prod/etc/custxmltest/both.xml",
"touch /sys-prod/etc/custxmltest/user.xml"
]
}
]
}
{
"app": {
"bundleName": "ohos.cust.test",
"vendor": "acts",
"version": {
"code": 1000000,
"name": "1.0.0"
},
"apiVersion": {
"compatible": 4,
"target": 5
}
},
"deviceConfig": {},
"module": {
"package": "ohos.cust.test",
"name": ".MyApplication",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
},
"abilities": [
{
"visible": true,
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"name": "ohos.cust.test.MainAbility",
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "$string:app_name",
"type": "page",
"launchType": "standard"
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
]
}
}
/*
* 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('TestApplication onCreate');
},
onDestroy() {
console.info('TestApplication onDestroy');
}
};
{
"strings": {
"hello": "Hello",
"world": "World"
}
}
\ No newline at end of file
{
"strings": {
"hello": "您好",
"world": "世界"
}
}
\ No newline at end of file
.container {
flex-direction: column;
justify-content: center;
align-items: center;
}
.title {
font-size: 100px;
}
<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.
*/
import {Core, ExpectExtend} from 'deccjsunit/index'
export default {
data: {
title: ""
},
onInit() {
this.title = this.$t('strings.world');
},
onShow() {
console.info('onShow finish')
const core = Core.getInstance()
const expectExtend = new ExpectExtend({
'id': 'extend'
})
core.addService('expect', expectExtend)
core.init()
const configService = core.getDefaultService('config')
configService.setConfig(this)
require('../../test/List.test')
core.execute()
},
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.
*/
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
import cust from '@ohos.cust'
describe('GetCfgDirListTest', function () {
/* *
* @tc.number SUB_CUST_JS_005
* @tc.name test getCfgDirList method in callback mode
* @tc.desc get getCfgDirList in callback mode
*/
it('getCfgDirList_test_005', 0, async function (done) {
cust.getCfgDirList((error, value) => {
expect(value.length != 0).assertTrue();
console.log('CustTest getCfgDirList_test_005:' + value);
});
done();
})
/* *
* @tc.number SUB_CUST_JS_006
* @tc.name test getCfgDirList method in promise mode
* @tc.desc get getCfgDirList in promise mode
*/
it('getCfgDirList_test_006', 0, async function (done) {
cust.getCfgDirList().then(value => {
expect(value.length != 0).assertTrue();
console.log('CustTest getCfgDirList_test_006:' + value);
});
done();
})
})
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
import cust from '@ohos.cust'
describe('GetCfgFilesTest', function () {
/* *
* @tc.number SUB_CUST_JS_003
* @tc.name test getCfgFiles method in callback mode
* @tc.desc get getCfgFiles in callback mode
*/
it('getCfgFiles_test_003', 0, async function (done) {
cust.getCfgFiles('custxmltest/none.xml', (error, value) => {
expect(value.length == 0).assertTrue();
console.log('CustTest getCfgFiles_test_003, none.xml:' + value);
});
cust.getCfgFiles('custxmltest/system.xml', (error, value) => {
expect(value.length != 0).assertTrue();
console.log('CustTest getCfgFiles_test_003, system.xml:' + value);
});
cust.getCfgFiles('custxmltest/both.xml', (error, value) => {
expect(value.length != 0).assertTrue();
console.log('CustTest getCfgFiles_test_003, both.xml:' + value);
});
cust.getCfgFiles('custxmltest/user.xml', (error, value) => {
expect(value.length != 0).assertTrue();
console.log('CustTest getCfgFiles_test_003, user.xml:' + value);
});
done();
})
/* *
* @tc.number SUB_CUST_JS_004
* @tc.name test getCfgFiles method in promise mode
* @tc.desc get getCfgFiles in promise mode
*/
it('getCfgFiles_test_004', 0, async function (done) {
cust.getCfgFiles('custxmltest/none.xml').then(value => {
expect(value.length == 0).assertTrue();
console.log('CustTest getCfgFiles_test_004, none.xml:' + value);
});
cust.getCfgFiles('custxmltest/system.xml').then(value => {
expect(value.length != 0).assertTrue();
console.log('CustTest getCfgFiles_test_004, system.xml:' + value);
});
cust.getCfgFiles('custxmltest/both.xml').then(value => {
expect(value.length != 0).assertTrue();
console.log('CustTest getCfgFiles_test_004, both.xml:' + value);
});
cust.getCfgFiles('custxmltest/user.xml').then(value => {
expect(value.length != 0).assertTrue();
console.log('CustTest getCfgFiles_test_004, user.xml:' + value);
});
done();
})
})
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
import cust from '@ohos.cust'
describe('GetOneCfgFileTest', function () {
/* *
* @tc.number SUB_CUST_JS_001
* @tc.name test getOneCfgFile method in callback mode
* @tc.desc get getOneCfgFile in callback mode
*/
it('getOneCfgFile_test_001', 0, async function (done) {
cust.getOneCfgFile('custxmltest/none.xml', (error, value) => {
expect(value.length == 0).assertTrue();
console.log('CustTest getOneCfgFile_test_001, none.xml:' + value);
});
cust.getOneCfgFile('custxmltest/system.xml', (error, value) => {
expect(value.length != 0).assertTrue();
console.log('CustTest getOneCfgFile_test_001, system.xml:' + value);
});
cust.getOneCfgFile('custxmltest/both.xml', (error, value) => {
expect(value.length != 0).assertTrue();
console.log('CustTest getOneCfgFile_test_001, both.xml:' + value);
});
cust.getOneCfgFile('custxmltest/user.xml', (error, value) => {
expect(value.length != 0).assertTrue();
console.log('CustTest getOneCfgFile_test_001, user.xml:' + value);
});
done();
})
/* *
* @tc.number SUB_CUST_JS_002
* @tc.name test getOneCfgFile method in promise mode
* @tc.desc get getOneCfgFile in promise mode
*/
it('getOneCfgFile_test_002', 0, async function (done) {
cust.getOneCfgFile('custxmltest/none.xml').then(value => {
expect(value.length == 0).assertTrue();
console.log('CustTest getOneCfgFile_test_002, none.xml:' + value);
});
cust.getOneCfgFile('custxmltest/system.xml').then(value => {
expect(value.length != 0).assertTrue();
console.log('CustTest getOneCfgFile_test_002, system.xml:' + value);
});
cust.getOneCfgFile('custxmltest/both.xml').then(value => {
expect(value.length != 0).assertTrue();
console.log('CustTest getOneCfgFile_test_002, both.xml:' + value);
});
cust.getOneCfgFile('custxmltest/user.xml').then(value => {
expect(value.length != 0).assertTrue();
console.log('CustTest getOneCfgFile_test_002, user.xml:' + value);
});
done();
})
})
/*
* 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.
*/
require('./GetOneCfgFile.test.js')
require('./GetCfgFiles.test.js')
require('./GetCfgDirList.test.js')
\ No newline at end of file
{
"string": [
{
"name": "app_name",
"value": "JsTimeTest"
},
{
"name": "mainability_description",
"value": "JS_Phone_Empty Feature Ability"
}
]
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册