[common][filesystem][change time sequence for async apis] 05/266205/2
authorchen89.chen <chen89.chen@samsung.com>
Tue, 9 Nov 2021 13:58:26 +0000 (21:58 +0800)
committerchen89.chen <chen89.chen@samsung.com>
Tue, 9 Nov 2021 14:44:24 +0000 (22:44 +0800)
Change-Id: I74a92404bde4298f0124822ecabb2a390c273552
Signed-off-by: chen89.chen <chen89.chen@samsung.com>
13 files changed:
common/tct-filesystem-tizen-tests/filesystem/FileHandle_flushNonBlocking.html
common/tct-filesystem-tizen-tests/filesystem/FileHandle_flushNonBlocking_with_onerror.html
common/tct-filesystem-tizen-tests/filesystem/FileHandle_readBlobNonBlocking.html
common/tct-filesystem-tizen-tests/filesystem/FileHandle_readBlobNonBlocking_with_size.html
common/tct-filesystem-tizen-tests/filesystem/FileHandle_readData.html
common/tct-filesystem-tizen-tests/filesystem/FileHandle_readDataNonBlocking.html
common/tct-filesystem-tizen-tests/filesystem/FileHandle_readDataNonBlocking_with_size.html
common/tct-filesystem-tizen-tests/filesystem/FileHandle_readData_InvalidValuesError.html
common/tct-filesystem-tizen-tests/filesystem/FileHandle_syncNonBlocking.html
common/tct-filesystem-tizen-tests/filesystem/FileHandle_syncNonBlocking_with_onerror.html
common/tct-filesystem-tizen-tests/filesystem/FileHandle_writeBlobNonBlocking_with_onerror.html
common/tct-filesystem-tizen-tests/filesystem/FileHandle_writeDataNonBlocking_with_onerror.html
common/tct-filesystem-tizen-tests/filesystem/FileHandle_writeStringNonBlocking_with_outputEncoding.html

