[common][iotcon][Fix tc issue about TSAM-13309] 39/132039/1
authoryuanzhongyuan <zy123.yuan@samsung.com>
Thu, 1 Jun 2017 01:07:03 +0000 (09:07 +0800)
committeryuanzhongyuan <zy123.yuan@samsung.com>
Thu, 1 Jun 2017 01:07:03 +0000 (09:07 +0800)
Change-Id: Ibf70d348d611b56e79188e5562d09fbe7e2551bf

20 files changed:
common/tct-iotcon-tizen-tests/iotcon/CacheUpdatedCallback_onupdated.html
common/tct-iotcon-tizen-tests/iotcon/RemoteResourceResponseCallback_onsuccess.html
common/tct-iotcon-tizen-tests/iotcon/RemoteResource_methodDelete.html
common/tct-iotcon-tizen-tests/iotcon/RemoteResource_methodDelete_with_errorCallback.html
common/tct-iotcon-tizen-tests/iotcon/RemoteResource_methodGet.html
common/tct-iotcon-tizen-tests/iotcon/RemoteResource_methodGet_with_errorCallback.html
common/tct-iotcon-tizen-tests/iotcon/RemoteResource_methodPost.html
common/tct-iotcon-tizen-tests/iotcon/RemoteResource_methodPost_with_errorCallback.html
common/tct-iotcon-tizen-tests/iotcon/RemoteResource_methodPut.html
common/tct-iotcon-tizen-tests/iotcon/RemoteResource_methodPut_with_errorCallback.html
common/tct-iotcon-tizen-tests/iotcon/RemoteResource_startCaching.html
common/tct-iotcon-tizen-tests/iotcon/RemoteResource_startCaching_with_updatedCallback.html
common/tct-iotcon-tizen-tests/iotcon/RemoteResource_startObserving.html
common/tct-iotcon-tizen-tests/iotcon/RemoteResource_startObserving_with_query.html
common/tct-iotcon-tizen-tests/iotcon/RemoteResource_timeInterval_attribute.html
common/tct-iotcon-tizen-tests/iotcon/RemoteResource_unsetResourceStateChangeListener.html
common/tct-iotcon-tizen-tests/iotcon/RemoteResponse_options_attribute.html
common/tct-iotcon-tizen-tests/iotcon/RemoteResponse_representation_attribute.html
common/tct-iotcon-tizen-tests/iotcon/RemoteResponse_result_attribute.html
common/tct-iotcon-tizen-tests/iotcon/support/iotcon_common.js

