diff --git a/storage/storagefileiojstest/src/main/config.json b/storage/storagefileiojstest/src/main/config.json index 9b7cfe5d04d1f2f807e5c7dc8ceff403cde6a9df..beb7366c8d05ae0ab29ee07302404db7c77e164e 100644 --- a/storage/storagefileiojstest/src/main/config.json +++ b/storage/storagefileiojstest/src/main/config.json @@ -1,6 +1,6 @@ { "app": { - "bundleName": "ohos.acts.stroage.fileio", + "bundleName": "ohos.acts.storage.fileio", "vendor": "example", "version": { "code": 1000000, @@ -13,7 +13,7 @@ }, "deviceConfig": {}, "module": { - "package": "ohos.acts.stroage.fileio", + "package": "ohos.acts.storage.fileio", "name": ".MyApplication", "deviceType": [ "phone" @@ -36,7 +36,7 @@ ] } ], - "name": "ohos.acts.stroage.fileio.MainAbility", + "name": "ohos.acts.storage.fileio.MainAbility", "icon": "$media:icon", "description": "$string:mainability_description", "label": "$string:app_name", diff --git a/storage/storagefileiojstest/src/main/js/default/test/Common.js b/storage/storagefileiojstest/src/main/js/default/test/Common.js index b948dbd1253116ce81783953c76d489584d3ba57..bd146b8968d85f2d1c2739e1019a6cf59e2abd45 100644 --- a/storage/storagefileiojstest/src/main/js/default/test/Common.js +++ b/storage/storagefileiojstest/src/main/js/default/test/Common.js @@ -17,11 +17,6 @@ import fileio from '@ohos.fileio'; export const FILE_CONTENT = 'hello world'; -import { - expect -} -from 'deccjsunit/index' - export function prepareFile(fpath, content) { try { let fd = fileio.openSync(fpath, 0o102, 0o666) @@ -36,20 +31,6 @@ export function prepareFile(fpath, content) { 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) @@ -87,74 +68,19 @@ export function fileToWriteOnly(fpath) { return false } } -export function fileToReadAndWrite(fpath) { - try { - let fd = fileio.openSync(fpath, 0o1) - fileio.fchmodSync(fd, 0o777) - fileio.fsyncSync(fd) - fileio.closeSync(fd) - return true - } - catch (e) { - console.log('Failed to fileToReadAndWrite ' + e); - return false - } -} -export function appName(testName) { - const BASE_PATH = '/data/accounts/account_0/appdata/ohos.acts.stroage.fileio/' - return BASE_PATH + testName + '_' + randomString(testName.length); -} export function nextFileName(testName) { - const BASE_PATH = '/data/accounts/account_0/appdata/ohos.acts.stroage.fileio/cache/' + const BASE_PATH = '/data/accounts/account_0/appdata/ohos.acts.storage.fileio/cache/' return BASE_PATH + testName + '_' + randomString(testName.length); } export function fileName(testName) { - const BASE_PATH = '/data/accounts/account_0/appdata/ohos.acts.stroage.fileio/files/' + const BASE_PATH = '/data/accounts/account_0/appdata/ohos.acts.storage.fileio/files/' return BASE_PATH + testName + '_' + randomString(testName.length); } export function cacheFileName(testName) { - const BASE_PATH = '/data/accounts/account_0/appdata/ohos.acts.stroage.fileio/files/cache/' - return BASE_PATH + testName + '_' + randomString(testName.length); -} -export function differentFileName(testName) { - const BASE_PATH = '/data/accounts/account_0/ohos.acts.distributeddatamgr.distributedfile/' - return BASE_PATH + testName + '_' + randomString(testName.length); -} -export function differentCacheName(testName) { - const BASE_PATH = '/data/accounts/account_0/ohos.acts.distributeddatamgr.distributedfile/cache/' + const BASE_PATH = '/data/accounts/account_0/appdata/ohos.acts.storage.fileio/files/cache/' return BASE_PATH + testName + '_' + randomString(testName.length); } -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) { diff --git a/storage/storagefileiojstest/src/main/js/default/test/FileIO.test.js b/storage/storagefileiojstest/src/main/js/default/test/FileIO.test.js index cc2c4b68621c817854d6f66f44b22d4e69bf7c80..1f244012726ae08f43eeabff848467fe3e103eae 100644 --- a/storage/storagefileiojstest/src/main/js/default/test/FileIO.test.js +++ b/storage/storagefileiojstest/src/main/js/default/test/FileIO.test.js @@ -29,7 +29,6 @@ import { prepareFile, nextFileName, prepareEmptyFile, - differentFileName, randomString, fileName, sleep diff --git a/storage/storagefileiojstest/src/main/js/default/test/FileIOStream.test.js b/storage/storagefileiojstest/src/main/js/default/test/FileIOStream.test.js index d69f17564b074e6a1dd6a4418421de8800d905a2..bc4b42575f59132f3169e2af63654d7e2c0ba374 100644 --- a/storage/storagefileiojstest/src/main/js/default/test/FileIOStream.test.js +++ b/storage/storagefileiojstest/src/main/js/default/test/FileIOStream.test.js @@ -30,7 +30,6 @@ import { fileToReadOnly, fileToWriteOnly, sleep, - fileToReadAndWrite, nextFileName, randomString }