提交 de80da6b 编写于 作者: M mamingshuai

update OpenHarmony 2.0 Canary

上级 37017f92
*.tgz filter=lfs diff=lfs merge=lfs -text
*.trp filter=lfs diff=lfs merge=lfs -text
*.apk filter=lfs diff=lfs merge=lfs -text
*.jar filter=lfs diff=lfs merge=lfs -text
*.mp4 filter=lfs diff=lfs merge=lfs -text
*.zip filter=lfs diff=lfs merge=lfs -text
*.asm filter=lfs diff=lfs merge=lfs -text
*.8svn filter=lfs diff=lfs merge=lfs -text
*.9svn filter=lfs diff=lfs merge=lfs -text
*.dylib filter=lfs diff=lfs merge=lfs -text
*.exe filter=lfs diff=lfs merge=lfs -text
*.a filter=lfs diff=lfs merge=lfs -text
*.so filter=lfs diff=lfs merge=lfs -text
*.bin filter=lfs diff=lfs merge=lfs -text
*.dll filter=lfs diff=lfs merge=lfs -text
### 该问题是怎么引起的?
### 重现步骤
### 报错信息
### 相关的Issue
### 原因(目的、解决的问题等)
### 描述(做了什么,变更了什么)
### 测试用例(新增、改动、可能影响的功能)
# Copyright (C) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#import("//hit/build/suite.gni")
import("test_packages.gni")
ohos_test_suite("acts") {
deps = selected_packages
}
ohos_test_suite("acts_ivi") {
deps = selected_packages_ivi
}
ohos_test_suite("acts_intellitv") {
deps = selected_packages_intellitv
}
ohos_test_suite("acts_wearable") {
deps = selected_packages_wearable
}
文件模式从 100755 更改为 100644
<?xml version="1.0" encoding="UTF-8"?>
<!-- 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.
-->
<!-- OAT(OSS Audit Tool) configuration guide:
basedir: Root dir, the basedir + project path is the real source file location.
licensefile:
1.If the project don't have "LICENSE" in root dir, please define all the license files in this project in , OAT will check license files according to this rule.
tasklist(only for batch mode):
1. task: Define oat check thread, each task will start a new thread.
2. task name: Only an name, no practical effect.
3. task policy: Default policy for projects under this task, this field is required and the specified policy must defined in policylist.
4. task filter: Default filefilter for projects under this task, this field is required and the specified filefilter must defined in filefilterlist.
5. task project: Projects to be checked, the path field define the source root dir of the project.
policyList:
1. policy: All policyitems will be merged to default OAT.xml rules, the name of policy doesn't affect OAT check process.
2. policyitem: The fields type, name, path, desc is required, and the fields rule, group, filefilter is optional,the default value is:
<policyitem type="" name="" path="" desc="" rule="may" group="defaultGroup" filefilter="defaultPolicyFilter"/>
3. policyitem type:
"compatibility" is used to check license compatibility in the specified path;
"license" is used to check source license header in the specified path;
"copyright" is used to check source copyright header in the specified path;
"import" is used to check source dependency in the specified path, such as import ... ,include ...
"filetype" is used to check file type in the specified path, supported file types: archive, binary
"filename" is used to check whether the specified file exists in the specified path(support projectroot in default OAT.xml), supported file names: LICENSE, README, README.OpenSource
4. policyitem name: This field is used for define the license, copyright, "*" means match all, the "!" prefix means could not match this value. For example, "!GPL" means can not use GPL license.
5. policyitem path: This field is used for define the source file scope to apply this policyitem, the "!" prefix means exclude the files. For example, "!.*/lib/.*" means files in lib dir will be exclude while process this policyitem.
6. policyitem rule and group: These two fields are used together to merge policy results. "may" policyitems in the same group means any one in this group passed, the result will be passed.
7. policyitem filefilter: Used to bind filefilter which define filter rules.
8. filefilter: Filter rules, the type filename is used to filter file name, the type filepath is used to filter file path.
Note:If the text contains special characters, please escape them according to the following rules:
" == &gt;
& == &gt;
' == &gt;
< == &gt;
> == &gt;
-->
<configuration>
<oatconfig>
<filefilterlist>
<filefilter name="binaryFileTypePolicyFilter" desc="Filters for binaryFile" >
<filteritem type="filename" name="entry-debug-rich-signed.hap" desc="./multimedia/audio/audio_js_standard dir src code compile"/>
<filteritem type="filename" name="entry-debug-signed.hap" desc="./global/resmgr_L2/resmgrjs/hap dir src code compile"/>
<filteritem type="filename" name="entry-debug-rich-unsigned.hap" desc="./distributeddatamgr/distributedfilejstest dir src code compile"/>
<filteritem type="filename" name="entry-test-signed.hap" desc="./distributeddatamgr/appdatamgrjstest dir src code compile"/>
</filefilter>
</filefilterlist>
</oatconfig>
</configuration>
此差异已折叠。
此差异已折叠。
# Copyright (C) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//build/ohos_var.gni")
group("account") {
testonly = true
if (is_standard_system) {
deps = [ "OsAccountTest_js:osaccount_js_test" ]
} else {
deps = [
"appaccount:appaccount_hap",
"osaccount:osaccount_hap",
]
}
}
# Copyright (C) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("osaccount_js_test") {
test_hap_name = "OsAccountJSApiTest"
hap_source_path = "hap/entry-debug-rich-signed.hap"
}
{
"description": "Configuration for osaccount js api Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "21600000",
"package": "ohos.acts.account.osaccount",
"shell-timeout": "21600000"
},
"kits": [
{
"test-file-name": [
"OsAccountJSApiTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
{
"app": {
"bundleName": "ohos.acts.account.osaccount",
"vendor": "acts",
"version": {
"code": 1000000,
"name": "1.0.0"
},
"apiVersion": {
"compatible": 4,
"target": 5
}
},
"deviceConfig": {},
"module": {
"package": "ohos.acts.account.osaccount",
"name": ".MyApplication",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"name": "ohos.acts.account.osaccount.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) 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('AceApplication onCreate');
},
onDestroy() {
console.info('AceApplication 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) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import file from '@system.file'
import app from '@system.app'
//import {Core, ExpectExtend, ReportExtend, InstrumentLog} from 'deccjsunit/index'
import {Core, ExpectExtend, ReportExtend} 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'
})
const reportExtend = new ReportExtend(file)
// const instrumentLog = new InstrumentLog({
// 'id': 'report'
// })
core.addService('expect', expectExtend)
core.addService('report', reportExtend)
// core.addService('report', instrumentLog)
core.init()
// core.subscribeEvent('spec', instrumentLog)
// core.subscribeEvent('suite', instrumentLog)
// core.subscribeEvent('task', instrumentLog)
const configService = core.getDefaultService('config')
configService.setConfig(this)
require('../../../test/List.test')
core.execute()
},
onReady() {
},
}
/*
* 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.
*/
require('./OsAccount.test.js')
\ 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.
*/
// @ts-nocheck
import {describe, beforeEach, afterEach, it, expect} from 'deccjsunit/index'
import account from '@ohos.account.distributedAccount'
describe('AccountTest', function () {
beforeEach(function () {
})
afterEach(function () {
})
/**
* @tc.number SUB_Account_distributedAccount_JS_API_0100
* @tc.name Test distributedAccount.getDistributedAccountAbility.
* @tc.desc Test distributedAccount.getDistributedAccountAbility API functionality.
*/
it('account_getDistributedAccountAbility_test', 0, function () {
var ret = false;
const accountAbility = account.getDistributedAccountAbility()
if(accountAbility !== null){
ret = true;
}
expect(ret).assertTrue()
})
/**
* @tc.number SUB_Account_distributedAccount_JS_API_0200
* @tc.name Test distributedAccount.queryOsAccountDistributedInfo.
* @tc.desc Test distributedAccount.queryOsAccountDistributedInfo API functionality.
*/
it('account_queryOsAccountDistributedInfo_test001', 0, function () {
const accountAbility = account.getDistributedAccountAbility()
accountAbility.queryOsAccountDistributedInfo().then(function (data) {
expect(data.name).assertEqual('anonymous')
});
})
/**
* @tc.number SUB_Account_distributedAccount_JS_API_0300
* @tc.name Test distributedAccount.queryOsAccountDistributedInfo by callback.
* @tc.desc Test distributedAccount.queryOsAccountDistributedInfo API functionality by callback.
*/
it('account_queryOsAccountDistributedInfo_test002', 0, function () {
const accountAbility = account.getDistributedAccountAbility()
accountAbility.queryOsAccountDistributedInfo(function (data) {
expect(data.name).assertEqual('anonymous')
});
})
/**
* @tc.number SUB_Account_distributedAccount_JS_API_0400
* @tc.name Test distributedAccount.updateOsAccountDistributedInfo.
* @tc.desc Test distributedAccount.updateOsAccountDistributedInfo API functionality.
*/
it('account_updateOsAccountDistributedInfo_test001', 0, function () {
const accountAbility = account.getDistributedAccountAbility()
let obj = {
id: '12345',
name: 'ZhangSan',
event: 'Ohos.account.event.LOGIN'
};
accountAbility.updateOsAccountDistributedInfo(obj).then(function (result) {
expect(result).assertTrue()
accountAbility.queryOsAccountDistributedInfo(function (data) {
expect(data.name).assertEqual('ZhangSan')
expect(data.id).assertEqual('12345')
let obj = {
id: '12345',
name: 'ZhangSan',
event: 'Ohos.account.event.LOGOUT'
};
accountAbility.updateOsAccountDistributedInfo(obj).then(function (result) {
expect(result).assertTrue()
});
});
});
})
/**
* @tc.number SUB_Account_distributedAccount_JS_API_0500
* @tc.name Test distributedAccount.updateOsAccountDistributedInfo by callback.
* @tc.desc Test distributedAccount.updateOsAccountDistributedInfo API functionality by callback.
*/
it('account_updateOsAccountDistributedInfo_test002', 0, function () {
const accountAbility = account.getDistributedAccountAbility()
let obj = {
id: '12345',
name: 'ZhangSan',
event: 'Ohos.account.event.LOGIN'
};
accountAbility.updateOsAccountDistributedInfo(obj, function (result) {
expect(result).assertTrue()
accountAbility.queryOsAccountDistributedInfo(function (data) {
expect(data.name).assertEqual('ZhangSan')
expect(data.id).assertEqual('12345')
const accountAbility = account.getDistributedAccountAbility()
let obj = {
id: '12345',
name: 'ZhangSan',
event: 'Ohos.account.event.LOGOUT'
};
accountAbility.updateOsAccountDistributedInfo(obj).then(function (result) {
expect(result).assertTrue()
});
});
});
})
})
\ No newline at end of file
{
"string": [
{
"name": "app_name",
"value": "OsAccountTest"
},
{
"name": "mainability_description",
"value": "JS_Phone_Empty Feature Ability"
}
]
}
\ 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.
group("ace") {
testonly = true
deps = [
"ace_standard:ace_standard_test",
]
}
# Copyright (C) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ace_standard_test") {
test_hap_name = "ace_standard"
hap_source_path = "hap/entry-debug-signed.hap"
}
{
"description": "Configuration for aceceshi Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "21600000",
"package": "com.example.aceceshi",
"abilityName": "decc.testkit.runner.JsEntryAbility",
"shell-timeout": "21600000"
},
"kits": [
{
"test-file-name": [
"ace_standard.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
{
"app": {
"bundleName": "com.example.aceceshi",
"vendor": "example",
"version": {
"code": 1,
"name": "1.0"
},
"apiVersion": {
"compatible": 5,
"target": 5,
"releaseType": "Release"
}
},
"deviceConfig": {},
"module": {
"package": "com.example.aceceshi",
"name": "testModule",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry_test",
"moduleType": "feature"
},
"abilities": [
{
"name": "decc.testkit.runner.JsEntryAbility",
"description": "Test Entry Ability",
"icon": "$media:icon",
"label": "TestAbility",
"launchType": "standard",
"orientation": "landscape",
"visible": true,
"type": "page"
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 750,
"autoDesignWidth": false
}
}
]
}
}
\ 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');
}
};
{
"strings": {
"hello": "Hello",
"world": "World"
},
"Files": {
}
}
\ No newline at end of file
{
"strings": {
"hello": "您好",
"world": "世界"
},
"Files": {
}
}
\ 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) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import file from '@system.file'
import {Core, ExpectExtend, ReportExtend} 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'
})
const reportExtend = new ReportExtend(file)
core.addService('expect', expectExtend)
core.addService('report', reportExtend)
core.init()
const configService = core.getDefaultService('config')
configService.setConfig(this)
require('../../../test/List.test')
core.execute()
},
onReady() {
},
}
/*
* 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.
*/
require('./basicabilityapi.test.js')
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import configuration from '@system.configuration';
import prompt from '@system.prompt';
import router from '@system.router';
describe('basicabilityapi', function() {
let testResult;
let testResultFail;
let test;
beforeAll(function() {
testResult = true;
testResultFail = false;
test="success"
});
beforeEach(function() {});
afterEach(function() {});
/**
* @tc.number SUB_ACE_BASICABILITY_JS_API_0100
* @tc.name testClearInterval
* @tc.desc Cancel the repetitive timing tasks previously set by setInterval.
*/
it('testClearInterval', 0, function() {
console.info('testClearInterval START');
let intervalID = setInterval(function() {
console.info('TEST do very 1s.');
}, 1000);
clearInterval(intervalID);
expect(test).assertEqual('success');
console.info('[clearInterval] success');
console.info('testClearInterval END');
});
/**
* @tc.number SUB_ACE_BASICABILITY_JS_API_0200
* @tc.name testConsole
* @tc.desc Print a text message.
*/
it('testConsole', 0, function() {
console.info('testConsole START');
const versionCode = 1.1;
console.info('[console.info] versionCode: ' + versionCode);
console.debug('[console.debug] versionCode: ' + versionCode);
console.log('[console.log] versionCode: ' + versionCode);
console.warn('[console.warn] versionCode: ' + versionCode);
console.error('[console.error] versionCode: ' + versionCode);
expect(test).assertEqual('success');
console.info('testConsole END');
});
/**
* @tc.number SUB_ACE_BASICABILITY_JS_API_0300
* @tc.name testRouterPush
* @tc.desc Go to the specified page of the application.
*/
it('testRouterPush', 0, function() {
router.push({
uri:'pages/routePush/index',
params: {
myData:'this is params data'
}
});
setTimeout(() => {
let pages = router.getState();
console.info("[router.clear] getState"+JSON.stringify(pages));
}, 500);
expect(test).assertEqual('success');
});
/**
* @tc.number SUB_ACE_BASICABILITY_JS_API_0400
* @tc.name testRouterReplace
* @tc.desc Replace the current page with a page in the application, and destroy the replaced page.
*/
it('testRouterReplace', 0, function() {
console.info('testRouterReplace START');
router.replace({
uri: 'pages/routerReplace/index',
params: {
data1: 'message',
}
});
expect(test).assertEqual('success');
console.info("[router.replace] success");
console.info('testRouterReplace END');
});
/**
* @tc.number SUB_ACE_BASICABILITY_JS_API_0500
* @tc.name testRouterBack
* @tc.desc Return to the previous page or the specified page.
*/
it('testRouterBack', 0, function() {
console.info('testRouterBack START');
router.push({
uri: 'pages/detail/detail'
});
router.back({
path: 'pages/mediaquery/mediaquery'
});
expect(test).assertEqual('success');
console.info('[router.back] success');
console.info('testRouterBack END');
});
/**
* @tc.number SUB_ACE_BASICABILITY_JS_API_0600
* @tc.name testRouterClear
* @tc.desc Clear all historical pages in the page stack, and only keep the current page as the top page.
*/
it('testRouterClear', 0, function() {
console.info('testRouterClear START');
new Promise(function(resolve, reject) {
router.push({
uri:'pages/routePush/index',
params:{
myData:'message'
}
});
setTimeout(()=>{
console.info("[router.clear] getLength: " + router.getLength());
}, 2000);
resolve();
}).then(function() {
expect(testResult).toBeTrue();
}, function() {
console.log('[router.clear] fail');
expect(testResultFail).toBeTrue();
});
console.info('testRouterClear END');
});
/**
* @tc.number SUB_ACE_BASICABILITY_JS_API_0700
* @tc.name testRouterLength
* @tc.desc Get the number of pages currently in the page stack.
*/
it('testRouterLength', 0, function() {
router.push({
uri: 'pages/dialog/dialog',
params: {
data1: 'message',
data2: {
data3: [123, 456, 789],
data4: {
data5: 'message'
}
}
}
});
console.info('testRouterLength START');
let size = router.getLength();
console.info('[router.getLength] pages stack size = ' + size);
expect(size).assertEqual('1');
console.info('testRouterLength END');
});
/**
* @tc.number SUB_ACE_BASICABILITY_JS_API_0800
* @tc.name testRouterGetState
* @tc.desc Get the status information of the current page.
*/
it('testRouterGetState', 0, function() {
console.info('testRouterGetState START');
let page = router.getState();
console.info('[router.getState] index: ' + page.index);
console.info('[router.getState] name: ' + page.name);
console.info('[router.getState] path: ' + page.path);
expect(page.index).assertEqual('1');
expect(page.name).assertEqual('index');
expect(page.path).assertEqual('pages/index/');
console.info('testRouterGetState END');
});
/**
* @tc.number SUB_ACE_BASICABILITY_JS_API_0900
* @tc.name testPromptShowToast
* @tc.desc Show text pop-up window.
*/
it('testPromptShowToast', 0, function() {
console.info('testPromptShowToast START');
const delay = 5000;
prompt.showToast({
message:'message',
duration:delay,
});
expect(test).assertEqual('success');
console.info('[prompt.showToast] success');
console.info('testPromptShowToast END');
});
/**
* @tc.number SUB_ACE_BASICABILITY_JS_API_1000
* @tc.name testPromptDialog
* @tc.desc Display the dialog box in the page.
*/
it('testPromptDialog', 0, function() {
console.info('testPromptDialog START')
prompt.showDialog({
title: 'dialog showDialog test',
message: 'message of dialog',
buttons: [
{
text: 'OK',
color: '#0000ff',
index: 0
}
],
success: function(ret) {
console.info("[prompt.showDialog] ret.index " + ret.index);
expect(testResult).toBeTrue();
},
cancel: function() {
console.log('[prompt.showDialog] dialog cancel callback');
expect(testResultFail).toBeTrue();
},
complete: function() {
console.log('[prompt.showDialog] complete');
}
});
console.info('testPromptDialog END');
});
/**
* @tc.number SUB_ACE_BASICABILITY_JS_API_1100
* @tc.name testConfigurationGetLocale
* @tc.desc Get the current language and region of the app. Synchronize with the language and region.
*/
it('testConfigurationGetLocale', 0, function() {
console.info('testConfigurationGetLocale START');
const localeInfo = configuration.getLocale();
console.info("[configuration.getLocale] language: " + localeInfo.language);
console.info("[configuration.getLocale] countryOrRegion: " + localeInfo.countryOrRegion);
console.info("[configuration.getLocale] dir: " + localeInfo.dir);
expect(localeInfo.language).assertEqual('zh');
expect(localeInfo.countryOrRegion).assertEqual('CN');
expect(localeInfo.dir).assertEqual('ltr');
console.info('testConfigurationGetLocale END');
});
/**
* @tc.number SUB_ACE_BASICABILITY_JS_API_1200
* @tc.name testSetTimeout
* @tc.desc Set up a timer that executes a function or a specified piece of code after the timer expires.
*/
it('testSetTimeout', 0, function() {
console.info('testSetTimeout START');
let start_time = new Date().getTime();
const delay = 200;
console.info("[settimeout] start_time: " + start_time);
setTimeout(function(v1,v2) {
let end_time = new Date().getTime();
console.info('[settimeout] delay: ' + (end_time - start_time) / 1000);
console.info('[settimeout] v1: ' + v1);
console.info('[settimeout] v2: ' + v2);
expect(testResult).toBeTrue();
}, delay, 'test', 'message');
console.info('testSetTimeout END');
});
/**
* @tc.number SUB_ACE_BASICABILITY_JS_API_1300
* @tc.name testClearTimeout
* @tc.desc The timer previously established by calling setTimeout() is cancelled.
*/
it('testClearTimeout', 0, function() {
console.info('testClearTimeout START');
let timeoutID = setTimeout(function() {
console.info('delay 1s');
}, 1000);
clearTimeout(timeoutID);
expect(test).assertEqual('success');
console.info("[clearTimeout] success");
console.info('testClearTimeout END');
});
/**
* @tc.number SUB_ACE_BASICABILITY_JS_API_1400
* @tc.name testSetInterval
* @tc.desc Call a function or execute a code segment repeatedly, with a fixed time delay between each call.
*/
it('testSetInterval', 0, function() {
console.info('testSetInterval START');
let intervalID = setInterval(function() {
console.log('do very 1s.');
expect(testResult).toBeTrue();
}, 1000);
console.info("[setInterval] intervalID: " + intervalID);
console.info('testSetInterval END');
});
});
\ No newline at end of file
{
"plural":[
{
"name":"plural_name",
"value":[
{
"quantity":"zero",
"value":"%d test zero"
},
{
"quantity":"one",
"value":"%d test one"
},
{
"quantity":"two",
"value":"%d test two"
},
{
"quantity":"few",
"value":"%d test few"
},
{
"quantity":"many",
"value":"%d test many"
},
{
"quantity":"other",
"value":"%d test other"
}
]
}
]
}
\ No newline at end of file
{
"strarray": [
{
"name": "sizeList",
"value":[
{
"value":"small"
},
{
"value":"middle"
},
{
"value":"large"
},
{
"value":"extra large"
}
]
}
]
}
\ No newline at end of file
{
"string": [
{
"name": "app_name",
"value": "aceceshi"
},
{
"name": "mainability_description",
"value": "hap sample empty page"
}
]
}
# Copyright (C) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//build/ohos_var.gni")
group("appexecfwk") {
testonly = true
if (is_standard_system) {
} else {
deps = [
]
}
}
#!/bin/bash
# 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.
set -e
usage()
{
echo
echo "USAGE"
echo " ./build.sh [suite=BUILD_TARGET] [target_os=TARGET_OS] [target_arch=TARGET_ARCH] [variant=BUILD_VARIANT] [target_subsystem=TARGET_SUBSYSTEM]"
echo " target_platform : TARGET_PLATFORM the target platform, such as phone or ivi; Default to phone"
echo " suite : BUILD_TARGET cts/hit/vts and so on, default value is hit"
echo " target_arch : TARGET_ARCH arm64 or arm32, default value is arm64"
echo " variant : BUILD_VARIANT release or debug, default value is debug"
echo " target_subsystem : TARGET_SUBSYSTEM the target subsystem to build"
echo " system_size : SYSTEM_SIZE standard, large and son on, large is for L3-L5, standard is for L2 default value is large"
echo " product_name : PRODUCT_NAME the name of product. such as hikey960, Hi3516DV300, and so on."
echo
exit 1
}
parse_cmdline()
{
BASE_HOME=$(dirname $(cd $(dirname $0); pwd))
BASE_HOME=${BASE_HOME}/../..
BUILD_TOOLS_DIR=${BASE_HOME}/prebuilts/build-tools/linux-x86/bin
OUT_DIR=${BASE_HOME}/out
BUILD_SHELL=${BASE_HOME}/build.sh
# build all parts for all products by default
BUILD_TARGET=""
TARGET_PLATFORM=all
GN_ARGS="is_dbt_test=true include_all=false"
TARGET_ARCH=arm64
BUILD_VARIANT=release
UPLOAD_API_INFO=False
SYSTEM_SIZE=large
PRODUCT_NAME=""
export PATH=${BASE_HOME}/prebuilts/python/linux-x86/3.8.3/bin:$PATH
while [ -n "$1" ]
do
var="$1"
OPTIONS=${var%%=*}
PARAM=${var#*=}
echo "OPTIONS=$OPTIONS"
echo "PARAM=$PARAM"
echo "-------------------"
case "$OPTIONS" in
suite) BUILD_TARGET="$PARAM"
;;
target_arch) TARGET_ARCH="$PARAM"
;;
variant) BUILD_VARIANT="$PARAM"
;;
target_platform) TARGET_PLATFORM="$PARAM"
;;
target_subsystem) export target_subsystem=${PARAM}
;;
system_size) SYSTEM_SIZE="$PARAM"
;;
product_name) PRODUCT_NAME="$PARAM"
;;
upload_api_info) UPLOAD_API_INFO=$(echo $PARAM |tr [a-z] [A-Z])
;;
*) usage
break;;
esac
shift
done
if [ "$SYSTEM_SIZE" = "standard" ]; then
BUILD_TARGET=${BUILD_TARGET:-"acts"}
PRODUCT_NAME=${PRODUCT_NAME:-"Hi3516DV300"}
else
BUILD_TARGET=${BUILD_TARGET:-"acts acts_ivi acts_intellitv acts_wearable"}
PRODUCT_NAME=${PRODUCT_NAME:-"arm64"}
fi
}
do_make()
{
cd $BASE_HOME
ACTS_ROOT="$BASE_HOME/test/xts/acts"
rm -rf "$BASE_HOME/test/xts/autogen_apiobjs"
export XTS_SUITENAME=acts
if [ "$SYSTEM_SIZE" = "standard" ]; then
./build.sh --product-name $PRODUCT_NAME --gn-args build_xts=true --build-target $BUILD_TARGET --build-target "deploy_testtools" --gn-args is_standard_system=true
else
if [ "$BUILD_TARGET" = "acts acts_ivi acts_intellitv acts_wearable" ]; then
./build.sh --product-name $PRODUCT_NAME --gn-args build_xts=true --build-target "acts" --build-target "acts_ivi" --build-target "acts_intellitv" --build-target "acts_wearable" --build-target "deploy_testtools"
else
./build.sh --product-name $PRODUCT_NAME --gn-args build_xts=true --build-target $BUILD_TARGET --build-target "deploy_testtools"
fi
fi
ret=$?
rm -rf "$BASE_HOME/test/xts/autogen_apiobjs"
if [ "$ret" != 0 ]; then
echo "build error"
exit 1
fi
}
parse_cmdline $@
do_make
exit 0
# Copyright (C) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//build/ohos_var.gni")
group("demo") {
testonly = true
if (is_standard_system) {
deps = [
"hjsunit_sample:hjs_demo_test",
]
}
}
# Copyright (C) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("hjs_demo_test") {
test_hap_name = "Hjsdemotest"
hap_source_path = "hap/entry-debug-signed.hap"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "21600000",
"package": "com.example.myapplication",
"shell-timeout": "21600000"
},
"kits": [
{
"test-file-name": [
"Hjsdemotest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
{
"app": {
"bundleName": "com.example.myapplication",
"vendor": "example",
"version": {
"code": 1,
"name": "1.0"
},
"apiVersion": {
"compatible": 4,
"target": 4
}
},
"deviceConfig": {},
"module": {
"package": "com.example.myapplication",
"name": ".MyApplication",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"name": "com.example.myapplication.MainAbility",
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "MyApplication",
"type": "page",
"launchType": "standard"
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
]
}
}
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import device from '@system.device';
export default {
onCreate() {
console.info('AceApplication onCreate');
},
onDestroy() {
console.info('AceApplication onDestroy');
}
};
{
"strings": {
"hello": "Hello",
"world": "World"
}
}
\ No newline at end of file
{
"strings": {
"hello": "您好",
"world": "世界"
}
}
\ No newline at end of file
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import file from '@system.file'
import app from '@system.app'
//import {Core, ExpectExtend, ReportExtend, InstrumentLog} from 'deccjsunit/index'
import {Core, ExpectExtend, ReportExtend} 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'
})
const reportExtend = new ReportExtend(file)
// const instrumentLog = new InstrumentLog({
// 'id': 'report'
// })
core.addService('expect', expectExtend)
core.addService('report', reportExtend)
// core.addService('report', instrumentLog)
core.init()
// core.subscribeEvent('spec', instrumentLog)
// core.subscribeEvent('suite', instrumentLog)
// core.subscribeEvent('task', instrumentLog)
const configService = core.getDefaultService('config')
configService.setConfig(this)
require('../../../test/List.test')
core.execute()
},
onReady() {
},
}
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import app from '@system.app'
import Context from '@ohos.napi_context'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
describe('appInfoTest', function () {
console.log("*************00000000000000000000000*************");
it('app_info_test_001', 0, function () {
var info = app.getInfo()
expect(info.versionName).assertEqual('1.0')
expect(info.versionCode).assertEqual('3')
})
it('app_info_test_002', 0, function () {
var info = app.getInfo()
expect(info.versionName).assertEqual('1.0')
expect(info.versionCode).assertEqual('2')
expect(info).assertNull()
})
it('app_info_test_003', 0, function () {
var info = app.getInfo()
expect(info.versionName).assertEqual('1.0')
expect(info.versionCode).assertEqual('4')
})
it('app_info_test_004', 0, function () {
var info = app.getInfo()
expect(info.versionName).assertEqual('1.0')
expect(info.versionCode).assertEqual('5')
})
it('get_process_info_test_001', 0, async function (done) {
console.log("111")
expect(1).assertLarger(0)
Context.getProcessInfo().then(info => {
console.log("222");
console.log("process_info: " + JSON.stringify(info));
expect(info.processName.length).assertLarger(0);
expect(info.pid).assertLarger(0);
});
done()
})
})
/*
* 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.
*/
require('./ExampleJsunit.test.js')
# Copyright (C) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
import("//build/ohos_var.gni")
group("developtoolstestacts") {
testonly = true
if (is_standard_system) {
deps = [ "hiplugintest:hipluginmoduleapitest" ]
}
}
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//build/test.gni")
import("//test/xts/tools/build/suite.gni")
import("../../../../../developtools/profiler/device/base/config.gni")
###############################################################################
config("module_private_config") {
visibility = [":*"]
}
ohos_moduletest_suite("hipluginmoduleapitest") {
deps = [
"//third_party/googletest:gtest",
"${OHOS_PROFILER_DIR}/protos/types/plugins/memory_data:memory_data_cpp",
"${OHOS_PROFILER_DIR}/device/plugins/memory_plugin:memdataplugin",
]
include_dirs = [
"${OHOS_PROFILER_DIR}/interfaces/kits/",
"${OHOS_PROFILER_DIR}/device/plugins/memory_plugin/include",
"${OHOS_PROFILER_DIR}/device/plugins/api/include",
"${OHOS_PROFILER_DIR}/device/plugins/api/src",
"${OHOS_PROFILER_DIR}/device/base/include/",
"//third_party/googletest/googletest/include/gtest",
]
sources = [
"${OHOS_PROFILER_DIR}/device/plugins/memory_plugin/test/unittest/buffer_splitter_unittest.cpp",
"${OHOS_PROFILER_DIR}/device/plugins/memory_plugin/test/unittest/memory_data_plugin_unittest.cpp",
"hipluginmoduleapitest.cpp",
]
cflags = [
"-pthread",
"-Wno-inconsistent-missing-override",
"-Dprivate=public", #allow test code access private members
]
external_deps = [
"hiviewdfx_hilog_native:libhilog",
]
subsystem_name = "${OHOS_PROFILER_SUBSYS_NAME}"
defines = [ "HAVE_HILOG", ]
}
{
"kits": [
{
"push": [
"hipluginmoduleapitest->/data/local/tmp/hipluginmoduleapitest"
],
"type": "PushKit",
"post-push": [
"chmod -R 777 /data/local/tmp/*"
]
}
],
"driver": {
"native-test-timeout": "120000",
"type": "CppTest",
"module-name": "hipluginmoduleapitest",
"runtime-hint": "1s",
"native-test-device-path": "/data/local/tmp"
},
"description": "Configuration for hipluginmoduleapitest Tests"
}
/*
* 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.
*/
#include <dlfcn.h>
#include <hwext/gtest-ext.h>
#include <hwext/gtest-tag.h>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
#include <sys/types.h>
#include <time.h>
#include <unistd.h>
#include <vector>
#include "logging.h"
#include "memory_plugin_config.pb.h"
#include "memory_plugin_result.pb.h"
#include "plugin_module_api.h"
using namespace testing::ext;
#if defined(__i386__) || defined(__x86_64__)
const std::string LIB_PATH = const_cast<char*>("./hos/out/hos-arm/clang_x64/devtools/devtools/libmemdataplugin.z.so");
#else
const std::string LIB_PATH = const_cast<char*>("/system/lib/libmemdataplugin.z.so");
#endif
namespace {
enum NumType {
BIT_WIDTH = 35,
MS_S = 1000000,
};
class PluginModuleApiTest : public ::testing::Test {
protected:
static void SetUpTestCase() {}
static void TearDownTestCase() {}
void SetUp() override {}
void TearDown() override {}
bool MatchTail(const std::string& name, const char* str)
{
int index = name.size() - strlen(str);
if (index < 0) {
return false;
}
return strncmp(name.c_str() + index, str, strlen(str)) == 0;
}
bool MemoryPluginTest(MemoryConfig& protoConfig, const std::string libPath)
{
MemoryData memoryData;
PluginModuleStruct* memplugin;
void* handle;
int cnt = 1;
uint8_t* dataBuffer;
clock_t clockstart, clockend;
struct timeval start, end;
int timeuse;
if (!MatchTail(libPath, ".so")) {
printf("libPath=%s\r\n", libPath.c_str());
return false;
}
handle = dlopen(libPath.c_str(), RTLD_LAZY);
if (handle == nullptr) {
HILOG_DEBUG(LOG_CORE, "test:dlopen err:%s.", dlerror());
return false;
}
memplugin = (PluginModuleStruct*)dlsym(handle, "g_pluginModule");
dataBuffer = (uint8_t*)malloc(memplugin->resultBufferSizeHint);
int configlength = protoConfig.ByteSizeLong();
std::vector<uint8_t> config(configlength);
protoConfig.SerializeToArray(config.data(), config.size());
if (memplugin->callbacks->onPluginSessionStart(config.data(), config.size()) < 0) {
HILOG_DEBUG(LOG_CORE, "start failed");
dlclose(handle);
free(dataBuffer);
return false;
}
clockstart = clock();
gettimeofday(&start, nullptr);
while (cnt--) {
int len = memplugin->callbacks->onPluginReportResult(dataBuffer, memplugin->resultBufferSizeHint);
if (len > 0) {
memoryData.ParseFromArray(dataBuffer, len);
}
}
gettimeofday(&end, nullptr);
clockend = clock();
timeuse = MS_S * (end.tv_sec - start.tv_sec) + end.tv_usec - start.tv_usec;
HILOG_DEBUG(LOG_CORE, "clock time=%.3fs, timeofday=%.3fs", (double)(clockend - clockstart) / CLOCKS_PER_SEC,
(double)timeuse / MS_S);
memplugin->callbacks->onPluginSessionStop();
memplugin->callbacks->onRegisterWriterStruct(nullptr);
dlclose(handle);
free(dataBuffer);
return true;
}
};
HWTEST_F(PluginModuleApiTest, ProtoConfigNullAndInvalidSo, TestSize.Level1)
{
MemoryConfig protoConfig;
EXPECT_FALSE(PluginModuleApiTest::MemoryPluginTest(protoConfig, "1111"));
}
HWTEST_F(PluginModuleApiTest, ProtoConfigNullAndEffectiveSo, TestSize.Level1)
{
MemoryConfig protoConfig;
EXPECT_TRUE(PluginModuleApiTest::MemoryPluginTest(protoConfig, LIB_PATH));
}
HWTEST_F(PluginModuleApiTest, ProtoConfigMemAndInvalidSo, TestSize.Level1)
{
MemoryConfig protoConfig;
protoConfig.set_report_process_mem_info(true);
EXPECT_FALSE(PluginModuleApiTest::MemoryPluginTest(protoConfig, "1111"));
}
HWTEST_F(PluginModuleApiTest, ProtoConfigMemAndEffectiveSo, TestSize.Level1)
{
MemoryConfig protoConfig;
protoConfig.set_report_process_mem_info(true);
EXPECT_TRUE(PluginModuleApiTest::MemoryPluginTest(protoConfig, LIB_PATH));
}
HWTEST_F(PluginModuleApiTest, ProtoConfigPidAndInvalidSo, TestSize.Level1)
{
MemoryConfig protoConfig;
protoConfig.set_report_app_mem_info(true);
protoConfig.add_pid(1);
EXPECT_FALSE(PluginModuleApiTest::MemoryPluginTest(protoConfig, "1111"));
}
HWTEST_F(PluginModuleApiTest, ProtoConfigPidAndEffectiveSo, TestSize.Level1)
{
MemoryConfig protoConfig;
protoConfig.set_report_app_mem_info(true);
protoConfig.add_pid(1);
EXPECT_TRUE(PluginModuleApiTest::MemoryPluginTest(protoConfig, LIB_PATH));
}
HWTEST_F(PluginModuleApiTest, MemoryPluginTreeAndInvalidSo, TestSize.Level1)
{
MemoryConfig protoConfig;
protoConfig.set_report_process_tree(true);
EXPECT_FALSE(PluginModuleApiTest::MemoryPluginTest(protoConfig, "1111"));
}
HWTEST_F(PluginModuleApiTest, MemoryPluginTreeAndEffectiveSo, TestSize.Level1)
{
MemoryConfig protoConfig;
protoConfig.set_report_process_tree(true);
EXPECT_TRUE(PluginModuleApiTest::MemoryPluginTest(protoConfig, LIB_PATH));
}
HWTEST_F(PluginModuleApiTest, ApiCallInvalidSoAndInvalidStruct, TestSize.Level1)
{
PluginModuleStruct memplugin;
ASSERT_EQ(memplugin.callbacks->onPluginSessionStart(nullptr, 0), 0);
ASSERT_EQ(memplugin.callbacks->onPluginReportResult(nullptr, 0), 0);
ASSERT_EQ(memplugin.callbacks->onPluginSessionStop(), 0);
ASSERT_EQ(memplugin.callbacks->onRegisterWriterStruct(nullptr), 0);
}
HWTEST_F(PluginModuleApiTest, ApiCallEffectiveSoAndInvalidStruct, TestSize.Level1)
{
PluginModuleStruct* memplugin;
void* handle = dlopen(LIB_PATH.c_str(), RTLD_LAZY);
if (handle == nullptr) {
HILOG_DEBUG(LOG_CORE, "test:dlopen err:%s.", dlerror());
}
memplugin = (PluginModuleStruct*)dlsym(handle, "g_pluginModule");
ASSERT_EQ(memplugin->callbacks->onPluginSessionStart(nullptr, 0), 0);
ASSERT_EQ(memplugin->callbacks->onPluginReportResult(nullptr, 0), 0);
ASSERT_EQ(memplugin->callbacks->onPluginSessionStop(), 0);
ASSERT_EQ(memplugin->callbacks->onRegisterWriterStruct(nullptr), 0);
}
HWTEST_F(PluginModuleApiTest, ApiCallInvalidSoAndEffectiveStruct, TestSize.Level1)
{
PluginModuleStruct memplugin;
WriterStruct writer;
ASSERT_EQ(memplugin.callbacks->onPluginSessionStart(nullptr, 0), 0);
ASSERT_EQ(memplugin.callbacks->onPluginSessionStop(), 0);
ASSERT_EQ(memplugin.callbacks->onRegisterWriterStruct(&writer), 0);
}
HWTEST_F(PluginModuleApiTest, ApiCallEffectiveSoAndEffectiveStruct, TestSize.Level1)
{
PluginModuleStruct* memplugin;
WriterStruct writer;
void* handle = dlopen(LIB_PATH.c_str(), RTLD_LAZY);
if (handle == nullptr) {
HILOG_DEBUG(LOG_CORE, "test:dlopen err:%s.", dlerror());
}
memplugin = (PluginModuleStruct*)dlsym(handle, "g_pluginModule");
ASSERT_EQ(memplugin->callbacks->onPluginSessionStart(nullptr, 0), 0);
ASSERT_EQ(memplugin->callbacks->onPluginSessionStop(), 0);
ASSERT_EQ(memplugin->callbacks->onRegisterWriterStruct(&writer), 0);
}
} // namespace
# Copyright (C) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
group("distributeddatamgr") {
testonly = true
if (is_standard_system) {
deps = [
"appdatamgrjstest/hap:appdatamgr_js_test",
"distributedfilejstest:distributedfile_js_test",
]
} else {
deps = [
"appdatamgrtest/hap:appdatamgrfunctest_hap",
"distributeddatamgrtest/hap:distributeddatamgrfunctest_hap",
"distributedfiletest/hap:distributedfilefunctest_hap",
"searchtest/hap:searchfunctest_hap",
]
}
}
# Copyright (C) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("appdatamgr_js_test") {
test_hap_name = "AppdatamagrJsTest"
hap_source_path = "entry-test-signed.hap"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "21600000",
"package": "com.example.myapplication",
"abilityName": "decc.testkit.runner.JsEntryAbility",
"shell-timeout": "21600000"
},
"kits": [
{
"test-file-name": [
"AppdatamagrJsTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
{
"app": {
"bundleName": "com.example.myapplication",
"vendor": "example",
"version": {
"code": 1,
"name": "1.0"
},
"apiVersion": {
"compatible": 4,
"target": 4
}
},
"deviceConfig": {},
"module": {
"package": "com.example.myapplication",
"name": ".AppdatamgrJSTest",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"name": "decc.testkit.runner.JsEntryAbility",
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "AppdatamgrJSTest",
"type": "page",
"launchType": "standard"
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
]
}
}
/*
* 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');
}
};
{
"strings": {
"hello": "Hello",
"world": "World"
},
"Files": {
}
}
\ No newline at end of file
{
"strings": {
"hello": "您好",
"world": "世界"
},
"Files": {
}
}
\ 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.
*/
.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) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import file from '@system.file'
import {Core, ExpectExtend, ReportExtend} 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'
})
const reportExtend = new ReportExtend(file)
core.addService('expect', expectExtend)
core.addService('report', reportExtend)
core.init()
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.
* 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('./StorageHelperJsunit.test.js')
require('./StorageSyncJsunit.test.js')
require('./StoragePromiseJsunit.test.js')
require('./StorageCallBackJsunit.test.js')
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
import storage from '@ohos.data.storage'
const PATH = '/data/test_storage';
const KEY_TEST_INT_ELEMENT = 'key_test_int';
const KEY_TEST_LONG_ELEMENT = 'key_test_long';
const KEY_TEST_FLOAT_ELEMENT = 'key_test_float';
const KEY_TEST_BOOLEAN_ELEMENT = 'key_test_boolean';
const KEY_TEST_STRING_ELEMENT = 'key_test_string';
var mPref;
describe('storageTest', function () {
beforeAll(function () {
console.info('beforeAll')
mPref = storage.getStorageSync(PATH);
})
afterAll(function () {
console.info('afterAll')
storage.deleteStorageSync(PATH);
})
/**
* @tc.name clear callback interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_CallBack_0010
* @tc.desc clear callback interface test
*/
it('testClear0012', 0, async function (done) {
mPref.putSync(KEY_TEST_STRING_ELEMENT, "test");
mPref.flushSync();
await mPref.clear(function (err, ret) {
expect("defaultvalue").assertEqual(mPref.getSync(KEY_TEST_STRING_ELEMENT, "defaultvalue"));
});
done();
})
/**
* @tc.name has callback interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_CallBack_0020
* @tc.desc has callback interface test
*/
it('testHasKey0032', 0, async function (done) {
mPref.putSync(KEY_TEST_STRING_ELEMENT, "test");
await mPref.has(KEY_TEST_STRING_ELEMENT, function (err, ret) {
expect(true).assertEqual(ret);
})
done();
})
/**
* @tc.name get defaultValue callback interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_CallBack_0030
* @tc.desc get defaultValue callback interface test
*/
it('testGetDefValue0062', 0, async function (done) {
mPref.clearSync();
await mPref.get(KEY_TEST_STRING_ELEMENT, "defaultValue", function (err, ret) {
expect('defaultValue').assertEqual(ret);
})
done();
})
/**
* @tc.name get float callback interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_CallBack_0040
* @tc.desc get float callback interface test
*/
it('testGetFloat0072', 0, async function (done) {
mPref.clearSync();
mPref.putSync(KEY_TEST_FLOAT_ELEMENT, 3.0);
await mPref.get(KEY_TEST_FLOAT_ELEMENT, 0.0, function (err, ret) {
expect(3.0).assertEqual(ret);
})
done();
})
/**
* @tc.name get int callback interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_CallBack_0050
* @tc.desc get int callback interface test
*/
it('testGetInt0082', 0, async function (done) {
mPref.clearSync();
mPref.putSync(KEY_TEST_INT_ELEMENT, 3);
await mPref.get(KEY_TEST_INT_ELEMENT, 0.0, function (err, ret) {
expect(3).assertEqual(ret);
})
done();
})
/**
* @tc.name get long callback interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_CallBack_0060
* @tc.desc get long callback interface test
*/
it('testGetLong0092', 0, async function (done) {
mPref.clearSync();
mPref.putSync(KEY_TEST_LONG_ELEMENT, 3);
expect(3).assertEqual(mPref.getSync(KEY_TEST_LONG_ELEMENT, 0));
await mPref.get(KEY_TEST_LONG_ELEMENT, 0, function (err, ret) {
expect(3).assertEqual(ret);
});
done();
})
/**
* @tc.name get String callback interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_CallBack_0070
* @tc.desc get String callback interface test
*/
it('testGetString102', 0, async function (done) {
mPref.clearSync();
mPref.putSync(KEY_TEST_STRING_ELEMENT, "test");
mPref.flushSync();
await mPref.get(KEY_TEST_STRING_ELEMENT, "defaultvalue", function (err, ret) {
expect('test').assertEqual(ret);
});
done();
})
/**
* @tc.name put boolean callback interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_CallBack_0080
* @tc.desc put boolean callback interface test
*/
it('testPutBoolean0122', 0, async function (done) {
mPref.clearSync();
await mPref.put(KEY_TEST_BOOLEAN_ELEMENT, true, function (err, ret) {
expect(true).assertEqual(mPref.getSync(KEY_TEST_BOOLEAN_ELEMENT, false));
mPref.flushSync();
expect(true).assertEqual(mPref.getSync(KEY_TEST_BOOLEAN_ELEMENT, false));
});
done();
})
/**
* @tc.name put float callback interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_CallBack_0090
* @tc.desc put float callback interface test
*/
it('testPutFloat0132', 0, async function (done) {
mPref.clearSync();
await mPref.put(KEY_TEST_FLOAT_ELEMENT, 4.0, function (err, ret) {
expect(4.0).assertEqual(mPref.getSync(KEY_TEST_FLOAT_ELEMENT, 0.0));
mPref.flushSync();
expect(4.0).assertEqual(mPref.getSync(KEY_TEST_FLOAT_ELEMENT, 0.0));
});
done();
})
/**
* @tc.name put int callback interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_CallBack_0100
* @tc.desc put int callback interface test
*/
it('testPutInt0142', 0, async function (done) {
mPref.clearSync();
await mPref.put(KEY_TEST_INT_ELEMENT, 4, function (err, ret) {
expect(4).assertEqual(mPref.getSync(KEY_TEST_INT_ELEMENT, 0));
mPref.flushSync();
expect(4).assertEqual(mPref.getSync(KEY_TEST_INT_ELEMENT, 0));
});
done();
})
/**
* @tc.name put long callback interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_CallBack_0110
* @tc.desc put long callback interface test
*/
it('testPutLong0152', 0, async function (done) {
mPref.clearSync();
mPref.putSync(KEY_TEST_LONG_ELEMENT, 4);
await mPref.put(KEY_TEST_LONG_ELEMENT, 4, function (err, ret) {
expect(4).assertEqual(mPref.getSync(KEY_TEST_LONG_ELEMENT, 0));
mPref.flushSync();
expect(4).assertEqual(mPref.getSync(KEY_TEST_LONG_ELEMENT, 0));
});
done();
})
/**
* @tc.name put String callback interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_CallBack_0120
* @tc.desc put String callback interface test
*/
it('testPutString0162', 0, async function (done) {
mPref.clearSync();
await mPref.put(KEY_TEST_STRING_ELEMENT, "abc", function (err, ret) {
mPref.put(KEY_TEST_STRING_ELEMENT, '', function (err, ret) {
expect('').assertEqual(mPref.getSync(KEY_TEST_STRING_ELEMENT, "defaultvalue"));
mPref.flushSync();
expect('').assertEqual(mPref.getSync(KEY_TEST_STRING_ELEMENT, "defaultvalue"));
});
});
done();
})
})
\ No newline at end of file
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
import storage from '@ohos.data.storage'
const PATH = '/data/test_storage';
var mPref;
describe('storageTest', function () {
beforeAll(function () {
console.info('beforeAll')
mPref = storage.getStorageSync(PATH);
})
afterAll(function () {
console.info('afterAll')
storage.deleteStorageSync(PATH);
})
/**
* @tc.name getStorageSync interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0010
* @tc.desc getStorageSync interface test
*/
it('testGetStorageHelper001', 0, function () {
mPref = storage.getStorageSync(PATH);
mPref.putSync('test', 2);
mPref.flushSync();
var value = mPref.getSync('test', 0);
expect(value).assertEqual(2);
})
/**
* @tc.name getStorage interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0020
* @tc.desc getStorage interface test
*/
it('testGetStorageHelper002', 0, async function (done) {
const promise = storage.getStorage(PATH);
promise.then((pref) => {
pref.putSync('test', 2);
pref.flushSync();
var value = mPref.getSync('test', 0);
expect(value).assertEqual(2);
}).catch((err) => {
expect(null).assertFail();
});
await promise;
done();
})
/**
* @tc.name removeStorageFromCacheSync interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0030
* @tc.desc removeStorageFromCacheSync interface test
*/
it('testRemoveStorageFromCache001', 0, function () {
let perf = storage.getStorageSync('/data/test_storage1');
perf = null;
try {
storage.removeStorageFromCacheSync('/data/test_storage1');
} catch (e) {
expect(null).assertFail();
}
})
/**
* @tc.name removeStorageFromCache interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0040
* @tc.desc removeStorageFromCache interface test
*/
it('testRemoveStorageFromCache002', 0, async function (done) {
let perf = storage.getStorageSync('/data/test_storage2');
perf = null;
const promise = storage.removeStorageFromCache('/data/test_storage2');
promise.then((pref) => {
}).catch((err) => {
expect(null).assertFail();
});
await promise;
done();
})
/**
* @tc.name deleteStorageSync interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0050
* @tc.desc deleteStorageSync interface test
*/
it('testDeleteStorageHelper001', 0, function () {
let perf = storage.getStorageSync('/data/test_storage3');
perf = null;
try {
storage.deleteStorageSync('/data/test_storage3');
} catch (e) {
expect(null).assertFail();
}
})
/**
* @tc.name deleteStorage interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0060
* @tc.desc deleteStorage interface test
*/
it('testDeleteStorageHelper002', 0, async function (done) {
let perf = storage.getStorageSync('/data/test_storage4');
perf = null;
const promise = storage.deleteStorage('/data/test_storage4');
promise.then((pref) => {
}).catch((err) => {
expect(null).assertFail();
});
await promise;
done();
})
})
\ No newline at end of file
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
import storage from '@ohos.data.storage'
const PATH = '/data/test_storage';
const KEY_TEST_INT_ELEMENT = 'key_test_int';
const KEY_TEST_LONG_ELEMENT = 'key_test_long';
const KEY_TEST_FLOAT_ELEMENT = 'key_test_float';
const KEY_TEST_BOOLEAN_ELEMENT = 'key_test_boolean';
const KEY_TEST_STRING_ELEMENT = 'key_test_string';
var mPref;
describe('storageTest', function () {
beforeAll(function () {
console.info('beforeAll')
mPref = storage.getStorageSync(PATH);
})
afterAll(function () {
console.info('afterAll')
storage.deleteStorageSync(PATH);
})
/**
* @tc.name clear promise interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Promise_0010
* @tc.desc clear promise interface test
*/
it('testClear0011', 0, async function (done) {
mPref.putSync(KEY_TEST_STRING_ELEMENT, "test");
mPref.flushSync();
const promise = mPref.clear();
promise.then((ret) => {
expect("defaultvalue").assertEqual(mPref.getSync(KEY_TEST_STRING_ELEMENT, "defaultvalue"));
}).catch((err) => {
expect(null).assertFail();
});
await promise;
done();
})
/**
* @tc.name has promise interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0020
* @tc.desc has promise interface test
*/
it('testHasKey0031', 0, async function (done) {
mPref.putSync(KEY_TEST_STRING_ELEMENT, "test");
const promise = mPref.has(KEY_TEST_STRING_ELEMENT);
promise.then((ret) => {
expect(true).assertEqual(ret);
}).catch((err) => {
expect(null).assertFail();
});
await promise;
done();
})
/**
* @tc.name get defalut promise interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0030
* @tc.desc deleteStorage interface test
*/
it('testGetDefValue0061', 0, async function (done) {
mPref.clearSync();
const promise = mPref.get(KEY_TEST_STRING_ELEMENT, "defaultValue");
promise.then((ret) => {
expect('defaultValue').assertEqual(ret);
}).catch((err) => {
expect(null).assertFail();
});
await promise;
done();
})
/**
* @tc.name get float promise interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0040
* @tc.desc get float promise interface test
*/
it('testGetFloat0071', 0, async function (done) {
mPref.clearSync();
mPref.putSync(KEY_TEST_FLOAT_ELEMENT, 3.0);
const promise = mPref.get(KEY_TEST_FLOAT_ELEMENT, 0.0);
promise.then((ret) => {
expect(3.0).assertEqual(ret);
}).catch((err) => {
expect(null).assertFail();
});
await promise;
done();
})
/**
* @tc.name get int promise interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0050
* @tc.desc get int promise interface test
*/
it('testGetInt0081', 0, async function (done) {
mPref.clearSync();
mPref.putSync(KEY_TEST_INT_ELEMENT, 3);
const promise = mPref.get(KEY_TEST_INT_ELEMENT, 0.0);
promise.then((ret) => {
expect(3).assertEqual(ret);
}).catch((err) => {
expect(null).assertFail();
});
await promise;
done();
})
/**
* @tc.name get long promise interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0060
* @tc.desc get long promise interface test
*/
it('testGetLong0091', 0, async function (done) {
mPref.clearSync();
mPref.putSync(KEY_TEST_LONG_ELEMENT, 3);
const promise = mPref.get(KEY_TEST_LONG_ELEMENT, 0);
promise.then((ret) => {
expect(3).assertEqual(ret);
}).catch((err) => {
expect(null).assertFail();
});
await promise;
done();
})
/**
* @tc.name get String promise interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0070
* @tc.desc get String promise interface test
*/
it('testGetString101', 0, async function (done) {
mPref.clearSync();
mPref.putSync(KEY_TEST_STRING_ELEMENT, "test");
mPref.flushSync();
const promise = mPref.get(KEY_TEST_STRING_ELEMENT, "defaultvalue");
promise.then((ret) => {
expect('test').assertEqual(ret);
}).catch((err) => {
expect(null).assertFail();
});
await promise;
done();
})
/**
* @tc.name get String promise interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0090
* @tc.desc get String promise interface test
*/
it('testPutBoolean0121', 0, async function (done) {
mPref.clearSync();
const promise = mPref.put(KEY_TEST_BOOLEAN_ELEMENT, true);
promise.then((ret) => {
expect(true).assertEqual(mPref.getSync(KEY_TEST_BOOLEAN_ELEMENT, false));
mPref.flushSync();
expect(true).assertEqual(mPref.getSync(KEY_TEST_BOOLEAN_ELEMENT, false));
}).catch((err) => {
expect(null).assertFail();
});
await promise;
done();
})
/**
* @tc.name put float promise interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0100
* @tc.desc put float promise interface test
*/
it('testPutFloat0131', 0, async function (done) {
mPref.clearSync();
const promise = mPref.put(KEY_TEST_FLOAT_ELEMENT, 4.0);
promise.then((ret) => {
expect(4.0).assertEqual(mPref.getSync(KEY_TEST_FLOAT_ELEMENT, 0.0));
mPref.flushSync();
expect(4.0).assertEqual(mPref.getSync(KEY_TEST_FLOAT_ELEMENT, 0.0));
}).catch((err) => {
expect(null).assertFail();
});
await promise;
done();
})
/**
* @tc.name put int promise interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0110
* @tc.desc put int promise interface test
*/
it('testPutInt0141', 0, async function (done) {
mPref.clearSync();
const promise = mPref.put(KEY_TEST_INT_ELEMENT, 4);
promise.then((ret) => {
expect(4).assertEqual(mPref.getSync(KEY_TEST_INT_ELEMENT, 0));
mPref.flushSync();
expect(4).assertEqual(mPref.getSync(KEY_TEST_INT_ELEMENT, 0));
}).catch((err) => {
expect(null).assertFail();
});
await promise;
done();
})
/**
* @tc.name put long promise interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0120
* @tc.desc put long promise interface test
*/
it('testPutLong0151', 0, async function (done) {
mPref.clearSync();
mPref.putSync(KEY_TEST_LONG_ELEMENT, 4);
const promise = mPref.put(KEY_TEST_LONG_ELEMENT, 4);
promise.then((ret) => {
expect(4).assertEqual(mPref.getSync(KEY_TEST_LONG_ELEMENT, 0));
mPref.flushSync();
expect(4).assertEqual(mPref.getSync(KEY_TEST_LONG_ELEMENT, 0));
}).catch((err) => {
expect(null).assertFail();
});
await promise;
done();
})
/**
* @tc.name put String promise interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0130
* @tc.desc put String promise interface test
*/
it('testPutString0161', 0, async function (done) {
mPref.clearSync();
mPref.putSync(KEY_TEST_STRING_ELEMENT, "abc");
const promise = mPref.put(KEY_TEST_STRING_ELEMENT, '');
promise.then((ret) => {
expect('').assertEqual(mPref.getSync(KEY_TEST_STRING_ELEMENT, "defaultvalue"));
mPref.flushSync();
expect('').assertEqual(mPref.getSync(KEY_TEST_STRING_ELEMENT, "defaultvalue"));
}).catch((err) => {
expect(null).assertFail();
});
await promise;
done();
})
})
\ No newline at end of file
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
import storage from '@ohos.data.storage'
const PATH = '/data/test_storage';
const KEY_TEST_INT_ELEMENT = 'key_test_int';
const KEY_TEST_LONG_ELEMENT = 'key_test_long';
const KEY_TEST_FLOAT_ELEMENT = 'key_test_float';
const KEY_TEST_BOOLEAN_ELEMENT = 'key_test_boolean';
const KEY_TEST_STRING_ELEMENT = 'key_test_string';
var mPref;
describe('storageTest', function () {
beforeAll(function() {
console.info('beforeAll')
mPref = storage.getStorageSync(PATH);
})
afterAll(function () {
console.info('afterAll')
storage.deleteStorageSync(PATH);
})
it('testClear001', 0, function () {
mPref.putSync(KEY_TEST_STRING_ELEMENT, "test");
mPref.putSync(KEY_TEST_INT_ELEMENT, 3);
mPref.flushSync();
mPref.clearSync();
expect("defaultvalue").assertEqual(mPref.getSync(KEY_TEST_STRING_ELEMENT, "defaultvalue"));
expect(0).assertEqual(mPref.getSync(KEY_TEST_INT_ELEMENT, 0));
})
/**
* @tc.name Constructor test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Sync_0010
* @tc.desc Constructor test
*/
it('testConstructor002', 0, function () {
expect(mPref).assertInstanceOf('Object');
})
/**
* @tc.name has sync inteface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Sync_0020
* @tc.desc has sync inteface test
*/
it('testHasKey003', 0, function () {
mPref.putSync(KEY_TEST_STRING_ELEMENT, "test");
expect(true).assertEqual(mPref.hasSync(KEY_TEST_STRING_ELEMENT));
})
/**
* @tc.name get boolean sync inteface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Sync_0030
* @tc.desc get boolean sync inteface test
*/
it('testGetBoolean005', 0, function () {
mPref.putSync(KEY_TEST_BOOLEAN_ELEMENT, true);
expect(true).assertEqual(mPref.hasSync(KEY_TEST_BOOLEAN_ELEMENT));
})
/**
* @tc.name get defaltValue sync inteface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Sync_0040
* @tc.desc get defaltValue sync inteface test
*/
it('testGetDefValue006', 0, function () {
mPref.clearSync();
expect(-1).assertEqual(mPref.getSync(KEY_TEST_INT_ELEMENT, -1));
expect(1.0).assertEqual(mPref.getSync(KEY_TEST_FLOAT_ELEMENT, 1.0));
expect(10000).assertEqual(mPref.getSync(KEY_TEST_LONG_ELEMENT, 10000));
expect(true).assertEqual(mPref.getSync(KEY_TEST_BOOLEAN_ELEMENT, true));
expect('defaultValue').assertEqual(mPref.getSync(KEY_TEST_STRING_ELEMENT, "defaultValue"));
})
/**
* @tc.name get float sync inteface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Sync_0050
* @tc.desc get float sync inteface test
*/
it('testGetFloat007', 0, function () {
mPref.clearSync();
mPref.putSync(KEY_TEST_FLOAT_ELEMENT, 3.0);
expect(3.0).assertEqual(mPref.getSync(KEY_TEST_FLOAT_ELEMENT, 0.0), 0);
expect(0.0).assertEqual(mPref.getSync(KEY_TEST_STRING_ELEMENT, 0.0), 0);
})
/**
* @tc.name get int sync inteface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Sync_0060
* @tc.desc get int sync inteface test
*/
it('testGetInt008', 0, function () {
mPref.clearSync();
mPref.putSync(KEY_TEST_INT_ELEMENT, 3);
expect(3).assertEqual(mPref.getSync(KEY_TEST_INT_ELEMENT, 0.0), 0);
})
/**
* @tc.name get long sync inteface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Sync_0070
* @tc.desc get long sync inteface test
*/
it('testGetLong009', 0, function () {
mPref.clearSync();
mPref.putSync(KEY_TEST_LONG_ELEMENT, 3);
expect(3).assertEqual(mPref.getSync(KEY_TEST_LONG_ELEMENT, 0));
expect(0).assertEqual(mPref.getSync(KEY_TEST_STRING_ELEMENT, 0));
})
/**
* @tc.name get String sync inteface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Sync_0080
* @tc.desc get String sync inteface test
*/
it('testGetString10', 0, function () {
mPref.clearSync();
mPref.putSync(KEY_TEST_STRING_ELEMENT, "test");
mPref.putSync(KEY_TEST_INT_ELEMENT, 3);
mPref.flushSync();
expect('test').assertEqual(mPref.getSync(KEY_TEST_STRING_ELEMENT, "defaultvalue"));
expect('defaultvalue').assertEqual(mPref.getSync(KEY_TEST_INT_ELEMENT, "defaultvalue"));
})
/**
* @tc.name put float sync inteface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Sync_0090
* @tc.desc put float sync inteface test
*/
it('testPutBoolean012', 0, function () {
mPref.clearSync();
mPref.putSync(KEY_TEST_BOOLEAN_ELEMENT, true);
expect(true).assertEqual(mPref.getSync(KEY_TEST_BOOLEAN_ELEMENT, false));
mPref.flushSync();
expect(true).assertEqual(mPref.getSync(KEY_TEST_BOOLEAN_ELEMENT, false));
})
/**
* @tc.name put float sync inteface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Sync_0100
* @tc.desc put float sync inteface test
*/
it('testPutFloat013', 0, function () {
mPref.clearSync();
mPref.putSync(KEY_TEST_FLOAT_ELEMENT, 4.0);
expect(4.0).assertEqual(mPref.getSync(KEY_TEST_FLOAT_ELEMENT, 0.0));
mPref.flushSync();
expect(4.0).assertEqual(mPref.getSync(KEY_TEST_FLOAT_ELEMENT, 0.0));
})
/**
* @tc.name put int sync inteface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Sync_0110
* @tc.desc put int sync inteface test
*/
it('testPutInt014', 0, function () {
mPref.clearSync();
mPref.putSync(KEY_TEST_INT_ELEMENT, 4);
expect(4).assertEqual(mPref.getSync(KEY_TEST_INT_ELEMENT, 0));
mPref.flushSync();
expect(4).assertEqual(mPref.getSync(KEY_TEST_INT_ELEMENT, 0));
})
/**
* @tc.name put long sync inteface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Sync_0120
* @tc.desc put long sync inteface test
*/
it('testPutLong015', 0, function () {
mPref.clearSync();
mPref.putSync(KEY_TEST_LONG_ELEMENT, 4);
expect(4).assertEqual(mPref.getSync(KEY_TEST_LONG_ELEMENT, 0));
mPref.flushSync();
expect(4).assertEqual(mPref.getSync(KEY_TEST_LONG_ELEMENT, 0));
})
/**
* @tc.name put String sync inteface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Sync_0130
* @tc.desc put String sync inteface test
*/
it('testPutString016', 0, function () {
mPref.clearSync();
mPref.putSync(KEY_TEST_STRING_ELEMENT, "abc");
mPref.putSync(KEY_TEST_STRING_ELEMENT, '');
expect('').assertEqual(mPref.getSync(KEY_TEST_STRING_ELEMENT, "defaultvalue"));
mPref.flushSync();
expect('').assertEqual(mPref.getSync(KEY_TEST_STRING_ELEMENT, "defaultvalue"));
})
/**
* @tc.name on interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Sync_0140
* @tc.desc on interface test
*/
it('testRegisterObserver001', 0, function () {
mPref.clearSync();
var observer = function (key) {
expect('abcd').assertEqual(key);
};
mPref.on('change', observer);
mPref.putSync(KEY_TEST_STRING_ELEMENT, "abcd");
})
/**
* @tc.name repeat on interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Sync_0150
* @tc.desc repeat on interface test
*/
it('testRegisterObserver002', 0, function () {
mPref.clearSync();
var observer = function (key) {
console.info('testRegisterObserver001 key' + key);
expect('abc').assertEqual(key);
};
mPref.on('change', observer);
mPref.on('change', observer);
mPref.putSync(KEY_TEST_STRING_ELEMENT, "abc");
})
/**
* @tc.name off interface test
* @tc.number SUB_DDM_AppDataFWK_JSPreferences_Sync_0160
* @tc.desc off interface test
*/
it('testUnRegisterObserver001', 0, function () {
var observer = function (key) {
console.info('testUnRegisterObserver001 key' + key);
expect('').assertEqual(key);
};
mPref.on('change', observer);
mPref.off('change', observer);
mPref.putSync(KEY_TEST_STRING_ELEMENT, "abc");
})
})
\ No newline at end of file
{
"string": [
{
"name": "app_name",
"value": "MyApplication"
},
{
"name": "mainability_description",
"value": "hap sample empty page"
}
]
}
# Copyright (C) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("distributedfile_js_test") {
test_hap_name = "DistributedfileJSTest"
hap_source_path = "hap/entry-debug-rich-signed.hap"
}
{
"description": "Configuration for distributed file Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "21600000",
"package": "ohos.acts.distributeddatamgr.distributedfile",
"shell-timeout": "21600000"
},
"kits": [
{
"test-file-name": [
"DistributedfileJSTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
{
"app": {
"bundleName": "ohos.acts.distributeddatamgr.distributedfile",
"vendor": "example",
"version": {
"code": 1,
"name": "1.0"
},
"apiVersion": {
"compatible": 4,
"target": 4
}
},
"deviceConfig": {},
"module": {
"package": "ohos.acts.distributeddatamgr.distributedfile",
"name": ".DistributedFileJSTest",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"name": "ohos.acts.distributeddatamgr.distributedfile.MainAbility",
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "DistributedFileJSTest",
"type": "page",
"launchType": "standard"
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
]
}
}
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import device from '@system.device';
export default {
onCreate() {
console.info('ohos.acts.distributeddatamgr.distributedfile onCreate');
},
onDestroy() {
console.info('ohos.acts.distributeddatamgr.distributedfile onCreate');
}
};
{
"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) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import file from '@system.file'
import app from '@system.app'
import {Core, ExpectExtend, ReportExtend} 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'
})
const reportExtend = new ReportExtend(file)
core.addService('expect', expectExtend)
core.addService('report', reportExtend)
core.init()
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.
* 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 fileio from '@ohos.fileio'
export const FILE_CONTENT = "hello, world"
export function prepareFile(fpath, content) {
try {
let fd = fileio.openSync(fpath, 0o102, 0o666)
fileio.ftruncateSync(fd)
fileio.writeSync(fd, content)
fileio.fsyncSync(fd)
fileio.closeSync(fd)
return true
} catch (e) {
console.log("Failed to prepareFile for " + e)
return false
}
}
var fileSeed = 0
export function nextFileName(testName) {
const BASE_PATH = "/data/accounts/account_0/appdata/ohos.acts.distributeddatamgr.distributedfile/cache/"
return BASE_PATH + testName + fileSeed++
}
\ 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.
*/
require('./FileIO.test.js')
require('./FileIODir.test.js')
require('./FileIODirent.test.js')
require('./FileIOStat.test.js')
require('./FileIOStream.test.js')
\ No newline at end of file
{
"string": [
{
"name": "app_name",
"value": "DistributedFileJSTest"
},
{
"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.
先完成此消息的编辑!
想要评论请 注册