[common][download][DPTTIZEN-3052, modify 7 tcs to avoid unexpected exception] 92/180992/2
authorzhongyuan <zy123.yuan@samsung.com>
Thu, 7 Jun 2018 06:31:50 +0000 (14:31 +0800)
committerzhongyuan <zy123.yuan@samsung.com>
Tue, 12 Jun 2018 01:37:32 +0000 (09:37 +0800)
Change-Id: Ic9d09de176bcc8dcaa3f47a9c625ac8192ec429e

common/tct-download-tizen-tests/download/DownloadCallback_oncanceled.html
common/tct-download-tizen-tests/download/DownloadCallback_onpaused.html
common/tct-download-tizen-tests/download/DownloadCallback_onprogress.html
common/tct-download-tizen-tests/download/DownloadManager_cancel.html
common/tct-download-tizen-tests/download/DownloadManager_getState_url_DOWNLOADING.html
common/tct-download-tizen-tests/download/DownloadManager_getState_url_URL_CANCELED.html
common/tct-download-tizen-tests/download/DownloadManager_getState_url_URL_PAUSE.html
common/tct-download-tizen-tests/download/DownloadManager_pause.html

index d6a8a127b87db548574f19870582a69f608105d7..ab56dcab6ace6960dd7bad8ee73c0fa57aedc87c 100755 (executable)
@@ -38,14 +38,17 @@ Authors:
 
 setup({timeout: 90000});
 var t = async_test(document.title, {timeout: 90000}), listener,
