提交 10abbe4f 编写于 作者: S Storage sandboxing

删除没使用的用例,修改file为storagefilejstest工程,storagefileiojstest修改路径提交

Signed-off-by: NStorage sandboxing <raoxian@huawei.com>
上级 e491cd21
......@@ -16,20 +16,10 @@ group("storage") {
testonly = true
if (is_standard_system) {
deps = [
#"storagedsmjstest:storagedsm_js_test",
# "storagedsmstabilityjstest:storagedsmstability_js_test",
#"storagefileconcurrentjstest:storagefileconcurrent_js_test",
"storagefileioerrorjstest:storagefileioerror_js_test",
"storagefileiojstest:storagefileio_js_test",
"storagefilejstest:storagefile_js_test",
"storagestatfsjstest:storagestatfs_js_test",
# "storagefmspublicjstest:storagefmspublic_js_test",
# "storagefmssharejstest:storagefmsshare_js_test",
# "storagefileioperformancejstest:storagefileioperformance_js_test",
# "storagefileioreliabilityjstest:storagefileioreliability_js_test",
# "storagefileiostabilityjstest:storagefileiostability_js_test",
# "storagefilestabilityjstest:storagefilestability_js_test",
]
}
}
{
"description": "Configuration for storage file and fileio Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "60000",
"package": "ohos.acts.stroage.fileio",
"shell-timeout": "60000"
},
"kits": [
{
"test-file-name": [
"ActsStorageFmsPublicJsTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
\ No newline at end of file
{
"app": {
"bundleName": "ohos.acts.stroage.fileio",
"vendor": "example",
"version": {
"code": 1000000,
"name": "1.0.0"
},
"apiVersion": {
"compatible": 4,
"target": 5
}
},
"deviceConfig": {},
"module": {
"package": "ohos.acts.stroage.fileio",
"name": ".MyApplication",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry",
"installationFree": true
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"name": "ohos.acts.stroage.fileio.MainAbility",
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "$string:app_name",
"type": "page",
"launchType": "standard",
"visible": true
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"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.
*/
import app from '@system.app'
import {Core} from 'deccjsunit/index'
const injectRef = Object.getPrototypeOf(global) || global
injectRef.regeneratorRuntime = require('@babel/runtime/regenerator')
export default {
data: {
title: ''
},
onInit() {
this.title = this.$t('strings.world');
},
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() {
},
}
\ 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 '@system.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
}
}
export function prepareFile1(fpath, content) {
try {
let fd = fileio.openSync(fpath, 0o102, 0o777)
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
}
}
export function prepareEmptyFile(fpath) {
try {
let fd = fileio.openSync(fpath, 0o102, 0o777)
fileio.closeSync(fd)
return true
}
catch (e) {
console.log('Failed to prepareFile for ' + e)
return false
}
}
export function fileToReadOnly(fpath) {
try {
let fd = fileio.openSync(fpath, 0o1)
fileio.fchmodSync(fd, 0o444)
fileio.fsyncSync(fd)
fileio.closeSync(fd)
return true
}
catch (e) {
console.log('Failed to fileToReadOnly for ' + e);
return false
}
}
export function fileToWriteOnly(fpath) {
try {
let fd = fileio.openSync(fpath, 0o2)
fileio.fchmodSync(fd, 0o222)
fileio.fsyncSync(fd)
fileio.closeSync(fd)
return true
}
catch (e) {
console.log('Failed to fileToWriteOnly ' + e)
return false
}
}
export function fileToReadAndWrite(fpath) {
try {
let fd = fileio.openSync(fpath, 0o1)
fileio.fchmodSync(fd, 0o777)
fileio.fsyncSync(fd)
fileio.closeSync(fd)
return true
}
catch (e) {
console.log('Failed to fileToReadAndWrite ' + e);
return false
}
}
export function filePickerName(testName,deviceID) {
const BASE_PATH = '/data/ss/'+deviceID+'/fms_test/'
return BASE_PATH + testName
}
export function filePickerName1(testName,deviceID) {
const BASE_PATH = '/data/ss/'+ deviceID +'/fms_test/'
return BASE_PATH + testName
}
export function filePickerName2(testName,deviceID) {
const BASE_PATH = '/data/ss/'+ deviceID
return BASE_PATH + testName
}
export function appName(testName) {
const BASE_PATH = '/data/accounts/account_0/appdata/ohos.acts.stroage.fileio/'
return BASE_PATH + testName
}
export function nextFileName(testName) {
const BASE_PATH = '/data/accounts/account_0/appdata/ohos.acts.stroage.fileio/cache/'
return BASE_PATH + testName
}
export function fileName(testName) {
const BASE_PATH = '/data/accounts/account_0/appdata/ohos.acts.stroage.fileio/files/'
return BASE_PATH + testName
}
export function cacheFileName(testName) {
const BASE_PATH = '/data/accounts/account_0/appdata/ohos.acts.stroage.fileio/files/cache/'
return BASE_PATH + testName
}
export function differentFileName(testName) {
const BASE_PATH = '/data/accounts/account_0/ohos.acts.distributeddatamgr.distributedfile/'
return BASE_PATH + testName
}
export function differentCacheName(testName) {
const BASE_PATH = '/data/accounts/account_0/ohos.acts.distributeddatamgr.distributedfile/cache/'
return BASE_PATH + testName
}
export function fmsFileName(testName) {
const BASE_PATH = "/data/accounts/account_0/appdata/ohos.acts.test/files/"
return BASE_PATH + testName
}
export function fmsCacheName(testName) {
const BASE_PATH = "/data/accounts/account_0/appdata/ohos.acts.test/cache/"
return BASE_PATH + testName
}
export function fmsPublic(testName) {
const BASE_PATH = '/data/ss/files/'
return BASE_PATH + testName
}
export function getFileTextLen(fpath) {
let ss
try {
ss = fileio.Stream.createStreamSync(fpath, 'r+')
expect(ss !== null).assertTrue()
let len = ss.readSync(new ArrayBuffer(4096))
console.log('file:' + fpath)
console.log('file lenth:' + len)
expect(ss.closeSync() !== null).assertTrue()
return len
}
catch (e) {
console.log('Failed to getFileTextLen ' + e)
expect(ss.closeSync() == null).assertTrue()
return null
}
}
export function isFileExist(fpath) {
try {
expect(fileio.accessSync(fpath) !== null).assertTrue()
console.log('file:' + fpath)
console.log('status:exist')
return true
}
catch (e) {
console.log('file:' + fpath)
console.log('status:non-existen')
return false
}
}
export function sleep(n) {
var start = new Date().getTime();
while (true) {
if (new Date().getTime() - start > n) {
break;
}
}
}
export function randomString(num) {
let len= num;
var $chars = 'aaaabbbbcccc';
var maxPos = $chars.length;
var pwd = '';
for (var i = 0; i < len; i++) {
pwd += $chars.charAt(Math.floor(Math.random() * maxPos));
}
return pwd;
}
/*
* 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 devicesmgr from '@system.devicesmgr';
import {
describe,
beforeAll,
beforeEach,
afterEach,
afterAll,
it,
expect
}
from 'deccjsunit/index'
describe('dsmErrorTest', function () {
/**
* @tc.number SUB_STORAGE_DSM_JS_ERROR_0100
* @tc.name DSM_JS_ERROR_0100
* @tc.desc Verify that the mount volume ID is null successfully.
*/
it('DSM_JS_ERROR_0100', 0, function () {
devicesmgr.mount({
volId: '',
success: function () {
console.log('DSM_JS_ERROR_0100 call mount success, fail!');
expect(null).assertFail();
},
fail: function (data, code) {
console.log('DSM_JS_ERROR_0100 call mount pass, code: ' + code + ', data: ' + data);
expect(code == 202).assertTrue();
},
})
})
/**
* @tc.number SUB_STORAGE_DSM_JS_ERROR_0200
* @tc.name DSM_JS_ERROR_0200
* @tc.desc Verify that the mount does not exist and the volume ID is successful.
*/
it('DSM_JS_ERROR_0200', 0, function () {
devicesmgr.mount({
volId: '123',
success: function () {
console.log('DSM_JS_ERROR_0200 call mount success, fail!');
expect(null).assertFail();
},
fail: function (data, code) {
console.log('DSM_JS_ERROR_0200 call mount pass, code: ' + code + ', data: ' + data);
expect(code == 300).assertTrue();
},
})
})
/**
* @tc.number SUB_STORAGE_DSM_JS_ERROR_0300
* @tc.name DSM_JS_ERROR_0300
* @tc.desc Verify that the unmount does not exist and the volume ID is successful.
*/
it('DSM_JS_ERROR_0300', 0, function () {
devicesmgr.unMount({
volId: '123',
success: function () {
console.log('DSM_JS_ERROR_0300 call unMount success, fail!');
expect(null).assertFail();
},
fail: function (data, code) {
console.log('DSM_JS_ERROR_0300 call unMount pass, code: ' + code + ', data: ' + data);
expect(code == 300).assertTrue();
},
})
})
/**
* @tc.number SUB_STORAGE_DSM_JS_ERROR_0400
* @tc.name DSM_JS_ERROR_0400
* @tc.desc Verify that the unmount volume ID is null successfully.
*/
it('DSM_JS_ERROR_0400', 0, function () {
devicesmgr.unMount({
volId: '',
success: function () {
console.log('DSM_JS_ERROR_0400 call unMount success, fail!');
expect(null).assertFail();
},
fail: function (data, code) {
console.log('DSM_JS_ERROR_0400 call unMount pass, code: ' + code + ', data: ' + data);
expect(code == 202).assertTrue();
},
})
})
/**
* @tc.number SUB_STORAGE_DSM_JS_ERROR_0500
* @tc.name DSM_JS_ERROR_0500
* @tc.desc Verify that the format does not exist and whether the volume ID is successful.
*/
it('DSM_JS_ERROR_0500', 0, function () {
devicesmgr.format({
volId: '123',
success: function () {
console.log('DSM_JS_ERROR_0500 call format success, fail!');
expect(null).assertFail();
},
fail: function (data, code) {
console.log('DSM_JS_ERROR_0500 call format pass, code: ' + code + ', data: ' + data);
expect(code == 300).assertTrue();
},
})
})
/**
* @tc.number SUB_STORAGE_DSM_JS_ERROR_0600
* @tc.name DSM_JS_ERROR_0600
* @tc.desc Verify that the ID of the formatted volume is null successfully.
*/
it('DSM_JS_ERROR_0600', 0, function () {
devicesmgr.format({
volId: '',
success: function () {
console.log('DSM_JS_ERROR_0600 call format success, fail!');
expect(null).assertFail();
},
fail: function (data, code) {
console.log('DSM_JS_ERROR_0600 call format pass, code: ' + code + ', data: ' + data);
expect(code == 202).assertTrue();
},
})
})
/**
* @tc.number SUB_STORAGE_DSM_JS_ERROR_0700
* @tc.name DSM_JS_ERROR_0700
* @tc.desc Verify that the SD card is successfully copied and mounted..
*/
it('DSM_JS_ERROR_0700', 0, function () {
let mId;
devicesmgr.getVolumes({
success: function (data) {
console.log('DSM_JS_ERROR_0900 call getVolumes success. data:' + JSON.stringify(data));
for (let i = 0; i < data.volumeInfos.length; i++) {
if (data.volumeInfos[i].mState == 2 && data.volumeInfos[i].mId.indexOf('public:179') != -1) {
mId = data.volumeInfos[i].mId;
break;
}
}
},
fail: function (data, code) {
console.log('DSM_JS_ERROR_0700 call getVolumes fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
});
devicesmgr.mount({
volId: mId,
success: function () {
console.log('DSM_JS_ERROR_0700 call mount success');
},
fail: function (data, code) {
console.log('DSM_JS_ERROR_0700 call mount fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
})
})
/**
* @tc.number SUB_STORAGE_DSM_JS_ERROR_0800
* @tc.name DSM_JS_ERROR_0800
* @tc.desc Verify that volId is empty
*/
it('DSM_JS_ERROR_0800', 0, function () {
devicesmgr.findVolumeById({
volId: '',
success: function () {
console.log('DSM_JS_ERROR_0800 call findVolumeById success, fail!');
expect(null).assertFail();
},
fail: function (data, code) {
console.log('DSM_JS_ERROR_0800 call findVolumeById pass, code: ' + code + ', data: ' + data);
expect(code == 202).assertTrue();
},
})
})
/**
* @tc.number SUB_STORAGE_DSM_JS_ERROR_0900
* @tc.name DSM_JS_ERROR_0900
* @tc.desc Invalid volId validation
*/
it('DSM_JS_ERROR_0900', 0, function () {
devicesmgr.findVolumeById({
volId: '1234',
success: function () {
console.log('DSM_JS_ERROR_0900 call findVolumeById success, fail!');
expect(null).assertFail();
},
fail: function (data, code) {
console.log('DSM_JS_ERROR_0900 call findVolumeById pass, code: ' + code + ', data: ' + data);
expect(code == 300).assertTrue();
},
})
})
/**
* @tc.number SUB_STORAGE_DSM_JS_ERROR_1000
* @tc.name DSM_JS_ERROR_1000
* @tc.desc Verify that volumeUuid is null
*/
it('DSM_JS_ERROR_1000', 0, function () {
devicesmgr.findVolumeByUuid({
volumeUuid: '',
success: function () {
console.log('DSM_JS_ERROR_1000 call findVolumeByUuid success, fail!');
expect(null).assertFail();
},
fail: function (data, code) {
console.log('DSM_JS_ERROR_1000 call findVolumeByUuid pass, code: ' + code + ', data: ' + data);
expect(code == 202).assertTrue();
},
})
})
/**
* @tc.number SUB_STORAGE_DSM_JS_ERROR_1100
* @tc.name DSM_JS_ERROR_1100
* @tc.desc Invalid volumeUuid validation
*/
it('DSM_JS_ERROR_1100', 0, function () {
devicesmgr.findVolumeByUuid({
volumeUuid: '321',
success: function () {
console.log('DSM_JS_ERROR_1100 call findVolumeByUuid success, fail!');
expect(null).assertFail();
},
fail: function (data, code) {
console.log('DSM_JS_ERROR_1100 call findVolumeByUuid pass, code: ' + code + ', data: ' + data);
expect(code == 300).assertTrue();
},
})
})
/**
* @tc.number SUB_STORAGE_DSM_JS_ERROR_1200
* @tc.name DSM_JS_ERROR_1200
* @tc.desc Verify that diskId is empty
*/
it('DSM_JS_ERROR_1200', 0, function () {
devicesmgr.findDiskById({
diskId: '',
success: function () {
console.log('DSM_JS_ERROR_1200 call findDiskById success, fail!');
expect(null).assertFail();
},
fail: function (data, code) {
console.log('DSM_JS_ERROR_1200 call findDiskById pass, code: ' + code + ', data: ' + data);
expect(code == 202).assertTrue();
},
})
})
/**
* @tc.number SUB_STORAGE_DSM_JS_ERROR_1300
* @tc.name DSM_JS_ERROR_1300
* @tc.desc Invalid DiskID verified
*/
it('DSM_JS_ERROR_1300', 0, function () {
devicesmgr.findDiskById({
diskId: '789',
success: function () {
console.log('DSM_JS_ERROR_1300 call findDiskById success, fail!');
expect(null).assertFail();
},
fail: function (data, code) {
console.log('DSM_JS_ERROR_1300 call findDiskById pass, code: ' + code + ', data: ' + data);
expect(code == 300).assertTrue();
},
})
})
/**
* @tc.number SUB_STORAGE_DSM_JS_ERROR_1400
* @tc.name DSM_JS_ERROR_1400
* @tc.desc Verify that the value of the incoming simulate collection is null
*/
it('DSM_JS_ERROR_1400', 0, function () {
devicesmgr.findPrivateForEmulate({
emuVol: {
mId: '',
mDiskId: '',
mPartGuid: '',
mFsUuid: '',
mType: '',
mMountFlags: '',
mMountUserId: '',
mState: '',
mPath: '',
mInternalPath: '',
mFsLabel: '',
Description: '',
IsVisibleForUser: '',
IsEmulated: '',
IsPrimaryEmulatedForUser: '',
IsRemovable: '',
IsPrimary: ''
},
success: function () {
console.log('DSM_JS_ERROR_1400 call findPrivateForEmulate success, fail!');
expect(null).assertFail();
},
fail: function (data, code) {
console.log('DSM_JS_ERROR_1400 call findPrivateForEmulate pass, code: ' + code + ', data: ' + data);
expect(code == 300).assertTrue();
},
})
})
/**
* @tc.number SUB_STORAGE_DSM_JS_ERROR_1500
* @tc.name DSM_JS_ERROR_1500
* @tc.desc Verify that an invalid simulate set value was passed in
*/
it('DSM_JS_ERROR_1500', 0, function () {
devicesmgr.findPrivateForEmulate({
emuVol: {
mId: '1234',
mDiskId: '321',
mPartGuid: '1357',
mFsUuid: '7890',
mType: 2,
mMountFlags: 3,
mMountUserId: 0,
mState: 6,
mPath: '/storage/emulated',
mInternalPath: '/data/media',
mFsLabel: '123',
Description: true,
IsVisibleForUser: true,
IsEmulated: true,
IsPrimaryEmulatedForUser: true,
IsRemovable: true,
IsPrimary: true
},
success: function () {
console.log('DSM_JS_ERROR_1500 call findPrivateForEmulate success, fail!');
expect(null).assertFail();
},
fail: function (data, code) {
console.log('DSM_JS_ERROR_1500 call findPrivateForEmulate pass, code: ' + code + ', data: ' + data);
expect(code == 300).assertTrue();
},
})
})
/**
* @tc.number SUB_STORAGE_DSM_JS_ERROR_1600
* @tc.name DSM_JS_ERROR_1600
* @tc.desc Verify that the value of the incoming private collection is empty
*/
it('DSM_JS_ERROR_1600', 0, function () {
devicesmgr.findEmulateForPrivate({
priVol: {
mId: '',
mDiskId: '',
mPartGuid: '',
mFsUuid: '',
mType: '',
mMountFlags: '',
mMountUserId: '',
mState: '',
mPath: '',
mInternalPath: '',
mFsLabel: '',
Description: '',
IsVisibleForUser: '',
IsEmulated: '',
IsPrimaryEmulatedForUser: '',
IsRemovable: '',
IsPrimary: ''
},
success: function () {
console.log('DSM_JS_ERROR_1600 call findEmulateForPrivate success, fail!');
expect(null).assertFail();
},
fail: function (data, code) {
console.log('DSM_JS_ERROR_1600 call findEmulateForPrivate pass, code: ' + code + ', data: ' + data);
expect(code == 300).assertTrue();
},
})
})
/**
* @tc.number SUB_STORAGE_DSM_JS_ERROR_1700
* @tc.name DSM_JS_ERROR_1700
* @tc.desc Verify that an invalid private collection value was passed in
*/
it('DSM_JS_ERROR_1700', 0, function () {
devicesmgr.findEmulateForPrivate({
priVol: {
mId: '1234',
mDiskId: '321',
mPartGuid: '456',
mFsUuid: '789',
mType: 1,
mMountFlags: 0,
mMountUserId: 0,
mState: 2,
mPath: 'data',
mInternalPath: '',
mFsLabel: '',
Description: true,
IsVisibleForUser: true,
IsEmulated: true,
IsPrimaryEmulatedForUser: true,
IsRemovable: true,
IsPrimary: true
},
success: function () {
console.log('DSM_JS_ERROR_1700 call findEmulateForPrivate success, fail!');
expect(null).assertFail();
},
fail: function (data, code) {
console.log('DSM_JS_ERROR_1700 call findEmulateForPrivate pass, code: ' + code + ', data: ' + data);
expect(code == 300).assertTrue();
},
})
})
/**
* @tc.number SUB_STORAGE_DSM_JS_ERROR_1800
* @tc.name DSM_JS_ERROR_1800
* @tc.desc Verify that the vol set value is empty
*/
it('DSM_JS_ERROR_1800', 0, function () {
devicesmgr.getBestVolumeDescription({
vol: {
mId: '',
mDiskId: '',
mPartGuid: '',
mFsUuid: '',
mType: '',
mMountFlags: '',
mMountUserId: '',
mState: '',
mPath: '',
mInternalPath: '',
mFsLabel: '',
Description: '',
IsVisibleForUser: '',
IsEmulated: '',
IsPrimaryEmulatedForUser: '',
IsRemovable: '',
IsPrimary: ''
},
success: function () {
console.log('DSM_JS_ERROR_1800 call getBestVolumeDescription success, fail!');
expect(null).assertFail();
},
fail: function (data, code) {
console.log('DSM_JS_ERROR_1800 call getBestVolumeDescription pass, code: ' + code + ', data: ' + data);
expect(code == 300).assertTrue();
},
})
})
/**
* @tc.number SUB_STORAGE_DSM_JS_ERROR_1900
* @tc.name DSM_JS_ERROR_1900
* @tc.desc Validate invalid vol set value
*/
it('DSM_JS_ERROR_1900', 0, function () {
devicesmgr.getBestVolumeDescription({
vol: {
mId: 'public:177,25',
mDiskId: 'disk:178,24',
mPartGuid: '',
mFsUuid: 'd87ba2fe-828f-4237-8006-c6dc6c2910e7',
mType: 0,
mMountFlags: 2,
mMountUserId: 0,
mState: 2,
mPath: '/storage/d87ba2fe-828f-4237-8006-c6dc6c2910e7',
mInternalPath: '/data/ss/d87ba2fe-828f-4237-8006-c6dc6c2910e7',
mFsLabel: '',
Description: true,
IsVisibleForUser: true,
IsEmulated: true,
IsPrimaryEmulatedForUser: true,
IsRemovable: true,
IsPrimary: true
},
success: function () {
console.log('DSM_JS_ERROR_1900 call getBestVolumeDescription success, fail!');
expect(null).assertFail();
},
fail: function (data, code) {
console.log('DSM_JS_ERROR_1900 call getBestVolumeDescription pass, code: ' + code + ', data: ' + data);
expect(code == 300).assertTrue();
},
})
})
})
/*
* 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('./Dsm.test.js')
require('./DsmError.test.js')
{
"string": [
{
"name": "app_name",
"value": "storagefilestabilityjstest"
},
{
"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.
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("storagedsmstability_js_test") {
hap_profile = "./src/main/config.json"
deps = [
":storagedsmstability_js_assets",
":storagedsmstability_js_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsStorageFmsPublicJsTest"
}
ohos_js_assets("storagedsmstability_js_assets") {
source_dir = "./src/main/js/default"
}
ohos_resources("storagedsmstability_js_resources") {
sources = [ "./src/main/resources" ]
hap_profile = "./src/main/config.json"
}
{
"description": "Configuration for storage file and fileio Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "60000",
"package": "ohos.acts.stroage.fileio",
"shell-timeout": "60000"
},
"kits": [
{
"test-file-name": [
"ActsStorageFmsPublicJsTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
\ 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('ohos.acts.distributeddatamgr.distributedfile onCreate');
},
onDestroy() {
console.info('ohos.acts.distributeddatamgr.distributedfile onCreate');
}
};
{
"strings": {
"hello": "Hello",
"world": "Test"
}
}
\ 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 app from '@system.app'
import {Core} from 'deccjsunit/index'
const injectRef = Object.getPrototypeOf(global) || global
injectRef.regeneratorRuntime = require('@babel/runtime/regenerator')
export default {
data: {
title: ''
},
onInit() {
this.title = this.$t('strings.world');
},
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() {
},
}
\ 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 '@system.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
}
}
export function prepareFile1(fpath, content) {
try {
let fd = fileio.openSync(fpath, 0o102, 0o777)
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
}
}
export function prepareEmptyFile(fpath) {
try {
let fd = fileio.openSync(fpath, 0o102, 0o777)
fileio.closeSync(fd)
return true
}
catch (e) {
console.log('Failed to prepareFile for ' + e)
return false
}
}
export function fileToReadOnly(fpath) {
try {
let fd = fileio.openSync(fpath, 0o1)
fileio.fchmodSync(fd, 0o444)
fileio.fsyncSync(fd)
fileio.closeSync(fd)
return true
}
catch (e) {
console.log('Failed to fileToReadOnly for ' + e);
return false
}
}
export function fileToWriteOnly(fpath) {
try {
let fd = fileio.openSync(fpath, 0o2)
fileio.fchmodSync(fd, 0o222)
fileio.fsyncSync(fd)
fileio.closeSync(fd)
return true
}
catch (e) {
console.log('Failed to fileToWriteOnly ' + e)
return false
}
}
export function fileToReadAndWrite(fpath) {
try {
let fd = fileio.openSync(fpath, 0o1)
fileio.fchmodSync(fd, 0o777)
fileio.fsyncSync(fd)
fileio.closeSync(fd)
return true
}
catch (e) {
console.log('Failed to fileToReadAndWrite ' + e);
return false
}
}
export function filePickerName(testName,deviceID) {
const BASE_PATH = '/data/ss/'+deviceID+'/fms_test/'
return BASE_PATH + testName
}
export function appName(testName) {
const BASE_PATH = '/data/accounts/account_0/appdata/ohos.acts.stroage.fileio/'
return BASE_PATH + testName
}
export function nextFileName(testName) {
const BASE_PATH = '/data/accounts/account_0/appdata/ohos.acts.stroage.fileio/cache/'
return BASE_PATH + testName
}
export function fileName(testName) {
const BASE_PATH = '/data/accounts/account_0/appdata/ohos.acts.stroage.fileio/files/'
return BASE_PATH + testName
}
export function cacheFileName(testName) {
const BASE_PATH = '/data/accounts/account_0/appdata/ohos.acts.stroage.fileio/files/cache/'
return BASE_PATH + testName
}
export function differentFileName(testName) {
const BASE_PATH = '/data/accounts/account_0/ohos.acts.distributeddatamgr.distributedfile/'
return BASE_PATH + testName
}
export function differentCacheName(testName) {
const BASE_PATH = '/data/accounts/account_0/ohos.acts.distributeddatamgr.distributedfile/cache/'
return BASE_PATH + testName
}
export function fmsFileName(testName) {
const BASE_PATH = "/data/accounts/account_0/appdata/ohos.acts.test/files/"
return BASE_PATH + testName
}
export function fmsCacheName(testName) {
const BASE_PATH = "/data/accounts/account_0/appdata/ohos.acts.test/cache/"
return BASE_PATH + testName
}
export function getFileTextLen(fpath) {
let ss
try {
ss = fileio.Stream.createStreamSync(fpath, 'r+')
expect(ss !== null).assertTrue()
let len = ss.readSync(new ArrayBuffer(4096))
console.log('file:' + fpath)
console.log('file lenth:' + len)
expect(ss.closeSync() !== null).assertTrue()
return len
}
catch (e) {
console.log('Failed to getFileTextLen ' + e)
expect(ss.closeSync() == null).assertTrue()
return null
}
}
export function isFileExist(fpath) {
try {
expect(fileio.accessSync(fpath) !== null).assertTrue()
console.log('file:' + fpath)
console.log('status:exist')
return true
}
catch (e) {
console.log('file:' + fpath)
console.log('status:non-existen')
return false
}
}
export function sleep(n) {
var start = new Date().getTime();
while (true) {
if (new Date().getTime() - start > n) {
break;
}
}
}
export function randomString(num) {
let len= num;
var $chars = 'aaaabbbbcccc';
var maxPos = $chars.length;
var pwd = '';
for (var i = 0; i < len; i++) {
pwd += $chars.charAt(Math.floor(Math.random() * maxPos));
}
return pwd;
}
/*
* 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 devicesmgr from '@system.devicesmgr';
import {
describe,
beforeAll,
beforeEach,
afterEach,
afterAll,
it,
expect
}
from 'deccjsunit/index'
describe('dsmPerformanceTest', function () {
/**
* @tc.number SUB_STORAGE_DSM_Performance_0000
* @tc.name DSM_Performance_0000
* @tc.desc getVolumes Performance test
*/
it('DSM_Performance_0000', 0, function () {
for (let i = 0; i < 1000; i++) {
var start = new Date().getTime();
devicesmgr.getVolumes({
success: function (data) {
var end = new Date().getTime();
console.log('DSM_Performance_0000 call getVolumes success' + JSON.stringify(data));
console.log('---DSM_Performance_0000---time:-' + (end - start) + '-----' + i);
},
fail: function (data, code) {
console.log('DSM_Performance_0000 call getVolumes fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
}
});
}
})
/**
* @tc.number SUB_STORAGE_DSM_Performance_0100
* @tc.name DSM_Performance_0100
* @tc.desc unMount mount Performance test
*/
it('DSM_Performance_0100', 0, function () {
let mId;
devicesmgr.getVolumes({
success: function (data) {
console.log('DSM_Performance_0100 call getVolumes success' + data);
mId = data.volumeInfos[2].mId;
},
fail: function (data, code) {
console.log('DSM_Performance_0100 call getVolumes fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
});
for (let i = 0; i < 1000; i++) {
var start = new Date().getTime();
if (mId != null) {
devicesmgr.unMount({
volId: mId,
success: function () {
console.log('DSM_Performance_0100 call unMount success.');
var end = new Date().getTime();
console.log('---DSM_Performance_0100---time:-' + (end - start) + '-----' + i);
},
fail: function (data, code) {
console.log('DSM_Performance_0100 call unMount fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
}
})
var start1 = new Date().getTime();
devicesmgr.mount({
volId: mId,
success: function () {
var end1 = new Date().getTime();
console.log('---DSM_Performance_0200---time:-' + (end1 - start1) + '-----' + i);
},
fail: function (data, code) {
console.log('DSM_Performance_0200 call mount fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
})
} else {
expect(null).assertFail();
}
}
})
/**
* @tc.number SUB_STORAGE_DSM_Performance_0300
* @tc.name DSM_Performance_0300
* @tc.desc getDisks Performance test
*/
it('DSM_Performance_0300', 0, function () {
for (let i = 0; i < 1000; i++) {
var start = new Date().getTime();
devicesmgr.getDisks({
success: function (data) {
console.log('DSM_Performance_0300 call getDisks success.' + JSON.stringify(data));
var end = new Date().getTime();
console.log('---DSM_Performance_0300---time:-' + (end - start) + '-----' + i);
},
fail: function (data, code) {
console.log('DSM_Performance_0300 call getDisks fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
})
}
})
/**
* @tc.number SUB_STORAGE_DSM_Performance_0400
* @tc.name DSM_Performance_0400
* @tc.desc findVolumeById Performance test
*/
it('DSM_Performance_0400', 0, function () {
for (let i = 0; i < 1000; i++) {
let mId;
devicesmgr.getVolumes({
success: function (data) {
console.log('DSM_Performance_0400 call getVolumes success' + JSON.stringify(data));
mId = data.volumeInfos[2].mId;
},
fail: function (data, code) {
console.log('DSM_Performance_0400 call getVolumes fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
});
var start = new Date().getTime();
devicesmgr.findVolumeById({
volId: mId,
success: function (data) {
console.log('DSM_Performance_0400 call findVolumeById success' + JSON.stringify(data))
var end = new Date().getTime();
console.log('---DSM_Performance_0400---time:-' + (end - start) + '-----' + i);
},
fail: function (data, code) {
console.log('DSM_Performance_0400 call findVolumeById fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
})
}
})
/**
* @tc.number SUB_STORAGE_DSM_Performance_0500
* @tc.name DSM_Performance_0500
* @tc.desc findVolumeByUuid Performance test
*/
it('DSM_Performance_0500', 0, function () {
let mFsUuid;
devicesmgr.getVolumes({
success: function (data) {
console.log('DSM_Performance_0500 call getVolumes success' + JSON.stringify(data));
mFsUuid = data.volumeInfos[2].mFsUuid;
},
fail: function (data, code) {
console.log('DSM_Performance_0500 call getVolumes fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
});
for (let i = 0; i < 1000; i++) {
var start = new Date().getTime();
devicesmgr.findVolumeByUuid({
volumeUuid: mFsUuid,
success: function (vol) {
console.log('DSM_Performance_0500 call findVolumeByUuid success' + JSON.stringify(vol));
var end = new Date().getTime();
console.log('---DSM_Performance_0500---time:-' + (end - start) + '-----' + i);
},
fail: function (data, code) {
console.log('DSM_Performance_0500 call findVolumeByUuid fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
})
}
})
/**
* @tc.number SUB_STORAGE_DSM_Performance_0600
* @tc.name DSM_Performance_0600
* @tc.desc getWritableVolumes Performance test
*/
it('DSM_Performance_0600', 0, function () {
for (let i = 0; i < 1000; i++) {
var start = new Date().getTime();
devicesmgr.getWritableVolumes({
success: function (data) {
console.log('DSM_Performance_0600 call getWritableVolumes success. data:' + JSON.stringify(data));
var end = new Date().getTime();
console.log('---DSM_Performance_0600---time:-' + (end - start) + '-----' + i);
},
fail: function (data, code) {
console.log('DSM_Performance_0600 call getWritableVolumes fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
});
}
})
/**
* @tc.number SUB_STORAGE_DSM_Performance_0700
* @tc.name DSM_Performance_0700
* @tc.desc findDiskById Performance test
*/
it('DSM_Performance_0700', 0, function () {
let mDiskId;
devicesmgr.getVolumes({
success: function (data) {
console.log('DSM_Performance_0700 call getVolumes success' + JSON.stringify(data));
mDiskId = data.volumeInfos[2].mDiskId;
},
fail: function (data, code) {
console.log('DSM_Performance_0700 call getVolumes fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
});
for (let i = 0; i < 1000; i++) {
var start = new Date().getTime();
devicesmgr.findDiskById({
diskId: mDiskId,
success: function (disk) {
console.log('DSM_Performance_0700 call findDiskById success' + JSON.stringify(disk))
var end = new Date().getTime();
console.log('---DSM_Performance_0700---time:-' + (end - start) + '-----' + i);
},
fail: function (data, code) {
console.log('DSM_Performance_0700 call findDiskById fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
})
}
})
/**
* @tc.number SUB_STORAGE_DSM_Performance_0800
* @tc.name DSM_Performance_0800
* @tc.desc getPrimaryStorageUuid Performance test
*/
it('DSM_Performance_0800', 0, function () {
for (let i = 0; i < 1000; i++) {
var start = new Date().getTime();
devicesmgr.getPrimaryStorageUuid({
success: function (primaryUuid) {
console.log('DSM_Performance_0800 call getPrimaryStorageUuid success.' + JSON.stringify(primaryUuid));
var end = new Date().getTime();
console.log('---DSM_Performance_0800---time:-' + (end - start) + '-----' + i);
},
fail: function (data, code) {
console.log('DSM_Performance_0800 call getPrimaryStorageUuid fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
});
}
})
/**
* @tc.number SUB_STORAGE_DSM_Performance_0900
* @tc.name DSM_Performance_0900
* @tc.desc findPrivateForEmulate Performance test
*/
it('DSM_Performance_0900', 0, function () {
let emuVol;
devicesmgr.getVolumes({
success: function (data) {
console.log('DSM_Performance_0900 call getVolumes success' + JSON.stringify(data));
emuVol = data.volumeInfos[0]
},
fail: function (data, code) {
console.log('DSM_Performance_0900 call getVolumes fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
});
for (let i = 0; i < 1000; i++) {
var start = new Date().getTime();
devicesmgr.findPrivateForEmulate({
emuVol: emuVol,
success: function (priVol) {
console.log('DSM_Performance_0900 call findPrivateForEmulate success' + JSON.stringify(priVol))
var end = new Date().getTime();
console.log('---DSM_Performance_0900---time:-' + (end - start) + '-----' + i);
},
fail: function (data, code) {
console.log('DSM_Performance_0900 call findPrivateForEmulate fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
})
}
})
/**
* @tc.number SUB_STORAGE_DSM_Performance_1000
* @tc.name DSM_Performance_1000
* @tc.desc findPrivateForEmulate Performance test
*/
it('DSM_Performance_1000', 0, function () {
let emuVol ;
devicesmgr.getVolumes({
success: function (data) {
console.log('DSM_Performance_1000 call getVolumes success' + JSON.stringify(data));
emuVol = data.volumeInfos[1]
},
fail: function (data, code) {
console.log('DSM_Performance_1000 call getVolumes fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
});
for (let i = 0; i < 1000; i++) {
var start = new Date().getTime();
devicesmgr.findEmulateForPrivate({
priVol: emuVol,
success: function (emuVol) {
console.log('DSM_Performance_1000 call findEmulateForPrivate success' + JSON.stringify(emuVol))
var end = new Date().getTime();
console.log('---DSM_Performance_1000---time:-' + (end - start) + '-----' + i);
},
fail: function (data, code) {
console.log('DSM_Performance_1000 call findEmulateForPrivate fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
})
}
})
/**
* @tc.number SUB_STORAGE_DSM_Performance_1100
* @tc.name DSM_Performance_1100
* @tc.desc findPrivateForEmulate Performance test
*/
it('DSM_Performance_1100', 0, function () {
let emuVol;
devicesmgr.getVolumes({
success: function (data) {
console.log('DSM_Performance_1100 call getVolumes success' + JSON.stringify(data));
emuVol = data.volumeInfos[2]
},
fail: function (data, code) {
console.log('DSM_Performance_1100 call getVolumes fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
});
for (let i = 0; i < 1000; i++) {
var start = new Date().getTime();
devicesmgr.getBestVolumeDescription({
vol: emuVol,
success: function (desCription) {
console.log('DSM_JS_Function_1100 call getBestVolumeDescription success' + desCription)
var end = new Date().getTime();
console.log('---DSM_Performance_1100---time:-' + (end - start) + '-----' + i);
},
fail: function (data, code) {
console.log('DSM_JS_Function_1100 call getBestVolumeDescription fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
})
}
})
})
/*
* 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 devicesmgr from '@system.devicesmgr';
import {
describe,
beforeAll,
beforeEach,
afterEach,
afterAll,
it,
expect
}
from 'deccjsunit/index'
describe('dsmReliabilityTest', function () {
/**
* @tc.number SUB_STORAGE_DSM_Reliability_0000
* @tc.name DSM_Reliability_0000
* @tc.desc Reliability test
*/
it('DSM_Reliability_0000', 0, function () {
for (let i = 0; i < 100000; i++) {
let mId;
let mFsUuid;
let mDiskId;
devicesmgr.getVolumes({
success: function (data) {
console.log('DSM_Reliability_0000 getVolumes success' + JSON.stringify(data) + i);
mId = data.volumeInfos[2].mId;
mFsUuid = data.volumeInfos[2].mFsUuid;
mDiskId = data.volumeInfos[2].mDiskId;
},
fail: function (data, code) {
console.log('DSM_Reliability_0000 getVolumes fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
}
});
devicesmgr.getDisks({
success: function () {
console.log('DSM_Reliability_0300 getDisks success.' + i);
},
fail: function (data, code) {
console.log('DSM_Reliability_0300 getVolumes fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
});
devicesmgr.findVolumeById({
volId: mId,
success: function () {
console.log('DSM_Reliability_0400 findVolumeById success' + i)
},
fail: function (data, code) {
console.log('DSM_Reliability_0400 findVolumeById fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
})
devicesmgr.findVolumeByUuid({
volumeUuid: mFsUuid,
success: function () {
console.log('DSM_Reliability_0500 findVolumeByUuid success' + i);
},
fail: function (data, code) {
console.log('DSM_Reliability_0500 findVolumeByUuid fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
})
devicesmgr.getWritableVolumes({
success: function () {
console.log('DSM_Reliability_0600 getWritableVolumes success. data:' + i);
},
fail: function (data, code) {
console.log('DSM_Reliability_0600 getWritableVolumes fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
});
devicesmgr.findDiskById({
diskId: mDiskId,
success: function () {
console.log('DSM_Reliability_0700 findDiskById success' + i)
},
fail: function (data, code) {
console.log('DSM_Reliability_0700 findDiskById fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
})
devicesmgr.getPrimaryStorageUuid({
success: function () {
console.log('DSM_Reliability_0800 getPrimaryStorageUuid success.' + i);
},
fail: function (data, code) {
console.log('DSM_Reliability_0800 getPrimaryStorageUuid fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
});
devicesmgr.unMount({
volId: mId,
success: function () {
console.log('DSM_Reliability_0100 unMount success.' + i);
},
fail: function (data, code) {
console.log('DSM_Reliability_0100 unMount fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
}
})
devicesmgr.mount({
volId: mId,
success: function () {
console.log('DSM_Reliability_0200 mount success.' + i);
},
fail: function (data, code) {
console.log('DSM_Reliability_0200 mount fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
})
}
})
/**
* @tc.number SUB_STORAGE_DSM_Reliability_0900
* @tc.name DSM_Reliability_0900
* @tc.desc Reliability test
*/
it('DSM_Reliability_0900', 0, function () {
let emuVol;
devicesmgr.getVolumes({
success: function (data) {
console.log('DSM_Reliability_0900 getVolumes success');
emuVol = data.volumeInfos[0]
},
fail: function (data, code) {
console.log('DSM_Reliability_0900 getVolumes fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
});
for (let i = 0; i < 100000; i++) {
devicesmgr.findPrivateForEmulate({
emuVol: emuVol,
success: function () {
console.log('DSM_Reliability_0900 findPrivateForEmulate success' + i)
},
fail: function (data, code) {
console.log('DSM_Reliability_0900 findPrivateForEmulate fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
})
}
})
/**
* @tc.number SUB_STORAGE_DSM_Reliability_1000
* @tc.name DSM_Reliability_1000
* @tc.desc Reliability test
*/
it('DSM_Reliability_1000', 0, function () {
let emuVol;
devicesmgr.getVolumes({
success: function (data) {
console.log('DSM_Reliability_1000 getVolumes success');
emuVol = data.volumeInfos[1]
},
fail: function (data, code) {
console.log('DSM_Reliability_1000 getVolumes fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
});
for (let i = 0; i < 100000; i++) {
devicesmgr.findEmulateForPrivate({
emuVol: emuVol,
success: function () {
console.log('DSM_Reliability_1000 findPrivateForEmulate success' + i)
},
fail: function (data, code) {
console.log('DSM_Reliability_1000 findPrivateForEmulate fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
})
}
})
/**
* @tc.number SUB_STORAGE_DSM_Reliability_1100
* @tc.name DSM_Reliability_1100
* @tc.desc Reliability test
*/
it('DSM_Reliability_1100', 0, function () {
let vol;
devicesmgr.getVolumes({
success: function (data) {
console.log('DSM_Reliability_1100 getVolumes success');
vol = data.volumeInfos[0]
},
fail: function (data, code) {
console.log('DSM_Reliability_1100 getVolumes fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
});
for (let i = 0; i < 100000; i++) {
devicesmgr.getBestVolumeDescription({
vol: vol,
success: function (desCription) {
console.log('DSM_Reliability_1100 call getBestVolumeDescription success' + desCription)
},
fail: function (data, code) {
console.log('DSM_Reliability_1100 call getBestVolumeDescription fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
})
}
})
})
/*
* 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('./DsmPerformance.test.js')
require('./DsmReliability.test.js')
{
"string": [
{
"name": "app_name",
"value": "storagefilestabilityjstest"
},
{
"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.
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("storagefileconcurrent_js_test") {
hap_profile = "./src/main/config.json"
deps = [
":storagefileconcurrent_js_assets",
":storagefileconcurrent_js_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsStorageFileConcurrentJsTest"
}
ohos_js_assets("storagefileconcurrent_js_assets") {
source_dir = "./src/main/js/default"
}
ohos_resources("storagefileconcurrent_js_resources") {
sources = [ "./src/main/resources" ]
hap_profile = "./src/main/config.json"
}
{
"description": "Configuration for storage file and fileio Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "60000",
"package": "ohos.acts.stroage.fileio",
"shell-timeout": "60000"
},
"kits": [
{
"test-file-name": [
"ActsStorageFileConcurrentJsTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
\ No newline at end of file
{
"app": {
"bundleName": "ohos.acts.stroage.fileio",
"vendor": "example",
"version": {
"code": 1000000,
"name": "1.0.0"
},
"apiVersion": {
"compatible": 4,
"target": 5
}
},
"deviceConfig": {},
"module": {
"package": "ohos.acts.stroage.fileio",
"name": ".MyApplication",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry",
"installationFree": true
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"name": "ohos.acts.stroage.fileio.MainAbility",
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "$string:app_name",
"type": "page",
"launchType": "standard",
"visible": true
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"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('ohos.acts.distributeddatamgr.distributedfile onCreate');
},
onDestroy() {
console.info('ohos.acts.distributeddatamgr.distributedfile onCreate');
}
};
{
"strings": {
"hello": "Hello",
"world": "Test"
}
}
\ 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 fileio from '@system.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
}
}
export function prepareFile1(fpath, content) {
try {
let fd = fileio.openSync(fpath, 0o102, 0o777)
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
}
}
export function prepareEmptyFile(fpath) {
try {
let fd = fileio.openSync(fpath, 0o102, 0o777)
fileio.closeSync(fd)
return true
}
catch (e) {
console.log('Failed to prepareFile for ' + e)
return false
}
}
export function fileToReadOnly(fpath) {
try {
let fd = fileio.openSync(fpath, 0o1)
fileio.fchmodSync(fd, 0o444)
fileio.fsyncSync(fd)
fileio.closeSync(fd)
return true
}
catch (e) {
console.log('Failed to fileToReadOnly for ' + e);
return false
}
}
export function fileToWriteOnly(fpath) {
try {
let fd = fileio.openSync(fpath, 0o2)
fileio.fchmodSync(fd, 0o222)
fileio.fsyncSync(fd)
fileio.closeSync(fd)
return true
}
catch (e) {
console.log('Failed to fileToWriteOnly ' + e)
return false
}
}
export function fileToReadAndWrite(fpath) {
try {
let fd = fileio.openSync(fpath, 0o1)
fileio.fchmodSync(fd, 0o777)
fileio.fsyncSync(fd)
fileio.closeSync(fd)
return true
}
catch (e) {
console.log('Failed to fileToReadAndWrite ' + e);
return false
}
}
export function appName(testName) {
const BASE_PATH = '/data/accounts/account_0/appdata/ohos.acts.stroage.fileio/'
return BASE_PATH + testName
}
export function nextFileName(testName) {
const BASE_PATH = '/data/accounts/account_0/appdata/ohos.acts.stroage.fileio/cache/'
return BASE_PATH + testName
}
export function fileName(testName) {
const BASE_PATH = '/data/accounts/account_0/appdata/ohos.acts.stroage.fileio/files/'
return BASE_PATH + testName
}
export function cacheFileName(testName) {
const BASE_PATH = '/data/accounts/account_0/appdata/ohos.acts.stroage.fileio/files/cache/'
return BASE_PATH + testName
}
export function differentFileName(testName) {
const BASE_PATH = '/data/accounts/account_0/ohos.acts.distributeddatamgr.distributedfile/'
return BASE_PATH + testName
}
export function differentCacheName(testName) {
const BASE_PATH = '/data/accounts/account_0/ohos.acts.distributeddatamgr.distributedfile/cache/'
return BASE_PATH + testName
}
export function getFileTextLen(fpath) {
let ss
try {
ss = fileio.Stream.createStreamSync(fpath, 'r+')
expect(ss !== null).assertTrue()
let len = ss.readSync(new ArrayBuffer(4096))
console.log('file:' + fpath)
console.log('file lenth:' + len)
expect(ss.closeSync() !== null).assertTrue()
return len
}
catch (e) {
console.log('Failed to getFileTextLen ' + e)
expect(ss.closeSync() !== null).assertTrue()
return null
}
}
export function isFileExist(fpath) {
try {
expect(fileio.accessSync(fpath) !== null).assertTrue()
console.log('file:' + fpath)
console.log('status:exist')
return true
}
catch (e) {
console.log('file:' + fpath)
console.log('status:non-existen')
return false
}
}
export function sleep(n) {
var start = new Date().getTime();
while (true) {
if (new Date().getTime() - start > n) {
break;
}
}
}
export function randomString(num) {
let len= num;
var $chars = 'aaaabbbbcccc';
var maxPos = $chars.length;
var pwd = '';
for (var i = 0; i < len; i++) {
pwd += $chars.charAt(Math.floor(Math.random() * maxPos));
}
return pwd;
}
/*
* 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 '@system.fileio'
import file from '@system.file';
import {
describe,
beforeAll,
beforeEach,
afterEach,
afterAll,
it,
expect
}
from 'deccjsunit/index'
describe('fileconcurrent', function () {
/**
* @tc.number SUB_STORAGE_file_test_0000
* @tc.name file_test_0000 Function of API, out of package, Virtual path(create and give 777 authority).
* @tc.desc Function of API, Simultaneous write.
*/
it('file_test_000', 0, async function (done) {
for (let i = 0; i < 10; i++) {
file.writeText({
uri: 'internal://app/file_test_000',
text: 'Text',
success: function () {
console.log('file_test_000 => pass, call writeText success. ');
done();
},
fail: function (data, code) {
console.log('file_test_000 => call writeText fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
});
file.writeText({
uri: 'internal://app/file_test_000',
text: 'Text1',
success: function () {
console.log('file_test_000 => pass, call writeText success. ');
done();
},
fail: function (data, code) {
console.log('file_test_000 => call writeText fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
});
file.writeText({
uri: 'internal://app/file_test_000',
text: 'Text2',
success: function () {
console.log('file_test_000 => pass, call writeText success. ');
done();
},
fail: function (data, code) {
console.log('file_test_000 => call writeText fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
});
}
setTimeout(
function(){
expect(null).assertFail();
done();
},30)
});
/**
* @tc.number SUB_STORAGE_File_readText_0100
* @tc.name file_test_001
* @tc.desc Function of API Simultaneous reading.
*/
it('file_test_001', 0, async function (done) {
file.writeText({
uri: 'internal://app/file_test_001',
text: 'Text',
success: function () {
console.log('file_test_001 call writeText success.');
done();
},
fail: function (data, code) {
console.log('file_test_001 call writeText fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
});
for (let i = 0; i < 10; i++) {
file.readText({
uri: 'internal://app/file_test_001',
success: function () {
console.log('file_test_001 => pass, call readText success. data.text: ' );
done();
},
fail: function (data, code) {
console.log('file_test_001 => call readText fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
});
file.readText({
uri: 'internal://app/file_test_001',
success: function () {
console.log('file_test_001 => pass, call readText success. data.text: ' );
done();
},
fail: function (data, code) {
console.log('file_test_001 => call readText fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
});
file.readText({
uri: 'internal://app/file_test_001',
success: function () {
console.log('file_test_001 => pass, call readText success. data.text: ' );
done();
},
fail: function (code, data) {
console.log('file_test_001 => call readText fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
});
}
setTimeout(
function(){
expect(null).assertFail();
done();
},30)
});
/**
* @tc.number SUB_STORAGE_file_test_0200
* @tc.name file_test_002
* @tc.desc Function of API Simultaneous copying.
*/
it('file_test_002', 0, async function (done) {
file.writeText({
uri: 'internal://app/file_test_002',
text: 'Text',
append: true,
success: function () {
console.log('file_test_002 call writeText success.');
done();
},
fail: function (data, code) {
console.log('file_test_002 call writeText fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
});
for (let i = 0; i < 10; i++) {
file.copy({
srcUri: 'internal://app/file_test_002',
dstUri: 'internal://app/file_test_002',
success: function () {
console.log('file_test_002 => pass,call copy success. uri:' );
done();
},
fail: function (data, code) {
console.log('file_test_002 => call copy fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
});
file.copy({
srcUri: 'internal://app/file_test_002',
dstUri: 'internal://app/file_test_002' + '100',
success: function () {
console.log('file_test_002 => pass,call copy success. uri:' );
done();
},
fail: function (data, code) {
console.log('file_test_002 => call copy fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
});
file.copy({
srcUri: 'internal://app/file_test_002',
dstUri: 'internal://app/file_test_002' + '200',
success: function () {
console.log('file_test_002 => pass,call copy success. uri:' );
done();
},
fail: function (data, code) {
console.log('file_test_002 => call copy fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
});
}
setTimeout(
function(){
expect(null).assertFail();
done();
},30)
});
/**
* @tc.number SUB_STORAGE_file_test_0300
* @tc.name file_test_003
* @tc.desc Function of API, Move files while writing to them continuously
*/
it('file_test_003', 0, async function (done) {
for (let i = 0; i < 10; i++) {
file.writeText({
uri: 'internal://app/file_test_003',
text: 'Text',
append: true,
success: function () {
console.log('file_test_003 => pass,call writeText success.');
done();
},
fail: function (data, code) {
console.log('file_test_003 => call writeText fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
});
file.move({
srcUri: 'internal://app/file_test_003',
dstUri: 'internal://file_test_003',
success: function () {
console.log('file_test_003 => pass,call move success. uri:' );
done();
},
fail: function (data, code) {
console.log('file_test_003 =>call move fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
});
}
setTimeout(
function(){
expect(null).assertFail();
done();
},30)
});
/**
* @tc.number SUB_STORAGE_file_test_0400
* @tc.name file_test_004
* @tc.desc Function of API,Continuous reading
*/
it('file_test_004', 0, async function (done) {
let buf = new Uint8Array([48, 49, 50, 51, 65, 66, 67, 68, 32, 33]);
file.writeArrayBuffer({
uri: 'internal://app/file_test_004',
buffer: buf,
success: function () {
console.log('file_test_004 call writeArrayBuffer success.');
done();
},
fail: function (data, code) {
console.error('file_test_004 call writeArrayBuffer fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
});
for (let i = 0; i < 10; i++) {
file.readArrayBuffer({
uri: 'internal://app/file_test_004',
success: function () {
console.log('file_test_004 => pass,call readArrayBuffer success. ');
done();
},
fail: function (data, code) {
console.log('file_test_004 => call readArrayBuffer fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
});
file.readArrayBuffer({
uri: 'internal://app/file_test_004',
success: function () {
console.log('file_test_004 => pass,call readArrayBuffer success. ');
done();
},
fail: function (data, code) {
console.log('file_test_004 => call readArrayBuffer fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
});
file.readArrayBuffer({
uri: 'internal://app/file_test_004',
success: function () {
console.log('file_test_004 => pass,call readArrayBuffer success. ');
done();
},
fail: function (data, code) {
console.log('file_test_004 => call readArrayBuffer fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
});
}
setTimeout(
function(){
expect(null).assertFail();
done();
},30)
});
/**
* @tc.number SUB_STORAGE_file_test_0500
* @tc.name file_test_005
* @tc.desc Function of API,Continuous writeing
*/
it('file_test_005', 0, async function (done) {
let buf = new Uint8Array([48, 49, 50, 51, 65, 66, 67, 68, 32, 33]);
for (let i = 0; i < 10; i++) {
file.writeArrayBuffer({
uri: 'internal://app/file_test_005',
buffer: buf,
success: function () {
console.log('file_test_005 => pass,call writeArrayBuffer success.');
done();
},
fail: function (data, code) {
console.log('file_test_005 => call writeArrayBuffer fail, code: ' + code);
expect(null).assertFail();
},
});
file.writeArrayBuffer({
uri: 'internal://app/file_test_005',
buffer: buf,
success: function () {
console.log('file_test_005 => pass,call writeArrayBuffer success.');
done();
},
fail: function (data, code) {
console.log('file_test_005 => call writeArrayBuffer fail, code: ' + code);
expect(null).assertFail();
},
});
file.writeArrayBuffer({
uri: 'internal://app/file_test_005',
buffer: buf,
success: function () {
console.log('file_test_005 => pass,call writeArrayBuffer success.');
done();
},
fail: function (data, code) {
console.log('file_test_005 => call writeArrayBuffer fail, code: ' + code);
expect(null).assertFail();
},
});
}
setTimeout(
function(){
expect(null).assertFail();
done();
},30)
});
/**
* @tc.number SUB_STORAGE_file_test_0600
* @tc.name file_test_006
* @tc.desc Function of API,Write and read simultaneously for one file
*/
it('file_test_006', 0, async function (done) {
for (let i = 0; i < 10; i++) {
file.writeText({
uri: 'internal://app/file_test_006',
text: 'Text',
success: function () {
console.log('file_test_006 => pass,call writeText success.');
done();
},
fail: function (data, code) {
console.log('file_test_006 => call fail callback fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
});
file.readText({
uri: 'internal://app/file_test_006',
success: function () {
console.log('file_test_006 => pass,call readText success: ');
done();
},
fail: function (data, code) {
console.log('file_test_006 => call readText fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
});
}
setTimeout(
function(){
expect(null).assertFail();
done();
},30)
});
/**
* @tc.number SUB_STORAGE_file_test_0700
* @tc.name file_test_007
* @tc.desc Function of API,Write and read simultaneously for one file
*/
it('file_test_007', 0, async function (done) {
let buf = new Uint8Array([48, 49, 50, 51, 65, 66, 67, 68, 32, 33]);
for (let i = 0; i < 10; i++) {
file.writeArrayBuffer({
uri: 'internal://app/file_test_007',
buffer: buf,
success: function () {
console.log('file_test_007 => pass,call writeArrayBuffer success.');
done();
},
fail: function (data, code) {
console.log('file_test_007 => call writeArrayBuffer fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
});
file.readArrayBuffer({
uri: 'internal://app/file_test_007',
success: function () {
console.log('file_test_007 => pass,call readArrayBuffer success: ');
done();
},
fail: function (data, code) {
console.log('file_test_007 => call readArrayBuffer fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
});
}
setTimeout(
function(){
expect(null).assertFail();
done();
},30)
});
/**
* @tc.number SUB_STORAGE_file_test_0800
* @tc.name file_test_008
* @tc.desc Function of API, Copy files while writing
*/
it('file_test_008', 0, async function (done) {
for (let i = 0; i < 10; i++) {
file.writeText({
uri: 'internal://app/file_test_008',
text: 'Text',
success: function () {
console.log('file_test_008 => pass, call writeText success.');
done();
},
fail: function (data, code) {
console.log('file_test_008 => call writeText fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
});
file.copy({
srcUri: 'internal://app/file_test_008',
dstUri: 'internal://app/file_test_008',
success: function () {
console.log('file_test_008 => pass,call copy success. uri:');
done();
},
fail: function (data, code) {
console.log('file_test_008 => call copy fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
});
}
setTimeout(
function(){
expect(null).assertFail();
done();
},30)
});
});
/*
* 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('./FileConcurrent.test.js')
{
"string": [
{
"name": "app_name",
"value": "storagefileconcurrentjstest"
},
{
"name": "mainability_description",
"value": "JS_Phone_Empty Feature Ability"
}
]
}
\ No newline at end of file
......@@ -14,6 +14,7 @@
*/
import fileio from '@ohos.fileio';
import featureAbility from '@ohos.ability.featureAbility';
export const FILE_CONTENT = 'hello world';
......@@ -73,27 +74,23 @@ export function fileToWriteOnly(fpath) {
return false
}
}
export function nextFileName(testName) {
export function nextFileName1(testName) {
const BASE_PATH = '/data/accounts/account_0/appdata/ohos.acts.storage.fileio/cache/'
return BASE_PATH + testName
return BASE_PATH + testName + '_' + randomString(testName.length);
}
export function fileName(testName) {
const BASE_PATH = '/data/accounts/account_0/appdata/ohos.acts.storage.fileio/files/'
return BASE_PATH + testName
export async function nextFileName(testName) {
let context = featureAbility.getContext();
let data = await context.getFilesDir();
let BASE_PATH = data.substring(0, data.length - 5) + 'cache/';
return BASE_PATH + testName + '_' + randomString(testName.length);
}
export function cacheFileName(testName) {
const BASE_PATH = '/data/accounts/account_0/appdata/ohos.acts.storage.fileio/files/cache/'
return BASE_PATH + testName
export async function fileName(testName) {
let context = featureAbility.getContext();
let data = await context.getFilesDir();
let BASE_PATH = data + '/';
return BASE_PATH + testName + '_' + randomString(testName.length);
}
export function sleep(n) {
var start = new Date().getTime();
while (true) {
if (new Date().getTime() - start > n) {
break;
}
}
}
export function randomString(num) {
let len= num;
var $chars = 'aaaabbbbcccc';
......
......@@ -35,8 +35,8 @@ describe('fileIOTestDir', function () {
* @tc.name fileio_test_dir_open_sync_000
* @tc.desc Function of API, opendirSync.
*/
it('fileio_test_dir_open_sync_000', 0, function () {
let dpath = nextFileName('fileio_test_dir_open_sync_000') + 'd'
it('fileio_test_dir_open_sync_000', 0, async function () {
let dpath = await nextFileName('fileio_test_dir_open_sync_000') + 'd'
try {
expect(fileio.mkdirSync(dpath) !== null).assertTrue();
let dd = fileio.opendirSync(dpath);
......@@ -70,8 +70,8 @@ describe('fileIOTestDir', function () {
* @tc.name fileio_test_dir_open_sync_002
* @tc.desc Function of API, dpath value is not exist.
*/
it('fileio_test_dir_open_sync_002', 0, function () {
let dpath = nextFileName('fileio_test_dir_open_sync_003') + 'd'
it('fileio_test_dir_open_sync_002', 0, async function () {
let dpath = await nextFileName('fileio_test_dir_open_sync_003') + 'd'
try {
fileio.opendirSync(dpath);
expect(null).assertFail();
......@@ -86,8 +86,8 @@ describe('fileIOTestDir', function () {
* @tc.name fileio_test_dir_open_sync_003
* @tc.desc Function of API, dpath too long.
*/
it('fileio_test_dir_open_sync_003', 0, function () {
let dpath = nextFileName('fileio_dir11');
it('fileio_test_dir_open_sync_003', 0, async function () {
let dpath = await nextFileName('fileio_dir11');
fileio.mkdirSync(dpath);
try {
for (let i = 0; i < 16; i++) {
......@@ -107,8 +107,8 @@ describe('fileIOTestDir', function () {
* @tc.name fileio_test_dir_open_sync_004
* @tc.desc Function of API, filename too long.
*/
it('fileio_test_dir_open_sync_004', 0, function () {
let dpath = nextFileName(randomString(256));
it('fileio_test_dir_open_sync_004', 0, async function () {
let dpath = await nextFileName(randomString(256));
try {
fileio.mkdirSync(dpath);
expect(null).assertFail();
......@@ -123,8 +123,8 @@ describe('fileIOTestDir', function () {
* @tc.name fileio_test_dir_open_sync_005
* @tc.desc Function of API, uri dir too many layers.
*/
it('fileio_test_dir_open_sync_005', 0, function () {
let dpath = nextFileName('dir');
it('fileio_test_dir_open_sync_005', 0, async function () {
let dpath = await nextFileName('dir');
fileio.mkdirSync(dpath);
try {
for (let i = 0; i < 1024; i++) {
......@@ -144,8 +144,8 @@ describe('fileIOTestDir', function () {
* @tc.name fileio_test_dir_open_sync_006
* @tc.desc Function of API, file name contain special character.
*/
it('fileio_test_dir_open_sync_006', 0, function () {
let dpath = nextFileName('?*:<>/|');
it('fileio_test_dir_open_sync_006', 0, async function () {
let dpath = await nextFileName('?*:<>/|');
try {
fileio.mkdirSync(dpath);
expect(null).assertFail();
......@@ -160,8 +160,8 @@ describe('fileIOTestDir', function () {
* @tc.name fileio_test_dir_read_sync_000
* @tc.desc Function of API, readSync. The dir contains 1 file.
*/
it('fileio_test_dir_read_sync_000', 0, function () {
let dpath = nextFileName('fileio_test_dir_read_sync_000') + 'd'
it('fileio_test_dir_read_sync_000', 0, async function () {
let dpath = await nextFileName('fileio_test_dir_read_sync_000') + 'd'
let fpath = dpath + '/f0'
try {
expect(typeof(fileio.mkdirSync(dpath)) == 'undefined').assertTrue();
......@@ -184,8 +184,8 @@ describe('fileIOTestDir', function () {
* @tc.name fileio_test_dir_read_sync_001
* @tc.desc Function of API, readSync. The dir contains more than 1 files.
*/
it('fileio_test_dir_read_sync_001', 0, function () {
let dpath = nextFileName('fileio_test_dir_read_sync_001') + 'd'
it('fileio_test_dir_read_sync_001', 0, async function () {
let dpath = await nextFileName('fileio_test_dir_read_sync_001') + 'd'
let fpathArray = new Array(dpath + '/f1', dpath + '/f2', dpath + '/d3');
try {
expect(fileio.mkdirSync(dpath) !== null).assertTrue();
......@@ -228,8 +228,8 @@ describe('fileIOTestDir', function () {
* @tc.name fileio_test_dir_read_sync_002
* @tc.desc Function of API, repeat read. The dir contains more than 1 files.
*/
it('fileio_test_dir_read_sync_002', 0, function () {
let dpath = nextFileName('fileio_test_dir_read_sync_002') + 'd'
it('fileio_test_dir_read_sync_002', 0, async function () {
let dpath = await nextFileName('fileio_test_dir_read_sync_002') + 'd'
let fpathArray = new Array(dpath + '/f1', dpath + '/f2', dpath + '/d3');
try {
expect(fileio.mkdirSync(dpath) !== null).assertTrue();
......@@ -267,8 +267,8 @@ describe('fileIOTestDir', function () {
* @tc.name fileio_test_dir_read_sync_003
* @tc.desc Function of API, readSync. The dir no any files.
*/
it('fileio_test_dir_read_sync_003', 0, function () {
let dpath = nextFileName('fileio_test_dir_read_sync_003') + 'd'
it('fileio_test_dir_read_sync_003', 0, async function () {
let dpath = await nextFileName('fileio_test_dir_read_sync_003') + 'd'
let dd;
try {
expect(fileio.mkdirSync(dpath) !== null).assertTrue();
......@@ -289,8 +289,8 @@ describe('fileIOTestDir', function () {
* @tc.name fileio_test_dir_read_sync_004
* @tc.desc Function of API, error parameter.
*/
it('fileio_test_dir_read_sync_004', 0, function () {
let dpath = nextFileName('fileio_test_dir_read_sync_004') + 'd'
it('fileio_test_dir_read_sync_004', 0, async function () {
let dpath = await nextFileName('fileio_test_dir_read_sync_004') + 'd'
let fpath = dpath + '/f1'
let dd
try {
......@@ -314,8 +314,8 @@ describe('fileIOTestDir', function () {
* @tc.name fileio_test_dir_read_sync_005
* @tc.desc Function of API, excess files.
*/
it('fileio_test_dir_read_sync_005', 0, function () {
let dpath = nextFileName('fileio_test_dir_read_sync_005') + 'd'
it('fileio_test_dir_read_sync_005', 0, async function () {
let dpath = await nextFileName('fileio_test_dir_read_sync_005') + 'd'
let fpath = dpath + '/f'
try {
expect(typeof(fileio.mkdirSync(dpath)) == 'undefined').assertTrue();
......@@ -342,8 +342,8 @@ describe('fileIOTestDir', function () {
* @tc.name fileio_test_dir_close_sync_000
* @tc.desc Function of API, closeSync.
*/
it('fileio_test_dir_close_sync_000', 0, function () {
let dpath = nextFileName('fileio_test_dir_close_sync_000') + 'd'
it('fileio_test_dir_close_sync_000', 0, async function () {
let dpath = await nextFileName('fileio_test_dir_close_sync_000') + 'd'
try {
expect(fileio.mkdirSync(dpath) !== null).assertTrue();
let dd = fileio.opendirSync(dpath);
......
......@@ -34,8 +34,8 @@ describe('fileIOTestDirent', function () {
* @tc.name fileio_test_dirent_name_000
* @tc.desc Function of API, Get file name.
*/
it('fileio_test_dirent_name_000', 0, function () {
let dpath = nextFileName('fileio_test_dirent_name_000') + 'd';
it('fileio_test_dirent_name_000', 0, async function () {
let dpath = await nextFileName('fileio_test_dirent_name_000') + 'd';
let fpath = dpath + '/f1';
try {
expect(fileio.mkdirSync(dpath) !== null);
......@@ -59,8 +59,8 @@ describe('fileIOTestDirent', function () {
* @tc.name fileio_test_dirent_is_block_device_000
* @tc.desc Function of API, isBlockDevice. Determine whether it is a block device.
*/
it('fileio_test_dirent_is_block_device_000', 0, function () {
let dpath = nextFileName('fileio_test_dirent_is_block_device_000') + 'd';
it('fileio_test_dirent_is_block_device_000', 0, async function () {
let dpath = await nextFileName('fileio_test_dirent_is_block_device_000') + 'd';
let fpath = dpath + '/f1';
try {
expect(fileio.mkdirSync(dpath) !== null);
......@@ -86,8 +86,8 @@ describe('fileIOTestDirent', function () {
* @tc.name fileio_test_dirent_is_block_device_001
* @tc.desc Function of API, isBlockDevice. The parameter is - 1.
*/
it('fileio_test_dirent_is_block_device_001', 0, function () {
let dpath = nextFileName('fileio_test_dirent_is_block_device_001') + 'd';
it('fileio_test_dirent_is_block_device_001', 0, async function () {
let dpath = await nextFileName('fileio_test_dirent_is_block_device_001') + 'd';
let fpath = dpath + '/f1';
let dd;
try {
......@@ -113,8 +113,8 @@ describe('fileIOTestDirent', function () {
* @tc.name fileio_test_dirent_is_character_device_000
* @tc.desc Function of API, isCharacterDevice. Determine whether it is a character device.
*/
it('fileio_test_dirent_is_character_device_000', 0, function () {
let dpath = nextFileName('fileio_test_dirent_is_character_device_000') + 'd';
it('fileio_test_dirent_is_character_device_000', 0, async function () {
let dpath = await nextFileName('fileio_test_dirent_is_character_device_000') + 'd';
let fpath = dpath + '/f1';
try {
expect(fileio.mkdirSync(dpath) !== null);
......@@ -139,8 +139,8 @@ describe('fileIOTestDirent', function () {
* @tc.name fileio_test_dirent_is_character_device_001
* @tc.desc Function of API, isCharacterDevice. The parameter is - 1.
*/
it('fileio_test_dirent_is_character_device_001', 0, function () {
let dpath = nextFileName('fileio_test_dirent_is_character_device_001') + 'd';
it('fileio_test_dirent_is_character_device_001', 0, async function () {
let dpath = await nextFileName('fileio_test_dirent_is_character_device_001') + 'd';
let fpath = dpath + '/f1';
let dd;
try {
......@@ -166,8 +166,8 @@ describe('fileIOTestDirent', function () {
* @tc.name fileio_test_dirent_is_directory_000
* @tc.desc Function of API, isDirectory. Determine whether it is a directory.
*/
it('fileio_test_dirent_is_directory_000', 0, function () {
let dpath = nextFileName('fileio_test_dirent_is_directory_000') + 'd';
it('fileio_test_dirent_is_directory_000', 0, async function () {
let dpath = await nextFileName('fileio_test_dirent_is_directory_000') + 'd';
let fpath = dpath + '/f1';
try {
expect(fileio.mkdirSync(dpath) !== null);
......@@ -192,8 +192,8 @@ describe('fileIOTestDirent', function () {
* @tc.name fileio_test_dirent_is_directory_001
* @tc.desc Function of API, isDirectory. The parameter is - 1
*/
it('fileio_test_dirent_is_directory_001', 0, function () {
let dpath = nextFileName('fileio_test_dirent_is_directory_001') + 'd';
it('fileio_test_dirent_is_directory_001', 0, async function () {
let dpath = await nextFileName('fileio_test_dirent_is_directory_001') + 'd';
let fpath = dpath + '/f1';
let dd;
try {
......@@ -219,8 +219,8 @@ describe('fileIOTestDirent', function () {
* @tc.name fileio_test_dirent_is_fifo_000
* @tc.desc Function of API, isFIFO. Determine whether it is a fifo.
*/
it('fileio_test_dirent_is_fifo_000', 0, function () {
let dpath = nextFileName('fileio_test_dirent_is_fifo_000') + 'd';
it('fileio_test_dirent_is_fifo_000', 0, async function () {
let dpath = await nextFileName('fileio_test_dirent_is_fifo_000') + 'd';
let fpath = dpath + '/f1';
try {
expect(fileio.mkdirSync(dpath) !== null);
......@@ -245,8 +245,8 @@ describe('fileIOTestDirent', function () {
* @tc.name fileio_test_dirent_is_fifo_001
* @tc.desc Function of API, isFIFO. The parameter is - 1
*/
it('fileio_test_dirent_is_fifo_001', 0, function () {
let dpath = nextFileName('fileio_test_dirent_is_fifo_001') + 'd';
it('fileio_test_dirent_is_fifo_001', 0, async function () {
let dpath = await nextFileName('fileio_test_dirent_is_fifo_001') + 'd';
let fpath = dpath + '/f1';
let dd;
try {
......@@ -272,8 +272,8 @@ describe('fileIOTestDirent', function () {
* @tc.name fileio_test_dirent_is_file_000
* @tc.desc Function of API, isFile. Determine whether it is a file.
*/
it('fileio_test_dirent_is_file_000', 0, function () {
let dpath = nextFileName('fileio_test_dirent_is_file_000') + 'd';
it('fileio_test_dirent_is_file_000', 0, async function () {
let dpath = await nextFileName('fileio_test_dirent_is_file_000') + 'd';
let fpath = dpath + '/f1';
try {
expect(fileio.mkdirSync(dpath) !== null);
......@@ -298,8 +298,8 @@ describe('fileIOTestDirent', function () {
* @tc.name fileio_test_dirent_is_file_001
* @tc.desc Function of API, isFile. The parameter is - 1
*/
it('fileio_test_dirent_is_file_001', 0, function () {
let dpath = nextFileName('fileio_test_dirent_is_file_001') + 'd';
it('fileio_test_dirent_is_file_001', 0, async function () {
let dpath = await nextFileName('fileio_test_dirent_is_file_001') + 'd';
let fpath = dpath + '/f1';
let dd;
try {
......@@ -325,8 +325,8 @@ describe('fileIOTestDirent', function () {
* @tc.name fileio_test_dirent_is_socket_000
* @tc.desc Function of API, isSocket. Determine whether it is a socket.
*/
it('fileio_test_dirent_is_socket_000', 0, function () {
let dpath = nextFileName('fileio_test_dirent_is_socket_000') + 'd';
it('fileio_test_dirent_is_socket_000', 0, async function () {
let dpath = await nextFileName('fileio_test_dirent_is_socket_000') + 'd';
let fpath = dpath + '/f1';
try {
expect(fileio.mkdirSync(dpath) !== null);
......@@ -351,8 +351,8 @@ describe('fileIOTestDirent', function () {
* @tc.name fileio_test_dirent_is_socket_001
* @tc.desc Function of API, isSocket. The parameter is - 1
*/
it('fileio_test_dirent_is_socket_001', 0, function () {
let dpath = nextFileName('fileio_test_dirent_is_socket_001') + 'd';
it('fileio_test_dirent_is_socket_001', 0, async function () {
let dpath = await nextFileName('fileio_test_dirent_is_socket_001') + 'd';
let fpath = dpath + '/f1';
let dd;
try {
......@@ -378,8 +378,8 @@ describe('fileIOTestDirent', function () {
* @tc.name fileio_test_dirent_is_symbolic_link_000
* @tc.desc Function of API, isSymbolicLink. Determine whether it is a symbolic link.
*/
it('fileio_test_dirent_is_symbolic_link_000', 0, function () {
let dpath = nextFileName('fileio_test_dirent_is_symbolic_link_000') + 'd';
it('fileio_test_dirent_is_symbolic_link_000', 0, async function () {
let dpath = await nextFileName('fileio_test_dirent_is_symbolic_link_000') + 'd';
let fpath = dpath + '/f1';
try {
expect(fileio.mkdirSync(dpath) !== null);
......@@ -404,8 +404,8 @@ describe('fileIOTestDirent', function () {
* @tc.name fileio_test_dirent_is_symbolic_link_001
* @tc.desc Function of API, isSymbolicLink. The parameter is - 1
*/
it('fileio_test_dirent_is_symbolic_link_001', 0, function () {
let dpath = nextFileName('fileio_test_dirent_is_symbolic_link_001') + 'd';
it('fileio_test_dirent_is_symbolic_link_001', 0, async function () {
let dpath = await nextFileName('fileio_test_dirent_is_symbolic_link_001') + 'd';
let fpath = dpath + '/f1';
let dd;
try {
......
......@@ -13,7 +13,6 @@
* limitations under the License.
*/
require('./File.test.js')
require('./FileIO.test.js')
require('./FileIODir.test.js')
require('./FileIODirent.test.js')
......@@ -51,7 +50,7 @@ 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/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');
......
......@@ -21,9 +21,13 @@ import {
describe('constants', function () {
/**
* @tc.number SUB_DF_FileIO_constants
* @tc.number SUB_DF_FILEIO_CONSTANTS
* @tc.name fileio_test_constants
* @tc.desc Test constants() interface.
* @tc.size MEDIUM(中型)
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_test_constants', 0, function () {
try {
......
......@@ -29,12 +29,16 @@ import {
describe('fileio_dir_close_read', function () {
/**
* @tc.number SUB_DF_FileIO_Dir_close_Async_0000
* @tc.number SUB_DF_FILEIO_DIR_CLOSE_ASYNC_0000
* @tc.name fileio_test_dir_close_async_000
* @tc.desc Test Dir.closeAsync() interface.
* @tc.size MEDIUM(中型)
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_test_dir_close_async_000', 0, async function (done) {
let dpath = nextFileName('fileio_test_dir_close_async_000') + 'd';
let dpath = await nextFileName('fileio_test_dir_close_async_000') + 'd';
try {
expect(fileio.mkdirSync(dpath) == null).assertTrue();
......@@ -55,7 +59,7 @@ describe('fileio_dir_close_read', function () {
* @tc.desc Test Dir.closeAsync() interface.
*/
it('fileio_test_dir_close_async_001', 0, async function (done) {
let dpath = nextFileName('fileio_test_dir_close_async_001') + 'd';
let dpath = await nextFileName('fileio_test_dir_close_async_001') + 'd';
try {
expect(fileio.mkdirSync(dpath) == null).assertTrue();
......
......@@ -21,12 +21,16 @@ import {
describe('fileio_stream', function () {
/**
* @tc.number SUB_DF_FileIO_Stream_CreateStreamSync_0000
* @tc.number SUB_DF_FILEIO_STREAM_CREATESTREAMSYNC_0000
* @tc.name fileio_test_stream_create_stream_sync_000
* @tc.desc Test createStreamSync() interface.
* @tc.size MEDIUM(中型)
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_test_stream_create_stream_sync_000', 0, function () {
let fpath = nextFileName('fileio_test_stream_create_stream_sync_000');
it('fileio_test_stream_create_stream_sync_000', 0, async function () {
let fpath = await nextFileName('fileio_test_stream_create_stream_sync_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
......@@ -41,12 +45,16 @@ describe('fileio_stream', function () {
});
/**
* @tc.number SUB_DF_FileIO_Stream_CreateStreamSync_0010
* @tc.number SUB_DF_FILEIO_STREAM_CREATESTREAMSYNC_0010
* @tc.name fileio_test_stream_create_stream_sync_001
* @tc.desc Test createStreamSync() interface.
* @tc.size MEDIUM(中型)
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_test_stream_create_stream_sync_001', 0, function () {
let fpath = nextFileName('fileio_test_stream_create_stream_sync_001');
it('fileio_test_stream_create_stream_sync_001', 0, async function () {
let fpath = await nextFileName('fileio_test_stream_create_stream_sync_001');
try {
fileio.createStreamSync(fpath, 'r+');
......@@ -56,12 +64,16 @@ describe('fileio_stream', function () {
});
/**
* @tc.number SUB_DF_FileIO_Stream_CreateStreamSync_0020
* @tc.number SUB_DF_FILEIO_STREAM_CREATESTREAMSYNC_0020
* @tc.name fileio_test_stream_create_stream_sync_002
* @tc.desc Test createStreamSync() interface.
* @tc.size MEDIUM(中型)
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_test_stream_create_stream_sync_002', 0, function () {
let fpath = nextFileName('fileio_test_stream_create_stream_sync_002');
it('fileio_test_stream_create_stream_sync_002', 0, async function () {
let fpath = await nextFileName('fileio_test_stream_create_stream_sync_002');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
......@@ -73,12 +85,16 @@ describe('fileio_stream', function () {
});
/**
* @tc.number SUB_DF_FileIO_Stream_ReadSync_0000
* @tc.number SUB_DF_FILEIO_STREAM_READSYNC_0000
* @tc.name fileio_test_stream_read_sync_000
* @tc.desc Test readSync() interface.
* @tc.size MEDIUM(中型)
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_test_stream_read_sync_000', 0, function () {
let fpath = nextFileName('fileio_test_stream_read_sync_000');
it('fileio_test_stream_read_sync_000', 0, async function () {
let fpath = await nextFileName('fileio_test_stream_read_sync_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
......@@ -95,14 +111,18 @@ describe('fileio_stream', function () {
});
/**
* @tc.number SUB_DF_FileIO_Stream_ReadSync_0010
* @tc.number SUB_DF_FILEIO_STREAM_READSYNC_0010
* @tc.name fileio_test_stream_read_sync_001
* @tc.desc Test the readSync method of class Stream.
* @tc.size MEDIUM(中型)
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_test_stream_read_sync_001', 0, function () {
it('fileio_test_stream_read_sync_001', 0, async function () {
let bufLen = 5;
expect(FILE_CONTENT.length > bufLen).assertTrue();
let fpath = nextFileName('fileio_test_stream_read_sync_001');
let fpath = await nextFileName('fileio_test_stream_read_sync_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
......@@ -120,12 +140,16 @@ describe('fileio_stream', function () {
});
/**
* @tc.number SUB_DF_FileIO_Stream_ReadSync_0020
* @tc.number SUB_DF_FILEIO_STREAM_READSYNC_0020
* @tc.name fileio_test_stream_read_sync_002
* @tc.desc Test the readSync method of class Stream.
* @tc.size MEDIUM(中型)
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_test_stream_read_sync_002', 0, function () {
let fpath = nextFileName('fileio_test_stream_read_sync_002');
it('fileio_test_stream_read_sync_002', 0, async function () {
let fpath = await nextFileName('fileio_test_stream_read_sync_002');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
......@@ -143,12 +167,16 @@ describe('fileio_stream', function () {
});
/**
* @tc.number SUB_DF_FileIO_Stream_ReadSync_0030
* @tc.number SUB_DF_FILEIO_STREAM_READSYNC_0030
* @tc.name fileio_test_stream_read_sync_003
* @tc.desc Test the readSync method of class Stream.
* @tc.size MEDIUM(中型)
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_test_stream_read_sync_003', 0, function () {
let fpath = nextFileName('fileio_test_stream_read_sync_003');
it('fileio_test_stream_read_sync_003', 0, async function () {
let fpath = await nextFileName('fileio_test_stream_read_sync_003');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
......@@ -166,14 +194,18 @@ describe('fileio_stream', function () {
});
/**
* @tc.number SUB_DF_FileIO_Stream_ReadSync_0040
* @tc.number SUB_DF_FILEIO_STREAM_READSYNC_0040
* @tc.name fileio_test_stream_read_sync_004
* @tc.desc Test the readSync method of class Stream.
* @tc.size MEDIUM(中型)
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_test_stream_read_sync_004', 0, function () {
it('fileio_test_stream_read_sync_004', 0, async function () {
let ss;
const invalidOffset = 99999;
let fpath = nextFileName('fileio_test_stream_read_sync_004');
let fpath = await nextFileName('fileio_test_stream_read_sync_004');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
......@@ -189,14 +221,18 @@ describe('fileio_stream', function () {
});
/**
* @tc.number SUB_DF_FileIO_Stream_ReadSync_0050
* @tc.number SUB_DF_FILEIO_STREAM_READSYNC_0050
* @tc.name fileio_test_stream_read_sync_005
* @tc.desc Test the readSync method of class Stream.
* @tc.size MEDIUM(中型)
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_test_stream_read_sync_005', 0, function () {
it('fileio_test_stream_read_sync_005', 0, async function () {
let ss;
const invalidLength = 9999;
let fpath = nextFileName('fileio_test_stream_read_sync_005');
let fpath = await nextFileName('fileio_test_stream_read_sync_005');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
......@@ -212,12 +248,16 @@ describe('fileio_stream', function () {
});
/**
* @tc.number SUB_DF_FileIO_Stream_ReadSync_0060
* @tc.number SUB_DF_FILEIO_STREAM_READSYNC_0060
* @tc.name fileio_test_stream_read_sync_006
* @tc.desc Test the readSync method of class Stream.
* @tc.size MEDIUM(中型)
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_test_stream_read_sync_006', 0, function () {
let fpath = nextFileName('fileio_test_stream_read_sync_006');
it('fileio_test_stream_read_sync_006', 0, async function () {
let fpath = await nextFileName('fileio_test_stream_read_sync_006');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
......@@ -236,12 +276,16 @@ describe('fileio_stream', function () {
});
/**
* @tc.number SUB_DF_FileIO_Stream_WriteSync_0000
* @tc.number SUB_DF_FILEIO_STREAM_WRITESYNC_0000
* @tc.name fileio_test_stream_write_sync_000
* @tc.desc Test writeSync() interface.
* @tc.size MEDIUM(中型)
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_test_stream_write_sync_000', 0, function () {
let fpath = nextFileName('fileio_test_stream_write_sync_000');
it('fileio_test_stream_write_sync_000', 0, async function () {
let fpath = await nextFileName('fileio_test_stream_write_sync_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
......
{
"strings": {
"hello": "Hello",
"world": "Test"
}
}
\ No newline at end of file
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册