Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(617)

Unified Diff: remoting/tools/remote_test_helper/rth_server.py

Issue 807343002: Adding the first set of remote test cases and associated framework. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changing enum naming format to eliminate name conflict. Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/tools/remote_test_helper/jsonrpclib.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/tools/remote_test_helper/rth_server.py
diff --git a/remoting/tools/remote_test_helper/rth_server.py b/remoting/tools/remote_test_helper/rth_server.py
new file mode 100644
index 0000000000000000000000000000000000000000..064c16b448b6fbb1396bc64c8b33e326a9156241
--- /dev/null
+++ b/remoting/tools/remote_test_helper/rth_server.py
@@ -0,0 +1,69 @@
+# Copyright 2014 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+import jsonrpclib
+import SimpleJSONRPCServer as _server
+
+
+class RequestHandler(_server.SimpleJSONRPCRequestHandler):
+ """Custom JSON-RPC request handler."""
+
+ FILES = {
+ 'client.html': {'content-type': 'text/html'},
+ 'host.html': {'content-type': 'text/html'},
+ 'client.js': {'content-type': 'application/javascript'},
+ 'host.js': {'content-type': 'application/javascript'},
+ 'jsonrpc.js': {'content-type': 'application/javascript'}
+ }
+
+ def do_GET(self):
+ """Custom GET handler to return default pages."""
+ filename = self.path.lstrip('/')
+ if filename not in self.FILES:
+ self.report_404()
+ return
+ with open(filename) as f:
+ data = f.read()
+ self.send_response(200)
+ for key, value in self.FILES[filename].iteritems():
+ self.send_header(key, value)
+ self.end_headers()
+ self.wfile.write(data)
+
+
+class RPCHandler(object):
+ """Class to define and handle RPC calls."""
+
+ CLEARED_EVENT = {'action': 0, 'event': 0, 'modifiers': 0}
+
+ def __init__(self):
+ self.last_event = self.CLEARED_EVENT
+
+ def ClearLastEvent(self):
+ """Clear the last event."""
+ self.last_event = self.CLEARED_EVENT
+ return True
+
+ def SetLastEvent(self, action, value, modifier):
+ """Set the last action, value, and modifiers."""
+ self.last_event = {
+ 'action': action,
+ 'value': value,
+ 'modifiers': modifier
+ }
+ return True
+
+ def GetLastEvent(self):
+ return self.last_event
+
+
+def main():
+ server = _server.SimpleJSONRPCServer(
+ ('', 3474), requestHandler=RequestHandler,
+ logRequests=True, allow_none=True)
+ server.register_instance(RPCHandler())
+ server.serve_forever()
+
+
+if __name__ == '__main__':
+ main()
« no previous file with comments | « remoting/tools/remote_test_helper/jsonrpclib.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698