1 | # Note: may be Apache 2.0 license-contaminated. |
---|
2 | # (I haven't checked whether there is a significant license compatibility issue here.) |
---|
3 | |
---|
4 | import sys |
---|
5 | import windmill |
---|
6 | from windmill.bin import admin_lib |
---|
7 | from twisted.internet import defer |
---|
8 | from foolscap.api import eventually |
---|
9 | from allmydata.util import log |
---|
10 | |
---|
11 | |
---|
12 | class TiltingMixin: |
---|
13 | # adapted from |
---|
14 | # http://github.com/windmill/windmill/blob/master/windmill/authoring/unit.py |
---|
15 | # http://github.com/windmill/windmill/blob/master/windmill/bin/shell_objects.py |
---|
16 | |
---|
17 | def setUp(self): |
---|
18 | self.browser_debugging = False |
---|
19 | self.settings = {} |
---|
20 | self.configure() |
---|
21 | |
---|
22 | log.msg("starting gateway") |
---|
23 | self.start_gateway() |
---|
24 | |
---|
25 | log.msg("setting up Windmill for browser '%s'" % (self.browserName,)) |
---|
26 | windmill.block_exit = True |
---|
27 | windmill.stdout = sys.stdout |
---|
28 | windmill.stdin = sys.stdin |
---|
29 | |
---|
30 | admin_lib.configure_global_settings() |
---|
31 | for (setting, value) in self.settings.iteritems(): |
---|
32 | windmill.settings[setting] = value |
---|
33 | windmill.settings['controllers'] = [] |
---|
34 | self.shell_objects = admin_lib.setup() |
---|
35 | |
---|
36 | log.msg("starting browser") |
---|
37 | self.shell_objects['start_' + self.browserName]() |
---|
38 | |
---|
39 | d = defer.Deferred() |
---|
40 | admin_lib.on_ide_awake.append(lambda: eventually(d.callback, None)) |
---|
41 | d.addCallback(lambda ign: log.msg("browser started")) |
---|
42 | |
---|
43 | if self.browser_debugging: |
---|
44 | self.xmlrpc = windmill.tools.make_xmlrpc_client() |
---|
45 | d.addCallback(lambda ign: |
---|
46 | self.xmlrpc.add_command({'method':'commands.setOptions', |
---|
47 | 'params':{'runTests':False, 'priority':'normal'}})) |
---|
48 | return d |
---|
49 | |
---|
50 | def tearDown(self): |
---|
51 | windmill.block_exit = False |
---|
52 | if self.browser_debugging: |
---|
53 | self.xmlrpc.add_command({'method':'commands.setOptions', |
---|
54 | 'params':{'runTests':True, 'priority':'normal'}}) |
---|
55 | else: |
---|
56 | log.msg("shutting down browser '%s'" % (self.browserName,)) |
---|
57 | admin_lib.teardown(self.shell_objects) |
---|
58 | log.msg("browser shutdown done") |
---|