提交 33f55296 编写于 作者: R raoxian

modified FA-JS

Signed-off-by: Nraoxian <raoxian@huawei.com>
上级 96573db5
...@@ -25,7 +25,9 @@ ohos_js_hap_suite("storagefileio_js_test") { ...@@ -25,7 +25,9 @@ ohos_js_hap_suite("storagefileio_js_test") {
part_name = "xts_acts" part_name = "xts_acts"
} }
ohos_js_assets("storagefileio_js_assets") { ohos_js_assets("storagefileio_js_assets") {
source_dir = "./src/main/js/default" js2abc = true
hap_profile = "./src/main/config.json"
source_dir = "./src/main/js"
} }
ohos_resources("storagefileio_js_resources") { ohos_resources("storagefileio_js_resources") {
sources = [ "./src/main/resources" ] sources = [ "./src/main/resources" ]
......
{ {
"description": "Configuration for storage file and fileio Tests", "description": "Configuration for storage fileio Tests",
"driver": { "driver": {
"type": "JSUnitTest", "type": "OHJSUnitTest",
"test-timeout": "1800000", "test-timeout": "1800000",
"package": "ohos.acts.storage.fileio", "shell-timeout": "1800000",
"shell-timeout": "60000" "bundle-name": "ohos.acts.storage.fileio",
"package-name": "ohos.acts.storage.fileio"
}, },
"kits": [ "kits": [
{ {
"test-file-name": [ "test-file-name": ["ActsStorageFileIoJSTest.hap"],
"ActsStorageFileIoJSTest.hap"
],
"type": "AppInstallKit", "type": "AppInstallKit",
"cleanup-apps": true "cleanup-apps": true
} }
......
{ {
"app": { "app": {
"bundleName": "ohos.acts.storage.fileio", "bundleName": "ohos.acts.storage.fileio",
"vendor": "example", "vendor": "example",
"version": { "version": {
"code": 1000000, "code": 1000000,
"name": "1.0.0" "name": "1.0.0"
}, },
"apiVersion": { "apiVersion": {
"compatible": 4, "compatible": 4,
"target": 5 "target": 5
} }
},
"deviceConfig": {},
"module": {
"package": "ohos.acts.storage.fileio",
"name": ".MyApplication",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry",
"installationFree": true
}, },
"abilities": [ "deviceConfig": {},
{ "module": {
"skills": [ "package": "ohos.acts.storage.fileio",
{ "name": ".entry",
"entities": [ "deviceType": [
"entity.system.home" "phone"
],
"actions": [
"action.system.home"
]
}
], ],
"name": "ohos.acts.storage.fileio.MainAbility", "distro": {
"icon": "$media:icon", "deliveryWithInstall": true,
"description": "$string:mainability_description", "moduleName": "entry",
"label": "$string:app_name", "moduleType": "entry",
"type": "page", "installationFree": true
"launchType": "standard", },
"visible": true "abilities": [
} {
], "skills": [
"js": [ {
{ "entities": [
"pages": [ "entity.system.home"
"pages/index/index" ],
"actions": [
"action.system.home"
]
}
],
"orientation": "unspecified",
"formsEnabled": false,
"name": ".MainAbility",
"srcLanguage": "js",
"srcPath": "MainAbility",
"icon": "$media:icon",
"description": "$string:MainAbility_desc",
"label": "$string:MainAbility_label",
"type": "page",
"visible": true,
"launchType": "standard"
},
{
"orientation": "unspecified",
"formsEnabled": false,
"name": ".TestAbility",
"srcLanguage": "js",
"srcPath": "TestAbility",
"icon": "$media:icon",
"description": "$string:TestAbility_desc",
"label": "$string:TestAbility_label",
"type": "page",
"visible": true,
"launchType": "standard"
}
], ],
"name": "default", "js": [
"window": { {
"designWidth": 720, "pages": [
"autoDesignWidth": false "pages/index/index"
} ],
} "name": "default",
] "window": {
} "designWidth": 720,
"autoDesignWidth": false
}
},
{
"pages": [
"pages/index/index"
],
"name": ".TestAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
],
"testRunner": {
"name": "OpenHarmonyTestRunner",
"srcPath": "TestRunner"
},
"mainAbility": ".MainAbility",
"srcPath": ""
}
} }
\ No newline at end of file
...@@ -15,9 +15,9 @@ ...@@ -15,9 +15,9 @@
export default { export default {
onCreate() { onCreate() {
console.info('ohos.acts.distributeddatamgr.distributedfile onCreate'); console.info('ohos.acts.storage.fileio onCreate');
}, },
onDestroy() { onDestroy() {
console.info('ohos.acts.distributeddatamgr.distributedfile onCreate'); console.info('ohos.acts.storage.fileio onDestroy');
} }
}; };
...@@ -15,26 +15,19 @@ ...@@ -15,26 +15,19 @@
import app from '@system.app' import app from '@system.app'
import {Core} from 'deccjsunit/index'
const injectRef = Object.getPrototypeOf(global) || global const injectRef = Object.getPrototypeOf(global) || global
injectRef.regeneratorRuntime = require('@babel/runtime/regenerator') injectRef.regeneratorRuntime = require('@babel/runtime/regenerator')
export default { export default {
data: { data: {
title: '' title: ''
}, },
onInit() { onInit() {
this.title = this.$t('strings.world'); this.title = this.$t('strings.world');
}, },
onShow() { onShow() {
console.info('onShow finish') console.info('onShow finish')
const core = Core.getInstance()
core.init()
const configService = core.getDefaultService('config')
configService.setConfig(this)
require('../../test/List.test')
core.execute()
}, },
onReady() { 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 AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
import testsuite from '../test/List.test'
export default {
onCreate() {
console.info('TestApplication onCreate')
var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
},
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 {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
left: 0px;
top: 0px;
width: 100%;
height: 100%;
}
.title {
font-size: 60px;
text-align: center;
width: 100%;
height: 40%;
margin: 10px;
}
@media screen and (device-type: phone) and (orientation: landscape) {
.title {
font-size: 60px;
}
}
@media screen and (device-type: tablet) and (orientation: landscape) {
.title {
font-size: 100px;
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export default {
data: {
title: ""
},
onInit() {
this.title = this.$t('strings.world');
}
}
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
function translateParamsToString(parameters) {
const keySet = new Set([
'-s class', '-s notClass', '-s suite', '-s itName',
'-s level', '-s testType', '-s size', '-s timeout',
'-s package', '-s dryRun'
])
let targetParams = '';
for (const key in parameters) {
if (keySet.has(key)) {
targetParams += ' ' + key + ' ' + parameters[key]
}
}
return targetParams.trim()
}
export default {
onPrepare() {
console.info('OpenHarmonyTestRunner OnPrepare')
},
onRun() {
console.log('OpenHarmonyTestRunner onRun run')
var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.TestAbility'
var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName
cmd += ' ' + translateParamsToString(abilityDelegatorArguments.parameters)
var debug = abilityDelegatorArguments.parameters["-D"]
console.info('debug value : '+debug)
if (debug == 'true')
{
cmd += ' -D'
}
console.info('cmd : '+cmd)
abilityDelegator.executeShellCommand(cmd, (err, data) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
console.info('executeShellCommand : data : ' + data.stdResult);
console.info('executeShellCommand : data : ' + data.exitCode);
})
}
};
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* 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')
require('./module_fileio/members/open_close.test.js');
require('./module_fileio/class_dirent/all.test.js');
require('./module_fileio/class_watcher/createWatcher.test.js');
require('./module_fileio/class_stream/flush.test.js');
require('./module_fileio/class_stream/read.test.js');
require('./module_fileio/members/access.test.js');
require('./module_fileio/members/chmod.test.js');
require('./module_fileio/members/chown.test.js');
require('./module_fileio/members/close.test.js');
require('./module_fileio/members/copyFile.test.js');
require('./module_fileio/members/createStream.test.js');
require('./module_fileio/members/fchmod.test.js');
require('./module_fileio/members/fchown.test.js');
require('./module_fileio/members/fdatasync.test.js');
require('./module_fileio/members/fdopenStream.test.js');
require('./module_fileio/members/fstat.test.js');
require('./module_fileio/members/fsync.test.js');
require('./module_fileio/members/ftruncate.test.js');
require('./module_fileio/members/hash.test.js');
require('./module_fileio/members/lchown.test.js');
require('./module_fileio/members/lseek.test.js');
require('./module_fileio/members/lstat.test.js');
require('./module_fileio/members/mkdir_rmdir.test.js');
require('./module_fileio/members/mkdtemp.test.js');
require('./module_fileio/members/open.test.js');
require('./module_fileio/members/opendir_close.test.js');
require('./module_fileio/members/posix_fallocate.test.js');
require('./module_fileio/members/read.test.js');
require('./module_fileio/members/readtext.test.js');
require('./module_fileio/members/rename.test.js');
require('./module_fileio/members/rmdir.test.js');
require('./module_fileio/members/stat.test.js');
require('./module_fileio/members/symlink.test.js');
require('./module_fileio/members/truncate.test.js');
require('./module_fileio/members/unlink.test.js');
require('./module_fileio/members/write.test.js');
require('./module_fileio/class_dir/read.test.js');
require('./module_fileio/class_dir/close.test.js');
require('./module_fileio/class_stream/all.test.js');
require('./module_fileio/class_stream/close.test.js');
require('./module_fileio/class_stream/write.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 {
fileio, FILE_CONTENT, prepareFile, nextFileName,
describe, it, expect,
} from '../../Common';
describe('fileio_rmdir', function () {
/**
* @tc.number SUB_DF_FILEIO_RMDIR_ASYNC_0000
* @tc.name fileio_test_rmdir_async_000
* @tc.desc Test rmdirAsync() interfaces.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileio_test_rmdir_async_000', 0, async function (done) {
let dpath = await nextFileName('fileio_test_rmdir_async_000') + 'd';
try {
expect(fileio.mkdirSync(dpath) == null).assertTrue();
expect(await fileio.rmdir(dpath) == null).assertTrue();
fileio
.access(dpath)
.then(function () {
expect(null).assertFail();
done();
})
.catch((err) => {
expect(!!err).assertTrue();
done();
});
} catch (e) {
console.log('fileio_test_rmdir_async_000 has failed for ' + e);
expect(null).assertFail();
}
});
/**
* @tc.number SUB_DF_FILEIO_RMDIR_ASYNC_0010
* @tc.name fileio_test_rmdir_async_001
* @tc.desc Test rmdirAsync() interfaces.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileio_test_rmdir_async_001', 0, async function (done) {
let dpath = await nextFileName('fileio_test_rmdir_async_001') + 'd';
try {
expect(fileio.mkdirSync(dpath) == null).assertTrue();
fileio.rmdir(dpath, function (err) {
fileio
.access(dpath)
.then(function () {
expect(null).assertFail();
done();
})
.catch((err) => {
expect(!!err).assertTrue();
done();
});
});
} catch (e) {
console.log('fileio_test_rmdir_async_001 has failed for ' + e);
expect(null).assertFail();
}
});
/**
* @tc.number SUB_DF_FILEIO_RMDIR_ASYNC_0020
* @tc.name fileio_test_rmdir_async_002
* @tc.desc Test rmdirAsync() interfaces.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileio_test_rmdir_async_002', 0, async function (done) {
let dpath = await nextFileName('fileio_test_rmdir_async_002') + 'd';
expect(prepareFile(dpath, FILE_CONTENT)).assertTrue();
try {
fileio.rmdir(dpath, async function (err) {
expect(!!err).assertTrue();
expect(await fileio.access(dpath) == null).assertTrue();
await fileio.unlink(dpath);
done();
});
} catch (e) {
console.log('fileio_test_rmdir_async_002 has failed for ' + e);
expect(null).assertFail();
}
});
/**
* @tc.number SUB_DF_FILEIO_RMDIR_ASYNC_0030
* @tc.name fileio_test_rmdir_async_003
* @tc.desc Test rmdirAsync() interfaces.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileio_test_rmdir_async_003', 0, function (done) {
try {
fileio.rmdir('1.js', function (err) {
expect(!!err).assertTrue();
done();
});
} catch (e) {
console.log('fileio_test_rmdir_async_003 has failed for ' + e);
expect(null).assertFail();
}
});
/**
* @tc.number SUB_DF_FILEIO_RMDIR_SYNC_0000
* @tc.name fileio_test_rmdir_sync_000
* @tc.desc Test rmdirSync() interfaces.
* @tc.size MEDIUM
* @tc.type Functoin
* @tc.level Level 0
* @tc.require
*/
it('fileio_test_rmdir_sync_000', 0, async function () {
let dpath = await nextFileName('fileio_test_rmdir_sync_000') + 'd';
try {
expect(fileio.mkdirSync(dpath) == null).assertTrue();
expect(fileio.rmdirSync(dpath) == null).assertTrue();
} catch (e) {
console.log('fileio_test_rmdir_sync_000 has failed for ' + e);
expect(null).assertFail();
}
});
});
...@@ -21,7 +21,7 @@ export const FILE_CONTENT = 'hello world'; ...@@ -21,7 +21,7 @@ export const FILE_CONTENT = 'hello world';
import { import {
describe, it, expect describe, it, expect
} }
from 'deccjsunit/index' from '@ohos/hypium'
export function prepareFile(fpath, content) { export function prepareFile(fpath, content) {
try { try {
...@@ -120,11 +120,16 @@ function isBoolean(val) { ...@@ -120,11 +120,16 @@ function isBoolean(val) {
return typeof val == 'boolean'; return typeof val == 'boolean';
} }
function isInclude(error, message) {
return error.toString().indexOf(message) != -1;
}
export { export {
fileio, fileio,
isIntNum, isIntNum,
isString, isString,
isBoolean, isBoolean,
isInclude,
describe, describe,
it, it,
expect expect
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
*/ */
import fileio from '@ohos.fileio'; import fileio from '@ohos.fileio';
import { describe,it,expect}from 'deccjsunit/index' import { describe,it,expect}from '@ohos/hypium'
import { import {
FILE_CONTENT, FILE_CONTENT,
prepareFile, prepareFile,
...@@ -24,6 +24,7 @@ import { ...@@ -24,6 +24,7 @@ import {
} }
from './Common' from './Common'
export default function fileIOTestDir() {
describe('fileIOTestDir', function () { describe('fileIOTestDir', function () {
/** /**
...@@ -54,7 +55,7 @@ describe('fileIOTestDir', function () { ...@@ -54,7 +55,7 @@ describe('fileIOTestDir', function () {
it('fileio_test_dir_open_sync_001', 0, function () { it('fileio_test_dir_open_sync_001', 0, function () {
try { try {
fileio.opendirSync(); fileio.opendirSync();
expect(null).assertFail(); throw new Error('No Parameter');
} }
catch (e) { catch (e) {
console.info('fileio_test_dir_open_sync_001 has failed for ' + e); console.info('fileio_test_dir_open_sync_001 has failed for ' + e);
...@@ -92,7 +93,7 @@ describe('fileIOTestDir', function () { ...@@ -92,7 +93,7 @@ describe('fileIOTestDir', function () {
dpath = dpath + '/d' + i; dpath = dpath + '/d' + i;
fileio.mkdirSync(dpath); fileio.mkdirSync(dpath);
} }
expect(null).assertFail(); throw new Error('dpath too long');
} }
catch (e) { catch (e) {
console.info('fileio_test_dir_open_sync_003 has failed for ' + e); console.info('fileio_test_dir_open_sync_003 has failed for ' + e);
...@@ -130,7 +131,7 @@ describe('fileIOTestDir', function () { ...@@ -130,7 +131,7 @@ describe('fileIOTestDir', function () {
dpath = dpath + '/d' + i dpath = dpath + '/d' + i
fileio.mkdirSync(dpath); fileio.mkdirSync(dpath);
} }
expect(null).assertFail(); throw new Error('dir too many layers');
} }
catch (e) { catch (e) {
console.info('fileio_test_dir_open_sync_005 has failed for ' + e); console.info('fileio_test_dir_open_sync_005 has failed for ' + e);
...@@ -408,3 +409,4 @@ describe('fileIOTestDir', function () { ...@@ -408,3 +409,4 @@ describe('fileIOTestDir', function () {
} }
}); });
}); });
}
...@@ -18,6 +18,7 @@ import { ...@@ -18,6 +18,7 @@ import {
describe, it, expect, describe, it, expect,
} from '../../Common'; } from '../../Common';
export default function constants() {
describe('constants', function () { describe('constants', function () {
/** /**
...@@ -71,4 +72,4 @@ describe('constants', function () { ...@@ -71,4 +72,4 @@ describe('constants', function () {
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
}); });}
\ No newline at end of file
此差异已折叠。
此差异已折叠。
<div class="container">
<text class="title">
{{ $t('strings.hello') }} {{ title }}
</text>
</div>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册