-    downloadRequest, downloadId;
+    downloadRequest, downloadId, flag = true;
 t.step(function () {
     listener = {
         onprogress: t.step_func(function (id, receivedSize, totalSize) {
-            try {
-                tizen.download.cancel(id);
-            } catch (e) {
-                assert_unreached("cancel() failed: " + e.name + " with message: " + e.message);
+            if (flag === true) {
+                try {
+                    tizen.download.cancel(id);
+                } catch (e) {
+                    assert_unreached("cancel() failed: " + e.name + " with message: " + e.message);
+                }
+                flag = false;
             }
         }),
         onpaused: t.step_func(function (id) {
index 314a135549ae8e4f52620225c327424d3d6386b4..a7ccfb2e8f1f65cffceb69026a2e1d41a2f95f46 100755 (executable)
@@ -38,14 +38,17 @@ Authors:
 
 setup({timeout: 90000});
 var t = async_test(document.title, {timeout: 90000}), listener,
-    downloadRequest, downloadId;
+    downloadRequest, downloadId, flag = true;
 t.step(function () {
     listener = {
         onprogress: t.step_func(function (id, receivedSize, totalSize) {
-            try {
-                tizen.download.pause(downloadId);
-            } catch (e) {
-                assert_unreached("pause() failed: " + e.name + " with message: " + e.message);          
+            if (flag === true) {
+                try {
+                    tizen.download.pause(downloadId);
+                } catch (e) {
+                    assert_unreached("pause() failed: " + e.name + " with message: " + e.message);
+                }
+                flag = false;
             }
         }),
         onpaused: t.step_func(function (id) {
index abde77ddd214e5afa3ba6a00daf332f4676e297b..f56d54ef27e3912986b88014974f4af1f87bb63f 100755 (executable)
@@ -38,7 +38,7 @@ Authors:
 
 setup({timeout: 90000});
 var t = async_test(document.title, {timeout: 90000}), listener,
-    downloadRequest, downloadId;
+    downloadRequest, downloadId, flag = true;
 t.step(function () {
     listener = {
         onprogress: t.step_func(function (id, receivedSize, totalSize) {
@@ -48,10 +48,13 @@ t.step(function () {
             assert_type(totalSize, "unsigned long long", "totalSize type should be a number");
             assert_greater_than(totalSize, 0, "totalSize is less than or equals to zero");
             assert_true(receivedSize >= 0 && receivedSize <= totalSize, "The length of receivedSize between zero and totalSize");
-            try {
-                tizen.download.cancel(downloadId);
-            } catch (e) {
-                assert_unreached("cancel() failed: " + e.name + " with message: " + e.message);
+            if (flag === true) {
+                try {
+                    tizen.download.cancel(downloadId);
+                } catch (e) {
+                    assert_unreached("cancel() failed: " + e.name + " with message: " + e.message);
+                }
+                flag = false;
             }
         }),
         onpaused: t.step_func(function (id) {
index c5a3f88526f2ac8cfe41b22f2c2c86077ec861ec..a67dddc4616b569779bd971150dfc58002739416 100755 (executable)
@@ -49,15 +49,18 @@ Authors:
 
 setup({timeout: 90000});
 var t = async_test(document.title, {timeout: 90000}), downloadRequest = null,
-    downloadId, listener, retValue = null;
+    downloadId, listener, retValue = null, flag = true;
 t.step(function () {
     listener = {
         onprogress: t.step_func(function (id, receivedSize, totalSize) {
             assert_not_equals(id, null, "id valid");
-            try {
-                retValue = tizen.download.cancel(downloadId);
-            } catch(e) {
-                assert_unreached("cancel() failed: " + e.name + " with message: " + e.message);
+            if (flag === true) {
+                try {
+                    retValue = tizen.download.cancel(downloadId);
+                } catch (e) {
+                    assert_unreached("cancel() failed: " + e.name + " with message: " + e.message);
+                }
+                flag = false;
             }
         }),
         onpaused: t.step_func(function (id) {
index f04e9038cc2b04787ed8a6bd3f25167591f1938a..1433fb711c3ae673eb7399f690edaef767752af5 100755 (executable)
@@ -39,6 +39,12 @@ Authors:
 setup({timeout: 90000});
 var t = async_test(document.title, {timeout: 90000}), downloadRequest = null, downloadId, listener, state;
 t.step(function () {
+    add_result_callback(function(){
+        try {
+            tizen.download.cancel(downloadId);
+        } catch (err) {
+        }
+    });
     listener = {
         onprogress: t.step_func(function (id, receivedSize, totalSize) {
             state = tizen.download.getState(downloadId);
index 112052312dc5bcc8c0a653592399c8565c520f9b..dc9704f653cda43e857fdb331c80cd9c6a2dcb6e 100755 (executable)
@@ -37,11 +37,14 @@ Authors:
 //==== TEST_CRITERIA MR
 
 setup({timeout: 90000});
-var t = async_test(document.title, {timeout: 90000}), downloadRequest = null, downloadId, listener, state;
+var t = async_test(document.title, {timeout: 90000}), downloadRequest = null, downloadId, listener, state, flag = true;
 t.step(function () {
     listener = {
         onprogress: t.step_func(function (id, receivedSize, totalSize) {
-            tizen.download.cancel(downloadId);
+            if (flag === true) {
+                tizen.download.cancel(downloadId);
+                flag = false;
+            }
         }),
         onpaused: t.step_func(function (id) {
             assert_unreached("onpaused should not be reached");
@@ -64,4 +67,4 @@ t.step(function () {
 
 </script>
 </body>
-</html>
\ No newline at end of file
+</html>
index 5fc7fccf97e3bd10b37a0ae09b1dcd883ac8e23d..e21ac365416b6442ef782da39d27d70ce6df23db 100755 (executable)
@@ -37,11 +37,20 @@ Authors:
 //==== TEST_CRITERIA MR
 
 setup({timeout: 90000});
-var t = async_test(document.title, {timeout: 90000}), downloadRequest = null, downloadId, listener, state;
+var t = async_test(document.title, {timeout: 90000}), downloadRequest = null, downloadId, listener, state, flag = true;
 t.step(function () {
+    add_result_callback(function(){
+        try {
+            tizen.download.cancel(downloadId);
+        } catch (err) {
+        }
+    });
     listener = {
         onprogress: t.step_func(function (id, receivedSize, totalSize) {
-            tizen.download.pause(downloadId);
+            if (flag === true) {
+                tizen.download.pause(downloadId);
+                flag = false;
+            }
         }),
         onpaused: t.step_func(function (id) {
             state = tizen.download.getState(downloadId);
@@ -64,4 +73,4 @@ t.step(function () {
 
 </script>
 </body>
-</html>
\ No newline at end of file
+</html>
index a0ec4472be0760726688ceed4928c5bec7e0902e..1c4069f07e863805df26482c5c90fa7f0acb104c 100755 (executable)
@@ -49,7 +49,7 @@ Authors:
 //==== ONLOAD_DELAY 90
 //==== TEST_CRITERIA MMINA MAST MR
 
-var t = async_test(document.title, {timeout: 90000}), downloadRequest = null,
+var t = async_test(document.title, {timeout: 90000}), downloadRequest = null, flag = true,
     downloadId, listener, retValue = null;
 setup({timeout: 90000});
 
@@ -57,10 +57,13 @@ t.step(function () {
     listener = {
         onprogress: t.step_func(function (id, receivedSize, totalSize) {
             assert_not_equals(id, null, "id should not be null");
-            try {
-                retValue = tizen.download.pause(downloadId);
-            } catch (e) {
-                assert_unreached("pause() failed: " + e.name + " with message: " + e.message);
+            if (flag === true) {
+                try {
+                    retValue = tizen.download.pause(downloadId);
+                } catch (e) {
+                    assert_unreached("pause() failed: " + e.name + " with message: " + e.message);
+                }
+                flag = false;
             }
         }),
         onpaused: t.step_func(function (id) {