[Messageport] removing registered listeners
authorMariusz Polasinski <m.polasinski@samsung.com>
Tue, 20 Aug 2013 10:55:34 +0000 (12:55 +0200)
committerGerrit Code Review <gerrit@gerrit.vlan144.tizendev.org>
Wed, 21 Aug 2013 06:51:58 +0000 (06:51 +0000)
Change-Id: I4010f964ff5f211cd628040a5c900265d04e4ad8

tct-messageport-tizen-tests/messageport/LocalMessagePort_addMessagePortListener.html
tct-messageport-tizen-tests/messageport/LocalMessagePort_addMessagePortListener_listener_TypeMismatch.html
tct-messageport-tizen-tests/messageport/LocalMessagePort_addMessagePortListener_listener_invalid_cb.html
tct-messageport-tizen-tests/messageport/LocalMessagePort_addMessagePortListener_missarg.html
tct-messageport-tizen-tests/messageport/LocalMessagePort_removeMessagePortListener.html
tct-messageport-tizen-tests/messageport/MessagePortCallback_onreceived.html
tct-messageport-tizen-tests/messageport/MessagePortCallback_onreceived_all.html
tct-messageport-tizen-tests/messageport/RemoteMessagePort_sendMessage.html
tct-messageport-tizen-tests/messageport/RemoteMessagePort_sendMessage_with_localMessagePort.html

index 2f29a09131cd71bfdea957002d7269a4a386bfe9..4b536a8f03e71282d8932548878551a8d7dc5d66 100644 (file)
@@ -37,7 +37,7 @@ Authors:
 var t = async_test("LocalMessagePort_addMessagePortListener");
 
 t.step(function () {
-    var remoteMsgPort, localMsgPort, onReceived, id,
+    var remoteMsgPort, localMsgPort, onReceived, listenerId,
         messagePortData = [{key:"RESULT", value:"OK"}],
         app = tizen.application.getCurrentApplication();
 
@@ -46,14 +46,15 @@ t.step(function () {
         assert_equals(data.length, 1, "There should be MessagePortDataItem");
         assert_array_equals(data[0], messagePortData[0],
             "Received data should be equal to init data.");
-        assert_not_equals(id, null, "id should be not null");
-        assert_type(id, "number", "id of MessagePortListener should be type of number.");
+        assert_not_equals(listenerId, null, "id should be not null");
+        assert_type(listenerId, "long", "id of MessagePortListener should be type of number.");
+        localMsgPort.removeMessagePortListener(listenerId);
         t.done();
     });
 
     localMsgPort = tizen.messageport.requestLocalMessagePort("remoteMsgPort");
     remoteMsgPort = tizen.messageport.requestRemoteMessagePort(app.appInfo.id, "remoteMsgPort");
-    id = localMsgPort.addMessagePortListener(onReceived);
+    listenerId = localMsgPort.addMessagePortListener(onReceived);
 
     remoteMsgPort.sendMessage(messagePortData);
 });
