提交 d56098c6 编写于 作者: X XTStarry

fixed c91b32ea from https://gitee.com/XTStarry/xts_acts/pulls/733

整改了部分用例,新增了dsm和fms部分的接口用例
Signed-off-by: NXTStarry <gaoxiaotian@huawei.com>
上级 3c3a8928
......@@ -16,9 +16,14 @@ 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",
......
# 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",
]
# shared_libraries = [
# "//third_party/giflib:libgif",
# "//third_party/libpng:libpng",
# ]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "storagedsmjstest"
# part_name = "prebuilt_hap"
# subsystem_name = "xts"
}
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": [
"storagefmspublicjstest.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",
]
# shared_libraries = [
# "//third_party/giflib:libgif",
# "//third_party/libpng:libpng",
# ]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "storagedsmstabilityjstest"
# part_name = "prebuilt_hap"
# subsystem_name = "xts"
}
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": [
"storagefmspublicjstest.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
......@@ -18,14 +18,16 @@ ohos_js_hap_suite("storagefileconcurrent_js_test") {
":storagefileconcurrent_js_assets",
":storagefileconcurrent_js_resources",
]
# shared_libraries = [
# "//third_party/giflib:libgif",
# "//third_party/libpng:libpng",
# ]
# shared_libraries = [
# "//third_party/giflib:libgif",
# "//third_party/libpng:libpng",
# ]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "storagefileconcurrentjstest"
# part_name = "prebuilt_hap"
# subsystem_name = "xts"
# part_name = "prebuilt_hap"
# subsystem_name = "xts"
}
ohos_js_assets("storagefileconcurrent_js_assets") {
source_dir = "./src/main/js/default"
......
......@@ -2,7 +2,7 @@
"description": "Configuration for storage file and fileio Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "120000",
"test-timeout": "60000",
"package": "ohos.acts.stroage.fileio",
"shell-timeout": "60000"
},
......
/*
* 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');
......
......@@ -12,6 +12,7 @@
* 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 {
......@@ -24,17 +25,6 @@ import {
expect
}
from 'deccjsunit/index'
import {
FILE_CONTENT,
prepareFile,
fileName,
cacheFileName,
getFileTextLen,
isFileExist,
prepareEmptyFile,
randomString
}
from './Common'
describe('fileconcurrent', function () {
......@@ -105,7 +95,7 @@ describe('fileconcurrent', function () {
for (let i = 0; i < 10; i++) {
file.readText({
uri: 'internal://app/file_test_001',
success: function (data) {
success: function () {
console.log('file_test_001 => pass, call readText success. data.text: ' );
done();
},
......@@ -116,7 +106,7 @@ describe('fileconcurrent', function () {
});
file.readText({
uri: 'internal://app/file_test_001',
success: function (data) {
success: function () {
console.log('file_test_001 => pass, call readText success. data.text: ' );
done();
},
......@@ -127,7 +117,7 @@ describe('fileconcurrent', function () {
});
file.readText({
uri: 'internal://app/file_test_001',
success: function (data) {
success: function () {
console.log('file_test_001 => pass, call readText success. data.text: ' );
done();
},
......@@ -162,7 +152,7 @@ describe('fileconcurrent', function () {
file.copy({
srcUri: 'internal://app/file_test_002',
dstUri: 'internal://app/file_test_002',
success: function (uri) {
success: function () {
console.log('file_test_002 => pass,call copy success. uri:' );
done();
},
......@@ -174,7 +164,7 @@ describe('fileconcurrent', function () {
file.copy({
srcUri: 'internal://app/file_test_002',
dstUri: 'internal://app/file_test_002' + '100',
success: function (uri) {
success: function () {
console.log('file_test_002 => pass,call copy success. uri:' );
done();
},
......@@ -186,7 +176,7 @@ describe('fileconcurrent', function () {
file.copy({
srcUri: 'internal://app/file_test_002',
dstUri: 'internal://app/file_test_002' + '200',
success: function (uri) {
success: function () {
console.log('file_test_002 => pass,call copy success. uri:' );
done();
},
......@@ -221,7 +211,7 @@ describe('fileconcurrent', function () {
file.move({
srcUri: 'internal://app/file_test_003',
dstUri: 'internal://file_test_003',
success: function (uri) {
success: function () {
console.log('file_test_003 => pass,call move success. uri:' );
done();
},
......@@ -255,7 +245,7 @@ describe('fileconcurrent', function () {
for (let i = 0; i < 10; i++) {
file.readArrayBuffer({
uri: 'internal://app/file_test_004',
success: function (data) {
success: function () {
console.log('file_test_004 => pass,call readArrayBuffer success. ');
done();
},
......@@ -266,7 +256,7 @@ describe('fileconcurrent', function () {
});
file.readArrayBuffer({
uri: 'internal://app/file_test_004',
success: function (data) {
success: function () {
console.log('file_test_004 => pass,call readArrayBuffer success. ');
done();
},
......@@ -277,7 +267,7 @@ describe('fileconcurrent', function () {
});
file.readArrayBuffer({
uri: 'internal://app/file_test_004',
success: function (data) {
success: function () {
console.log('file_test_004 => pass,call readArrayBuffer success. ');
done();
},
......@@ -357,7 +347,7 @@ describe('fileconcurrent', function () {
});
file.readText({
uri: 'internal://app/file_test_006',
success: function (data) {
success: function () {
console.log('file_test_006 => pass,call readText success: ');
done();
},
......@@ -391,7 +381,7 @@ describe('fileconcurrent', function () {
});
file.readArrayBuffer({
uri: 'internal://app/file_test_007',
success: function (data) {
success: function () {
console.log('file_test_007 => pass,call readArrayBuffer success: ');
done();
},
......@@ -425,7 +415,7 @@ describe('fileconcurrent', function () {
file.copy({
srcUri: 'internal://app/file_test_008',
dstUri: 'internal://app/file_test_008',
success: function (uri) {
success: function () {
console.log('file_test_008 => pass,call copy success. uri:');
done();
},
......
......@@ -18,14 +18,16 @@ ohos_js_hap_suite("storagefileioerror_js_test") {
":storagefileioerror_js_assets",
":storagefileioerror_js_resources",
]
# shared_libraries = [
# "//third_party/giflib:libgif",
# "//third_party/libpng:libpng",
# ]
# shared_libraries = [
# "//third_party/giflib:libgif",
# "//third_party/libpng:libpng",
# ]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "storagefileioerrorjstest"
# part_name = "prebuilt_hap"
# subsystem_name = "xts"
# part_name = "prebuilt_hap"
# subsystem_name = "xts"
}
ohos_js_assets("storagefileioerror_js_assets") {
source_dir = "./src/main/js/default"
......@@ -33,4 +35,4 @@ ohos_js_assets("storagefileioerror_js_assets") {
ohos_resources("storagefileioerror_js_resources") {
sources = [ "./src/main/resources" ]
hap_profile = "./src/main/config.json"
}
\ No newline at end of file
}
......@@ -12,6 +12,7 @@
* 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 {
......@@ -145,11 +146,11 @@ describe('FileError', function () {
uri: 'internal://app/file_test_error_005',
success: function (data) {
console.log('file_test_error_005 pass, Content:' + data.text);
done();
expect(null).assertFail();
},
fail: function (data, code) {
console.log('file_test_error_005 call readText fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
done();
},
});
});
......@@ -165,11 +166,11 @@ describe('FileError', function () {
uri: 'internal://app/file_test_error_006',
success: function (data) {
console.log('file_test_error_006 pass, Content:' + data.buffer);
done();
expect(null).assertFail();
},
fail: function (data, code) {
console.log('file_test_error_006 call readArrayBuffer fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
done();
},
});
});
......@@ -187,11 +188,11 @@ describe('FileError', function () {
recursive: true,
success: function () {
console.log('file_test_error_007 call rmdir success.');
done();
expect(null).assertFail();
},
fail: function (data, code) {
console.log('file_test_error_007 call rmdir fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
done();
},
});
});
......@@ -242,11 +243,11 @@ describe('FileError', function () {
recursive: true,
success: function () {
console.log('file_test_error_009 call rmdir success.');
done();
expect(null).assertFail();
},
fail: function (data, code) {
console.log('file_test_error_009 call rmdir fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
done();
},
});
});
......
......@@ -12,6 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import fileio from '@system.fileio'
import {
describe,
......@@ -59,10 +60,10 @@ describe('FileIOError', function () {
let dpath = nextFileName('fileio_test_error_001d');
try {
expect(fileio.mkdirSync(dpath) !== null).assertTrue();
expect(null).assertFail();
}
catch (e) {
console.log('fileio_test_error_001 has failed for ' + e);
expect(null).assertFail();
}
});
......@@ -105,7 +106,7 @@ describe('FileIOError', function () {
* @tc.number SUB_STORAGE_FileIo_test_error_0400
* @tc.name FileIo_test_error_004
* @tc.desc Function of API, When the disk space is full,
* verify synchronization and write the buffer data back to the disk for data synchronization
* verify synchronization and write the buffer data back to the disk for data synchronization
*/
it('FileIo_test_error_004', 0, function () {
let fpath = nextFileName('fileio_test_error_004');
......@@ -134,10 +135,10 @@ describe('FileIOError', function () {
let fd = fileio.openSync(fpath);
expect(fd !== null).assertTrue();
expect(fileio.closeSync(fd) !== null).assertTrue();
expect(null).assertFail();
}
catch (e) {
console.log('fileio_test_error_005 has failed for ' + e);
expect(null).assertFail();
}
});
......@@ -156,17 +157,18 @@ describe('FileIOError', function () {
let rlen = fileio.readSync(fd, new ArrayBuffer(209715200));
expect(rlen == 209715200).assertTrue();
expect(fileio.closeSync(fd) !== null).assertTrue();
expect(null).assertFail();
}
catch (e) {
console.log('fileio_test_error_006 has failed for ' + e);
expect(null).assertFail();
}
});
/**
* @tc.number SUB_STORAGE_FileIo_test_error_0700
* @tc.name FileIo_test_error_007
* @tc.desc Function of API, Verify the function of obtaining 200m file stream synchronously when 100m ram is left
* @tc.desc Function of API, Verify the function of obtaining
* 200m file stream synchronously when 100m ram is left
* Create a 200m file (fileio_test_error_005) and grant 777 permissions,
* path:/data/accounts/account_0/appdata/ohos.acts.stroage.fileio/cache/fileio_test_error_005
*/
......@@ -176,10 +178,10 @@ describe('FileIOError', function () {
let ss = fileio.createStreamSync(fpath, 'r+');
expect(ss !== null).assertTrue();
expect(ss.closeSync() !== null).assertTrue();
expect(null).assertFail();
}
catch (e) {
console.log('fileio_test_error_007 has failed for ' + e);
expect(null).assertFail();
}
});
......@@ -198,10 +200,10 @@ describe('FileIOError', function () {
let rlen = ss.readSync(new ArrayBuffer(209715200));
expect(rlen == 209715200).assertTrue();
expect(ss.closeSync() !== null).assertTrue();
expect(null).assertFail();
}
catch (e) {
console.log('fileio_test_error_008 has failed for ' + e);
expect(null).assertFail();
}
});
......@@ -247,7 +249,8 @@ describe('FileIOError', function () {
/**
* @tc.number SUB_STORAGE_FileIo_test_error_1100
* @tc.name FileIo_test_error_011
* @tc.desc Function of API, Pass in a path that exceeds 4096 bytes to copy the file
* @tc.desc Function of API, Pass in a
* path that exceeds 4096 bytes to copy the file
*/
it('FileIo_test_error_011', 0, function () {
let fpath = nextFileName('fileio_test_error_011');
......
......@@ -12,6 +12,7 @@
* 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 {
......@@ -24,6 +25,7 @@ import {
FILE_CONTENT,
prepareFile,
fileName,
nextFileName
}
from './Common'
......@@ -525,4 +527,47 @@ describe('fileVirtualPath', function () {
});
});
/**
* @tc.number SUB_STORAGE_fileioPerformance_prop_copyFile
* @tc.name fileioPerformance_prop_copyFile
* @tc.desc 0.5G Synchronous opening performance test of test files
* The path needs to be manually placed in advance
* data/accounts/account_0/appdata/ohos.acts.distributeddatamgr.distributedfile/cache/p1'的0.5g文件)
*/
it('fileioPerformance_prop_copyFile', 0, function () {
console.log('---fileioPerformance_prop_copyFile 0.5G---start---');
let fpath = nextFileName('p1');
let fpathTarget = nextFileName('p2');
for (let i = 0; i < 1000; i++) {
let start2 = new Date().getTime();
let copyFileSync = fileio.copyFileSync(fpath, fpathTarget);
let end2 = new Date().getTime();
let time2 = end2 - start2
console.log('fileioPerformance_prop_copyFileSync,copyFileSync:' + copyFileSync + ', time2:' + time2 + ',' + i);
fileio.unlinkSync(fpathTarget);
}
fileio.closeSync(fd);
});
/**
* @tc.number SUB_STORAGE_fileioPerformance_prop_openSync
* @tc.name fileioPerformance_prop_openSync
* @tc.desc 0.5G Synchronous opening performance test of test files
* The path needs to be manually placed in advance
* data/accounts/account_0/appdata/ohos.acts.distributeddatamgr.distributedfile/cache/p1'的0.5g文件)
*/
it('fileioPerformance_prop_openSync', 0, function () {
console.log('---fileioPerformance_prop_openSync 0.5G---start---');
let fpath = nextFileName('p1');
let fd
for (let i = 0; i < 1000; i++) {
let start = new Date().getTime();
fd = fileio.openSync(fpath, 0o2002);
let end = new Date().getTime();
let time = end - start
console.log('fileioPerformance_prop_openSync,openSync:' + fd + ', time:' + time + ',' + i);
}
fileio.closeSync(fd);
});
});
......@@ -18,14 +18,16 @@ ohos_js_hap_suite("storagefileio_js_test") {
":storagefileio_js_assets",
":storagefileio_js_resources",
]
# shared_libraries = [
# "//third_party/giflib:libgif",
# "//third_party/libpng:libpng",
# ]
# shared_libraries = [
# "//third_party/giflib:libgif",
# "//third_party/libpng:libpng",
# ]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "Storagefileiojstest"
# part_name = "prebuilt_hap"
# subsystem_name = "xts"
# part_name = "prebuilt_hap"
# subsystem_name = "xts"
}
ohos_js_assets("storagefileio_js_assets") {
source_dir = "./src/main/js/default"
......@@ -33,4 +35,4 @@ ohos_js_assets("storagefileio_js_assets") {
ohos_resources("storagefileio_js_resources") {
sources = [ "./src/main/resources" ]
hap_profile = "./src/main/config.json"
}
\ 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');
......
......@@ -12,6 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import fileio from '@system.fileio';
import bundle_mgr from '@ohos.bundle_mgr'
import file from '@system.file';
......@@ -606,7 +607,7 @@ describe('fileTest', function () {
done();
},
fail: function (data, code) {
console.log('File_writeText_010 fail');
console.log('File_writeText_010 fail code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
});
......@@ -633,7 +634,7 @@ describe('fileTest', function () {
uri: 'internal://app/../files/File_writeText_011',
text: 'sawyerwang',
success: function () {
console.log('File_writeText_011 mkdif success');
console.log('File_writeText_011 mkdir success ');
done();
},
fail: function (data, code) {
......@@ -933,7 +934,7 @@ describe('fileTest', function () {
});
file.readArrayBuffer({
uri: 'internal://cache/File_writeArrayBuffer_006',
success: function (data) {
success: function () {
console.log('File_writeArrayBuffer_006 pass');
done();
},
......
......@@ -14,6 +14,7 @@
*/
import fileio from '@ohos.fileio';
import file from '@system.file';
import bundle_mgr from '@ohos.bundle_mgr'
import {
describe,
......@@ -1356,7 +1357,7 @@ describe('fileIOTest', function () {
expect(null).assertFail();
}
catch (e) {
console.log('fileio_test_unlink_sync_003 has failed for ' + e);
console.log('fileio_test_unlink_sync_002 has failed for ' + e);
}
});
......@@ -1609,6 +1610,7 @@ describe('fileIOTest', function () {
success: function (data) {
console.log('call readText success: ' + data.text);
expect(text == data.text).assertTrue();
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
done();
},
fail: function (data, code) {
......@@ -1616,8 +1618,7 @@ describe('fileIOTest', function () {
expect(null).assertFail();
},
});
expect(fileio.unlinkSync(fpath) !== null).assertTrue();
}
}
catch (e) {
console.log('fileio_test_read_sync_000 has failed for ' + e);
expect(null).assertFail();
......
......@@ -18,14 +18,16 @@ ohos_js_hap_suite("storagefileioperformance_js_test") {
":storagefileioperformance_js_assets",
":storagefileioperformance_js_resources",
]
# shared_libraries = [
# "//third_party/giflib:libgif",
# "//third_party/libpng:libpng",
# ]
# shared_libraries = [
# "//third_party/giflib:libgif",
# "//third_party/libpng:libpng",
# ]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "storagefileioperformancejstest"
# part_name = "prebuilt_hap"
# subsystem_name = "xts"
# part_name = "prebuilt_hap"
# subsystem_name = "xts"
}
ohos_js_assets("storagefileioperformance_js_assets") {
source_dir = "./src/main/js/default"
......@@ -33,4 +35,4 @@ ohos_js_assets("storagefileioperformance_js_assets") {
ohos_resources("storagefileioperformance_js_resources") {
sources = [ "./src/main/resources" ]
hap_profile = "./src/main/config.json"
}
\ 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');
......
......@@ -12,6 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import fileio from '@system.fileio'
import {
describe,
......
......@@ -12,6 +12,7 @@
* 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 {
......
......@@ -18,14 +18,16 @@ ohos_js_hap_suite("storagefileioreliability_js_test") {
":storagefileioreliability_js_assets",
":storagefileioreliability_js_resources",
]
# shared_libraries = [
# "//third_party/giflib:libgif",
# "//third_party/libpng:libpng",
# ]
# shared_libraries = [
# "//third_party/giflib:libgif",
# "//third_party/libpng:libpng",
# ]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "storagefileioreliabilityjstest"
# part_name = "prebuilt_hap"
# subsystem_name = "xts"
# part_name = "prebuilt_hap"
# subsystem_name = "xts"
}
ohos_js_assets("storagefileioreliability_js_assets") {
source_dir = "./src/main/js/default"
......@@ -33,4 +35,4 @@ ohos_js_assets("storagefileioreliability_js_assets") {
ohos_resources("storagefileioreliability_js_resources") {
sources = [ "./src/main/resources" ]
hap_profile = "./src/main/config.json"
}
\ 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');
......
......@@ -12,6 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import fileio from '@system.fileio'
import {
describe,
......
......@@ -18,14 +18,16 @@ ohos_js_hap_suite("storagefileiostability_js_test") {
":storagefileiostability_js_assets",
":storagefileiostability_js_resources",
]
# shared_libraries = [
# "//third_party/giflib:libgif",
# "//third_party/libpng:libpng",
# ]
# shared_libraries = [
# "//third_party/giflib:libgif",
# "//third_party/libpng:libpng",
# ]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "storagefileiostabilityjstest"
# part_name = "prebuilt_hap"
# subsystem_name = "xts"
# part_name = "prebuilt_hap"
# subsystem_name = "xts"
}
ohos_js_assets("storagefileiostability_js_assets") {
source_dir = "./src/main/js/default"
......@@ -33,4 +35,4 @@ ohos_js_assets("storagefileiostability_js_assets") {
ohos_resources("storagefileiostability_js_resources") {
sources = [ "./src/main/resources" ]
hap_profile = "./src/main/config.json"
}
\ 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');
......
......@@ -12,6 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import fileio from '@system.fileio'
import {
describe,
......@@ -55,8 +56,8 @@ describe('fileIOStability', function () {
});
/**
* @tc.number SUB_STORAGE_fileIOStability_dir
* @tc.name fileIOStability_dir
* @tc.number SUB_STORAGE_fileIOStability_dirent
* @tc.name fileIOStability_dirent
* @tc.desc Function of API, 7*24
*/
it('fileIOStability_dirent', 0, function () {
......
......@@ -18,14 +18,16 @@ ohos_js_hap_suite("storagefilestability_js_test") {
":storagefilestability_js_assets",
":storagefilestability_js_resources",
]
# shared_libraries = [
# "//third_party/giflib:libgif",
# "//third_party/libpng:libpng",
# ]
# shared_libraries = [
# "//third_party/giflib:libgif",
# "//third_party/libpng:libpng",
# ]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "storagefilestabilityjstest"
# part_name = "prebuilt_hap"
# subsystem_name = "xts"
# part_name = "prebuilt_hap"
# subsystem_name = "xts"
}
ohos_js_assets("storagefilestability_js_assets") {
source_dir = "./src/main/js/default"
......@@ -33,4 +35,4 @@ ohos_js_assets("storagefilestability_js_assets") {
ohos_resources("storagefilestability_js_resources") {
sources = [ "./src/main/resources" ]
hap_profile = "./src/main/config.json"
}
\ 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');
......
......@@ -12,6 +12,7 @@
* 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 {
......
......@@ -12,6 +12,7 @@
* 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 {
......@@ -51,6 +52,7 @@ describe('FileReliability', function () {
});
setTimeout(function () {
resolve('mkdir success!');
done()
}, 250);
});
promiseMkdir.then(function () {
......@@ -75,6 +77,7 @@ describe('FileReliability', function () {
});
promiseWriteText.then(function () {
console.log('writeText success');
done();
});
let promiseReadText = new Promise(function (resolve, reject) {
file.readText({
......@@ -94,6 +97,7 @@ describe('FileReliability', function () {
});
promiseReadText.then(function () {
console.log('readText success');
done();
});
let promiseAccess = new Promise(function (resolve, reject) {
file.access({
......@@ -113,6 +117,7 @@ describe('FileReliability', function () {
});
promiseAccess.then(function () {
console.log('access success');
done();
});
let promiseGet = new Promise(function (resolve, reject) {
file.get({
......@@ -132,6 +137,7 @@ describe('FileReliability', function () {
});
promiseGet.then(function () {
console.log('get success');
done();
});
let promiseList = new Promise(function (resolve, reject) {
file.list({
......@@ -151,6 +157,7 @@ describe('FileReliability', function () {
});
promiseList.then(function () {
console.log('list success');
done();
});
let promiseCopy = new Promise(function (resolve, reject) {
file.copy({
......@@ -171,6 +178,7 @@ describe('FileReliability', function () {
});
promiseCopy.then(function () {
console.log('copy success');
done();
});
let promiseMove = new Promise(function (resolve, reject) {
file.move({
......@@ -191,6 +199,7 @@ describe('FileReliability', function () {
});
promiseMove.then(function () {
console.log('move success');
done();
});
file.delete({
uri: 'internal://app/fileStability01' + i,
......@@ -234,6 +243,7 @@ describe('FileReliability', function () {
});
promiseWriteArrayBuffer.then(function () {
console.log('writeArrayBuffer success');
done();
});
let promiseReadArrayBuffer = new Promise(function (resolve, reject) {
file.readArrayBuffer({
......@@ -252,6 +262,7 @@ describe('FileReliability', function () {
}, 250);
});
promiseReadArrayBuffer.then(function () {
done();
console.log('readArrayBuffer success');
});
file.delete({
......@@ -284,6 +295,7 @@ describe('FileReliability', function () {
});
promiseRmdir.then(function () {
console.log('rmdir success');
done();
});
}
......
# Copyright (C) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("storagefmspublic_js_test") {
hap_profile = "./src/main/config.json"
deps = [
":storagefmspublic_js_assets",
":storagefmspublic_js_resources",
]
# shared_libraries = [
# "//third_party/giflib:libgif",
# "//third_party/libpng:libpng",
# ]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "storagefmspublicjstest"
# part_name = "prebuilt_hap"
# subsystem_name = "xts"
}
ohos_js_assets("storagefmspublic_js_assets") {
source_dir = "./src/main/js/default"
}
ohos_resources("storagefmspublic_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": [
"storagefmspublicjstest.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 fileio from '@ohos.fileio';
import filepicker from '@ohos.filepicker'
import {
describe,
beforeAll,
beforeEach,
afterEach,
afterAll,
it,
expect
}
from 'deccjsunit/index'
import {
FILE_CONTENT,
prepareFile,
fileName,
filePickerName,
randomString,
cacheFileName,
prepareEmptyFile,
nextFileName
}
from './Common'
describe('FmsTest', function () {
let deviceID = 0;
/**
* @tc.number SUB_STORAGE_FMS_Function_0000
* @tc.name FMS_Function_0000
* @tc.desc Function of API,Get current device information
*/
it('FMS_Function_0000', 0, function (done) {
let progetDeviceInfo = new Promise(function (resolve, reject) {
filepicker.getDeviceInfo({
success: function (data) {
console.log('FMS_Function_0000 success.' + JSON.stringify(data));
if (data.deviceList.length == 0) {
console.log('FMS_Function_0000 fail');
expect(null).assertFail();
} else {
deviceID = data.deviceList[0].deviceID;
console.log("---FMS_Function_0000------" + deviceID);
done();
}
},
fail: function (data, code) {
console.log('FMS_Function_0000 fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
})
})
progetDeviceInfo.then(function () {
console.log('FMS_Function_0000 success');
});
})
/**
* @tc.number SUB_STORAGE_FMS_Function_0100
* @tc.name FMS_Function_0100
* @tc.desc Function of API, Creates the specified directory recursively
*/
it('FMS_Function_0100', 0, function (done) {
let proMkdir = new Promise(function (resolve, reject) {
filepicker.mkdir({
uri: 'dataability:///public.storage.ability/' + deviceID + '/document/fms_test/leaf',
success: function () {
console.log('FMS_Function_0100 mkdir success.');
done()
},
fail: function (data, code) {
console.log('FMS_Function_0100 fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
})
})
proMkdir.catch(function () {
console.log('FMS_Function_0100 success');
});
})
/**
* @tc.number SUB_STORAGE_FMS_Function_0200
* @tc.name FMS_Function_0200
* @tc.desc Function of API, Creates the specified directory recursively
*/
it('FMS_Function_0200', 0, function (done) {
let proMkdir = new Promise(function (resolve, reject) {
filepicker.mkdir({
uri: 'dataability:///public.storage.ability/' + deviceID + '/document/你好/leaf',
success: function () {
console.log('FMS_Function_0200 mkdir success.');
done()
},
fail: function (data, code) {
console.log('FMS_Function_0200 fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
})
})
proMkdir.then(function () {
console.log('FMS_Function_0200 success');
});
})
/**
* @tc.number SUB_STORAGE_FMS_Function_0300
* @tc.name FMS_Function_0300
* @tc.desc Function of API, Creates the specified directory recursively
*/
it('FMS_Function_0300', 0, function (done) {
let proMkdir = new Promise(function (resolve, reject) {
filepicker.mkdir({
uri: 'dataability:///public.storage.ability/' + deviceID + '/document/a/b/c/leaf',
success: function () {
console.log('FMS_Function_0300 mkdir success.');
done()
},
fail: function (data, code) {
console.log('FMS_Function_0300 fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
})
})
proMkdir.then(function () {
console.log('FMS_Function_0300 success');
});
})
/**
* @tc.number SUB_STORAGE_FMS_Function_0400
* @tc.name FMS_Function_0400
* @tc.desc Function of API,
*/
it('FMS_Function_0400', 0, function (done) {
let proMkdir = new Promise(function (resolve, reject) {
filepicker.mkdir({
uri: 'dataability:///public.storage.ability/' + deviceID + '/root/files',
success: function () {
console.log('FMS_Function_0400 success.');
done()
},
fail: function (data, code) {
console.log('call fail callback fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
})
})
proMkdir.then(function () {
console.log('FMS_Function_0400 success');
});
})
/**
* @tc.number SUB_STORAGE_FMS_Function_0500
* @tc.name FMS_Function_0500
* @tc.desc Function of API, save file.The test file is exist.
*/
it('FMS_Function_0500', 0, function (done) {
let fpath = filePickerName("a.txt", deviceID);
expect(prepareFile(fpath, FILE_CONTENT) !== null).assertTrue();
let proMkdir = new Promise(function (resolve, reject) {
filepicker.saveFile({
srcUri: ['dataability:///public.storage.ability/' + deviceID + '/document/fms_test/a.txt/leaf'],
dstUri: 'dataability:///public.storage.ability/' + deviceID + '/root',
success: function (data) {
console.log('FMS_Function_0500 success.' + data.saveFileList[0].status);
done()
},
fail: function (data, code) {
console.log('FMS_Function_0500 fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
});
})
proMkdir.then(function () {
console.log('FMS_Function_0500 success');
});
})
/**
* @tc.number SUB_STORAGE_FMS_Function_0600
* @tc.name FMS_Function_0600
* @tc.desc Function of API, save file.The test file is exist.
*/
it('FMS_Function_0600', 0, async function (done) {
let fpath = filePickerName("b.txt", deviceID);
expect(prepareFile(fpath, FILE_CONTENT) !== null).assertTrue();
let proMkdir = new Promise(function (resolve, reject) {
filepicker.saveFile({
srcUri: ['dataability:///public.storage.ability/' + deviceID + '/document/fms_test/a.txt/leaf',
'dataability:///public.storage.ability/' + deviceID + '/document/fms_test/b.txt/leaf'],
dstUri: 'dataability:///public.storage.ability/' + deviceID + '/root',
success: function (data) {
console.log('FMS_Function_0600 success.' + data.saveFileList[0].status);
done()
},
fail: function (data, code) {
console.log('FMS_Function_0600 fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
});
})
proMkdir.then(function () {
console.log('FMS_Function_0600 success');
});
})
/**
* @tc.number SUB_STORAGE_FMS_Function_0700
* @tc.name FMS_Function_0700
* @tc.desc Function of API, save file.The test file is exist.
*/
it('FMS_Function_0700', 0, async function (done) {
let proMkdir = new Promise(function (resolve, reject) {
filepicker.saveFile({
srcUri: ['dataability:///public.storage.ability/' + deviceID + '/document/fms_test/a.txt/leaf'],
dstUri: 'dataability:///public.storage.ability/' + deviceID + '/root/files',
success: function (data) {
console.log('FMS_Function_0700 success.' + data.saveFileList[0].status);
done()
},
fail: function (data, code) {
console.log('FMS_Function_0700 fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
});
})
proMkdir.then(function () {
console.log('FMS_Function_0700 success');
});
})
/**
* @tc.number SUB_STORAGE_FMS_Function_0800
* @tc.name FMS_Function_0800
* @tc.desc Function of API, save file.The test file is exist.
*/
it('FMS_Function_0800', 0, async function (done) {
let proMkdir = new Promise(function (resolve, reject) {
filepicker.saveFile({
srcUri: ['dataability:///public.storage.ability/' + deviceID + '/document/fms_test/a.txt/leaf',
'dataability:///public.storage.ability/' + deviceID + '/document/fms_test/b.txt/leaf'],
dstUri: 'dataability:///public.storage.ability/' + deviceID + '/root/files',
success: function (data) {
console.log('FMS_Function_0800 success.' + data.saveFileList[0].status);
done()
},
fail: function (data, code) {
console.log('FMS_Function_0800 fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
});
})
proMkdir.then(function () {
console.log('FMS_Function_0800 success');
});
})
/**
* @tc.number SUB_STORAGE_FMS_Function_0900
* @tc.name FMS_Function_0900
* @tc.desc Function of API, search file.The test file is exist.
*/
it('FMS_Function_0900', 0, async function (done) {
let proMkdir = new Promise(function (resolve, reject) {
filepicker.searchFile({
uri: 'dataability:///public.storage.ability/' + deviceID + '/document/fms_test/leaf',
name: 'a.txt',
success: function (data) {
console.log('FMS_Function_0900 success.' + data.fileList[0].uri);
done()
},
fail: function (data, code) {
console.log('FMS_Function_0900 fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
});
})
proMkdir.then(function () {
console.log('FMS_Function_0900 success');
});
})
/**
* @tc.number SUB_STORAGE_FMS_Function_1000
* @tc.name FMS_Function_1000
* @tc.desc Function of API, search file.The test file is exist.
*/
it('FMS_Function_1000', 0, async function (done) {
let proMkdir = new Promise(function (resolve, reject) {
filepicker.searchFile({
uri: 'dataability:///public.storage.ability/' + deviceID + '/document/fms_test/leaf',
name: 'b.txt',
success: function (data) {
console.log('FMS_Function_1000 success.' + data.fileList[0].uri);
done()
},
fail: function (data, code) {
console.log('FMS_Function_1000 fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
});
})
proMkdir.then(function () {
console.log('FMS_Function_1000 success');
});
})
/**
* @tc.number SUB_STORAGE_FMS_Function_1100
* @tc.name FMS_Function_1100
* @tc.desc Function of API, search file.The test file is exist.
*/
it('FMS_Function_1100', 0, async function (done) {
let proMkdir = new Promise(function (resolve, reject) {
filepicker.searchFile({
uri: 'dataability:///public.storage.ability/' + deviceID + '/root/files',
name: 'a.txt',
success: function (data) {
console.log('FMS_Function_1100 success.' + data.fileList[0].uri);
done()
},
fail: function (data, code) {
console.log('FMS_Function_1100 fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
});
})
proMkdir.then(function () {
console.log('FMS_Function_1100 success');
});
})
/**
* @tc.number SUB_STORAGE_FMS_Function_1200
* @tc.name FMS_Function_1200
* @tc.desc Function of API, Get all file information in the specified directory
*/
it('FMS_Function_1200', 0, async function (done) {
let proMkdir = new Promise(function (resolve, reject) {
filepicker.list({
uri: 'dataability:///public.storage.ability/' + deviceID + '/document/fms_test/leaf',
success: function (data) {
console.log('FMS_Function_1200 success.' + data.fileList[0].uri);
done()
},
fail: function (data, code) {
console.log('FMS_Function_1200 fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
});
})
proMkdir.then(function () {
console.log('FMS_Function_1200 success');
});
})
/**
* @tc.number SUB_STORAGE_FMS_Function_1300
* @tc.name FMS_Function_1300
* @tc.desc Function of API, Get all file information in the specified directory
*/
it('FMS_Function_1300', 0, async function (done) {
let proMkdir = new Promise(function (resolve, reject) {
filepicker.list({
uri: 'dataability:///public.storage.ability/' + deviceID + '/root',
success: function (data) {
console.log('FMS_Function_1300 success.' + data.fileList[0].uri);
done()
},
fail: function (data, code) {
console.log('FMS_Function_1300 fail, code: ' + code + ', data: ' + data);
expect(null).assertFail();
},
});
})
proMkdir.then(function () {
console.log('FMS_Function_1300 success');
});
})
})
/*
* 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 filepicker from '@ohos.filepicker';
import {
describe,
it,
expect
}
from 'deccjsunit/index'
import {
prepareFile,
fmsPublic,
}
from './Common'
describe('FilepickerTest', function () {
let deviceID = 0;
/**
* @tc.number SUB_STORAGE_File_Test_Error_0000
* @tc.name File_Test_Error_0000
* @tc.desc Error of API, Move files when disk space is full.
*/
it('File_Test_Error_0000', 0, function (done) {
try {
filepicker.getDeviceInfo({
success: function (data) {
console.log('File_Test_Error_0000_start call mkdir success.' + data.deviceList[0].deviceID);
deviceID = data.deviceList[2].deviceID;
if(deviceID == 0){
console.log('SD card not mounted')
done()
}else{
expect(null).assertFail()
}
},
fail: function (data, code) {
console.error('File_Test_Error_0000_start call fail callback fail, code: ' + code + ', data: ' + data);
},
});
} catch (e) {
console.log('File_Test_Error_0000 has failed for ' + e);
expect(null).assertFail();
}
});
/**
* @tc.number SUB_STORAGE_File_Test_Error_0100
* @tc.name File_Test_Error_0100
* @tc.desc Error of API, Move files when disk space is full.
* Create the file in advance and give 777 permission,
* path:/dataability:///public.storage.ability/deviceID/udocument/files/leaf
*/
it('File_Test_Error_0100', 0, function (done) {
try {
filepicker.mkdir({
uri: 'dataability:///public.storage.ability/' + deviceID + '/udocument/files/leaf',
success: function () {
console.log('File_Test_Error_0100 call mkdir success.');
expect(null).assertFail();
},
fail: function (data, code) {
console.error('File_Test_Error_0100 call fail callback fail, code: ' + code + ', data: ' + data);
expect(code == 202).assertTrue();
done()
},
});
} catch (e) {
console.log('File_Test_Error_0100 has failed for ' + e);
}
});
/**
* @tc.number SUB_STORAGE_File_Test_Error_0200
* @tc.name File_Test_Error_0200
* @tc.desc Error of API, Move files when disk space is full.
* Create the file in advance and give 777 permission,
* path:/data123ability:///public.storage.ability/deviceID/document/files.txt/leaf
*/
it('File_Test_Error_0200', 0, function (done) {
try {
filepicker.mkdir({
uri: 'data123ability:///public.storage.ability/' + deviceID + '/document/files/leaf',
success: function () {
console.log('File_Test_Error_0200 call mkdir success.');
expect(null).assertFail();
},
fail: function (data, code) {
console.error('File_Test_Error_0200 call fail callback fail, code: ' + code + ', data: ' + data);
expect(code == 302).assertTrue()
done()
},
});
} catch (e) {
console.log('File_Test_Error_0200 has failed for ' + e);
}
});
/**
* @tc.number SUB_STORAGE_File_Test_Error_0300
* @tc.name File_Test_Error_0300
* @tc.desc Error of API, Move files when disk space is full.
* Create the file in advance and give 777 permission,
* path:/dataability:///public.storage.ability/deviceID/document/files/lea
*/
it('File_Test_Error_0300', 0, function (done) {
try {
filepicker.mkdir({
uri: 'dataability:///public.storage.ability/' + deviceID + '/document/files/lea',
success: function () {
console.log('File_Test_Error_0300 call mkdir success.');
expect(null).assertFail();
},
fail: function (data, code) {
console.error('File_Test_Error_0300 call fail callback fail, code: ' + code + ', data: ' + data);
expect(code == 202).assertTrue()
done()
},
});
} catch (e) {
console.log('File_Test_Error_0300 has failed for ' + e);
}
});
/**
* @tc.number SUB_STORAGE_File_Test_Error_0400
* @tc.name File_Test_Error_0400
* @tc.desc Error of API, Move files when disk space is full.
* Create the file in advance and give 777 permission,
* path:/dataability:///public.storage.ability/‘’/document/files/leaf
*/
it('File_Test_Error_0400', 0, function (done) {
try {
filepicker.mkdir({
uri: '/data/ss/files'
});
let fpath = fmsPublic('File_Test_Error_0400');
prepareFile(fpath, 'hello');
filepicker.saveFile({
srcUri: ['dataability:///public.storage.ability/data/ss/files/File_Test_Error_0400'],
dstUri: 'dataability:///public.storage.ability/‘’/document/files/leaf',
success: function (data) {
console.log('File_Test_Error_0400 call mkdir success.' + data.saveFileList[0].status);
expect(null).assertFail();
},
fail: function (data, code) {
console.error('File_Test_Error_0400 call fail callback fail, code: ' + code + ', data: ' + data);
expect(code == 300).assertTrue()
done()
},
});
} catch (e) {
console.log('File_Test_Error_0400 has failed for ' + e);
}
});
/**
* @tc.number SUB_STORAGE_File_Test_Error_0500
* @tc.name File_Test_Error_0500
* @tc.desc Error of API, Move files when disk space is full.
* Create the file in advance and give 777 permission,
* path:/dataability:///public.storage.ability/deviceID/document/files/leaf
*/
it('File_Test_Error_0500', 0, function (done) {
try {
let fpath = fmsPublic('File_Test_Error_0500');
prepareFile(fpath, 'hello');
filepicker.saveFile({
srcUri: ['dataability:///public.storage.ability/data/ss/file/File_Test_Error_0500'],
dstUri: 'dataability:///public.storage.ability/' + deviceID + '/document/files/leaf',
success: function (data) {
console.log('File_Test_Error_0500 call mkdir success.' + data.saveFileList[0].status);
expect(null).assertFail();
},
fail: function (data, code) {
console.error('File_Test_Error_0500 call fail callback fail, code: ' + code + ', data: ' + data);
expect(code == 300).assertTrue()
done()
},
});
} catch (e) {
console.log('File_Test_Error_0500 has failed for ' + e);
}
});
/**
* @tc.number SUB_STORAGE_File_Test_Error_0600
* @tc.name File_Test_Error_0600
* @tc.desc Error of API, Move files when disk space is full.
* Create the file in advance and give 777 permission,
* path:/dataability:///public.storage.ability/deviceID/document/files/leaf
*/
it('File_Test_Error_0600', 0, function (done) {
try {
filepicker.saveFile({
srcUri: ['dataability:///public.storage.ability/data/ss/file/A.txt'],
dstUri: 'dataability:///public.storage.ability/' + deviceID + '/document/files/leaf',
success: function (data) {
console.log('File_Test_Error_0600 call mkdir success.' + data.saveFileList[0].status);
expect(null).assertFail();
},
fail: function (data, code) {
console.error('File_Test_Error_0600 call fail callback fail, code: ' + code + ', data: ' + data);
expect(code == 300).assertTrue()
done()
},
});
} catch (e) {
console.log('File_Test_Error_0600 has failed for ' + e);
}
});
/**
* @tc.number SUB_STORAGE_File_Test_Error_0700
* @tc.name File_Test_Error_0700
* @tc.desc Error of API, Move files when disk space is full.
* Create the file in advance and give 777 permission,
* path:/dataability:///public.storage.ability/deviceID/document/files/lea
*/
it('File_Test_Error_0700', 0, function (done) {
try {
filepicker.saveFile({
srcUri: ['dataability:///public.storage.ability/data/ss/files/a.txt'],
dstUri: 'dataability:///public.storage.ability/' + deviceID + '/document/files/lea',
success: function (data) {
console.log('File_Test_Error_0700 call mkdir success.' + data.saveFileList[0].status);
expect(null).assertFail();
},
fail: function (data, code) {
console.error('File_Test_Error_0700 call fail callback fail, code: ' + code + ', data: ' + data);
expect(code == 202).assertTrue()
done()
},
});
} catch (e) {
console.log('File_Test_Error_0700 has failed for ' + e);
}
});
/**
* @tc.number SUB_STORAGE_File_Test_Error_0800
* @tc.name File_Test_Error_0800
* @tc.desc Error of API, Move files when disk space is full.
* Create the file in advance and give 777 permission,
* path:/dataability:///public.storage.ability/deviceID/document/bb/aa/files/leaf
*/
it('File_Test_Error_0800', 0, function (done) {
try {
filepicker.saveFile({
srcUri: ['dataability:///public.storage.ability/data/ss/files/a.txt'],
dstUri: 'dataability:///public.storage.ability/' + deviceID + '/document/bb/aa/files/leaf',
success: function (data) {
console.log('File_Test_Error_0800 call mkdir success.' + data.saveFileList[0].status);
expect(null).assertFail();
},
fail: function (data, code) {
console.error('File_Test_Error_0800 call fail callback fail, code: ' + code + ', data: ' + data);
expect(code == 300).assertTrue()
done()
},
});
} catch (e) {
console.log('File_Test_Error_0800 has failed for ' + e);
}
});
/**
* @tc.number SUB_STORAGE_File_Test_Error_0900
* @tc.name File_Test_Error_0900
* @tc.desc Error of API, Move files when disk space is full.
* Create the file in advance and give 777 permission,
* path:/data123ability:///public.storage.ability/' + deviceID + '/document/files/leaf
*/
it('File_Test_Error_0900', 0, function (done) {
try {
filepicker.saveFile({
srcUri: ['dataability:///public.storage.ability/data/ss/files/a.txt'],
dstUri: 'data123ability:///public.storage.ability/' + deviceID + '/document/files/leaf',
success: function (data) {
console.log('File_Test_Error_0900 call mkdir success.' + data.saveFileList[0].status);
expect(null).assertFail();
},
fail: function (data, code) {
console.error('File_Test_Error_0900 call fail callback fail, code: ' + code + ', data: ' + data);
expect(code == 302).assertTrue()
done()
},
});
} catch (e) {
console.log('File_Test_Error_0900 has failed for ' + e);
}
});
/**
* @tc.number SUB_STORAGE_File_Test_Error_1000
* @tc.name File_Test_Error_1000
* @tc.desc Error of API, Move files when disk space is full.
* Create the file in advance and give 777 permission,
* path:/dataability:///public.storage.ability/deviceID/document/files/leaf
*/
it('File_Test_Error_1000', 0, function (done) {
try {
filepicker.saveFile({
srcUri: ['dataability:///public.storage.ability/data/ss/files/a.txt'],
srcUri1: ['dataability:///public.storage.ability/data/ss/files/a.txt'],
dstUri: 'dataability:///public.storage.ability/' + deviceID + '/document/files/leaf',
success: function (data) {
console.log('File_Test_Error_1000 call mkdir success.' + data.saveFileList[0].status);
expect(null).assertFail();
},
fail: function (data, code) {
console.error('File_Test_Error_1000 call fail callback fail, code: ' + code + ', data: ' + data);
expect(code == 300).assertTrue()
done()
},
});
} catch (e) {
console.log('File_Test_Error_1000 has failed for ' + e);
}
});
/**
* @tc.number SUB_STORAGE_File_Test_Error_1100
* @tc.name File_Test_Error_1100
* @tc.desc Error of API, Move files when disk space is full.
* Create the file in advance and give 777 permission,
* path:/dataability:///public.storage.ability/deviceID/document/files/leaf
*/
it('File_Test_Error_1100', 0, function (done) {
try {
filepicker.searchFile({
uri: 'dataability:///public.storage.ability/' + deviceID + '/document/files/leaf',
name: 'test',
success: function (data) {
console.log('File_Test_Error_1100 call mkdir success.' + data.fileList[0].uri);
expect(null).assertFail();
},
fail: function (data, code) {
console.error('File_Test_Error_1100 call fail callback fail, code: ' + code + ', data: ' + data);
expect(code == 300).assertTrue()
done()
},
});
} catch (e) {
console.log('File_Test_Error_1100 has failed for ' + e);
}
});
/**
* @tc.number SUB_STORAGE_File_Test_Error_1200
* @tc.name File_Test_Error_1200
* @tc.desc Error of API, Move files when disk space is full.
* Create the file in advance and give 777 permission,
* path:/dataability:///public.storage.ability/deviceID/document/a/b/files/leaf
*/
it('File_Test_Error_1200', 0, function (done) {
try {
filepicker.searchFile({
uri: 'dataability:///public.storage.ability/' + deviceID + '/document/a/b/files/leaf',
name: 'test',
success: function (data) {
console.log('File_Test_Error_1200 call mkdir success.' + data.fileList[0].uri);
expect(null).assertFail();
},
fail: function (data, code) {
console.error('File_Test_Error_1200 call fail callback fail, code: ' + code + ', data: ' + data);
expect(code == 300).assertTrue()
done()
},
});
} catch (e) {
console.log('File_Test_Error_1200 has failed for ' + e);
}
});
/**
* @tc.number SUB_STORAGE_File_Test_Error_1300
* @tc.name File_Test_Error_1300
* @tc.desc Error of API, Move files when disk space is full.
* Create the file in advance and give 777 permission,
* path:''
*/
it('File_Test_Error_1300', 0, function (done) {
try {
filepicker.searchFile({
uri: '',
name: 'a',
success: function (data) {
console.log('File_Test_Error_1300 call mkdir success.' + data.fileList[0].uri);
expect(null).assertFail();
},
fail: function (data, code) {
console.error('File_Test_Error_1300 call fail callback fail, code: ' + code + ', data: ' + data);
expect(code == 302).assertTrue()
done()
},
});
} catch (e) {
console.log('File_Test_Error_1300 has failed for ' + e);
}
});
/**
* @tc.number SUB_STORAGE_File_Test_Error_1400
* @tc.name File_Test_Error_1400
* @tc.desc Error of API, Move files when disk space is full.
* Create the file in advance and give 777 permission,
* path:'dataability:///public.storage.ability/device_id/udocument/files/leaf'
*/
it('File_Test_Error_1400', 0, function (done) {
try {
filepicker.list({
uri: 'dataability:///public.storage.ability/device_id/udocument/files/leaf',
success: function (data) {
console.log('File_Test_Error_1400 call mkdir success.' + data.fileList[0].uri);
expect(null).assertFail();
},
fail: function (data, code) {
console.error('File_Test_Error_1400 call fail callback fail, code: ' + code + ', data: ' + data);
expect(code == 202).assertTrue()
done()
},
});
} catch (e) {
console.log('File_Test_Error_1400 has failed for ' + e);
}
});
/**
* @tc.number SUB_STORAGE_File_Test_Error_1400
* @tc.name File_Test_Error_1400
* @tc.desc Error of API, Move files when disk space is full.
* Create the file in advance and give 777 permission,
* path:''
*/
it('File_Test_Error_1500', 0, function (done) {
try {
filepicker.list({
uri: '',
success: function (data) {
console.log('File_Test_Error_1500 call mkdir success.' + data.fileList[0].uri);
expect(null).assertFail();
},
fail: function (data, code) {
console.error('File_Test_Error_1500 call fail callback fail, code: ' + code + ', data: ' + data);
expect(code == 302).assertTrue()
done()
},
});
} catch (e) {
console.log('File_Test_Error_1500 has failed for ' + e);
}
});
/**
* @tc.number SUB_STORAGE_File_Test_Error_1500
* @tc.name File_Test_Error_1500
* @tc.desc Error of API, Move files when disk space is full.
* Create the file in advance and give 777 permission,
* path:/dataability:///public.storage.ability/deviceID/document/file/leaf
*/
it('File_Test_Error_1600', 0, function (done) {
try {
filepicker.list({
uri: 'dataability:///public.storage.ability/' + deviceID + '/document/file/leaf',
success: function (data) {
console.log('File_Test_Error_1600 call mkdir success.' + data.fileList[0].uri);
expect(null).assertFail();
},
fail: function (data, code) {
console.error('File_Test_Error_1600 call fail callback fail, code: ' + code + ', data: ' + data);
expect(code == 300).assertTrue()
done()
},
});
} catch (e) {
console.log('File_Test_Error_1600 has failed for ' + e);
}
});
/**
* @tc.number SUB_STORAGE_File_Test_Error_1700
* @tc.name File_Test_Error_1700
* @tc.desc Error of API, Move files when disk space is full.
* Create the file in advance and give 777 permission,
* path:/data123ability:///public.storage.ability/deviceID/document/file/leaf
*/
it('File_Test_Error_1700', 0, function (done) {
try {
filepicker.list({
uri: 'data123ability:///public.storage.ability/' + deviceID + '/document/file/leaf',
success: function (data) {
console.log('File_Test_Error_1700 call mkdir success.' + data.fileList[0].uri);
expect(null).assertFail();
},
fail: function (data, code) {
console.error('File_Test_Error_1700 call fail callback fail, code: ' + code + ', data: ' + data);
expect(code == 302).assertTrue()
done()
},
});
} catch (e) {
console.log('File_Test_Error_1700 has failed for ' + e);
}
});
});
/*
* 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('./FmsPublic.test.js')
require('./FmsPublicError.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("storagefmsshare_js_test") {
hap_profile = "./src/main/config.json"
deps = [
":storagefmsshare_js_assets",
":storagefmsshare_js_resources",
]
# shared_libraries = [
# "//third_party/giflib:libgif",
# "//third_party/libpng:libpng",
# ]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "storagefmssharejstest"
# part_name = "prebuilt_hap"
# subsystem_name = "xts"
}
ohos_js_assets("storagefmsshare_js_assets") {
source_dir = "./src/main/js/default"
}
ohos_resources("storagefmsshare_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.acys.test",
"shell-timeout": "60000"
},
"kits": [
{
"test-file-name": [
"storagefmssharejstest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
\ No newline at end of file
{
"app": {
"bundleName": "ohos.acts.test",
"vendor": "example",
"version": {
"code": 1000000,
"name": "1.0.0"
},
"apiVersion": {
"compatible": 4,
"target": 5,
"releaseType": "Release"
}
},
"deviceConfig": {},
"module": {
"package": "ohos.acts.test",
"name": ".MyApplication",
"deviceType": [
"phone"
],
"distro": {
"installationFree": true,
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"name": "ohos.acts.test.MainAbility",
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "$string:app_name",
"type": "page",
"visible": true,
"launchType": "standard"
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
},
{
"pages": [
"pages/index/index"
],
"name": "default2",
"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.
*/
require('./FmsShare.test.js')
{
"string": [
{
"name": "app_name",
"value": "storagefilestabilityjstest"
},
{
"name": "mainability_description",
"value": "JS_Phone_Empty Feature Ability"
}
]
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册