提交 e85ea373 编写于 作者: K kdjbb

storagefileiojstest下file.test.js测试用例还原

Signed-off-by: Nkdjbb <wangbo_jiaobaba@163.com>
上级 e2ea2159
......@@ -70,15 +70,15 @@ export function fileToWriteOnly(fpath) {
}
export function nextFileName(testName) {
const BASE_PATH = '/data/accounts/account_0/appdata/ohos.acts.storage.fileio/cache/'
return BASE_PATH + testName + '_' + randomString(testName.length);
return BASE_PATH + testName
}
export function fileName(testName) {
const BASE_PATH = '/data/accounts/account_0/appdata/ohos.acts.storage.fileio/files/'
return BASE_PATH + testName + '_' + randomString(testName.length);
return BASE_PATH + testName
}
export function cacheFileName(testName) {
const BASE_PATH = '/data/accounts/account_0/appdata/ohos.acts.storage.fileio/files/cache/'
return BASE_PATH + testName + '_' + randomString(testName.length);
return BASE_PATH + testName
}
export function sleep(n) {
......
......@@ -14,6 +14,7 @@
*/
import fileio from '@ohos.fileio';
import file from '@system.file';
import {
describe,
beforeAll,
......@@ -1577,6 +1578,40 @@ describe('fileIOTest', function () {
}
});
/**
* @tc.number SUB_STORAGE_FileIO_ReadSync_0000
* @tc.name fileio_test_read_sync_000
* @tc.desc Function of API, readSync.
*/
it("fileio_test_read_sync_000", 0, async function (done) {
let fpath = nextFileName("fileio_test_read_sync_000");
let text = "0123456789abcdefg";
expect(prepareFile(fpath, text)).assertTrue();
sleep(10);
try {
let fd = fileio.openSync(fpath, 0o2);
let len = fileio.readSync(fd, new ArrayBuffer(4096));
expect(len == text.length).assertTrue();
expect(fileio.closeSync(fd) !== null).assertTrue();
file.readText({
uri: "internal://cache/fileio_test_read_sync_000",
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) {
console.error("call fail callback fail, code: " + code + ", data: " + data);
expect(null).assertFail();
},
});
} catch (e) {
console.log("fileio_test_read_sync_000 has failed for " + e);
expect(null).assertFail();
}
});
/**
* @tc.number SUB_STORAGE_FileIO_ReadSync_0100
* @tc.name fileio_test_read_sync_001
......
......@@ -13,6 +13,7 @@
* limitations under the License.
*/
require('./File.test.js')
require('./FileIO.test.js')
require('./FileIODir.test.js')
require('./FileIODirent.test.js')
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册