提交 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") {
part_name = "xts_acts"
}
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") {
sources = [ "./src/main/resources" ]
......
{
"description": "Configuration for storage file and fileio Tests",
"description": "Configuration for storage fileio Tests",
"driver": {
"type": "JSUnitTest",
"type": "OHJSUnitTest",
"test-timeout": "1800000",
"package": "ohos.acts.storage.fileio",
"shell-timeout": "60000"
"shell-timeout": "1800000",
"bundle-name": "ohos.acts.storage.fileio",
"package-name": "ohos.acts.storage.fileio"
},
"kits": [
{
"test-file-name": [
"ActsStorageFileIoJSTest.hap"
],
"test-file-name": ["ActsStorageFileIoJSTest.hap"],
"type": "AppInstallKit",
"cleanup-apps": true
}
......
......@@ -14,7 +14,7 @@
"deviceConfig": {},
"module": {
"package": "ohos.acts.storage.fileio",
"name": ".MyApplication",
"name": ".entry",
"deviceType": [
"phone"
],
......@@ -36,13 +36,30 @@
]
}
],
"name": "ohos.acts.storage.fileio.MainAbility",
"orientation": "unspecified",
"formsEnabled": false,
"name": ".MainAbility",
"srcLanguage": "js",
"srcPath": "MainAbility",
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "$string:app_name",
"description": "$string:MainAbility_desc",
"label": "$string:MainAbility_label",
"type": "page",
"launchType": "standard",
"visible": true
"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"
}
],
"js": [
......@@ -55,7 +72,23 @@
"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 @@
export default {
onCreate() {
console.info('ohos.acts.distributeddatamgr.distributedfile onCreate');
console.info('ohos.acts.storage.fileio onCreate');
},
onDestroy() {
console.info('ohos.acts.distributeddatamgr.distributedfile onCreate');
console.info('ohos.acts.storage.fileio onDestroy');
}
};
......@@ -15,7 +15,6 @@
import app from '@system.app'
import {Core} from 'deccjsunit/index'
const injectRef = Object.getPrototypeOf(global) || global
injectRef.regeneratorRuntime = require('@babel/runtime/regenerator')
......@@ -29,12 +28,6 @@ export default {
},
onShow() {
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() {
},
......
/*
* 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';
import {
describe, it, expect
}
from 'deccjsunit/index'
from '@ohos/hypium'
export function prepareFile(fpath, content) {
try {
......@@ -120,11 +120,16 @@ function isBoolean(val) {
return typeof val == 'boolean';
}
function isInclude(error, message) {
return error.toString().indexOf(message) != -1;
}
export {
fileio,
isIntNum,
isString,
isBoolean,
isInclude,
describe,
it,
expect
......
......@@ -14,7 +14,7 @@
*/
import fileio from '@ohos.fileio';
import { describe,it,expect}from 'deccjsunit/index'
import { describe,it,expect}from '@ohos/hypium'
import {
FILE_CONTENT,
prepareFile,
......@@ -24,6 +24,7 @@ import {
}
from './Common'
export default function fileIOTestDir() {
describe('fileIOTestDir', function () {
/**
......@@ -54,7 +55,7 @@ describe('fileIOTestDir', function () {
it('fileio_test_dir_open_sync_001', 0, function () {
try {
fileio.opendirSync();
expect(null).assertFail();
throw new Error('No Parameter');
}
catch (e) {
console.info('fileio_test_dir_open_sync_001 has failed for ' + e);
......@@ -92,7 +93,7 @@ describe('fileIOTestDir', function () {
dpath = dpath + '/d' + i;
fileio.mkdirSync(dpath);
}
expect(null).assertFail();
throw new Error('dpath too long');
}
catch (e) {
console.info('fileio_test_dir_open_sync_003 has failed for ' + e);
......@@ -130,7 +131,7 @@ describe('fileIOTestDir', function () {
dpath = dpath + '/d' + i
fileio.mkdirSync(dpath);
}
expect(null).assertFail();
throw new Error('dir too many layers');
}
catch (e) {
console.info('fileio_test_dir_open_sync_005 has failed for ' + e);
......@@ -408,3 +409,4 @@ describe('fileIOTestDir', function () {
}
});
});
}
......@@ -14,13 +14,14 @@
*/
import fileio from '@ohos.fileio';
import { describe,it,expect}from 'deccjsunit/index'
import { describe,it,expect}from '@ohos/hypium'
import {
FILE_CONTENT,
prepareFile,
nextFileName
}from './Common';
export default function fileIOTestDirent() {
describe('fileIOTestDirent', function () {
/**
......@@ -420,4 +421,4 @@ describe('fileIOTestDirent', function () {
}
});
});
\ No newline at end of file
});}
......@@ -14,7 +14,7 @@
*/
import fileio from '@ohos.fileio';
import { describe,it,expect}from 'deccjsunit/index'
import { describe,it,expect}from '@ohos/hypium'
import {
FILE_CONTENT,
prepareFile,
......@@ -24,6 +24,7 @@ import {
}
from './Common'
export default function fileIOTestStat() {
describe('fileIOTestStat', function () {
/**
......@@ -781,3 +782,4 @@ describe('fileIOTestStat', function () {
});
});
}
......@@ -18,6 +18,7 @@ import {
describe, it, expect,
} from '../../Common';
export default function constants() {
describe('constants', function () {
/**
......@@ -71,4 +72,4 @@ describe('constants', function () {
expect(null).assertFail();
}
});
});
\ No newline at end of file
});}
......@@ -21,6 +21,7 @@ import {
expect,
} from '../../Common';
export default function fileio_dir_close() {
describe('fileio_dir_close', function () {
/**
......@@ -96,3 +97,4 @@ describe('fileio_dir_close', function () {
}
});
});
}
......@@ -18,6 +18,7 @@ import {
describe, it, expect,
} from '../../Common';
export default function fileio_dir_read() {
describe('fileio_dir_read', function () {
/**
......@@ -677,4 +678,4 @@ describe('fileio_dir_read', function () {
expect(null).assertFail();
}
});
})
\ No newline at end of file
})}
......@@ -18,6 +18,7 @@ import {
describe, it, expect,
} from '../../Common';
export default function fileio_stream_1() {
describe('fileio_stream_1', function () {
/**
......@@ -299,4 +300,4 @@ describe('fileio_stream_1', function () {
expect(null).assertFail();
}
});
});
\ No newline at end of file
});}
......@@ -18,6 +18,7 @@ import {
describe, it, expect,
} from '../../Common';
export default function fileio_stream_close() {
describe('fileio_stream_close', function () {
/**
......@@ -121,4 +122,4 @@ describe('fileio_stream_close', function () {
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.
先完成此消息的编辑!
想要评论请 注册