Commit cacd2161 authored by Vivek's avatar Vivek

renderjs interface primary testcases

parent b86a5d5d
......@@ -75,7 +75,7 @@
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>rjs_test_correct_implemented_gadget.html</string> </value>
<value> <string>interface_test_correct_implemented_gadget.html</string> </value>
</item>
<item>
<key> <string>description</string> </key>
......@@ -85,7 +85,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>rjs_test_correct_implemented_gadget_html</string> </value>
<value> <string>interface_test_correct_implemented_gadget_html</string> </value>
</item>
<item>
<key> <string>language</string> </key>
......@@ -121,7 +121,7 @@
<script src="jquery.js" type="text/javascript"></script>\n
\n
<!-- custom script -->\n
<script src="rjs_test_correct_implemented_gadget.js" type="text/javascript"></script>\n
<script src="interface_test_correct_implemented_gadget.js" type="text/javascript"></script>\n
</head>\n
<body> </body>\n
</html>
......@@ -261,7 +261,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>944.35772.28941.3942</string> </value>
<value> <string>944.37533.56469.39680</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -279,7 +279,7 @@
</tuple>
<state>
<tuple>
<float>1437553652.82</float>
<float>1437658341.95</float>
<string>GMT</string>
</tuple>
</state>
......
......@@ -71,7 +71,7 @@
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>rjs_test_correct_implemented_gadget.js</string> </value>
<value> <string>interface_test_correct_implemented_gadget.js</string> </value>
</item>
<item>
<key> <string>description</string> </key>
......@@ -81,7 +81,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>rjs_test_correct_implemented_gadget_js</string> </value>
<value> <string>interface_test_correct_implemented_gadget_js</string> </value>
</item>
<item>
<key> <string>language</string> </key>
......@@ -257,7 +257,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>944.35771.55710.44851</string> </value>
<value> <string>944.37533.31884.34508</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -275,7 +275,7 @@
</tuple>
<state>
<tuple>
<float>1437551760.54</float>
<float>1437657462.42</float>
<string>GMT</string>
</tuple>
</state>
......
......@@ -75,7 +75,7 @@
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>rjs_test_missing_method_declaration_gadget.html</string> </value>
<value> <string>interface_test_missing_method_declaration_gadget.html</string> </value>
</item>
<item>
<key> <string>description</string> </key>
......@@ -85,7 +85,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>rjs_test_missing_method_declaration_gadget_html</string> </value>
<value> <string>interface_test_missing_method_declaration_gadget_html</string> </value>
</item>
<item>
<key> <string>language</string> </key>
......@@ -121,7 +121,7 @@
<script src="jquery.js" type="text/javascript"></script>\n
\n
<!-- custom script -->\n
<script src="rjs_test_missing_method_declaration_gadget.js" type="text/javascript"></script>\n
<script src="interface_test_missing_method_declaration_gadget.js" type="text/javascript"></script>\n
</head>\n
<body> </body>\n
</html>
......@@ -261,7 +261,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>944.35773.25327.42376</string> </value>
<value> <string>944.37533.18013.5000</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -279,7 +279,7 @@
</tuple>
<state>
<tuple>
<float>1437553642.54</float>
<float>1437658329.61</float>
<string>GMT</string>
</tuple>
</state>
......
......@@ -71,7 +71,7 @@
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>rjs_test_missing_method_declaration_gadget.js</string> </value>
<value> <string>interface_test_missing_method_declaration_gadget.js</string> </value>
</item>
<item>
<key> <string>description</string> </key>
......@@ -81,7 +81,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>rjs_test_missing_method_declaration_gadget_js</string> </value>
<value> <string>interface_test_missing_method_declaration_gadget_js</string> </value>
</item>
<item>
<key> <string>language</string> </key>
......@@ -257,7 +257,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>944.35772.57743.26316</string> </value>
<value> <string>944.37531.48676.30498</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -275,7 +275,7 @@
</tuple>
<state>
<tuple>
<float>1437551825.92</float>
<float>1437657354.09</float>
<string>GMT</string>
</tuple>
</state>
......
......@@ -123,36 +123,107 @@
\n
QUnit.config.testTimeout = 5000;\n
\n
module("RJSGadgetInterfaceImplementationVerification");\n
module("RJSInterfaceCorrectImplementationTest");\n
\n
test("verify correctly implemented gadget test", function() {\n
var gadget_url = "https://softinst60317.host.vifib.net/erp5/web_site_module/rjs_interface_test/rjs_test_correct_implemented_gadget.html",\n
var gadget_url = "https://softinst60317.host.vifib.net/erp5/web_site_module/rjs_interface_test/interface_test_correct_implemented_gadget.html",\n
interface_url = "https://softinst60317.host.vifib.net/erp5/web_site_module/rjs_interface_test/demo_interface1.html";\n
return new RSVP.Queue()\n
.push(function() {\n
return root_gadget_defer.promise;\n
})\n
.push(function(gadget) {\n
return gadget.verifyInterfaceImplementation(gadget_url, interface_url);\n
return gadget.verifyGadgetInterfaceImplementation(gadget_url, interface_url);\n
})\n
.push(function(result) {\n
equal(result, true, "verifyInterfaceImplementation success");\n
equal(result, true, "verify correctly implemented gadget test - expected true - success");\n
});\n
\n
});\n
\n
module("RJSMissingMethodDeclarationTest");\n
\n
test("verify missing method declaration gadget test", function() {\n
var gadget_url = "https://softinst60317.host.vifib.net/erp5/web_site_module/rjs_interface_test/rjs_test_missing_method_declaration_gadget.html",\n
var gadget_url = "https://softinst60317.host.vifib.net/erp5/web_site_module/rjs_interface_test/interface_test_missing_method_declaration_gadget.html",\n
interface_url = "https://softinst60317.host.vifib.net/erp5/web_site_module/rjs_interface_test/demo_interface1.html";\n
return new RSVP.Queue()\n
.push(function() {\n
return root_gadget_defer.promise;\n
})\n
.push(function(gadget) {\n
return gadget.verifyInterfaceImplementation(gadget_url, interface_url);\n
return gadget.verifyGadgetInterfaceImplementation(gadget_url, interface_url);\n
})\n
.push(function(result) {\n
equal(result, false, "verifyInterfaceImplementation success");\n
equal(result, false, "verify missing method declaration gadget test - expected false - success");\n
});\n
\n
});\n
\n
module("RJSMismatchedMethodArgumentTest");\n
\n
test("verify mismatched method argument gadget test", function() {\n
var gadget_url = "https://softinst60317.host.vifib.net/erp5/web_site_module/rjs_interface_test/interface_test_mismatched_argument_gadget.html",\n
interface_url = "https://softinst60317.host.vifib.net/erp5/web_site_module/rjs_interface_test/demo_interface1.html";\n
return new RSVP.Queue()\n
.push(function() {\n
return root_gadget_defer.promise;\n
})\n
.push(function(gadget) {\n
return gadget.verifyGadgetInterfaceImplementation(gadget_url, interface_url);\n
})\n
.push(function(result) {\n
equal(result, false, "verify mismatched method argument gadget test - expected false - success");\n
});\n
\n
});\n
\n
module("RJSMultipleInterfaceCorrectImplementationTest");\n
\n
test("verify multiple interface correct gadget test", function() {\n
var gadget_url = "https://softinst60317.host.vifib.net/erp5/web_site_module/rjs_interface_test/interface_test_multiple_interface_correct_gadget.html";\n
return new RSVP.Queue()\n
.push(function() {\n
return root_gadget_defer.promise;\n
})\n
.push(function(gadget) {\n
return gadget.verifyGadgetAllInterfaceImplementation(gadget_url);\n
})\n
.push(function(result) {\n
equal(result, true, "verify multiple interface correct gadget test - expected true - success");\n
});\n
\n
});\n
\n
module("RJSMultipleInterfaceMissingMethodDeclarationTest");\n
\n
test("verify multiple interface missing method declaration gadget test", function() {\n
var gadget_url = "https://softinst60317.host.vifib.net/erp5/web_site_module/rjs_interface_test/interface_test_multiple_interface_missing_method_declaration_gadget.html";\n
return new RSVP.Queue()\n
.push(function() {\n
return root_gadget_defer.promise;\n
})\n
.push(function(gadget) {\n
return gadget.verifyGadgetAllInterfaceImplementation(gadget_url);\n
})\n
.push(function(result) {\n
equal(result, false, "verify multiple interface missing method declaration gadget test - expected false - success");\n
});\n
\n
});\n
\n
module("RJSMultipleInterfaceMismatchedArgumentTest");\n
\n
test("verify multiple interface mismatched argument gadget test", function() {\n
var gadget_url = "https://softinst60317.host.vifib.net/erp5/web_site_module/rjs_interface_test/interface_test_multiple_interface_mismached_argument_gadget.html";\n
return new RSVP.Queue()\n
.push(function() {\n
return root_gadget_defer.promise;\n
})\n
.push(function(gadget) {\n
return gadget.verifyGadgetAllInterfaceImplementation(gadget_url);\n
})\n
.push(function(result) {\n
equal(result, false, "verify multiple interface mismatched argument gadget test - expected false - success");\n
});\n
\n
});\n
......@@ -293,7 +364,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>944.35764.57171.32221</string> </value>
<value> <string>944.37707.19532.10803</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -311,7 +382,7 @@
</tuple>
<state>
<tuple>
<float>1437553623.38</float>
<float>1437667980.8</float>
<string>GMT</string>
</tuple>
</state>
......
......@@ -167,11 +167,11 @@
});\n
}\n
\n
function verifyInterfaceDefinition(interface_name) {\n
function verifyInterfaceDefinition(interface_url) {\n
//to verify if interface definition follows the correct template.\n
return RSVP.Queue()\n
.push(function () {\n
return jQuery.get(interface_name);\n
return jQuery.get(interface_url);\n
})\n
.push(function(file_data) {\n
var doc = (new DOMParser()).parseFromString(file_data, \'text/html\').body,\n
......@@ -211,11 +211,11 @@
});\n
}\n
\n
function verifyInterfaceDeclaration(interface_name, declared_interface_list) {\n
function verifyInterfaceDeclaration(interface_url, declared_interface_list) {\n
//to verify if gadget declares the interface.\n
var defer = RSVP.defer();\n
try {\n
if (declared_interface_list.indexOf(interface_name) > -1) {\n
if (declared_interface_list.indexOf(interface_url) > -1) {\n
defer.resolve("Success");\n
} else {\n
throw new Error("Interface not declared.");\n
......@@ -230,10 +230,10 @@
var defer = RSVP.defer();\n
return RSVP.Queue()\n
.push(function() {\n
return verifyAllMethodDeclared(interface_method_list, gadget_method_list);\n
return verifyAllMethodDeclared(interface_method_list, gadget_method_list[0]);\n
})\n
.push(function() {\n
return verifyAllMethodsSignature(interface_method_list, gadget_method_list);\n
return verifyAllMethodsSignature(interface_method_list, gadget_method_list[1]);\n
})\n
.push (function() {\n
defer.resolve("Success");\n
......@@ -247,17 +247,14 @@
function verifyAllMethodDeclared(interface_method_list, gadget_method_list) {\n
//to verify if all the interface methods are declared by the gadget.\n
var defer = RSVP.defer(),\n
gadget_method_name_list = [],\n
gadget_method_name_list = gadget_method_list,\n
interface_method_name_list = [];\n
for (var i=0; i<gadget_method_list.length; i+=1) {\n
gadget_method_name_list.push(gadget_method_list[i].name);\n
}\n
for (var j=0; j<interface_method_list.length; j+=1) {\n
interface_method_name_list.push(interface_method_list[j].name);\n
for (var i=0; i<interface_method_list.length; i+=1) {\n
interface_method_name_list.push(interface_method_list[i].name);\n
}\n
try {\n
for (var k=0; k<interface_method_name_list.length; k+=1) {\n
if(gadget_method_name_list.indexOf(interface_method_name_list[k]) < 0) {\n
for (var j=0; j<interface_method_name_list.length; j+=1) {\n
if(gadget_method_name_list.indexOf(interface_method_name_list[j]) < 0) {\n
throw new Error("All methods are not declared.");\n
}\n
}\n
......@@ -272,16 +269,18 @@
//to verify if all the declared methods match the signature of the interface methods.\n
var defer = RSVP.defer(),\n
interface_method_dict = {},\n
gadget_methods_dict = {};\n
gadget_method_name_list = [],\n
index;\n
for(var i=0; i<interface_method_list.length; i+=1) {\n
interface_method_dict[interface_method_list[i].name] = interface_method_list[i];\n
}\n
for(var j=0; j<gadget_method_list.length; j+=1) {\n
gadget_methods_dict[gadget_method_list[j].name] = gadget_method_list[j];\n
gadget_method_name_list.push(gadget_method_list[j].name);\n
}\n
try {\n
for(var item in interface_method_dict) {\n
if(!verifyMethodSignature(interface_method_dict[item], gadget_methods_dict[item])) {\n
index = gadget_method_name_list.lastIndexOf(item);\n
if(!verifyMethodSignature(interface_method_dict[item], gadget_method_list[index])) {\n
throw new Error("All methods signature do not match.");\n
}\n
}\n
......@@ -317,10 +316,23 @@
})\n
\n
.declareMethod("getDeclaredGadgetMethods", function (gadget) {\n
return gadget.getDeclaredMethodList();\n
var declared_method_dict = {},\n
declared_method_list = [],\n
item;\n
for (item in gadget) {\n
if (!(/__/).test(item)) {\n
declared_method_dict[item] = gadget[item];\n
}\n
}\n
for(item in declared_method_dict) {\n
declared_method_list.push(item);\n
} \n
return RSVP.all([\n
declared_method_list,\n
gadget.getDeclaredMethodList()]); \n
})\n
\n
.declareMethod("getInterfaceData", function (interface_name) {\n
.declareMethod("getInterfaceData", function (interface_url) {\n
var interface_data = {\n
name: "",\n
description: "",\n
......@@ -328,7 +340,7 @@
};\n
return RSVP.Queue()\n
.push(function() {\n
return jQuery.get(interface_name);\n
return jQuery.get(interface_url);\n
})\n
.push(function(file_data) {\n
var doc = (new DOMParser()).parseFromString(file_data, \'text/html\').body,\n
......@@ -365,21 +377,21 @@
});\n
})\n
\n
.declareMethod("getDefinedInterfaceMethods", function (interface_name) {\n
return this.getInterfaceData(interface_name)\n
.declareMethod("getDefinedInterfaceMethods", function (interface_url) {\n
return this.getInterfaceData(interface_url)\n
.push(function(interface_data) {\n
return interface_data.method_list;\n
});\n
})\n
\n
.declareMethod("verifyInterfaceImplementation", function (gadget_url, interface_name) {\n
.declareMethod("verifyGadgetInterfaceImplementation", function (gadget_url, interface_url) {\n
var interface_gadget = this;\n
return RSVP.Queue()\n
.push(function () {\n
if(!gadget_url || !interface_name) {\n
if(!gadget_url || !interface_url) {\n
throw new Error("Invalid Inputs");\n
}\n
return verifyInterfaceDefinition(interface_name);\n
return verifyInterfaceDefinition(interface_url);\n
})\n
.push(function () {\n
return getVerifyGadget(gadget_url, interface_gadget);\n
......@@ -388,14 +400,14 @@
return interface_gadget.getDeclaredGadgetInterfaces(gadget);\n
})\n
.push(function (declared_interface_list) {\n
return verifyInterfaceDeclaration(interface_name, declared_interface_list);\n
return verifyInterfaceDeclaration(interface_url, declared_interface_list);\n
})\n
.push(function () {\n
return interface_gadget.getDeclaredGadget(VERIFY_GADGET_SCOPE);\n
})\n
.push(function (gadget) {\n
return RSVP.all([\n
interface_gadget.getDefinedInterfaceMethods(interface_name),\n
interface_gadget.getDefinedInterfaceMethods(interface_url),\n
interface_gadget.getDeclaredGadgetMethods(gadget)\n
]);\n
})\n
......@@ -408,6 +420,41 @@
console.log("Verified : Failure", error);\n
return false;\n
});\n
})\n
\n
.declareMethod("verifyGadgetAllInterfaceImplementation", function (gadget_url) {\n
var interface_gadget = this;\n
return RSVP.Queue()\n
.push(function () {\n
if(!gadget_url) {\n
throw new Error("Invalid Inputs");\n
}\n
return getVerifyGadget(gadget_url, interface_gadget);\n
})\n
.push(function (gadget) {\n
return interface_gadget.getDeclaredGadgetInterfaces(gadget);\n
})\n
.push(function (declared_interface_list) {\n
var interface_url,\n
result_list = [];\n
for (var item in declared_interface_list) {\n
interface_url = declared_interface_list[item];\n
result_list.push(interface_gadget.verifyGadgetInterfaceImplementation(gadget_url, interface_url));\n
}\n
return RSVP.all(result_list);\n
})\n
.push(function(result_list) {\n
for(var item in result_list) {\n
if (!result_list[item]) {\n
throw new Error("Interface Implementation Failure.");\n
}\n
}\n
})\n
.push (function() {\n
return true;\n
}, function(error) {\n
return false;\n
});\n
});\n
\n
}(window, rJS, $, jQuery, RSVP, DOMParser));
......@@ -547,7 +594,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>944.35769.642.2969</string> </value>
<value> <string>944.37629.16120.45687</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -565,7 +612,7 @@
</tuple>
<state>
<tuple>
<float>1437551594.23</float>
<float>1437724277.41</float>
<string>GMT</string>
</tuple>
</state>
......
web_page_module/demo_interface*
web_page_module/rjs_gadget_interface*
web_page_module/renderjs*
web_page_module/rjs_test*
web_page_module/interface_test*
web_site_module/rjs_interface_test
web_site_module/rjs_interface_test/**
\ No newline at end of file
web_page_module/demo_interface*
web_page_module/rjs_gadget_interface*
web_page_module/renderjs*
web_page_module/rjs_test*
web_page_module/interface_test*
web_site_module/rjs_interface_test
web_site_module/rjs_interface_test/**
\ No newline at end of file
web_page_module/demo_interface*
web_page_module/interface_test*
web_page_module/renderjs*
web_page_module/rjs_gadget_interface*
web_page_module/rjs_test*
web_site_module/rjs_interface_test
web_site_module/rjs_interface_test/**
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment