From 1b40beda5c48fbb15431578025f43d9dba29059f Mon Sep 17 00:00:00 2001 From: "wei625.zhang" Date: Sun, 9 Oct 2022 15:10:06 +0800 Subject: [PATCH] [common][calendar][TSEVEN-3269 change cleanup() to add_result_callback] Change-Id: I0911e4b0cc5c0d2ba7021459e3cf58f9e24c0c14 Signed-off-by: wei625.zhang --- ...darItemArraySuccessCallback_onsuccess.html | 8 +++++++- ...m_convertToString_format_TypeMismatch.html | 8 +++++++- .../Calendar_addBatch_with_errorCallback.html | 8 +++++++- ...alendar_addBatch_with_successCallback.html | 8 +++++++- .../calendar/Calendar_find.html | 7 +++++++ .../calendar/Calendar_find_with_filter.html | 8 +++++++- ...dar_removeBatch_errorCallback_invoked.html | 8 +++++++- .../calendar/Calendar_updateBatch.html | 8 +++++++- ...dateBatch_taskType_with_optional_null.html | 7 +++++++ ...ateBatch_with_updateAllInstances_true.html | 8 +++++++- ...r_update_with_updateAllInstances_true.html | 8 +++++++- .../calendar/support/calendar_common.js | 20 +++++++++---------- 12 files changed, 87 insertions(+), 19 deletions(-) diff --git a/common/tct-calendar-tizen-tests/calendar/CalendarItemArraySuccessCallback_onsuccess.html b/common/tct-calendar-tizen-tests/calendar/CalendarItemArraySuccessCallback_onsuccess.html index 89d87e135..1a0a69d2f 100755 --- a/common/tct-calendar-tizen-tests/calendar/CalendarItemArraySuccessCallback_onsuccess.html +++ b/common/tct-calendar-tizen-tests/calendar/CalendarItemArraySuccessCallback_onsuccess.html @@ -53,6 +53,13 @@ var t = async_test(document.title), onsuccess, eventInit, calendar, ev; t.step(function () { + add_result_callback(function () { + try { + cleanup(calendar); + } catch (err) { + // do nothing in case cleanup throw an exception + } + }); onsuccess = t.step_func(function (items) { assert_type(items, "array", "items should be an array."); assert_greater_than(items.length, 0, "There should be any calendar in array."); @@ -76,7 +83,6 @@ t.step(function () { assert_own_property(items[0], "categories", "CalendarItem should have categories attribute."); assert_own_property(items[0], "attendees", "CalendarItem should have attendees attribute."); - cleanup(calendar); t.done(); }); eventInit = {description: "HTML5 Introduction", diff --git a/common/tct-calendar-tizen-tests/calendar/CalendarItem_convertToString_format_TypeMismatch.html b/common/tct-calendar-tizen-tests/calendar/CalendarItem_convertToString_format_TypeMismatch.html index 58d18f402..682d971d1 100755 --- a/common/tct-calendar-tizen-tests/calendar/CalendarItem_convertToString_format_TypeMismatch.html +++ b/common/tct-calendar-tizen-tests/calendar/CalendarItem_convertToString_format_TypeMismatch.html @@ -42,6 +42,13 @@ var t = async_test(document.title), calendar, start, end, rule, format, ev; t.step(function (){ + add_result_callback(function () { + try { + cleanup(calendar); + } catch (err) { + // do nothing in case cleanup throw an exception + } + }); onSuccess = t.step_func(function (events) { conversionTable = getTypeConversionExceptions("enum", false); for (i = 0; i < conversionTable.length; i++) { @@ -52,7 +59,6 @@ t.step(function (){ events[0].convertToString(format); }, exceptionName + " should be thrown - given incorrect format."); } - cleanup(calendar); t.done(); }); onError = t.step_func(function (error) { diff --git a/common/tct-calendar-tizen-tests/calendar/Calendar_addBatch_with_errorCallback.html b/common/tct-calendar-tizen-tests/calendar/Calendar_addBatch_with_errorCallback.html index 8b5b1c248..fcf6e236e 100755 --- a/common/tct-calendar-tizen-tests/calendar/Calendar_addBatch_with_errorCallback.html +++ b/common/tct-calendar-tizen-tests/calendar/Calendar_addBatch_with_errorCallback.html @@ -42,6 +42,13 @@ var t = async_test(document.title, {timeout: 5000}), events, eventCalendar, retu onAddBatchSuccessCB; t.step(function () { + add_result_callback(function () { + try { + cleanup(eventCalendar); + } catch (err) { + // do nothing in case cleanup throw an exception + } + }); eventCalendar = tizen.calendar.getDefaultCalendar("EVENT"); events = createTestEvents(); @@ -56,7 +63,6 @@ t.step(function () { "Add batch did not assign correctly"); assert_equals(response[1].description, events[1].description, "Add batch did not assign correctly"); - cleanup(eventCalendar); t.done(); }); diff --git a/common/tct-calendar-tizen-tests/calendar/Calendar_addBatch_with_successCallback.html b/common/tct-calendar-tizen-tests/calendar/Calendar_addBatch_with_successCallback.html index a2388efaa..2deb8bd02 100755 --- a/common/tct-calendar-tizen-tests/calendar/Calendar_addBatch_with_successCallback.html +++ b/common/tct-calendar-tizen-tests/calendar/Calendar_addBatch_with_successCallback.html @@ -41,6 +41,13 @@ Authors: var t = async_test(document.title, {timeout: 5000}), events, eventCalendar, onAddBatchSuccessCB, returnedValue = null; t.step(function () { + add_result_callback(function () { + try { + cleanup(eventCalendar); + } catch (err) { + // do nothing in case cleanup throw an exception + } + }); eventCalendar = tizen.calendar.getDefaultCalendar("EVENT"); events = createTestEvents(); @@ -51,7 +58,6 @@ t.step(function () { "Add batch did not assign correctly"); assert_equals(response[1].description, events[1].description, "Add batch did not assign correctly"); - cleanup(eventCalendar); t.done(); }); diff --git a/common/tct-calendar-tizen-tests/calendar/Calendar_find.html b/common/tct-calendar-tizen-tests/calendar/Calendar_find.html index bbdf005f5..acde62179 100755 --- a/common/tct-calendar-tizen-tests/calendar/Calendar_find.html +++ b/common/tct-calendar-tizen-tests/calendar/Calendar_find.html @@ -53,6 +53,13 @@ var t = async_test(document.title), eventSearchSuccessCallback, eventInit, calendar, ev, returnedValue = null; t.step(function (){ + add_result_callback(function () { + try { + cleanup(calendar); + } catch (err) { + // do nothing in case cleanup throw an exception + } + }); eventSearchSuccessCallback = t.step_func(function (events) { assert_equals(returnedValue, undefined, "Incorect returned value from find()"); assert_not_equals(events.length, 0, "Find() should find event."); diff --git a/common/tct-calendar-tizen-tests/calendar/Calendar_find_with_filter.html b/common/tct-calendar-tizen-tests/calendar/Calendar_find_with_filter.html index 73deda2e1..4ba9e32ed 100755 --- a/common/tct-calendar-tizen-tests/calendar/Calendar_find_with_filter.html +++ b/common/tct-calendar-tizen-tests/calendar/Calendar_find_with_filter.html @@ -41,6 +41,13 @@ var t = async_test(document.title), calendar, filter, onSuccess, onError, start, end, rule, ev, returnedValue = null; t.step(function (){ + add_result_callback(function () { + try { + cleanup(calendar); + } catch (err) { + // do nothing in case cleanup throw an exception + } + }); onSuccess = t.step_func(function (events) { assert_not_equals(events.length, 0, "find() should find event"); assert_true(events[0] instanceof tizen.CalendarEvent, @@ -48,7 +55,6 @@ t.step(function (){ assert_greater_than_equal(events[0].summary.indexOf("Tizen"), 0, "Tasks were not found properly"); assert_equals(returnedValue, undefined, "Incorect returned value from find()"); - cleanup(calendar); t.done(); }); onError = t.step_func(function (error) { diff --git a/common/tct-calendar-tizen-tests/calendar/Calendar_removeBatch_errorCallback_invoked.html b/common/tct-calendar-tizen-tests/calendar/Calendar_removeBatch_errorCallback_invoked.html index faa43ebf1..4552116ad 100755 --- a/common/tct-calendar-tizen-tests/calendar/Calendar_removeBatch_errorCallback_invoked.html +++ b/common/tct-calendar-tizen-tests/calendar/Calendar_removeBatch_errorCallback_invoked.html @@ -40,13 +40,19 @@ var t = async_test(document.title), calendar, eventInit1, eventInit2, ev1, ev2, getCalendar1, getCalendar2, successCallback, errorCallback, returnedValue = null; t.step(function () { + add_result_callback(function () { + try { + cleanup(calendar); + } catch (err) { + // do nothing in case cleanup throw an exception + } + }); successCallback = t.step_func(function () { assert_unreached("removeBatch() successCallaback should be not reached"); }); errorCallback = t.step_func(function (error) { assert_equals(returnedValue, undefined, "Incorect returned value from removeBatch()"); - cleanup(calendar); t.done(); }); diff --git a/common/tct-calendar-tizen-tests/calendar/Calendar_updateBatch.html b/common/tct-calendar-tizen-tests/calendar/Calendar_updateBatch.html index 0fff1ba51..e94626404 100755 --- a/common/tct-calendar-tizen-tests/calendar/Calendar_updateBatch.html +++ b/common/tct-calendar-tizen-tests/calendar/Calendar_updateBatch.html @@ -42,6 +42,13 @@ var t = async_test(document.title), addBatchSuccessCB, addBatchErrorCB, events = updateBatchErrorCB, findSuccessCB, findErrorCB, filter; t.step(function (){ + add_result_callback(function () { + try { + cleanup(calendar); + } catch (err) { + // do nothing in case cleanup throw an exception + } + }); findSuccessCB = t.step_func(function (events) { assert_equals(returnedValue, undefined, "Incorect returned value from updateBatch()"); assert_equals(events.length, 2, "Events were not found properly"); @@ -50,7 +57,6 @@ t.step(function (){ assert_equals(events[0].description, expected[events[0].id.uid], "description should be changed"); assert_equals(events[1].description, expected[events[1].id.uid], "description should be changed"); - cleanup(calendar); t.done(); }); findErrorCB = t.step_func(function (error) { diff --git a/common/tct-calendar-tizen-tests/calendar/Calendar_updateBatch_taskType_with_optional_null.html b/common/tct-calendar-tizen-tests/calendar/Calendar_updateBatch_taskType_with_optional_null.html index ddf8eeb9e..f7a2bbf10 100755 --- a/common/tct-calendar-tizen-tests/calendar/Calendar_updateBatch_taskType_with_optional_null.html +++ b/common/tct-calendar-tizen-tests/calendar/Calendar_updateBatch_taskType_with_optional_null.html @@ -44,6 +44,13 @@ var t = async_test(document.title), onAddBatchSuccessCB, taskCalendar; t.step(function () { + add_result_callback(function () { + try { + cleanup(taskCalendar); + } catch (err) { + // do nothing in case cleanup throw an exception + } + }); taskCalendar = tizen.calendar.getDefaultCalendar("TASK"); succCount = 3; diff --git a/common/tct-calendar-tizen-tests/calendar/Calendar_updateBatch_with_updateAllInstances_true.html b/common/tct-calendar-tizen-tests/calendar/Calendar_updateBatch_with_updateAllInstances_true.html index 87c678c67..dac02be56 100755 --- a/common/tct-calendar-tizen-tests/calendar/Calendar_updateBatch_with_updateAllInstances_true.html +++ b/common/tct-calendar-tizen-tests/calendar/Calendar_updateBatch_with_updateAllInstances_true.html @@ -39,8 +39,14 @@ var t = async_test(document.title), events = [], expLocation = "Nanjing", ev, eventInit, calendar, successCB, errorCB; t.step(function (){ + add_result_callback(function () { + try { + cleanup(calendar); + } catch (err) { + // do nothing in case cleanup throw an exception + } + }); successCB = t.step_func(function (events) { - cleanup(calendar); t.done(); }); diff --git a/common/tct-calendar-tizen-tests/calendar/Calendar_update_with_updateAllInstances_true.html b/common/tct-calendar-tizen-tests/calendar/Calendar_update_with_updateAllInstances_true.html index 795300236..a5e1b8fee 100755 --- a/common/tct-calendar-tizen-tests/calendar/Calendar_update_with_updateAllInstances_true.html +++ b/common/tct-calendar-tizen-tests/calendar/Calendar_update_with_updateAllInstances_true.html @@ -42,6 +42,13 @@ var t = async_test(document.title, {timeout: 90000}), eventInit, calendar, ev, setup({timeout: 90000}); t.step(function () { + add_result_callback(function () { + try { + cleanup(calendar); + } catch (err) { + // do nothing in case cleanup throw an exception + } + }); description = "Description Warsaw " + Math.random() + new Date().getTime(); eventInit = { @@ -73,7 +80,6 @@ t.step(function () { for (i = 0; i < events.length; i++) { assert_equals(events[i].summary, "updated summary", "Event was not updated."); } - cleanup(calendar); t.done(); }); diff --git a/common/tct-calendar-tizen-tests/calendar/support/calendar_common.js b/common/tct-calendar-tizen-tests/calendar/support/calendar_common.js index 15bfe980c..4f2bd0cb9 100755 --- a/common/tct-calendar-tizen-tests/calendar/support/calendar_common.js +++ b/common/tct-calendar-tizen-tests/calendar/support/calendar_common.js @@ -41,16 +41,16 @@ function events_to_ids(events) { } function cleanup(calendar) { - var ids = []; - calendar.find(function (found_events) { - var ids = events_to_ids(found_events); - if (ids.length > 0) { - calendar.removeBatch(ids); - console.log("cleanup: remove all events in calendar"); - } else { - console.log("cleanup: no events in calendar"); - } - }); + var ids = []; + calendar.find(function (found_events) { + var ids = events_to_ids(found_events); + if (ids.length > 0) { + calendar.removeBatch(ids); + console.log("cleanup: remove all events in calendar"); + } else { + console.log("cleanup: no events in calendar"); + } + }); } function assert_equalsArrays(array1, array2, compare, msg) { -- 2.34.1