[common][calendar][TSEVEN-3269 change cleanup() to add_result_callback] 88/282688/1
authorwei625.zhang <wei625.zhang@samsung.com>
Sun, 9 Oct 2022 07:10:06 +0000 (15:10 +0800)
committerwei625.zhang <wei625.zhang@samsung.com>
Sun, 9 Oct 2022 07:19:15 +0000 (15:19 +0800)
Change-Id: I0911e4b0cc5c0d2ba7021459e3cf58f9e24c0c14
Signed-off-by: wei625.zhang <wei625.zhang@samsung.com>
12 files changed:
common/tct-calendar-tizen-tests/calendar/CalendarItemArraySuccessCallback_onsuccess.html
common/tct-calendar-tizen-tests/calendar/CalendarItem_convertToString_format_TypeMismatch.html
common/tct-calendar-tizen-tests/calendar/Calendar_addBatch_with_errorCallback.html
common/tct-calendar-tizen-tests/calendar/Calendar_addBatch_with_successCallback.html
common/tct-calendar-tizen-tests/calendar/Calendar_find.html
common/tct-calendar-tizen-tests/calendar/Calendar_find_with_filter.html
common/tct-calendar-tizen-tests/calendar/Calendar_removeBatch_errorCallback_invoked.html
common/tct-calendar-tizen-tests/calendar/Calendar_updateBatch.html
common/tct-calendar-tizen-tests/calendar/Calendar_updateBatch_taskType_with_optional_null.html
common/tct-calendar-tizen-tests/calendar/Calendar_updateBatch_with_updateAllInstances_true.html
common/tct-calendar-tizen-tests/calendar/Calendar_update_with_updateAllInstances_true.html
common/tct-calendar-tizen-tests/calendar/support/calendar_common.js

index 89d87e135f616db2d5ff2d18923146e5e372faa3..1a0a69d2f7a3838dd0c5f21ccb9d69024ab8c540 100755 (executable)
@@ -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",
index 58d18f402d6ca72f5e7848d273aaf287e0571787..682d971d133d8eae79fdab159fef464b47d14e9f 100755 (executable)
@@ -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) {
index 8b5b1c2485dab421524feacf1f7d8b9669c14705..fcf6e236edf642e4556098683122c97bbab7b70d 100755 (executable)
@@ -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();
     });
 
index a2388efaaa31623bd5eed787d1d8658499cea2a5..2deb8bd02c374de708e58a8fd33490aadac403d1 100755 (executable)
@@ -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();
     });
 
index bbdf005f51d2661915e2be613a45fc6473a25058..acde62179e81e3bc72512a2ac3cd0899e2f0d4ae 100755 (executable)
@@ -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.");
index 73deda2e1dfddb1443ee07a6d26577d3295d32a7..4ba9e32eddf264040efa23a6e379bda71039cc28 100755 (executable)
@@ -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) {
index faa43ebf15f558a6668cc24cff98ae16a53b700f..4552116ad7080bf79f31cec0ef9d305a7ab89006 100755 (executable)
@@ -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();
     });
 
index 0fff1ba51ebdb642f9400598d7a9ec2cfaf1fca5..e94626404f53ec52089129ccc5ed889c0cfb214d 100755 (executable)
@@ -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) {
index ddf8eeb9ee84f39a15f64dc60154b32490f27a76..f7a2bbf10fa27bd0521b1255623c9185901182be 100755 (executable)
@@ -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;
index 87c678c6775bc00b7400e271d4123ac086f4f9f4..dac02be5694ef5524ffc98271fb1873cc26a53e9 100755 (executable)
@@ -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();
     });
 
index 795300236478d650dffd8fe049e47f7bd7d37354..a5e1b8feeba74483b2a9080fa370cbcf5d704654 100755 (executable)
@@ -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();
     });
 
index 15bfe980c76d4c3d8277dac57c2716553453621d..4f2bd0cb9604035a6cbb951cd5ebec590dc8f8f3 100755 (executable)
@@ -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) {