index 7daa3cb17498f9f050ca5df76cae0f677ccec2a1..4674557f81c374f20d70e0fed19eaed32749336c 100755 (executable)
@@ -41,6 +41,13 @@ var t = async_test(document.title, {timeout: 30000}), query = {}, client, onFoun
     onError, onResponse, representation, remoteResource, onUpdate;
 
 t.step(function () {
+    add_result_callback(function(){
+        try{
+            Remove_Resource();
+        }catch(err){
+        }
+    });
+
     onError = t.step_func(function(error) {
         assert_unreached("Error occured: " + error.name);
     });
@@ -73,6 +80,7 @@ t.step(function () {
     });
 
     iotInit();
+    Create_Resource();
     client = tizen.iotcon.getClient();
     query.resourceType = "core.light";
     client.findResource(null, query, "ALL", onFoundSuccess);
index 24fdacdebba27b31851a9c2dbc392aaa509cf94b..726278d6e4b2587467c06386959e56b4014e207f 100755 (executable)
@@ -38,6 +38,13 @@ Authors:
 var t = async_test(document.title), onresponse, client, foundSuccess, query = {};
 
 t.step(function () {
+    add_result_callback(function(){
+        try{
+            Remove_Resource();
+        }catch(err){
+        }
+    });
+
     onresponse = t.step_func(function (remoteResponse) {
         assert_type(remoteResponse, "object", "remoteResponse should be an object.");
         assert_own_property(remoteResponse, "result", "remoteResponse should have result property.");
@@ -51,6 +58,7 @@ t.step(function () {
     });
 
     iotInit();
+    Create_Resource();
     client = tizen.iotcon.getClient();
     query.resourceType = "core.light";
     client.findResource(null, query, "ALL", foundSuccess);
index cb98f257a61a429a753f528c8c0529c6f393b102..c228c923dd06ad989fe0daac5a65520ae53566e1 100755 (executable)
@@ -40,6 +40,13 @@ setup({timeout: 30000});
 var t = async_test(document.title, {timeout: 30000}), client, onFoundSuccess, onResponse, retVal, query = {};
 
 t.step(function () {
+    add_result_callback(function(){
+        try{
+            Remove_Resource();
+        }catch(err){
+        }
+    });
+
     onResponse = t.step_func(function(remoteResponse) {
         assert_equals(retVal, undefined, "Returned value of methodDelete method should be undefined");
         t.done();
@@ -50,6 +57,7 @@ t.step(function () {
     });
 
     iotInit();
+    Create_Resource();
     client = tizen.iotcon.getClient();
     query.resourceType = "core.light";
     client.findResource(null, query, "ALL", onFoundSuccess);
index fa4bee3f4dfe4e91234bc306551212b7974a9a33..900444fd0d06dccc8f68fc825e37fd40f5755e3c 100755 (executable)
@@ -41,6 +41,13 @@ setup({timeout: 30000});
 var t = async_test(document.title, {timeout: 30000}), client, onFoundSuccess, onResponse, onError, retVal, query = {};
 
 t.step(function () {
+    add_result_callback(function(){
+        try{
+            Remove_Resource();
+        }catch(err){
+        }
+    });
+
     onResponse = t.step_func(function(remoteResponse) {
         assert_equals(retVal, undefined, "Returned value of methodDelete method should be undefined");
         t.done();
@@ -55,6 +62,7 @@ t.step(function () {
     });
 
     iotInit();
+    Create_Resource();
     client = tizen.iotcon.getClient();
     query.resourceType = "core.light";
     client.findResource(null, query, "ALL", onFoundSuccess);
index ba3cb9944a5eeba6720aaeae40ffc5de7a65b8e1..cdb9a2246fd806b72db256e45d01ccf22eb2e59f 100755 (executable)
@@ -41,6 +41,13 @@ setup({timeout: 30000});
 var t = async_test(document.title, {timeout: 30000}), client, onFoundSuccess, onResponse, retVal, query = {};
 
 t.step(function () {
+    add_result_callback(function(){
+        try{
+            Remove_Resource();
+        }catch(err){
+        }
+    });
+
     onResponse = t.step_func(function(remoteResponse) {
         assert_equals(retVal, undefined, "Returned value of methodDelete method should be undefined");
         t.done();
@@ -51,6 +58,7 @@ t.step(function () {
     });
 
     iotInit();
+    Create_Resource();
     client = tizen.iotcon.getClient();
     query.resourceType = "core.light";
     client.findResource(null, query, "ALL", onFoundSuccess);
index 57e6a97b846eacbf49ce031bbc7db4b75dfef83b..21e948ce6fa86d6cdb385cd7578206528b371620 100755 (executable)
@@ -41,6 +41,13 @@ setup({timeout: 30000});
 var t = async_test(document.title, {timeout: 30000}), client, onFoundSuccess, onResponse, retVal, query = {};
 
 t.step(function () {
+    add_result_callback(function(){
+        try{
+            Remove_Resource();
+        }catch(err){
+        }
+    });
+
     onResponse = t.step_func(function(remoteResponse) {
         assert_equals(retVal, undefined, "Returned value of methodDelete method should be undefined");
         t.done();
@@ -55,6 +62,7 @@ t.step(function () {
     });
 
     iotInit();
+    Create_Resource();
     client = tizen.iotcon.getClient();
     query.resourceType = "core.light";
     client.findResource(null, query, "ALL", onFoundSuccess);
index 4e506172e219621de6451f2d394e05d0abcdad1e..907fc1a6cb6318a1a39e9ffe34efc0ca49643040 100755 (executable)
@@ -41,6 +41,13 @@ setup({timeout: 30000});
 var t = async_test(document.title, {timeout: 30000}), client, onFoundSuccess, onResponse, retVal, query = {};
 
 t.step(function () {
+    add_result_callback(function(){
+        try{
+            Remove_Resource();
+        }catch(err){
+        }
+    });
+
     onResponse = t.step_func(function(remoteResponse) {
         assert_equals(retVal, undefined, "Returned value of methodDelete method should be undefined");
         t.done();
@@ -55,6 +62,7 @@ t.step(function () {
     });
 
     iotInit();
+    Create_Resource();
     client = tizen.iotcon.getClient();
     query.resourceType = "core.light";
     client.findResource(null, query, "ALL", onFoundSuccess);
index 1b93be64c3a9cdaa3e9b6312f5abebd523d443ff..68e90330d38ffd3eb1f900e1055ee9c7efdb4d6b 100755 (executable)
@@ -41,6 +41,13 @@ setup({timeout: 30000});
 var t = async_test(document.title, {timeout: 30000}), client, onFoundSuccess, onResponse, onError, retVal, query = {};
 
 t.step(function () {
+    add_result_callback(function(){
+        try{
+            Remove_Resource();
+        }catch(err){
+        }
+    });
+
     onResponse = t.step_func(function(remoteResponse) {
         assert_equals(retVal, undefined, "Returned value of methodDelete method should be undefined");
         t.done();
@@ -59,6 +66,7 @@ t.step(function () {
     });
 
     iotInit();
+    Create_Resource();
     client = tizen.iotcon.getClient();
     query.resourceType = "core.light";
     client.findResource(null, query, "ALL", onFoundSuccess);
index 522cb22bc7e5b09d1869a59faeb0c52326c2a22b..6bf8b17944676b41b87686a738dcdaf7c1d06193 100755 (executable)
@@ -41,6 +41,13 @@ setup({timeout: 30000});
 var t = async_test(document.title, {timeout: 30000}), client, onFoundSuccess, onResponse, retVal, query = {};
 
 t.step(function () {
+    add_result_callback(function(){
+        try{
+            Remove_Resource();
+        }catch(err){
+        }
+    });
+
     onResponse = t.step_func(function(remoteResponse) {
         assert_equals(retVal, undefined, "Returned value of methodDelete method should be undefined");
         t.done();
@@ -55,6 +62,7 @@ t.step(function () {
     });
 
     iotInit();
+    Create_Resource();
     client = tizen.iotcon.getClient();
     query.resourceType = "core.light";
     client.findResource(null, query, "ALL", onFoundSuccess);
index 2ffaa60177298f73686435bfb6aff8ce860d0b1e..92932a35a9dd464bcbaedbda45aa6f5e397ca753 100755 (executable)
@@ -41,6 +41,13 @@ setup({timeout: 30000});
 var t = async_test(document.title, {timeout: 30000}), client, onFoundSuccess, onResponse, onError, retVal, requestListener, query = {};
 
 t.step(function () {
+    add_result_callback(function(){
+        try{
+            Remove_Resource();
+        }catch(err){
+        }
+    });
+
     onResponse = t.step_func(function(remoteResponse) {
         assert_equals(retVal, undefined, "Returned value of methodDelete method should be undefined");
         t.done();
@@ -59,6 +66,7 @@ t.step(function () {
     });
 
     iotInit();
+    Create_Resource();
     client = tizen.iotcon.getClient();
     query.resourceType = "core.light";
     client.findResource(null, query, "ALL", onFoundSuccess);
index b109ecb24242bc7fe6036f17a65434ee8c2f26d6..a273b5aede927304fb54421019362e77f29e786a 100755 (executable)
@@ -41,6 +41,12 @@ setup({timeout: 30000});
 var t = async_test(document.title, {timeout: 30000}), client, onFoundSuccess, retVal, query = {};
 
 t.step(function () {
+    add_result_callback(function(){
+        try{
+            Remove_Resource();
+        }catch(err){
+        }
+    });
 
     onFoundSuccess = t.step_func(function(resource) {
         retVal = resource.startCaching();
@@ -50,6 +56,7 @@ t.step(function () {
     });
 
     iotInit();
+    Create_Resource();
     client = tizen.iotcon.getClient();
     query.resourceType = "core.light";
     client.findResource(null, query, "ALL", onFoundSuccess);
index 949d04517b8fe32356cfb952169f2486d7ed9ab7..a102f003cb97da18ec9f70b5f5c658041a39c861 100755 (executable)
@@ -40,6 +40,13 @@ setup({timeout: 30000});
 var t = async_test(document.title, {timeout: 30000}), client, onFoundSuccess, retVal, onUpdated, query = {};
 
 t.step(function () {
+    add_result_callback(function(){
+        try{
+            Remove_Resource();
+        }catch(err){
+        }
+    });
+
     onUpdated = t.step_func(function() {
     });
 
@@ -51,6 +58,7 @@ t.step(function () {
     });
 
     iotInit();
+    Create_Resource();
     client = tizen.iotcon.getClient();
     query.resourceType = "core.light";
     client.findResource(null, query, "ALL", onFoundSuccess);
index 63cf782eb71d1814e34368a74d28427b63094e9c..b88e57fe34d956a25ff860f3eba738dacce141fe 100755 (executable)
@@ -41,6 +41,13 @@ setup({timeout: 30000});
 var t = async_test(document.title, {timeout: 30000}), client, onFoundSuccess, onResponse, retVal, query = {};
 
 t.step(function () {
+    add_result_callback(function(){
+        try{
+            Remove_Resource();
+        }catch(err){
+        }
+    });
+
     onResponse = t.step_func(function(remoteResponse) {
         assert_equals(retVal, undefined, "Returned value of methodDelete method should be undefined");
         t.done();
@@ -51,6 +58,7 @@ t.step(function () {
     });
 
     iotInit();
+    Create_Resource();
     client = tizen.iotcon.getClient();
     query.resourceType = "core.light";
     client.findResource(null, query, "ALL", onFoundSuccess);
index 2348123c4d0af707462638bb2f697b91255f9967..eccfb75c540146865afe7b1484aae2d27a7b58ca 100755 (executable)
@@ -40,6 +40,13 @@ setup({timeout: 30000});
 var t = async_test(document.title, {timeout: 30000}), client, onFoundSuccess, onResponse, retVal, query = {};
 
 t.step(function () {
+    add_result_callback(function(){
+        try{
+            Remove_Resource();
+        }catch(err){
+        }
+    });
+
     onResponse = t.step_func(function(remoteResponse) {
         assert_equals(retVal, undefined, "Returned value of methodDelete method should be undefined");
         t.done();
@@ -50,6 +57,7 @@ t.step(function () {
     });
 
     iotInit();
+    Create_Resource();
     client = tizen.iotcon.getClient();
     query.resourceType = "core.light";
     client.findResource(null, query, "ALL", onFoundSuccess);
index 37ba316c9c415cf5ca646e7435be5ba2e728f854..2ecf76ed223d198f8070cdef6400e28443ed1386 100755 (executable)
@@ -53,7 +53,7 @@ t.step(function () {
     iotInit();
     client = tizen.iotcon.getClient();
     client.findResource(null, null, "ALL", onFoundSuccess, onError);
-});s
+});
 </script>
 </body>
 </html>
index 2ab4941f59ec84e9427bf7df764dec2ce7014198..54a8a6c4800caf9499a8e89ca9b13c1cfcb1b91f 100755 (executable)
@@ -41,6 +41,13 @@ setup({timeout: 30000});
 var t = async_test(document.title, {timeout: 30000}), client, onFoundSuccess, onError, onChanged, retVal, query = {};
 
 t.step(function () {
+    add_result_callback(function(){
+        try{
+            Remove_Resource();
+        }catch(err){
+        }
+    });
+
     onChanged = t.step_func(function(isActive) {
         assert_unreached("Error occured: " + error.name);
     });
@@ -53,6 +60,7 @@ t.step(function () {
     });
 
     iotInit();
+    Create_Resource();
     client = tizen.iotcon.getClient();
     query.resourceType = "core.light";
     client.findResource(null, query, "ALL", onFoundSuccess);
index b1109f2c4389fa7c185f707fdc317d98e0356cf0..2e6865b8ea10369878a91fba06d5a313a79c0abc 100755 (executable)
@@ -40,6 +40,13 @@ setup({timeout: 30000});
 var t = async_test(document.title, {timeout: 30000}), client, onFoundSuccess, onResponse, query = {};
 
 t.step(function () {
+    add_result_callback(function(){
+        try{
+            Remove_Resource();
+        }catch(err){
+        }
+    });
+
     onResponse = t.step_func(function(remoteResponse) {
         check_readonly(remoteResponse, "options", remoteResponse.options, "array", new tizen.IotconOption(3000, "12345"));
         t.done();
@@ -50,6 +57,7 @@ t.step(function () {
     });
 
     iotInit();
+    Create_Resource();
     client = tizen.iotcon.getClient();
     query.resourceType = "core.light";
     client.findResource(null, query, "ALL", onFoundSuccess);
index b4668a397ab3baf7ca3967856a1434fa3e23610a..76ddd26088da29e5a5f2c7845ea7c56edaa13b87 100755 (executable)
@@ -40,6 +40,13 @@ setup({timeout: 30000});
 var t = async_test(document.title, {timeout: 30000}), client, onFoundSuccess, onResponse, query = {};
 
 t.step(function () {
+    add_result_callback(function(){
+        try{
+            Remove_Resource();
+        }catch(err){
+        }
+    });
+
     onResponse = t.step_func(function(remoteResponse) {
         check_readonly(remoteResponse, "representation", remoteResponse.representation, "object", null);
         t.done();
@@ -50,6 +57,7 @@ t.step(function () {
     });
 
     iotInit();
+    Create_Resource();
     client = tizen.iotcon.getClient();
     query.resourceType = "core.light";
     client.findResource(null, query, "ALL", onFoundSuccess);
index c62b22c67eb9a8c8526e10eb3f8564998bca225e..c529979877bfd9450f9ef9543d7bfab89eb0fc50 100755 (executable)
@@ -40,6 +40,13 @@ setup({timeout: 30000});
 var t = async_test(document.title, {timeout: 30000}), client, onFoundSuccess, onResponse, query = {};
 
 t.step(function () {
+    add_result_callback(function(){
+        try{
+            Remove_Resource();
+        }catch(err){
+        }
+    });
+
     onResponse = t.step_func(function(remoteResponse) {
         check_readonly(remoteResponse, "result", remoteResponse.result, "string", "FORBIDDEN");
         assert_in_array(remoteResponse.result, ["SUCCESS", "ERROR", "RESOURCE_CREATED", "RESOURCE_DELETED", "SLOW", "FORBIDDEN"], "Incorrect value of type");
@@ -51,6 +58,7 @@ t.step(function () {
     });
 
     iotInit();
+    Create_Resource();
     client = tizen.iotcon.getClient();
     query.resourceType = "core.light";
     client.findResource(null, query, "ALL", onFoundSuccess);
index bea855608dc9322a57aefe26d5efb5e373be85bb..1e9e49e1dbf6e4090c53e2aa91aac254f8fdafb0 100755 (executable)
@@ -32,7 +32,7 @@ function Create_Resource() {
     resourceInterfaces = ["oic.if.b"];
     requestListener = {
         onget: function(request) {
-            representation = new tizen.Presentation(uriPath);
+            representation = new tizen.Representation(uriPath);
             representation.resourceTypes = ["core.light"];
             representation.resourceInterfaces = ["oic.if.b"];
             representation.attributes = {};
@@ -44,7 +44,6 @@ function Create_Resource() {
         onput:function(request) {
             var response = new tizen.Response(request);
             try {
-                resource.attributes = request.representation.attributes;
                 response.representation = request.representation;
                 response.result = 'RESOURCE_CHANGED';
                 response.send();
@@ -58,7 +57,6 @@ function Create_Resource() {
                 var uri = request.representation.uriPath;
                 if (uri == '/kitchen/light') {
                     //put attibute value
-                    resource.attributes = request.representation.attributes;
                     response.representation = request.representation;
                     response.result = 'RESOURCE_CHANGED';
                 }else{
@@ -67,11 +65,8 @@ function Create_Resource() {
                     var resourceTypes = ['core.light'];
                     var resourceInterfaces = ['oic.if.b'];
                     var attributes = { lightState: 'off' };
-                    that.addResource( newUriPath, resourceTypes, resourceInterfaces, attributes);
                     response.result = 'RESOURCE_CREATED';
 
-                    ui.listResourceURIPaths(that.resources);   //update UI
-
                     var representation = new tizen.Representation(newUriPath);
                     //set response representation.
                     representation.resourceTypes = resourceTypes;
@@ -92,10 +87,18 @@ function Create_Resource() {
             }
         },
         ondelete:function(request) {
-            var response = new tizen.Response(request);
-            response.representation = request.representation;
-            response.result = 'ERROR';
-            response.send();
+            try{
+                representation = new tizen.Representation(uriPath);
+                representation.resourceTypes = ["core.light"];
+                representation.resourceInterfaces = ["oic.if.b"];
+                representation.attributes = {};
+                response = new tizen.Response(request);
+                response.representation = representation;
+                response.result = 'ERROR';
+                response.send();
+            } catch (err) {
+                console.log('Failed to send a response: ' + err.name + ', ' + err.message);
+            }
         },
         onobserving: function(request, observeType, observeId) {
         }