From 39074cd354483764ef5cce580c152b8234ef1ccb Mon Sep 17 00:00:00 2001 From: bayanxing Date: Sat, 21 May 2022 15:57:02 +0800 Subject: [PATCH] description:add test cases Signed-off-by: bayanxing --- .../src/main/js/default/test/FileIO.test.js | 33 +++++++++++++++++++ .../main/js/default/test/FileIODir.test.js | 33 +++++++++++++++++++ 2 files changed, 66 insertions(+) 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 3ef24e876..9edd0fbc3 100644 --- a/storage/storagefileiojstest/src/main/js/default/test/FileIO.test.js +++ b/storage/storagefileiojstest/src/main/js/default/test/FileIO.test.js @@ -3826,4 +3826,37 @@ describe('fileIOTest', function () { expect(null).assertFail(); } }); + + /** + * @tc.number SUB_STORAGE_FileIO_stat_promise_000 + * @tc.name fileio_test_stat_promise_000 + * @tc.desc obtain file propertys by stat promise + */ + it('fileio_test_stat_promise_000', 0, async function () { + let fpath = await nextFileName('fileio_test_stat_promise_000'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + expect(fileio.chmodSync(fpath, 0o660) !== null).assertTrue(); + let stat = await fileio.stat(fpath).then(()=> { + expect((stat.mode & 0o777) == 0o660).assertTrue(); + expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + console.log('file stat Success'); + }).catch((err) => { + console.log("file stat err: " + JSON.stringify(err)); + }); + }); + + /** + * @tc.number fileio_test_stat_async_000 + * @tc.name fileio_test_stat_async_000 + * @tc.desc Function of API, obtain file propertys by stat async + */ + it('fileio_test_stat_async_000', 0, async function () { + let fpath = await nextFileName('fileio_test_stat_async_000'); + expect(prepareFile(fpath, FILE_CONTENT)).assertTrue(); + expect(fileio.chmodSync(fpath, 0o660) !== null).assertTrue(); + fileio.stat(fpath, function (err, stat) { + expect((stat.mode & 0o777) == 0o660).assertTrue(); + expect(fileio.unlinkSync(fpath) !== null).assertTrue(); + }); + }); }); \ No newline at end of file diff --git a/storage/storagefileiojstest/src/main/js/default/test/FileIODir.test.js b/storage/storagefileiojstest/src/main/js/default/test/FileIODir.test.js index bc8ee0ed3..7bbb2869e 100644 --- a/storage/storagefileiojstest/src/main/js/default/test/FileIODir.test.js +++ b/storage/storagefileiojstest/src/main/js/default/test/FileIODir.test.js @@ -155,6 +155,39 @@ describe('fileIOTestDir', function () { } }); + /** + * @tc.number SUB_STORAGE_FileIO_dir_OpenASync_001 + * @tc.name fileio_test_dir_open_async_001 + * @tc.desc Function of API, file name contain special character. + */ + it('fileio_test_dir_open_async_001', 0, async function () { + let dpath = await nextFileName('fileio_test_dir_open_async_001') + 'd' + expect(fileio.mkdirSync(dpath) !== null).assertTrue(); + fileio.opendir(dpath, function (err, dir) { + expect(dir !== null).assertTrue(); + expect(dir.closeSync() == null).assertTrue(); + expect(fileio.rmdirSync(dpath) !== null).assertTrue(); + }); + }); + + /** + * @tc.number SUB_STORAGE_FileIO_dir_OpenASync_001 + * @tc.name fileio_test_dir_open_async_001 + * @tc.desc Function of API, file name contain special character. + */ + it('fileio_test_dir_open_async_002', 0, async function () { + let dpath = await nextFileName('fileio_test_dir_open_async_002') + 'd' + expect(fileio.mkdirSync(dpath) !== null).assertTrue(); + let dir = await fileio.opendir(dpath).then(()=> { + expect(dir !== null).assertTrue(); + expect(dir.closeSync() == null).assertTrue(); + expect(fileio.rmdirSync(dpath) !== null).assertTrue(); + console.log('fileio opendir Success'); + }).catch((err) => { + console.log("fileio opendir err: " + JSON.stringify(err)); + }); + }); + /** * @tc.number SUB_STORAGE_FileIO_dir_ReadSync_0000 * @tc.name fileio_test_dir_read_sync_000 -- GitLab