[common][tct-datacontrol-tizen-tests][DPTTIZEN-2901 Modify tc] 34/157434/1
authorxy.qian <xy.qian@samsung.com>
Tue, 24 Oct 2017 11:20:44 +0000 (19:20 +0800)
committerxy.qian <xy.qian@samsung.com>
Tue, 24 Oct 2017 11:20:44 +0000 (19:20 +0800)
Change-Id: Id82a7c7c907a6f0203bcad9a13813cc5a56ba6e3
Signed-off-by: xy.qian <xy.qian@samsung.com>
common/tct-datacontrol-tizen-tests/datacontrol/DataControlChangeCallback_onsuccess.html
common/tct-datacontrol-tizen-tests/datacontrol/DataControlConsumerObject_addChangeListener.html
common/tct-datacontrol-tizen-tests/datacontrol/DataControlConsumerObject_addChangeListener_with_errorCallback.html

index eb85e60f33b6a47ad12af7c3656e8dd037e185fb..69cc250f561a4208d9be4e1d21e8fadc3066481f 100644 (file)
@@ -43,7 +43,15 @@ setup({timeout: 30000});
 
 var t = async_test(document.title, {timeout: 30000}), globalDataControl, globalReqId = generateGlobalReqId(), watchId, currentDate = new Date().getTime().toString(),
     rowData, descriptionToSet = currentDate + "_desc", returnedValue = null, dataChangeSuccessCallback;
+
 t.step(function () {
+    add_result_callback(function (res) {
+        try {
+            globalDataControl.removeChangeListener(returnedValue);
+        } catch (err) {
+            // do nothing in case removeChangeListener throw an exception
+        }
+    });
 
     rowData = {
         columns: ["WORD", "WORD_DESC"],
@@ -51,16 +59,14 @@ t.step(function () {
     };
 
     dataChangeSuccessCallback = t.step_func(function (eventType, rowData) {
-        assert_equals(returnedValue, undefined, "Incorrect returned value");
+        assert_type(returnedValue, "long", "Incorrect returned value");
         assert_equals(eventType, "SQL_INSERT", "incorrect request eventType");
         assert_type(rowData, "object", "rowData is not object");
-        globalDataControl.removeChangeListener(watchId);
         t.done();
     });
 
     globalDataControl = tizen.datacontrol.getDataControlConsumer(PROVIDER_ID, DATA_ID, TYPE_SQL);
     returnedValue = globalDataControl.addChangeListener(dataChangeSuccessCallback);
-    alert(returnedValue);
     globalReqId++;
     globalDataControl.insert(globalReqId, rowData);
 });
index 441a682f3fa1a929b0a4b92f61ff2e761bbe4233..f452c8e46cfed05c04128380b6523ad3ff7e8b76 100644 (file)
@@ -41,7 +41,15 @@ setup({timeout: 30000});
 
 var t = async_test(document.title, {timeout: 30000}), globalDataControl, globalReqId = generateGlobalReqId(), watchId, currentDate = new Date().getTime().toString(),
     rowData, descriptionToSet = currentDate + "_desc", returnedValue = null, dataChangeSuccessCallback;
+
 t.step(function () {
+    add_result_callback(function (res) {
+        try {
+            globalDataControl.removeChangeListener(returnedValue);
+        } catch (err) {
+            // do nothing in case removeChangeListener throw an exception
+        }
+    });
 
     rowData = {
         columns: ["WORD", "WORD_DESC"],
@@ -49,7 +57,7 @@ t.step(function () {
     };
 
     dataChangeSuccessCallback = t.step_func(function (eventType, rowData) {
-        globalDataControl.removeChangeListener(watchId);
+        assert_type(returnedValue, "long", "Incorrect returned value");
         t.done();
     });
 
index 9f2490604cd217d72e89f79358d571d492ea2a25..4745a01f6a827d74b8baeb006d56225f66ffbfd4 100644 (file)
@@ -41,7 +41,15 @@ setup({timeout: 30000});
 
 var t = async_test(document.title, {timeout: 30000}), globalDataControl, globalReqId = generateGlobalReqId(), currentDate = new Date().getTime().toString(),
     rowData, descriptionToSet = currentDate + "_desc", returnedValue = null, dataChangeSuccessCallback, errorCallback;
+
 t.step(function () {
+    add_result_callback(function (res) {
+        try {
+            globalDataControl.removeChangeListener(returnedValue);
+        } catch (err) {
+            // do nothing in case removeChangeListener throw an exception
+        }
+    });
 
     rowData = {
         columns: ["WORD", "WORD_DESC"],
@@ -53,9 +61,10 @@ t.step(function () {
     });
 
     dataChangeSuccessCallback = t.step_func(function (eventType, rowData) {
-        assert_equals(returnedValue, undefined, "Incorrect returned value");
+        assert_type(returnedValue, "long", "Incorrect returned value");
         assert_equals(eventType, "SQL_INSERT", "incorrect request eventType");
         assert_type(rowData, "object", "rowData is not object");
+        t.done();
     });
 
     globalDataControl = tizen.datacontrol.getDataControlConsumer(PROVIDER_ID, DATA_ID, TYPE_SQL);