Allow overlapping sync and async startup requests
[chromium-blink-merge.git] / chrome / test / pyautolib / chromeos / enable_testing.py
blob373c7646c48e08838f5831b97ec6a213e5d61f6b
1 #!/usr/bin/env python
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
6 """Enable chrome testing interface on ChromeOS.
8 Enables chrome automation over a named automation channel on ChromeOS.
9 Also, allows passing extra flags to chrome (--extra-chrome-flags).
10 The path to named testing interface automation socket is printed out.
12 Needs to be run with superuser privileges.
14 Usage:
15 sudo python enable_testing.py --extra-chrome-flags="--homepage=about:blank"
16 """
18 import dbus
19 import optparse
20 import os
21 import sys
24 class EnableChromeTestingOnChromeOS(object):
25 """Helper to enable chrome testing interface on ChromeOS.
27 Also, can add additional flags to chrome to be used for testing.
28 """
30 SESSION_MANAGER_INTERFACE = 'org.chromium.SessionManagerInterface'
31 SESSION_MANAGER_PATH = '/org/chromium/SessionManager'
32 SESSION_MANAGER_SERVICE = 'org.chromium.SessionManager'
34 def _ParseArgs(self):
35 parser = optparse.OptionParser()
36 parser.add_option(
37 '', '--extra-chrome-flags', action='append', default=[],
38 help='Pass extra flags to chrome.')
39 self._options, self._args = parser.parse_args()
41 def Run(self):
42 self._ParseArgs()
43 assert os.geteuid() == 0, 'Needs superuser privileges.'
44 system_bus = dbus.SystemBus()
45 manager = dbus.Interface(system_bus.get_object(self.SESSION_MANAGER_SERVICE,
46 self.SESSION_MANAGER_PATH),
47 self.SESSION_MANAGER_INTERFACE)
48 print manager.EnableChromeTesting(True, self._options.extra_chrome_flags)
49 return 0
52 if __name__ == '__main__':
53 sys.exit(EnableChromeTestingOnChromeOS().Run())