index acdb08fe985d967f9aae3581389ccbfb0efce8f1..2a2e0aaac9488fdbdc3d8c5d66c44e3bf2d7b1b2 100755 (executable)
@@ -51,6 +51,10 @@ t.step(function () {
     });
 
     writeStringNonBlockingSuccess = t.step_func(function (bytesCount) {
+        retVal = fileHandleWrite.flushNonBlocking();
+        assert_equals(retVal, undefined, "return value should be undefined");
+        fileHandleRead = tizen.filesystem.openFile("documents/file", "r");
+        fileHandleRead.readStringNonBlocking(readStringNonBlockingSuccess, readStringNonBlockingError);
     });
 
     writeStringNonBlockingError = t.step_func(function (error) {
@@ -68,11 +72,6 @@ t.step(function () {
 
     fileHandleWrite = tizen.filesystem.openFile("documents/file", "w");
     fileHandleWrite.writeStringNonBlocking(content, writeStringNonBlockingSuccess, writeStringNonBlockingError);
-    retVal = fileHandleWrite.flushNonBlocking();
-    assert_equals(retVal, undefined, "return value should be undefined");
-
-    fileHandleRead = tizen.filesystem.openFile("documents/file", "r");
-    fileHandleRead.readStringNonBlocking(readStringNonBlockingSuccess, readStringNonBlockingError);
 });
 
 </script>
index 7e41892cb4e482440a9c695abd2920e9ad8f6eb2..400bbb9d7296cd370303641016e41545601344a3 100755 (executable)
@@ -50,36 +50,35 @@ t.step(function () {
         }
     });
 
-    writeStringNonBlockingSuccess = t.step_func(function (bytesCount) {
+    readStringNonBlockingSuccess = t.step_func(function (output) {
+        assert_equals(output, content, "the flush content is not right");
+        t.done();
     });
 
-    writeStringNonBlockingError = t.step_func(function (error) {
-        assert_unreached("writeStringNonBlocking() error callback invoked: name:" + error.name + "msg:" + error.message);
+    readStringNonBlockingError = t.step_func(function (error) {
+        assert_unreached("readStringNonBlocking() error callback invoked: name:" + error.name + "msg:" + error.message);
     });
 
     flushNonBlockingSuccess = t.step_func(function () {
+        fileHandleRead = tizen.filesystem.openFile("documents/file", "r");
+        fileHandleRead.readStringNonBlocking(readStringNonBlockingSuccess, readStringNonBlockingError);
     });
 
     flushNonBlockingError = t.step_func(function (error) {
         assert_unreached("flushNonBlocking() error callback invoked: name:" + error.name + "msg:" + error.message);
     });
 
-    readStringNonBlockingSuccess = t.step_func(function (output) {
-        assert_equals(output, content, "the flush content is not right");
-        t.done();
+    writeStringNonBlockingSuccess = t.step_func(function (bytesCount) {
+        retVal = fileHandleWrite.flushNonBlocking(flushNonBlockingSuccess, flushNonBlockingError);
+        assert_equals(retVal, undefined, "return value should be undefined");
     });
 
-    readStringNonBlockingError = t.step_func(function (error) {
-        assert_unreached("readStringNonBlocking() error callback invoked: name:" + error.name + "msg:" + error.message);
+    writeStringNonBlockingError = t.step_func(function (error) {
+        assert_unreached("writeStringNonBlocking() error callback invoked: name:" + error.name + "msg:" + error.message);
     });
 
     fileHandleWrite = tizen.filesystem.openFile("documents/file", "w");
     fileHandleWrite.writeStringNonBlocking(content, writeStringNonBlockingSuccess, writeStringNonBlockingError);
-    retVal = fileHandleWrite.flushNonBlocking(flushNonBlockingSuccess, flushNonBlockingError);
-    assert_equals(retVal, undefined, "return value should be undefined");
-
-    fileHandleRead = tizen.filesystem.openFile("documents/file", "r");
-    fileHandleRead.readStringNonBlocking(readStringNonBlockingSuccess, readStringNonBlockingError);
 });
 
 </script>
index a2fd5609399760f168c9162a0ee07cc3c9170e19..0b43983506a89077d9b202cb4ca02b58e73158e7 100755 (executable)
@@ -42,12 +42,18 @@ var t = async_test(document.title), writeBlobNonBlockingSuccess, writeBlobNonBlo
 t.step(function () {
     add_result_callback(function () {
         try {
+            fileHandleWrite.close();
+            fileHandleRead.close();
             tizen.filesystem.deleteFile("documents/file");
         } catch (err) {
         }
     });
 
     writeBlobNonBlockingSuccess = t.step_func(function (blob) {
+        fileHandleRead = tizen.filesystem.openFile("documents/file", "r");
+        retVal = fileHandleRead.readBlobNonBlocking();
+        assert_equals(retVal, undefined, "return value should be undefined");
+        t.done();
     });
 
     writeBlobNonBlockingError = t.step_func(function (error) {
@@ -57,13 +63,6 @@ t.step(function () {
     blob = new Blob([content], {type: "text/plain"});
     fileHandleWrite = tizen.filesystem.openFile("documents/file", "w");
     fileHandleWrite.writeBlobNonBlocking(blob, writeBlobNonBlockingSuccess, writeBlobNonBlockingError);
-    fileHandleWrite.close();
-
-    fileHandleRead = tizen.filesystem.openFile("documents/file", "r");
-    retVal = fileHandleRead.readBlobNonBlocking();
-    assert_equals(retVal, undefined, "return value should be undefined");
-    fileHandleRead.close();
-    t.done();
 });
 
 </script>
index f65c2d5798d18a3dc1dd2680112461f39a3ce869..808b57ecc7eda5dc305b309111e50fa75b0aa4f8 100755 (executable)
@@ -43,6 +43,8 @@ var t = async_test(document.title), writeBlobNonBlockingSuccess, writeBlobNonBlo
 t.step(function () {
     add_result_callback(function () {
         try {
+            fileHandleWrite.close();
+            fileHandleRead.close();
             tizen.filesystem.deleteFile("documents/file");
         } catch (err) {
         }
@@ -51,11 +53,14 @@ t.step(function () {
     eventCallback = t.step_func(function (contents) {
         text = contents.srcElement.result;
         assert_equals(text, content.substring(0, 5), "The read blob content is not right");
-        fileHandleRead.close();
         t.done();
     });
 
     writeBlobNonBlockingSuccess = t.step_func(function (blob) {
+        fileHandleRead = tizen.filesystem.openFile("documents/file", "r");
+        reader = new FileReader(),
+        reader.addEventListener("loadend", eventCallback);
+        retVal = fileHandleRead.readBlobNonBlocking(readBlobNonBlockingSuccess, readBlobNonBlockingError, 5);
     });
 
     writeBlobNonBlockingError = t.step_func(function (error) {
@@ -74,12 +79,6 @@ t.step(function () {
     blob = new Blob([content], {type: "text/plain"});
     fileHandleWrite = tizen.filesystem.openFile("documents/file", "w");
     fileHandleWrite.writeBlobNonBlocking(blob, writeBlobNonBlockingSuccess, writeBlobNonBlockingError);
-    fileHandleWrite.close();
-
-    fileHandleRead = tizen.filesystem.openFile("documents/file", "r");
-    reader = new FileReader(),
-    reader.addEventListener("loadend", eventCallback);
-    retVal = fileHandleRead.readBlobNonBlocking(readBlobNonBlockingSuccess, readBlobNonBlockingError, 5);
 });
 
 </script>
index c441359e620967dc7807ec28f5b5642528cd71dc..010d35ce2a2fd7183a58e46ae75cd73e4e4e0858 100755 (executable)
@@ -40,6 +40,7 @@ test(function () {
 
     add_result_callback(function () {
         try {
+            fileHandleRead.close();
             tizen.filesystem.deleteFile("documents/file");
         } catch (err) {
         }
@@ -53,7 +54,6 @@ test(function () {
     fileContentsInUint8Array = fileHandleRead.readData();
     assert_type(fileContentsInUint8Array, "object", "The type returned should be of object type.");
     assert_array_equals(fileContentsInUint8Array, dataToWrite, "Data read from file is not right");
-    fileHandleRead.close();
 }, document.title);
 
 </script>
index 8a0434a503fd706b6bced77c93b5b684a51cccc7..d8041480893c4099abeac9cd845002af97d538f7 100755 (executable)
@@ -42,12 +42,18 @@ var t = async_test(document.title), dataToWrite = new Uint8Array([11, 21, 31, 71
 t.step(function () {
     add_result_callback(function () {
         try {
+            fileHandleWrite.close();
+            fileHandleRead.close();
             tizen.filesystem.deleteFile("documents/file");
         } catch (err) {
         }
     });
 
     writeDataNonBlockingSuccess = t.step_func(function () {
+        fileHandleRead = tizen.filesystem.openFile("documents/file", "r");
+        retVal = fileHandleRead.readDataNonBlocking();
+        assert_equals(retVal, undefined, "return value should be undefined");
+        t.done();
     });
 
     writeDataNonBlockingError = t.step_func(function (error) {
@@ -56,14 +62,6 @@ t.step(function () {
 
     fileHandleWrite = tizen.filesystem.openFile("documents/file", "w");
     fileHandleWrite.writeDataNonBlocking(dataToWrite, writeDataNonBlockingSuccess, writeDataNonBlockingError);
-    fileHandleWrite.close();
-
-    fileHandleRead = tizen.filesystem.openFile("documents/file", "r");
-    retVal = fileHandleRead.readDataNonBlocking();
-    assert_equals(retVal, undefined, "return value should be undefined");
-
-    fileHandleRead.close();
-    t.done();
 });
 
 </script>
index 2d78461e6dad2dc0c028296de6e1296e2d25cbc1..fb75456fed1a7650f978fb17e9fd87ad2e23a508 100755 (executable)
@@ -42,12 +42,16 @@ var t = async_test(document.title), dataToWrite = new Uint8Array([11, 21, 31, 71
 t.step(function () {
     add_result_callback(function () {
         try {
+            fileHandleWrite.close();
+            fileHandleRead.close();
             tizen.filesystem.deleteFile("documents/file");
         } catch (err) {
         }
     });
 
     writeDataNonBlockingSuccess = t.step_func(function () {
+        fileHandleRead = tizen.filesystem.openFile("documents/file", "r");
+        retVal = fileHandleRead.readDataNonBlocking(readDataNonBlockingSuccess, readDataNonBlockingError, 3);
     });
 
     writeDataNonBlockingError = t.step_func(function (error) {
@@ -57,8 +61,6 @@ t.step(function () {
     readDataNonBlockingSuccess = t.step_func(function (data) {
         assert_equals(retVal, undefined, "return value should be undefined");
         assert_array_equals(data, dataToWrite.subarray(0, 3), "Data read from file is not right");
-
-        fileHandleRead.close();
         t.done();
     });
 
@@ -68,10 +70,6 @@ t.step(function () {
 
     fileHandleWrite = tizen.filesystem.openFile("documents/file", "w");
     fileHandleWrite.writeDataNonBlocking(dataToWrite, writeDataNonBlockingSuccess, writeDataNonBlockingError);
-    fileHandleWrite.close();
-
-    fileHandleRead = tizen.filesystem.openFile("documents/file", "r");
-    retVal = fileHandleRead.readDataNonBlocking(readDataNonBlockingSuccess, readDataNonBlockingError, 3);
 });
 
 </script>
index ad4172c29db5bc6e211d0c3e2a992a50e997c6cc..4df1aae7fa54cfcd095a75e967c35d2d23a55ff7 100755 (executable)
@@ -40,6 +40,7 @@ test(function () {
 
     add_result_callback(function () {
         try {
+            fileHandleRead.close();
             tizen.filesystem.deleteFile("documents/file");
         } catch (err) {
         }
@@ -53,7 +54,6 @@ test(function () {
     assert_throws(INVALID_VALUES_EXCEPTION, function () {
         fileHandleRead.readData(0x7fffffffffffffff);
     }, "InvalidValuesError should be thrown - invalid count.");
-    fileHandleRead.close();
 }, document.title);
 
 </script>
index 0725429d76b3bb56fd3ebf861cdff16f47789cac..f41f381fd467bd04470387139d817df78f8f1d3d 100755 (executable)
@@ -50,6 +50,11 @@ t.step(function () {
     });
 
     writeDataNonBlockingSuccess = t.step_func(function (data) {
+        retVal = fileHandleWrite.syncNonBlocking();
+        assert_equals(retVal, undefined, "return value should be undefined");
+
+        fileHandleRead = tizen.filesystem.openFile("documents/file", "r");
+        fileHandleRead.readDataNonBlocking(readDataNonBlockingSuccess, readDataNonBlockingError);
     });
 
     writeDataNonBlockingError = t.step_func(function (error) {
@@ -67,11 +72,6 @@ t.step(function () {
 
     fileHandleWrite = tizen.filesystem.openFile("documents/file", "w");
     fileHandleWrite.writeDataNonBlocking(dataToWrite, writeDataNonBlockingSuccess, writeDataNonBlockingError);
-    retVal = fileHandleWrite.syncNonBlocking();
-    assert_equals(retVal, undefined, "return value should be undefined");
-
-    fileHandleRead = tizen.filesystem.openFile("documents/file", "r");
-    fileHandleRead.readDataNonBlocking(readDataNonBlockingSuccess, readDataNonBlockingError);
 });
 
 </script>
index a793cbdd990d4eff945469f99a971430e3b06188..7f7479499fecc9b4a82b1204089fbe6a6392f490 100755 (executable)
@@ -51,6 +51,8 @@ t.step(function () {
     });
 
     writeDataNonBlockingSuccess = t.step_func(function (data) {
+        retVal = fileHandleWrite.syncNonBlocking(syncNonBlockingSuccess, syncNonBlockingError);
+        assert_equals(retVal, undefined, "return value should be undefined");
     });
 
     writeDataNonBlockingError = t.step_func(function (error) {
@@ -67,6 +69,8 @@ t.step(function () {
     });
 
     syncNonBlockingSuccess = t.step_func(function () {
+        fileHandleRead = tizen.filesystem.openFile("documents/file", "r");
+        fileHandleRead.readDataNonBlocking(readDataNonBlockingSuccess, readDataNonBlockingError);
     });
 
     syncNonBlockingError = t.step_func(function (error) {
@@ -75,11 +79,6 @@ t.step(function () {
 
     fileHandleWrite = tizen.filesystem.openFile("documents/file", "w");
     fileHandleWrite.writeDataNonBlocking(dataToWrite, writeDataNonBlockingSuccess, writeDataNonBlockingError);
-    retVal = fileHandleWrite.syncNonBlocking(syncNonBlockingSuccess, syncNonBlockingError);
-    assert_equals(retVal, undefined, "return value should be undefined");
-
-    fileHandleRead = tizen.filesystem.openFile("documents/file", "r");
-    fileHandleRead.readDataNonBlocking(readDataNonBlockingSuccess, readDataNonBlockingError);
 });
 
 </script>
index 4567c761ae514049002a4c169a6d7dc8d5b2b88b..f41338eae15ab1e954e5d2eca95aa6afdf381b55 100755 (executable)
@@ -43,6 +43,7 @@ var t = async_test(document.title), writeBlobNonBlockingSuccess, writeBlobNonBlo
 t.step(function () {
     add_result_callback(function () {
         try {
+            fileHandleWrite.close();
             fileHandleRead.close();
             tizen.filesystem.deleteFile("documents/file");
         } catch (err) {
@@ -56,6 +57,10 @@ t.step(function () {
     });
 
     writeBlobNonBlockingSuccess = t.step_func(function (blob) {
+        fileHandleRead = tizen.filesystem.openFile("documents/file", "r");
+        reader = new FileReader(),
+        reader.addEventListener("loadend", eventCallback);
+        fileHandleRead.readBlobNonBlocking(readBlobNonBlockingSuccess, readBlobNonBlockingError);
     });
 
     writeBlobNonBlockingError = t.step_func(function (error) {
@@ -74,12 +79,6 @@ t.step(function () {
     fileHandleWrite = tizen.filesystem.openFile("documents/file", "w");
     retVal = fileHandleWrite.writeBlobNonBlocking(blob, writeBlobNonBlockingSuccess, writeBlobNonBlockingError);
     assert_equals(retVal, undefined, "return value should be undefined");
-    fileHandleWrite.close();
-
-    fileHandleRead = tizen.filesystem.openFile("documents/file", "r");
-    reader = new FileReader(),
-    reader.addEventListener("loadend", eventCallback);
-    fileHandleRead.readBlobNonBlocking(readBlobNonBlockingSuccess, readBlobNonBlockingError);
 });
 
 </script>
index 91b9b79940fc3a334bd21bb607bd388a1953f5af..8edc20c0f64d5a6c176610db249e896a53369bc9 100755 (executable)
@@ -42,12 +42,16 @@ var t = async_test(document.title), dataToWrite = new Uint8Array([11, 21, 31, 71
 t.step(function () {
     add_result_callback(function () {
         try {
+            fileHandleWrite.close();
+            fileHandleRead.close();
             tizen.filesystem.deleteFile("documents/file");
         } catch (err) {
         }
     });
 
     writeDataNonBlockingSuccess = t.step_func(function () {
+        fileHandleRead = tizen.filesystem.openFile("documents/file", "r");
+        fileHandleRead.readDataNonBlocking(readDataNonBlockingSuccess, readDataNonBlockingError);
     });
 
     writeDataNonBlockingError = t.step_func(function (error) {
@@ -56,7 +60,6 @@ t.step(function () {
 
     readDataNonBlockingSuccess = t.step_func(function (data) {
         assert_array_equals(data, dataToWrite, "Data read from file is not right");
-        fileHandleRead.close();
         t.done();
     });
 
@@ -67,10 +70,6 @@ t.step(function () {
     fileHandleWrite = tizen.filesystem.openFile("documents/file", "w");
     retVal = fileHandleWrite.writeDataNonBlocking(dataToWrite, writeDataNonBlockingSuccess, writeDataNonBlockingError);
     assert_equals(retVal, undefined, "return value should be undefined");
-    fileHandleWrite.close();
-
-    fileHandleRead = tizen.filesystem.openFile("documents/file", "r");
-    fileHandleRead.readDataNonBlocking(readDataNonBlockingSuccess, readDataNonBlockingError);
 });
 
 </script>
index da02153889ab0d7258a8cf6a2d0ecaa1362571e6..6a1998c8ff9df62f87336edd07624f31e00ad4e5 100755 (executable)
@@ -43,12 +43,16 @@ var t = async_test(document.title), writeStringNonBlockingSuccess, writeStringNo
 t.step(function () {
     add_result_callback(function () {
         try {
+            fileHandleWrite.close();
+            fileHandleRead.close();
             tizen.filesystem.deleteFile("documents/file");
         } catch (err) {
         }
     });
 
     writeStringNonBlockingSuccess = t.step_func(function (bytesCount) {
+        fileHandleRead = tizen.filesystem.openFile("documents/file", "r");
+        fileHandleRead.readStringNonBlocking(readStringNonBlockingSuccess, readStringNonBlockingError, 5, "UTF-8");
     });
 
     writeStringNonBlockingError = t.step_func(function (error) {
@@ -57,7 +61,6 @@ t.step(function () {
 
     readStringNonBlockingSuccess = t.step_func(function (output) {
         assert_equals(output, content.substring(0, 5), "The read content should be same as the written content.");
-        fileHandleRead.close();
         t.done();
     });
 
@@ -68,10 +71,6 @@ t.step(function () {
     fileHandleWrite = tizen.filesystem.openFile("documents/file", "w");
     retVal = fileHandleWrite.writeStringNonBlocking(content, writeStringNonBlockingSuccess, writeStringNonBlockingError, "UTF-8");
     assert_equals(retVal, undefined, "return value should be undefined");
-    fileHandleWrite.close();
-
-    fileHandleRead = tizen.filesystem.openFile("documents/file", "r");
-    fileHandleRead.readStringNonBlocking(readStringNonBlockingSuccess, readStringNonBlockingError, 5, "UTF-8");
 });
 
 </script>