From: zhongyuan Date: Thu, 7 Jun 2018 06:31:50 +0000 (+0800) Subject: [common][download][DPTTIZEN-3052, modify 7 tcs to avoid unexpected exception] X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F92%2F180992%2F2;p=test%2Ftct%2Fweb%2Fapi.git [common][download][DPTTIZEN-3052, modify 7 tcs to avoid unexpected exception] Change-Id: Ic9d09de176bcc8dcaa3f47a9c625ac8192ec429e --- diff --git a/common/tct-download-tizen-tests/download/DownloadCallback_oncanceled.html b/common/tct-download-tizen-tests/download/DownloadCallback_oncanceled.html index d6a8a127b..ab56dcab6 100755 --- a/common/tct-download-tizen-tests/download/DownloadCallback_oncanceled.html +++ b/common/tct-download-tizen-tests/download/DownloadCallback_oncanceled.html @@ -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) { diff --git a/common/tct-download-tizen-tests/download/DownloadCallback_onpaused.html b/common/tct-download-tizen-tests/download/DownloadCallback_onpaused.html index 314a13554..a7ccfb2e8 100755 --- a/common/tct-download-tizen-tests/download/DownloadCallback_onpaused.html +++ b/common/tct-download-tizen-tests/download/DownloadCallback_onpaused.html @@ -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) { diff --git a/common/tct-download-tizen-tests/download/DownloadCallback_onprogress.html b/common/tct-download-tizen-tests/download/DownloadCallback_onprogress.html index abde77ddd..f56d54ef2 100755 --- a/common/tct-download-tizen-tests/download/DownloadCallback_onprogress.html +++ b/common/tct-download-tizen-tests/download/DownloadCallback_onprogress.html @@ -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) { diff --git a/common/tct-download-tizen-tests/download/DownloadManager_cancel.html b/common/tct-download-tizen-tests/download/DownloadManager_cancel.html index c5a3f8852..a67dddc46 100755 --- a/common/tct-download-tizen-tests/download/DownloadManager_cancel.html +++ b/common/tct-download-tizen-tests/download/DownloadManager_cancel.html @@ -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) { diff --git a/common/tct-download-tizen-tests/download/DownloadManager_getState_url_DOWNLOADING.html b/common/tct-download-tizen-tests/download/DownloadManager_getState_url_DOWNLOADING.html index f04e9038c..1433fb711 100755 --- a/common/tct-download-tizen-tests/download/DownloadManager_getState_url_DOWNLOADING.html +++ b/common/tct-download-tizen-tests/download/DownloadManager_getState_url_DOWNLOADING.html @@ -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); diff --git a/common/tct-download-tizen-tests/download/DownloadManager_getState_url_URL_CANCELED.html b/common/tct-download-tizen-tests/download/DownloadManager_getState_url_URL_CANCELED.html index 112052312..dc9704f65 100755 --- a/common/tct-download-tizen-tests/download/DownloadManager_getState_url_URL_CANCELED.html +++ b/common/tct-download-tizen-tests/download/DownloadManager_getState_url_URL_CANCELED.html @@ -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 () { - \ No newline at end of file + diff --git a/common/tct-download-tizen-tests/download/DownloadManager_getState_url_URL_PAUSE.html b/common/tct-download-tizen-tests/download/DownloadManager_getState_url_URL_PAUSE.html index 5fc7fccf9..e21ac3654 100755 --- a/common/tct-download-tizen-tests/download/DownloadManager_getState_url_URL_PAUSE.html +++ b/common/tct-download-tizen-tests/download/DownloadManager_getState_url_URL_PAUSE.html @@ -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 () { - \ No newline at end of file + diff --git a/common/tct-download-tizen-tests/download/DownloadManager_pause.html b/common/tct-download-tizen-tests/download/DownloadManager_pause.html index a0ec4472b..1c4069f07 100755 --- a/common/tct-download-tizen-tests/download/DownloadManager_pause.html +++ b/common/tct-download-tizen-tests/download/DownloadManager_pause.html @@ -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) {