提交 b662aef6 编写于 作者: R raoxian

删除storage下没使用的用例

Signed-off-by: Nraoxian <raoxian@huawei.com>
上级 608fb985
......@@ -16,19 +16,8 @@ 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",
# "storagefmspublicjstest:storagefmspublic_js_test",
# "storagefmssharejstest:storagefmsshare_js_test",
# "storagefileioperformancejstest:storagefileioperformance_js_test",
# "storagefileioreliabilityjstest:storagefileioreliability_js_test",
# "storagefileiostabilityjstest:storagefileiostability_js_test",
# "storagefilestabilityjstest:storagefilestability_js_test",
]
}
}
# Copyright (C) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("storagedsm_js_test") {
hap_profile = "./src/main/config.json"
deps = [
":storagedsm_js_assets",
":storagedsm_js_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsStorageFmsPublicJsTest"
}
ohos_js_assets("storagedsm_js_assets") {
source_dir = "./src/main/js/default"
}
ohos_resources("storagedsm_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
{
"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 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
{
"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 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 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 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
# 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("storagefileioperformance_js_test") {
hap_profile = "./src/main/config.json"
deps = [
":storagefileioperformance_js_assets",
":storagefileioperformance_js_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsStorageFileIoPerformanceJsTest"
}
ohos_js_assets("storagefileioperformance_js_assets") {
source_dir = "./src/main/js/default"
}
ohos_resources("storagefileioperformance_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": [
"ActsStorageFileIoPerformanceJsTest.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 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 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 file from '@system.file';
import fileio from '@ohos.fileio';
import {
describe,
it,
expect
}
from 'deccjsunit/index'
import {
randomString
}
from './Common'
describe('fileTest', function () {
/**
* @tc.number SUB_STORAGE_File_mkdir_1100
* @tc.name File_mkdir_011
* @tc.desc Function of API, Run 1000 times to obtain each running time.
*/
it('File_mkdir_011', 0, async function (done) {
let start = new Date().getTime();
for (let i = 0; i < 1000; i++) {
file.mkdir({
uri: 'internal://app/File_mkdir_011' + i,
success: function () {
let end = new Date().getTime();
let time = end - start;
console.log('-------File_mkdir_011 call mkdir success, time:' + time + ',' + i);
start = new Date().getTime();
done();
},
fail: function (data, code) {
console.log('-------File_mkdir_011 call mkdir fail! code:' + code + ', data' + data);
expect(null).assertFail();
},
});
}
setTimeout(
function(){
expect(null).assertFail();
done();
},30)
});
/**
* @tc.number SUB_STORAGE_File_access_1100
* @tc.name File_access_011
* @tc.desc Function of API, Run 1000 times to obtain each running time.
*/
it('File_access_011', 0, async function (done) {
let start = new Date().getTime();
for (let i = 0; i < 1000; i++) {
file.access({
uri: 'internal://app/File_mkdir_011' + i,
success: function () {
let end = new Date().getTime();
let time = end - start;
console.log('-------File_access_011 call access success, time:' + time + ',' + i);
start = new Date().getTime();
done();
},
fail: function (data, code) {
console.log('-------File_access_011 call access fail! code:' + code + ', data' + data);
expect(null).assertFail();
},
});
}
setTimeout(
function(){
expect(null).assertFail();
done();
},30)
});
/**
* @tc.number SUB_STORAGE_File_rmdir_1100
* @tc.name File_rmdir_011
* @tc.desc Function of API, Run 1000 times to obtain each running time.
*/
it('File_rmdir_011', 0, async function (done) {
let start = new Date().getTime();
for (let i = 0; i < 1000; i++) {
file.rmdir({
uri: 'internal://app/File_mkdir_011' + i,
success: function () {
let end = new Date().getTime();
let time = end - start;
console.log('-------File_rmdir_011 call rmdir success, time:' + time + ',' + i);
start = new Date().getTime();
done();
},
fail: function (data, code) {
console.log('-------File_rmdir_011 call rmdir fail! code:' + code + ', data' + data);
expect(null).assertFail();
},
});
}
setTimeout(
function(){
expect(null).assertFail();
done();
},30)
});
/**
* @tc.number SUB_STORAGE_File_Copy_1500
* @tc.name File_Copy_015
* @tc.desc Function of API, Run 1000 times to obtain each running time.
*/
it('File_Copy_015', 0, function (done) {
file.writeText({
uri: 'internal://app/File_Copy_015',
text: 'hello',
success: function () {
console.log('File_Copy_015 call writeText success');
done();
},
fail: function (data, code) {
console.log('File_Copy_015 call writeText fail! code:' + code + ', data' + data);
expect(null).assertFail();
},
});
let start = new Date().getTime();
for (let i = 0; i < 1000; i++) {
file.copy({
srcUri: 'internal://app/File_Copy_015',
dstUri: 'internal://app/File_Copy_015_1' + i,
success: function () {
let end = new Date().getTime();
let time = end - start;
console.log('-------File_Copy_015 call copy success, time:' + time + ',' + i);
start = new Date().getTime();
done();
},
fail: function (data, code) {
console.log('-------File_Copy_015 call copy fail! code:' + code + ', data' + data);
expect(null).assertFail();
},
});
}
file.delete({
uri: 'internal://app/File_Copy_015',
success: function () {
console.log('-------File_Copy_015 call delete success.');
done();
},
fail: function (data, code) {
console.log('-------File_Copy_015 call delete fail! code:' + code + ', data' + data);
expect(null).assertFail();
},
});
setTimeout(
function(){
expect(null).assertFail();
done();
},30)
});
/**
* @tc.number SUB_STORAGE_File_Delete_1100
* @tc.name File_Delete_011
* @tc.desc Function of API, Run 1000 times to obtain each running time.
*/
it('File_Delete_011', 0, function (done) {
let start = new Date().getTime();
for (let i = 0; i < 1000; i++) {
file.delete({
uri: 'internal://app/File_Copy_015_1' + i,
success: function () {
let end = new Date().getTime();
let time = end - start;
console.log('-------File_Delete_011 call delete success, time:' + time + ',' + i);
start = new Date().getTime();
done();
},
fail: function (data, code) {
console.log('-------File_Delete_011 call delete fail! code:' + code + ', data' + data);
expect(null).assertFail();
},
});
}
setTimeout(
function(){
expect(null).assertFail();
done();
},30)
});
/**
* @tc.number SUB_STORAGE_File_List_1300
* @tc.name File_List_013
* @tc.desc Function of API, Run 1000 times to obtain each running time.
*/
it('File_List_013', 0, async function (done) {
file.writeText({
uri: 'internal://app/File_List_013',
text: 'Text that just for test.',
success: function () {
console.log('File_List_013 call writeText success.');
done();
},
fail: function (data, code) {
console.error('File_List_013 call writeText fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
});
let start = new Date().getTime();
for (let i = 0; i <= 1000; i++) {
file.list({
uri: 'internal://app/',
success: function () {
let end = new Date().getTime();
let time = end - start;
console.log('File_List_013 Difference time:' + time + ',' + i);
start = new Date().getTime();
done();
},
fail: function (data, code) {
console.error('File_List_013 call list fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
});
}
setTimeout(
function(){
expect(null).assertFail();
done();
},30)
});
/**
* @tc.number SUB_STORAGE_File_List_1400
* @tc.name File_List_014
* @tc.desc Function of API, Run 1000 times to obtain each running time.
*/
it('File_List_014', 0, async function (done) {
for (let i = 0; i < 1000; i++) {
file.writeText({
uri: 'internal://app/File_List_014' + i,
text: 'Text that just for test.',
success: function () {
console.log('File_List_014 call writeText success.');
done();
},
fail: function (data, code) {
console.error('File_List_014 call writeText fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
});
}
let start = new Date().getTime();
for (let i = 0; i <= 1000; i++) {
file.list({
uri: 'internal://app/',
success: function () {
let end = new Date().getTime();
let time = end - start;
console.log('File_List_014 Difference time:' + time + ',' + i);
start = new Date().getTime();
done();
},
fail: function (data, code) {
console.error('File_List_014 call list fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
});
}
setTimeout(
function(){
expect(null).assertFail();
done();
},30)
});
/**
* @tc.number SUB_STORAGE_File_Get_1500
* @tc.name File_Get_015
* @tc.desc Function of API, Run 1000 times to obtain each running time.
*/
it('File_Get_015', 0, async function (done) {
file.writeText({
uri: 'internal://app/File_Get_015',
text: 'Text that just for test.',
success: function () {
console.log('File_Get_015 call writeText success.');
done();
},
fail: function (data, code) {
console.error('File_Get_015 call writeText fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
});
let start = new Date().getTime();
for (let i = 0; i <= 1000; i++) {
file.get({
uri: 'internal://app/File_Get_015',
success: function () {
let end = new Date().getTime();
let time = end - start;
console.log('File_Get_015 Difference time:' + time + ',' + i);
start = new Date().getTime();
done();
},
fail: function (data, code) {
console.error('File_Get_015 call get fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
});
}
setTimeout(
function(){
expect(null).assertFail();
done();
},30)
});
/**
* @tc.number SUB_STORAGE_File_Get_1600
* @tc.name File_Get_016
* @tc.desc Function of API, Run 1000 times to obtain each running time.
*/
it('File_Get_016', 0, async function (done) {
for (let i = 0; i < 1000; i++) {
file.writeText({
uri: 'internal://app/File_Get_016' + i,
text: 'Text that just for test.',
success: function () {
console.log('File_Get_016 call writeText success.');
done();
},
fail: function (data, code) {
console.error('File_Get_016 call writeText fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
});
}
let start = new Date().getTime();
for (let i = 0; i <= 1000; i++) {
file.get({
uri: 'internal://app/File_Get_016' + i,
success: function (data) {
console.log(data.uri);
let end = new Date().getTime();
let time = end - start;
console.log('File_Get_016 Difference time:' + time + ',' + i);
start = new Date().getTime();
done();
},
fail: function (data, code) {
console.error('File_Get_016 call get fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
});
}
setTimeout(
function(){
expect(null).assertFail();
done();
},30)
});
/**
* @tc.number SUB_STORAGE_File_writeText_1400
* @tc.name File_writeText_014
* @tc.desc Function of API, Run 1000 times to obtain each running time.
*/
it('File_writeText_014', 0, async function (done) {
let text = randomString(4096);
let start = new Date().getTime();
for (let i = 0; i <= 1000; i++) {
file.writeText({
uri: 'internal://app/File_writeText_014',
text: text,
success: function () {
let end = new Date().getTime();
let time = end - start;
console.log('File_writeText_014 4K Difference time:' + time + ',' + i);
start = new Date().getTime();
done();
},
fail: function (data, code) {
console.error('File_writeText_014 call writeText fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
});
}
setTimeout(
function(){
expect(null).assertFail();
done();
},30)
});
/**
* @tc.number SUB_STORAGE_File_readText_1000
* @tc.name File_readText_010
* @tc.desc Function of API, Run 1000 times to obtain each running time.
*/
it('File_readText_010', 0, async function (done) {
let start = new Date().getTime();
for (let i = 0; i <= 1000; i++) {
file.readText({
uri: 'internal://app/File_writeText_014',
success: function () {
let end = new Date().getTime();
let time = end - start;
console.log('File_readText_010 4K Difference time:' + time + ',' + i);
start = new Date().getTime();
done();
},
fail: function (data, code) {
console.log('File_readText_010 call readText fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
});
}
setTimeout(
function(){
expect(null).assertFail();
done();
},30)
});
/**
* @tc.number SUB_STORAGE_File_writeArrayBuffer_1300
* @tc.name File_writeArrayBuffer_013
* @tc.desc Function of API, Run 1000 times to obtain each running time.
*/
it('File_writeArrayBuffer_013', 0, async function (done) {
let buf = new Uint8Array(4096);
for (let i = 0; i < 4096; i++) {
buf[i] = 100
}
let start = new Date().getTime();
for (let i = 0; i <= 1000; i++) {
file.writeArrayBuffer({
uri: 'internal://app/File_writeArrayBuffer_013',
buffer: buf,
success: function () {
console.log('call writeArrayBuffer success.');
let end = new Date().getTime();
let time = end - start;
console.log('File_writeArrayBuffer_013 4K Difference time:' + time + ',' + i);
start = new Date().getTime();
done();
},
fail: function (data, code) {
console.error('File_writeArrayBuffer_013 call writeArrayBuffer fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
});
}
setTimeout(
function(){
expect(null).assertFail();
done();
},30)
});
/**
* @tc.number SUB_STORAGE_File_readArrayBuffer_1200
* @tc.name File_readArrayBuffer_012
* @tc.desc Function of API, Run 1000 times to obtain each running time.
*/
it('File_readArrayBuffer_012', 0, async function (done) {
let start = new Date().getTime();
for (let i = 0; i <= 1000; i++) {
file.readArrayBuffer({
uri: 'internal://app/File_writeArrayBuffer_013',
success: function () {
let end = new Date().getTime();
let time = end - start;
console.log('File_readArrayBuffer_012 4K Difference time:' + time + ',' + i);
start = new Date().getTime();
done();
},
fail: function (data, code) {
console.error('File_readArrayBuffer_012 call readArrayBuffer 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('./FileIOPerformance.js')
require('./FilePerformance.js')
{
"string": [
{
"name": "app_name",
"value": "storagefileioperformancejstest"
},
{
"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("storagefileioreliability_js_test") {
hap_profile = "./src/main/config.json"
deps = [
":storagefileioreliability_js_assets",
":storagefileioreliability_js_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsStorageFileIoreLiabilityJsTest"
}
ohos_js_assets("storagefileioreliability_js_assets") {
source_dir = "./src/main/js/default"
}
ohos_resources("storagefileioreliability_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": [
"ActsStorageFileIoreLiabilityJsTest.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 app from '@system.app'
import {Core} from 'deccjsunit/index'
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
此差异已折叠。
{
"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.
先完成此消息的编辑!
想要评论请 注册