From aed77f8d82aa330de1221f1baf57ed3104c4628f Mon Sep 17 00:00:00 2001 From: raoxian Date: Thu, 18 Aug 2022 14:54:09 +0800 Subject: [PATCH] =?UTF-8?q?fixed=20476b6ed=20from=20https://gitee.com/stor?= =?UTF-8?q?age-sandboxing/xts=5Facts/pulls/5026=20=E4=BF=AE=E6=94=B9File.t?= =?UTF-8?q?est.js=E9=BB=84=E5=8C=BA=E6=B5=8B=E8=AF=95=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: raoxian --- .../src/main/js/test/File.test.js | 234 +++++++++--------- 1 file changed, 116 insertions(+), 118 deletions(-) diff --git a/storage/storagefilejstest/src/main/js/test/File.test.js b/storage/storagefilejstest/src/main/js/test/File.test.js index 2d8f151a0..46d045cee 100644 --- a/storage/storagefilejstest/src/main/js/test/File.test.js +++ b/storage/storagefilejstest/src/main/js/test/File.test.js @@ -295,48 +295,45 @@ describe('fileTest', function () { text: 'Text1.', success: function () { console.info('File_writeText_002 call writeText success.'); - done(); - }, - fail: function (data, code) { - console.info('File_writeText_002 call writeText fail, code: ' + code + ', data: ' + data); - expect(null).assertFail(); - }, - }); - file.writeText({ - uri: 'internal://cache/File_writeText_002', - text: 'Text2.', - append: true, - success: function () { - console.info('File_writeText_002 call writeText success.'); - done(); + file.writeText({ + uri: 'internal://cache/File_writeText_002', + text: 'Text2.', + append: true, + success: function () { + console.info('File_writeText_002 call writeText success.'); + file.readText({ + uri: 'internal://cache/File_writeText_002', + success: function (data) { + console.info('File_writeText_002 call read success. Content: ' ); + file.delete({ + uri: 'internal://cache/File_writeText_002', + success: function () { + console.info('File_writeText_002 call delete success'); + done(); + }, + fail: function (data, code) { + console.info('File_writeText_002 call delete fail, code: ' + code + ', data: ' + data); + expect(null).assertFail(); + }, + }); + }, + fail: function (data, code) { + console.info('File_writeText_002 call read fail, code: ' + code + ', data: ' + data); + expect(null).assertFail(); + }, + }); + }, + fail: function (data, code) { + console.info('File_writeText_002 call writeText fail, code: ' + code + ', data: ' + data); + expect(null).assertFail(); + }, + }); }, fail: function (data, code) { console.info('File_writeText_002 call writeText fail, code: ' + code + ', data: ' + data); expect(null).assertFail(); }, }); - file.readText({ - uri: 'internal://cache/File_writeText_002', - success: function (data) { - console.info('File_writeText_002 call read success. Content: ' ); - done(); - }, - fail: function (data, code) { - console.info('File_writeText_002 call read fail, code: ' + code + ', data: ' + data); - expect(null).assertFail(); - }, - }); - file.delete({ - uri: 'internal://cache/File_writeText_002', - success: function () { - console.info('File_writeText_002 call delete success'); - done(); - }, - fail: function (data, code) { - console.info('File_writeText_002 call delete fail, code: ' + code + ', data: ' + data); - expect(null).assertFail(); - }, - }); }); /** @@ -865,40 +862,45 @@ describe('fileTest', function () { buffer: buf, success: function () { console.info('File_writeArrayBuffer_005 call writeText success.'); - done(); - }, - fail: function (data, code) { - console.info('File_writeArrayBuffer_005 , code: ' + code + ', data: ' + data); - expect(null).assertFail(); - }, - }); - file.writeArrayBuffer({ - uri: 'internal://cache/File_writeArrayBuffer_005', - buffer: buf, - position: 10, - success: function () { - console.info('File_writeArrayBuffer_005 call writeArrayBuffer success.'); - done(); - }, - fail: function (data, code) { - console.info('File_writeArrayBuffer_005 , code: ' + code + ', data: ' + data); - expect(null).assertFail(); - }, - }); - file.readArrayBuffer({ - uri: 'internal://cache/File_writeArrayBuffer_005', - success: function (data) { - console.info('File_writeArrayBuffer_005 read success:' ); - done(); + file.writeArrayBuffer({ + uri: 'internal://cache/File_writeArrayBuffer_005', + buffer: buf, + position: 10, + success: function () { + console.info('File_writeArrayBuffer_005 call writeArrayBuffer success.'); + file.readArrayBuffer({ + uri: 'internal://cache/File_writeArrayBuffer_005', + success: function (data) { + console.info('File_writeArrayBuffer_005 read success:' ); + file.delete({ + uri: 'internal://cache/File_writeArrayBuffer_005', + success: function () { + console.info('File_writeArrayBuffer_005 call delete success'); + done(); + }, + fail: function (data, code) { + console.info('File_writeArrayBuffer_005 delete fail, code: ' + code + ', data: ' + data); + expect(null).assertFail(); + }, + }); + }, + fail: function (data, code) { + console.info('File_writeArrayBuffer_005 read fail, code: ' + code + ', data: ' + data); + expect(null).assertFail(); + }, + }); + }, + fail: function (data, code) { + console.info('File_writeArrayBuffer_005 writeArrayBuffer fail, code: ' + code + ', data: ' + data); + expect(null).assertFail(); + }, + }); }, fail: function (data, code) { - console.info('File_writeArrayBuffer_005 , code: ' + code + ', data: ' + data); + console.info('File_writeArrayBuffer_005 writeText fail, code: ' + code + ', data: ' + data); expect(null).assertFail(); }, }); - file.delete({ - uri: 'internal://cache/File_writeArrayBuffer_005' - }); }); /** @@ -2103,26 +2105,25 @@ describe('fileTest', function () { recursive: true, success: function () { console.info('File_rmdir_002 mkdir success.'); - done(); + file.rmdir({ + uri: 'internal://app/test', + recursive: false, + success: function () { + console.info('File_rmdir_002 call rmdir success.'); + expect(null).assertFail(); + }, + fail: function (data, code) { + console.info('File_rmdir_002 fail, code: ' + code + ', data: ' + data); + expect(code == 301 || code == 300).assertTrue(); + done(); + }, + }); }, fail: function (data, code) { console.info('File_rmdir_002 fail, code: ' + code + ', data: ' + data); expect(null).assertFail(); }, }); - file.rmdir({ - uri: 'internal://app/test', - recursive: false, - success: function () { - console.info('File_rmdir_002 call rmdir success.'); - expect(null).assertFail(); - }, - fail: function (data, code) { - console.info('File_rmdir_002 fail, code: ' + code + ', data: ' + data); - expect(code == 301 || code == 300).assertTrue(); - done(); - }, - }); }); /** @@ -2136,49 +2137,46 @@ describe('fileTest', function () { recursive: true, success: function () { console.info('File_rmdir_003 mkdir success.'); - done(); - }, - fail: function (data, code) { - console.info('File_rmdir_003 fail, code: ' + code + ', data: ' + data); - expect(null).assertFail(); - }, - }); - file.mkdir({ - uri: 'internal://cache/test/File_rmdir_003_1/File_rmdir_003_1/File_rmdir_003_2', - recursive: true, - success: function () { - console.info('File_rmdir_003 mkdir success.'); - done(); - }, - fail: function (data, code) { - console.info('File_rmdir_003 fail, code: ' + code + ', data: ' + data); - expect(null).assertFail(); - }, - }); - file.mkdir({ - uri: 'internal://cache/test/File_rmdir_003_2/File_rmdir_003_1/File_rmdir_003_2', - recursive: true, - success: function () { - console.info('File_rmdir_003 mkdir success.'); - done(); + file.mkdir({ + uri: 'internal://cache/test/File_rmdir_003_1/File_rmdir_003_1/File_rmdir_003_2', + recursive: true, + success: function () { + console.info('File_rmdir_003 mkdir success.'); + file.mkdir({ + uri: 'internal://cache/test/File_rmdir_003_2/File_rmdir_003_1/File_rmdir_003_2', + recursive: true, + success: function () { + console.info('File_rmdir_003 mkdir success.'); + file.rmdir({ + uri: 'internal://cache/test', + recursive: true, + success: function () { + console.info('File_rmdir_003 call rmdir success.'); + done(); + }, + fail: function (data, code) { + console.info('File_rmdir_003 , code: ' + code + ', data: ' + data); + expect(null).assertFail(); + }, + }); + }, + fail: function (data, code) { + console.info('File_rmdir_003 fail, code: ' + code + ', data: ' + data); + expect(null).assertFail(); + }, + }); + }, + fail: function (data, code) { + console.info('File_rmdir_003 fail, code: ' + code + ', data: ' + data); + expect(null).assertFail(); + }, + }); }, fail: function (data, code) { console.info('File_rmdir_003 fail, code: ' + code + ', data: ' + data); expect(null).assertFail(); }, }); - file.rmdir({ - uri: 'internal://cache/test', - recursive: true, - success: function () { - console.info('File_rmdir_003 call rmdir success.'); - done(); - }, - fail: function (data, code) { - console.info('File_rmdir_003 , code: ' + code + ', data: ' + data); - expect(null).assertFail(); - }, - }); }); /** @@ -2208,13 +2206,13 @@ describe('fileTest', function () { */ it('File_rmdir_005', 0, async function (done) { file.rmdir({ - uri: 'internal://app/notdir/123', + uri: 'internal://app/123', success: function () { console.info('File_rmdir_005 call rmdir success.'); expect(null).assertFail(); }, fail: function (data, code) { - console.info('File_rmdir_005 , code: ' + code + ', data: ' + data); + console.info('File_rmdir_005 rmdir fail, code: ' + code + ', data: ' + data); expect(code == 301).assertTrue(); done(); }, -- GitLab