Author: johnh
Date: Wed Jan 20 22:13:10 2010
New Revision: 901404
URL: http://svn.apache.org/viewvc?rev=901404&view=rev
Log:
Added callback tests to the test harness.
Modified:
incubator/shindig/trunk/javascript/container/rpctest_container.html
incubator/shindig/trunk/javascript/container/rpctest_gadget.xml
incubator/shindig/trunk/javascript/container/rpctest_perf.js
Modified: incubator/shindig/trunk/javascript/container/rpctest_container.html
URL:
http://svn.apache.org/viewvc/incubator/shindig/trunk/javascript/container/rpctest_container.html?rev=901404&r1=901403&r2=901404&view=diff
==============================================================================
--- incubator/shindig/trunk/javascript/container/rpctest_container.html
(original)
+++ incubator/shindig/trunk/javascript/container/rpctest_container.html Wed Jan
20 22:13:10 2010
@@ -170,6 +170,13 @@
Bytes/second: <span id="results_bytes_per_sec"></span>
</div>
<hr/>
+ <div>Callback<br/>
+ <ul>
+ <li>Input: <input type="text" value="test-value" size="20"
id="echo_test_input"/> <input type="button" value="Sync Callback Test"
onclick="runCallbackTest('gadget',true);"/> <input type="button" value="Async
Callback Test" onclick="runCallbackTest('gadget',false);"/></li>
+ <li>Result: <span id="echo_test_result"></span></li>
+ </ul>
+ </div>
+ <hr/>
<div>Gadget: <span id="showgadget" style="display:none"><input
type="button" onclick="appendGadget(); this.style.display='none';"
value="Append Gadget Now (for delayed load testing)"/></span></div>
<div id="container"></div>
</body>
Modified: incubator/shindig/trunk/javascript/container/rpctest_gadget.xml
URL:
http://svn.apache.org/viewvc/incubator/shindig/trunk/javascript/container/rpctest_gadget.xml?rev=901404&r1=901403&r2=901404&view=diff
==============================================================================
--- incubator/shindig/trunk/javascript/container/rpctest_gadget.xml (original)
+++ incubator/shindig/trunk/javascript/container/rpctest_gadget.xml Wed Jan 20
22:13:10 2010
@@ -101,6 +101,12 @@
Messages/second: <span id="results_msgs_per_sec"></span><br/>
Bytes/second: <span id="results_bytes_per_sec"></span>
</div><hr/>
+ <div>Callback<br/>
+ <ul>
+ <li>Input: <input type="text" value="test-value" size="20"
id="echo_test_input"/> <input type="button" value="Sync Callback Test"
onclick="runCallbackTest(null,true);"/> <input type="button" value="Async
Callback Test" onclick="runCallbackTest(null,false);"/></li>
+ <li>Result: <span id="echo_test_result"></span></li>
+ </ul>
+ </div><hr/>
<div id="childgadgetdiv"><input type="button" value="Child Gadget Tests"
onclick="appendChildGadget();"/></div>
]]>
</Content>
Modified: incubator/shindig/trunk/javascript/container/rpctest_perf.js
URL:
http://svn.apache.org/viewvc/incubator/shindig/trunk/javascript/container/rpctest_perf.js?rev=901404&r1=901403&r2=901404&view=diff
==============================================================================
--- incubator/shindig/trunk/javascript/container/rpctest_perf.js (original)
+++ incubator/shindig/trunk/javascript/container/rpctest_perf.js Wed Jan 20
22:13:10 2010
@@ -58,11 +58,24 @@
document.getElementById("results").style.display = "";
};
+function syncCallbackService(toEcho) {
+ return toEcho;
+};
+
+function asyncCallbackService(toEcho) {
+ var self = this;
+ window.setTimeout(function() {
+ self.callback(toEcho);
+ }, 0);
+};
+
function initPerfTest() {
clearPerfStats();
gadgets.rpc.register("perf_service", perfService);
gadgets.rpc.register("clear_perf_stats", clearPerfStats);
gadgets.rpc.register("complete_perf_stats", completePerfStats);
+ gadgets.rpc.register("sync_callback_service", syncCallbackService);
+ gadgets.rpc.register("async_callback_service", asyncCallbackService);
};
var alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789
_-*&(){}'";
@@ -110,3 +123,13 @@
// kick off the send loop
sendPerfMessage();
};
+
+function runCallbackTest(targetId, isSync) {
+ document.getElementById("echo_test_result").innerHTML = "";
+ var service = (isSync ? "" : "a") + "sync_callback_service";
+ var echoValue = document.getElementById("echo_test_input").value;
+ var callback = function(response) {
+ document.getElementById("echo_test_result").innerHTML = response + " at "
+ new Date().toUTCString();
+ };
+ gadgets.rpc.call(targetId, service, callback, echoValue);
+};