Commit 01d900a2 authored by Vivek's avatar Vivek

renderjs_interfaces: updated demo application to allow inputs.

parent 90b812f1
......@@ -111,6 +111,7 @@
<meta charset="utf-8" />\n
<title>I-Demo</title>\n
<meta name="viewport" content="width=device-width, initial-scale=1" />\n
<link rel="stylesheet" href="jquerymobile.css">\n
\n
<link rel="http://www.renderjs.org/rel/interface" href="demo_interface1.html">\n
<link rel="http://www.renderjs.org/rel/interface" href="demo_interface2.html">\n
......@@ -119,7 +120,9 @@
<script src="rsvp.js" type="text/javascript"></script>\n
<script src="renderjs.js" type="text/javascript"></script>\n
<script src="handlebars.js" type="text/javascript"></script>\n
<script src="gadget_global.js" ></script>\n
<script src="jquery.js" type="text/javascript"></script>\n
<script src="jquerymobile.js"></script>\n
\n
<!-- custom script -->\n
<script src="gadget_interfacedemo.js" type="text/javascript"></script>\n
......@@ -127,15 +130,42 @@
<div class="ui-grid-b ui-responsive">\n
<div class="ui-block-a"></div>\n
<div class="ui-block-b">\n
<ul data-role="listview" data-inset="true">\n
{{#each interface_item}}\n
<li>\n
{{interface_name}}\n
<br>\n
Status: \n
<div data-i18n="status">{{status}}\n
<h2>Select Parameters</h2>\n
<form class="interface-verify-form">\n
<div data-role="fieldcontain">\n
<label for="gadget_selector" class="select">Select Gadget</label>\n
<select name="gadget_selector">\n
<option value="https://softinst60317.host.vifib.net/erp5/web_site_module/interface_demo/interface_test_correct_implemented_gadget.html">Gadget: Implements Interface 1 Correctly</option>\n
<option value="https://softinst60317.host.vifib.net/erp5/web_site_module/interface_demo/interface_test_missing_interface_declaration_gadget.html">Gadget: Missing Interface Declaration of Interface 1</option>\n
<option value="https://softinst60317.host.vifib.net/erp5/web_site_module/interface_demo/interface_test_missing_method_declaration_gadget.html">Gadget: Missing Method Declaration of Interface 1 </option>\n
<option value="https://softinst60317.host.vifib.net/erp5/web_site_module/interface_demo/interface_test_mismatched_argument_gadget.html">Gadget: Mismatched Method Argument of Interface 1 </option>\n
<option value="https://softinst60317.host.vifib.net/erp5/web_site_module/interface_demo/interface_test_multiple_interface_correct_gadget.html">Gadget: Multiple Interfaces Correctly Implements Interface 1 and 2</option>\n
<option value="https://softinst60317.host.vifib.net/erp5/web_site_module/interface_demo/interface_test_multiple_interface_mismached_argument_gadget.html">Gadget: Multiple Interfaces Mismatched Argument of Interface 2 </option>\n
<option value="https://softinst60317.host.vifib.net/erp5/web_site_module/interface_demo/interface_test_multiple_interface_missing_method_declaration_gadget.html">Gadget: Multiple Interfaces Missing Method Declaration of Interface 2</option>\n
<option value="https://softinst60317.host.vifib.net/erp5/web_site_module/interface_demo/interface_test_invalid_interface_gadget.html">Gadget: Implements All Invalid Interfaces</option>\n
</select>\n
</div>\n
<div data-role="fieldcontain">\n
<label for="interface_selector" class="select">Select Interface</label>\n
<select name="interface_selector">\n
<option value="">Default: Test all declared interfaces</option>\n
<option value="https://softinst60317.host.vifib.net/erp5/web_site_module/interface_demo/demo_interface1.html">Demo Interface 1</option>\n
<option value="https://softinst60317.host.vifib.net/erp5/web_site_module/interface_demo/demo_interface2.html">Demo Interface 2</option>\n
<option value="https://softinst60317.host.vifib.net/erp5/web_site_module/interface_demo/demo_interface_invalid1.html">Demo Interface Invalid 1</option>\n
<option value="https://softinst60317.host.vifib.net/erp5/web_site_module/interface_demo/demo_interface_invalid2.html">Demo Interface Invalid 2</option>\n
<option value="https://softinst60317.host.vifib.net/erp5/web_site_module/interface_demo/demo_interface_invalid3.html">Demo Interface Invalid 3</option>\n
</select>\n
</div>\n
</br>\n
<input data-inline="true" type="submit" value="Submit" data-theme="b">\n
</form>\n
<ul>\n
{{#each interface_item}}\n
<li> Gadget :<br />\n
{{gadget_name}} <br />\n
Interface : <br />\n
{{interface_name}} <br />\n
Status : <br />\n
<b>{{status}}</b>\n
</li>\n
{{/each}}\n
</ul> \n
......@@ -146,7 +176,7 @@
<script class="header-template" type="text/x-handlebars-template">\n
<h3 class="ui-title">{{title}}</h3>\n
</script>\n
\n
\n
</head>\n
<body>\n
<div data-role="page">\n
......@@ -293,7 +323,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>944.38728.22039.16742</string> </value>
<value> <string>944.43289.51727.28569</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -311,7 +341,7 @@
</tuple>
<state>
<tuple>
<float>1437744028.67</float>
<float>1438006248.54</float>
<string>GMT</string>
</tuple>
</state>
......
......@@ -101,7 +101,7 @@
<key> <string>text_content</string> </key>
<value> <string>/*global window, rJS, RSVP */\n
/*jslint nomen: true, indent: 2, maxerr: 3 */\n
(function (window, rJS, Handlebars, $, jQuery, RSVP) {\n
(function (window, rJS, Handlebars, promiseEventListener, $, jQuery, RSVP) {\n
"use strict";\n
\n
var INTERFACE_GADGET_URL = "./gadget_interfaces.html",\n
......@@ -125,46 +125,60 @@
});\n
})\n
\n
.declareMethod("interfaceGadgetTest", function (gadget_url, interface_url) {\n
.declareMethod("interfaceGadgetTest", function (display_data) {\n
var gadget = this;\n
return new RSVP.Queue()\n
.push(function () {\n
return gadget.getDeclaredGadget(INTERFACE_GADGET_SCOPE);\n
gadget.props.content_element.innerHTML =\n
gadget.props.interface_list_template({});\n
gadget.props.header_element.innerHTML = gadget.props.header_template({\n
title: "Interface Implementation Verification"\n
});\n
if(display_data) {\n
gadget.props.content_element.innerHTML =\n
gadget.props.interface_list_template(display_data);\n
}\n
$(gadget.props.element).trigger("create");\n
return RSVP.all([\n
gadget.getDeclaredGadget(INTERFACE_GADGET_SCOPE),\n
promiseEventListener(\n
gadget.props.content_element.querySelector(\'form.interface-verify-form\'),\n
\'submit\',\n
false\n
)\n
]);\n
})\n
.push(function (interface_gadget) {\n
.push(function (test_data) {\n
var status_list = [],\n
key;\n
interface_gadget = test_data[0],\n
submit_event = test_data[1],\n
gadget_url = submit_event.target[0].value,\n
interface_url = submit_event.target[1].value;\n
gadget.props.content_element.querySelector("input[type=submit]")\n
.disabled = true;\n
status_list.push(gadget_url);\n
if (interface_url !== "") {\n
status_list.push(interface_url);\n
status_list.push(interface_gadget.verifyGadgetInterfaceImplementation(gadget_url, interface_url));\n
} else {\n
status_list.push("All declared interfaces.");\n
status_list.push(interface_gadget.verifyGadgetAllInterfaceImplementation(gadget_url));\n
}\n
return RSVP.all(status_list);\n
})\n
.push(function (result_list) {\n
var parameter = {interface_item: []},\n
key,\n
i = 0;\n
var parameter = {interface_item: []};\n
parameter.interface_item.push({\n
interface_name: interface_url, \n
status: (result_list[0] ? "Verified Success":"Verified Failure")\n
gadget_name: result_list[0],\n
interface_name: result_list[1], \n
status: (result_list[2] ? "Verified Success.":"Verified Failure.")\n
});\n
gadget.props.header_element.innerHTML = gadget.props.header_template({\n
title: "Interface List"\n
});\n
gadget.props.content_element.innerHTML =\n
gadget.props.interface_list_template(parameter);\n
$(gadget.props.element).trigger("create");\n
return gadget.interfaceGadgetTest(parameter);\n
});\n
})\n
\n
.declareMethod("render", function (url_list) {\n
var gadget = this,\n
gadget_url = url_list.gadget_url,\n
interface_url = url_list.interface_url;\n
//temperoray hardcoded\n
if(!gadget_url) {\n
gadget_url = "https://softinst60317.host.vifib.net/erp5/web_site_module/interface_demo/interface_test_correct_implemented_gadget.html";\n
}\n
if(!interface_url) {\n
interface_url = "https://softinst60317.host.vifib.net/erp5/web_site_module/interface_demo/demo_interface1.html";\n
}\n
.declareMethod("render", function () {\n
var gadget = this;\n
return new RSVP.Queue()\n
.push(function () {\n
return gadget.declareGadget(INTERFACE_GADGET_URL, {\n
......@@ -173,11 +187,11 @@
});\n
})\n
.push(function () {\n
return gadget.interfaceGadgetTest(gadget_url, interface_url);\n
return gadget.interfaceGadgetTest();\n
});\n
});\n
\n
}(window, rJS, Handlebars, $, jQuery, RSVP));</string> </value>
}(window, rJS, Handlebars, promiseEventListener, $, jQuery, RSVP));</string> </value>
</item>
<item>
<key> <string>title</string> </key>
......@@ -312,7 +326,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>944.38973.25767.57053</string> </value>
<value> <string>944.43061.11797.41233</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -330,7 +344,7 @@
</tuple>
<state>
<tuple>
<float>1437743948.99</float>
<float>1437989200.53</float>
<string>GMT</string>
</tuple>
</state>
......
......@@ -155,6 +155,7 @@
var VERIFY_GADGET_SCOPE = "verify_gadget";\n
\n
function getVerifyGadget(gadget_url, interface_gadget) {\n
//to declare and get the gadget to be verified.\n
return new RSVP.Queue()\n
.push(function () {\n
return interface_gadget.declareGadget(gadget_url, {\n
......@@ -227,6 +228,7 @@
}\n
\n
function verifyAllMethod(interface_method_list, gadget_method_list) {\n
//to verify all methods of gadget and interface.\n
var defer = RSVP.defer();\n
return RSVP.Queue()\n
.push(function() {\n
......@@ -391,9 +393,6 @@
if(!gadget_url || !interface_url) {\n
throw new Error("Invalid Inputs");\n
}\n
return verifyInterfaceDefinition(interface_url);\n
})\n
.push(function () {\n
return getVerifyGadget(gadget_url, interface_gadget);\n
})\n
.push(function (gadget) {\n
......@@ -402,6 +401,9 @@
.push(function (declared_interface_list) {\n
return verifyInterfaceDeclaration(interface_url, declared_interface_list);\n
})\n
.push(function () {\n
return verifyInterfaceDefinition(interface_url);\n
})\n
.push(function () {\n
return interface_gadget.getDeclaredGadget(VERIFY_GADGET_SCOPE);\n
})\n
......@@ -417,7 +419,7 @@
.push (function() {\n
return true;\n
}, function(error) {\n
console.log("Verified : Failure", error);\n
console.log("Verified : Failure", error.message);\n
return false;\n
});\n
})\n
......@@ -594,7 +596,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>944.38727.51823.5973</string> </value>
<value> <string>944.43313.24628.20019</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -612,7 +614,7 @@
</tuple>
<state>
<tuple>
<float>1437739303.69</float>
<float>1438006033.5</float>
<string>GMT</string>
</tuple>
</state>
......
......@@ -155,6 +155,7 @@
var VERIFY_GADGET_SCOPE = "verify_gadget";\n
\n
function getVerifyGadget(gadget_url, interface_gadget) {\n
//to declare and get the gadget to be verified.\n
return new RSVP.Queue()\n
.push(function () {\n
return interface_gadget.declareGadget(gadget_url, {\n
......@@ -227,6 +228,7 @@
}\n
\n
function verifyAllMethod(interface_method_list, gadget_method_list) {\n
//to verify all methods of gadget and interface.\n
var defer = RSVP.defer();\n
return RSVP.Queue()\n
.push(function() {\n
......@@ -391,9 +393,6 @@
if(!gadget_url || !interface_url) {\n
throw new Error("Invalid Inputs");\n
}\n
return verifyInterfaceDefinition(interface_url);\n
})\n
.push(function () {\n
return getVerifyGadget(gadget_url, interface_gadget);\n
})\n
.push(function (gadget) {\n
......@@ -402,6 +401,9 @@
.push(function (declared_interface_list) {\n
return verifyInterfaceDeclaration(interface_url, declared_interface_list);\n
})\n
.push(function () {\n
return verifyInterfaceDefinition(interface_url);\n
})\n
.push(function () {\n
return interface_gadget.getDeclaredGadget(VERIFY_GADGET_SCOPE);\n
})\n
......@@ -417,7 +419,7 @@
.push (function() {\n
return true;\n
}, function(error) {\n
console.log("Verified : Failure", error);\n
console.log("Verified : Failure", error.message);\n
return false;\n
});\n
})\n
......@@ -594,7 +596,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>944.38727.51823.5973</string> </value>
<value> <string>944.43313.24628.20019</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -612,7 +614,7 @@
</tuple>
<state>
<tuple>
<float>1437739303.69</float>
<float>1438006033.5</float>
<string>GMT</string>
</tuple>
</state>
......
......@@ -127,7 +127,7 @@
\n
test("verify correctly implemented gadget test", function() {\n
var gadget_url = "./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
interface_url = "https://softinst60317.host.vifib.net/erp5/web_site_module/interface_test/demo_interface1.html";\n
return new RSVP.Queue()\n
.push(function() {\n
return root_gadget_defer.promise;\n
......@@ -145,7 +145,7 @@
\n
test("verify missing interface declaration gadget test", function() {\n
var gadget_url = "./interface_test_missing_interface_declaration_gadget.html",\n
interface_url = "https://softinst60317.host.vifib.net/erp5/web_site_module/rjs_interface_test/demo_interface1.html";\n
interface_url = "https://softinst60317.host.vifib.net/erp5/web_site_module/interface_test/demo_interface1.html";\n
return new RSVP.Queue()\n
.push(function() {\n
return root_gadget_defer.promise;\n
......@@ -163,7 +163,7 @@
\n
test("verify missing method declaration gadget test", function() {\n
var gadget_url = "./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
interface_url = "https://softinst60317.host.vifib.net/erp5/web_site_module/interface_test/demo_interface1.html";\n
return new RSVP.Queue()\n
.push(function() {\n
return root_gadget_defer.promise;\n
......@@ -181,7 +181,7 @@
\n
test("verify mismatched method argument gadget test", function() {\n
var gadget_url = "./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
interface_url = "https://softinst60317.host.vifib.net/erp5/web_site_module/interface_test/demo_interface1.html";\n
return new RSVP.Queue()\n
.push(function() {\n
return root_gadget_defer.promise;\n
......@@ -250,9 +250,9 @@
\n
test("verify invalid interface definition gadget test", function() {\n
var gadget_url = "./interface_test_missing_interface_declaration_gadget.html",\n
interface_url1 = "https://softinst60317.host.vifib.net/erp5/web_site_module/rjs_interface_test/demo_interface_invalid1.html",\n
interface_url2 = "https://softinst60317.host.vifib.net/erp5/web_site_module/rjs_interface_test/demo_interface_invalid2.html",\n
interface_url3 = "https://softinst60317.host.vifib.net/erp5/web_site_module/rjs_interface_test/demo_interface_invalid3.html";\n
interface_url1 = "https://softinst60317.host.vifib.net/erp5/web_site_module/interface_test/demo_interface_invalid1.html",\n
interface_url2 = "https://softinst60317.host.vifib.net/erp5/web_site_module/interface_test/demo_interface_invalid2.html",\n
interface_url3 = "https://softinst60317.host.vifib.net/erp5/web_site_module/interface_test/demo_interface_invalid3.html";\n
return new RSVP.Queue()\n
.push(function() {\n
return root_gadget_defer.promise;\n
......@@ -408,7 +408,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>944.38769.26131.52548</string> </value>
<value> <string>944.38901.1195.26897</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -426,7 +426,7 @@
</tuple>
<state>
<tuple>
<float>1437739501.09</float>
<float>1437747711.99</float>
<string>GMT</string>
</tuple>
</state>
......
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