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

Side by Side 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: Created 6 years 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 unified diff | Download patch
OLDNEW
(Empty)
1 # Copyright (c) 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4 import jsonrpclib
5 import SimpleJSONRPCServer as _server
6
7
8 class RequestHandler(_server.SimpleJSONRPCRequestHandler):
9 """Custom JSON-RPC request handler."""
10
11 FILES = {
12 'client.html': {'content-type': 'text/html'},
13 'host.html': {'content-type': 'text/html'},
14 'client.js': {'content-type': 'application/javascript'},
15 'host.js': {'content-type': 'application/javascript'},
16 'jsonrpc.js': {'content-type': 'application/javascript'}
17 }
18
19 def do_GET(self):
20 """Custom GET handler to return default pages."""
21 filename = self.path.lstrip('/')
22 if filename not in self.FILES:
23 self.report_404()
24 return
25 with open(filename) as f:
26 data = f.read()
27 self.send_response(200)
28 for key, value in self.FILES[filename].iteritems():
29 self.send_header(key, value)
30 self.end_headers()
31 self.wfile.write(data)
32
33
34 class RPCHandler(object):
35 """Class to define and handle RPC calls."""
36
37 CLEARED_EVENT = {'action': 0, 'event': 0, 'modifiers': 0}
38
39 def __init__(self):
40 self.last_event = self.CLEARED_EVENT
41
42 def ClearLastEvent(self):
43 """Clear the last event."""
44 self.last_event = self.CLEARED_EVENT
45 return True
46
47 def SetLastEvent(self, action, value, modifier):
48 """Set the last action, value, and modifiers."""
49 self.last_event = {
50 'action': action,
51 'value': value,
52 'modifiers': modifier
53 }
54 return True
55
56 def GetLastEvent(self):
57 return self.last_event
58
59
60 def main():
61 server = _server.SimpleJSONRPCServer(
62 ('', 3474), requestHandler=RequestHandler,
63 logRequests=True, allow_none=True)
64 server.register_instance(RPCHandler())
65 server.serve_forever()
66
67
68 if __name__ == '__main__':
69 main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698