Commit e234f354 authored by Romain Courteaud's avatar Romain Courteaud

[erp5_gadget_interface_validator] Not documented methods are reported as failure

parent 54f7b6b3
...@@ -202,25 +202,42 @@ ...@@ -202,25 +202,42 @@
interface_method_name_list = [], interface_method_name_list = [],
i, i,
j, j,
failed = false, missing_method_list = [],
failed_methods = [], unknown_method_list = [],
error_message; error_message;
for (i = 0; i < interface_method_list.length; i += 1) { for (i = 0; i < interface_method_list.length; i += 1) {
interface_method_name_list.push(interface_method_list[i].name); interface_method_name_list.push(interface_method_list[i].name);
} }
// Check missing method declaration
for (j = 0; j < interface_method_name_list.length; j += 1) { for (j = 0; j < interface_method_name_list.length; j += 1) {
if (gadget_method_name_list.indexOf( if (gadget_method_name_list.indexOf(
interface_method_name_list[j] interface_method_name_list[j]
) < 0) { ) < 0) {
failed = true; missing_method_list.push(interface_method_name_list[j]);
failed_methods.push(interface_method_name_list[j]);
} }
} }
if (failed) { if (missing_method_list.length) {
error_message = error_message =
"Following required methods are not declared in the gadget: "; "Following required methods are not declared in the gadget: ";
for (i = 0; i < failed_methods.length; i += 1) { for (i = 0; i < missing_method_list.length; i += 1) {
error_message += ("\n" + failed_methods[i]); error_message += ("\n" + missing_method_list[i]);
}
throw new Error(error_message);
}
// Check unknown method declaration
for (j = 0; j < gadget_method_name_list.length; j += 1) {
if (interface_method_name_list.indexOf(
gadget_method_name_list[j]
) < 0) {
unknown_method_list.push(gadget_method_name_list[j]);
}
}
if (unknown_method_list.length) {
error_message =
"Following methods are not documents in the interface: ";
for (i = 0; i < unknown_method_list.length; i += 1) {
error_message += ("\n" + unknown_method_list[i]);
} }
throw new Error(error_message); throw new Error(error_message);
} }
......
...@@ -230,7 +230,7 @@ ...@@ -230,7 +230,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>968.35510.60407.49868</string> </value> <value> <string>969.37975.64169.12509</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -248,7 +248,7 @@ ...@@ -248,7 +248,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1530266417.35</float> <float>1534260072.07</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -100,7 +100,7 @@ ...@@ -100,7 +100,7 @@
<item> <item>
<key> <string>text_content</string> </key> <key> <string>text_content</string> </key>
<value> <string>CACHE MANIFEST\n <value> <string>CACHE MANIFEST\n
# generated on Thu, 28 Jun 2018 15:31:33 +0000\n # generated on Thu, 14 Aug 2018 15:31:33 +0000\n
CACHE:\n CACHE:\n
favicon.ico\n favicon.ico\n
font-awesome/font-awesome-webfont.eot\n font-awesome/font-awesome-webfont.eot\n
...@@ -305,7 +305,7 @@ NETWORK:\n ...@@ -305,7 +305,7 @@ NETWORK:\n
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>968.34429.27639.36556</string> </value> <value> <string>968.41228.46964.12441</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -323,7 +323,7 @@ NETWORK:\n ...@@ -323,7 +323,7 @@ NETWORK:\n
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1530201523.97</float> <float>1534260712.58</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -119,19 +119,19 @@ ...@@ -119,19 +119,19 @@
<td>Error with gadget loading</td> <td>Error with gadget loading</td>
</tr> </tr>
<!--tr> <tr>
<td colspan="3"><b>Check unknown method declaration</b></td> <td colspan="3"><b>Check unknown method declaration</b></td>
</tr> </tr>
<tr> <tr>
<td>waitForElementPresent</td> <td>assertText</td>
<td>//tr[@id='${application_title}_test_unknown_method_declaration_gadget']//td[@class='validation_status final']</td> <td>//tbody/tr[6]/td</td>
<td></td> <td>gadget_interface_validator_test_unknown_method_declaration_gadget.html</td>
</tr> </tr>
<tr> <tr>
<td>assertText</td> <td>assertText</td>
<td>//tr[@id='${application_title}_test_unknown_method_declaration_gadget']//td[@class='validation_status final']</td> <td>//tbody/tr[6]/td[2]</td>
<td>Failure</td> <td>Failure</td>
</tr--> </tr>
</tbody></table> </tbody></table>
</body> </body>
......
...@@ -100,21 +100,23 @@ ...@@ -100,21 +100,23 @@
<item> <item>
<key> <string>text_content</string> </key> <key> <string>text_content</string> </key>
<value> <string>CACHE MANIFEST\n <value> <string>CACHE MANIFEST\n
# generated on Fri, 06 Feb 2015 15:31:33 +0000\n # generated on Fri, 14 Jun 2018 15:31:33 +0000\n
# XXX + fonts\n # XXX + fonts\n
# images/ajax-loader.gif\n # images/ajax-loader.gif\n
CACHE:\n CACHE:\n
URI.js\n URI.js\n
gadget_interface_validator_test_correct_implemented_gadget.html\n gadget_interface_validator_test_correct_implemented_gadget.html\n
gadget_interface_validator_test_correct_implemented_gadget.js\n gadget_interface_validator_test_correct_implemented_gadget.js\n
gadget_interface_validator_test_nonexistent_gadget.html\n
gadget_interface_validator_test_nonexistent_gadget.js\n
gadget_interface_validator_test_invalid_interface_gadget.html\n gadget_interface_validator_test_invalid_interface_gadget.html\n
gadget_interface_validator_test_invalid_interface_gadget.js\n gadget_interface_validator_test_invalid_interface_gadget.js\n
gadget_interface_validator_test_missing_interface_declaration_gadget.html\n gadget_interface_validator_test_missing_interface_declaration_gadget.html\n
gadget_interface_validator_test_missing_interface_declaration_gadget.js\n gadget_interface_validator_test_missing_interface_declaration_gadget.js\n
gadget_interface_validator_test_missing_method_declaration_gadget.html\n gadget_interface_validator_test_missing_method_declaration_gadget.html\n
gadget_interface_validator_test_missing_method_declaration_gadget.js\n gadget_interface_validator_test_missing_method_declaration_gadget.js\n
gadget_interface_validator_test_nonexistent_gadget.html\n gadget_interface_validator_test_unknown_method_declaration_gadget.html\n
gadget_interface_validator_test_nonexistent_gadget.js\n gadget_interface_validator_test_unknown_method_declaration_gadget.js\n
i18next.js\n i18next.js\n
jquery.js\n jquery.js\n
jquerymobile.css\n jquerymobile.css\n
...@@ -257,7 +259,7 @@ NETWORK:\n ...@@ -257,7 +259,7 @@ NETWORK:\n
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>946.44862.31274.46370</string> </value> <value> <string>968.14266.18355.13568</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -275,7 +277,7 @@ NETWORK:\n ...@@ -275,7 +277,7 @@ NETWORK:\n
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1445875941.09</float> <float>1529048876.03</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Unknown method declaration Test Gadget</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="http://www.renderjs.org/rel/interface" href="gadget_interface_validator_test_dummy_interface1.html">
<!-- renderjs -->
<script src="rsvp.js" type="text/javascript"></script>
<script src="renderjs.js" type="text/javascript"></script>
<!-- custom script -->
<script src="gadget_interface_validator_test_unknown_method_declaration_gadget.js" type="text/javascript"></script>
</head>
<body> </body>
</html>
\ No newline at end of file
/*global window, rJS , RSVP*/
/*jslint nomen: true, indent: 2, maxerr: 3 */
(function (window, rJS) {
"use strict";
rJS(window)
.ready(function (g) {
g.props = {};
})
.declareMethod("method1", function (param1, param2) {
return;
})
.declareMethod("method2", function (param1) {
return;
})
.declareMethod("method3", function () {
return;
})
.declareMethod("method4", function () {
return;
});
}(window, rJS));
\ 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