index 0700a893423daf8c338980da569baa56922318df..ccb4e4751dc62ffcea7e3bb69c8e92ad2ee49c5a 100644 (file)
@@ -36,7 +36,7 @@ Authors:
 //==== SPEC_URL https://developer.tizen.org/help/index.jsp?topic=/org.tizen.web.device.apireference/tizen/messageport.html
 //==== TEST_CRITERIA MC
 test(function () {
-    var localMsgPort, id, conversionTable, param, exceptionName, i;
+    var localMsgPort, conversionTable, param, exceptionName, i;
 
     localMsgPort = tizen.messageport.requestLocalMessagePort("localMsgPort");
 
@@ -47,7 +47,7 @@ test(function () {
 
         assert_throws({name : exceptionName},
             function () {
-                id = localMsgPort.addMessagePortListener(param);
+                localMsgPort.addMessagePortListener(param);
             }, exceptionName + " should be thrown - given incorrect.");
     }
 }, "LocalMessagePort_addMessagePortListener_listener_TypeMismatch");
index eaf97a4170cfde8dc919580b64b3dc12925b7131..5f54cfba3b125af8df44fa72306c8ac5840457ca 100644 (file)
@@ -38,7 +38,7 @@ Authors:
 var t = async_test("LocalMessagePort_addMessagePortListener_listener_invalid_cb");
 
 t.step(function () {
-    var localMsgPort, id, incorrectCallback;
+    var localMsgPort, incorrectCallback;
 
     localMsgPort = tizen.messageport.requestLocalMessagePort("localMsgPort");
 
@@ -50,7 +50,7 @@ t.step(function () {
 
     assert_throws({name: "TypeMismatchError"},
         function () {
-            id = localMsgPort.addMessagePortListener(incorrectCallback);
+            localMsgPort.addMessagePortListener(incorrectCallback);
         });
 
     t.done();
index 3c56e88a93b23a70fca4c5fa572c337628d25b33..b53e51ca682edb9446a5a1c09c7be4caaceba583 100644 (file)
@@ -35,13 +35,13 @@ Authors:
 //==== SPEC_URL https://developer.tizen.org/help/index.jsp?topic=/org.tizen.web.device.apireference/tizen/messageport.html
 //==== TEST_CRITERIA MMA
 test(function () {
-    var localMsgPort, id;
+    var localMsgPort;
 
     localMsgPort = tizen.messageport.requestLocalMessagePort("localMsgPort");
 
     assert_throws({name: "TypeMismatchError"},
         function () {
-            id = localMsgPort.addMessagePortListener();
+            localMsgPort.addMessagePortListener();
         }, "TypeMismatchError should be thrown");
 
 }, "LocalMessagePort_addMessagePortListener_missarg");
index 6ccf63b15d78330ee8da6d177123cf7b6de841d8..061f21bd879a03bb5b6e8993c50c5825acb5ebe9 100644 (file)
@@ -34,7 +34,7 @@ Authors:
 //==== SPEC Tizen Web API:IO:Messageport:LocalMessagePort:removeMessagePortListener M
 //==== SPEC_URL https://developer.tizen.org/help/index.jsp?topic=/org.tizen.web.device.apireference/tizen/messageport.html
 //==== TEST_CRITERIA MMINA MAST MR
-var t = async_test("LocalMessagePort_removeMessagePortListener"), localMsgPort, remoteMsgPort, id, onReceived,
+var t = async_test("LocalMessagePort_removeMessagePortListener"), localMsgPort, remoteMsgPort, listenerId, onReceived,
         app = tizen.application.getCurrentApplication(), messagePortData = [{key:"RESULT", value:"OK"}], retValue = null;
 
 t.step(function () {
@@ -43,13 +43,13 @@ t.step(function () {
     onReceived = t.step_func(function (data) {
         assert_unreached("Callback should be unregistered.");
     });
-    id = localMsgPort.addMessagePortListener(onReceived);
-    retValue = localMsgPort.removeMessagePortListener(id);
+    listenerId = localMsgPort.addMessagePortListener(onReceived);
+    retValue = localMsgPort.removeMessagePortListener(listenerId);
 
     remoteMsgPort = tizen.messageport.requestRemoteMessagePort(app.appInfo.id, "remoteMsgPort");
     remoteMsgPort.sendMessage(messagePortData);
 
-    setTimeout(t.step_func(function() {
+    setTimeout(t.step_func(function () {
         assert_equals(retValue, undefined, "removeMessagePortListener returns wrong value");
 
         t.done();
index a8a3d2b6c69b47a97095abb658a75159c5f8eaa4..04aa90ced0d3df5fd9ea0748f593dc2090ded066 100644 (file)
@@ -37,7 +37,7 @@ Authors:
 var t = async_test("MessagePortCallback_onreceived");
 
 t.step(function () {
-    var remoteMsgPort, localMsgPort, onReceived,
+    var remoteMsgPort, localMsgPort, onReceived, listenerId,
         messagePortData = [{key:"RESULT",value:"OK"}],
         app = tizen.application.getCurrentApplication();
 
@@ -48,12 +48,14 @@ t.step(function () {
 
         assert_equals(data[0].key, messagePortData[0].key, "received data should be the same");
         assert_equals(data[0].value, messagePortData[0].value, "received data should be the same");
+
+        localMsgPort.removeMessagePortListener(listenerId);
         t.done();
     });
 
     localMsgPort = tizen.messageport.requestLocalMessagePort("remoteMsgPort");
     remoteMsgPort = tizen.messageport.requestRemoteMessagePort(app.appInfo.id, "remoteMsgPort");
-    localMsgPort.addMessagePortListener(onReceived);
+    listenerId = localMsgPort.addMessagePortListener(onReceived);
 
     remoteMsgPort.sendMessage(messagePortData);
 });
index e4844dfd5bfda6d2de052c17f98750b4890e692d..108d722e40ccd3e61d63b15468fed4fdbe1b3878 100644 (file)
@@ -37,7 +37,7 @@ Authors:
 var t = async_test("MessagePortCallback_onreceived_all");
 
 t.step(function () {
-    var remoteMsgPort, localMsgPort, onReceived,
+    var remoteMsgPort, localMsgPort, onReceived, listenerId,
         messagePortData = [{key:"RESULT",value:"OK"}],
         app = tizen.application.getCurrentApplication();
 
@@ -45,12 +45,13 @@ t.step(function () {
         assert_equals(data.key, messagePortData.key, "received data should be the same");
         assert_equals(data.value, messagePortData.value, "received data should be the same");
         assert_not_equals(remoteMessagePort, null, "remoteMessagePort should be not null}");
+        localMsgPort.removeMessagePortListener(listenerId);
         t.done();
     });
 
     localMsgPort = tizen.messageport.requestLocalMessagePort("remoteMsgPort");
     remoteMsgPort = tizen.messageport.requestRemoteMessagePort(app.appInfo.id, "remoteMsgPort");
-    localMsgPort.addMessagePortListener(onReceived);
+    listenerId = localMsgPort.addMessagePortListener(onReceived);
 
     remoteMsgPort.sendMessage(messagePortData, localMsgPort);
 });
index 079383db9ec0b18585f27dcbf8d43586e580d581..2e936a548b37f0f759cb414e3987ac49cfa3a380 100644 (file)
@@ -37,19 +37,20 @@ Authors:
 var t = async_test("RemoteMessagePort_sendMessage"), retValue = null;
 
 t.step(function () {
-    var remoteMsgPort, localMsgPort, onReceived,
+    var remoteMsgPort, localMsgPort, onReceived, listenerId,
         messagePortData = [{key:"RESULT",value:"OK"}],
         app = tizen.application.getCurrentApplication();
 
     onReceived = t.step_func(function (data) {
         assert_equals(data.key, messagePortData.key, "received data should be the same");
         assert_equals(data.value, messagePortData.value, "received data should be the same");
+        localMsgPort.removeMessagePortListener(listenerId);
         t.done();
     });
 
     localMsgPort = tizen.messageport.requestLocalMessagePort("remoteMsgPort");
     remoteMsgPort = tizen.messageport.requestRemoteMessagePort(app.appInfo.id, "remoteMsgPort");
-    localMsgPort.addMessagePortListener(onReceived);
+    listenerId = localMsgPort.addMessagePortListener(onReceived);
 
     retValue = remoteMsgPort.sendMessage(messagePortData);
     assert_equals(retValue, undefined, "sendMessage returns wrong value");
index ba7c5801e920e7ba58f72ebdd9755b950e1bc094..ca894d018b87045d9bebe30b8c50aeb7ec63979f 100644 (file)
@@ -37,7 +37,7 @@ Authors:
 var t = async_test("RemoteMessagePort_sendMessage_with_localMessagePort");
 
 t.step(function () {
-    var remoteMsgPort, localMsgPort, onReceived,
+    var remoteMsgPort, localMsgPort, onReceived, listenerId,
         messagePortData = [{key:"RESULT", value:"OK"}],
         app = tizen.application.getCurrentApplication();
 
@@ -50,13 +50,14 @@ t.step(function () {
         if (remoteMessagePort !== null) {
             remoteMessagePort.sendMessage(messagePortData);
         } else {
+            localMsgPort.removeMessagePortListener(listenerId);
             t.done();
         }
     });
 
     localMsgPort = tizen.messageport.requestLocalMessagePort("remoteMsgPort");
     remoteMsgPort = tizen.messageport.requestRemoteMessagePort(app.appInfo.id, "remoteMsgPort");
-    localMsgPort.addMessagePortListener(onReceived);
+    listenerId = localMsgPort.addMessagePortListener(onReceived);
 
     remoteMsgPort.sendMessage(messagePortData, localMsgPort);
 });