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

Side by Side Diff: tools/telemetry_auto/examples/login_test.py

Issue 11412238: Proof of concept for running extension API stack through dev tools. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 # Copyright (c) 2012 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.
5 import os
6 import sys
7
8 sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
9 sys.path.append(os.path.join(os.path.dirname(__file__),
10 '..', '..', 'telemetry'))
11 import telemetry
12 import telemetry_auto
13
14 from telemetry import extension_page
15
16 def RunOOBE(browser):
17 p = telemetry_auto.OobePage(browser)
18 p.LoginUser('test@test.test', 'test')
19 # Wait until OOBE page goes away, we are logged in aftet that
20 p.WaitUnitGone()
21 print "OOBE completed!"
22
23 def LoadTab(ext, url):
24 create_properties = { 'url': url }
25 # Then open a new tab and wait until the new tab loads.
26 (call_results, event_args) = ext.RunMethodWithEvents(
27 [extension_page.ExtensionEvent('chrome.tabs.onUpdated',
28 """arguments.length >= 2 && arguments[1] &&
29 arguments[1].status == 'complete';""")],
30 'chrome.tabs.create',
31 create_properties)
32 # Return back Tab object properties.
33 return call_results["0"]
34
35 def RemoveTab(ext, tab_id):
36 remove_properties = [ tab_id ]
37 # Then open a new tab and wait until the new tab loads.
38 (call_results, event_args) = ext.RunMethodWithEvents(
39 [extension_page.ExtensionEvent('chrome.tabs.onRemoved',
40 """arguments.length >= 1 && arguments[0] &&
41 arguments[0] == %s;""" % tab_id)],
42 'chrome.tabs.remove',
43 remove_properties)
44
45 def FindAutomationExtension(browser):
46 # Attach to automation extension.
47 extensions = browser.extensions.GetAllForUrl(
48 'chrome-extension://aapnijgdinlhnhlmodcfapnahmbfebeb/' +
49 '_generated_background_page.html')
50 # Get the last loaded extension
51 return extensions[len(extensions) - 1]
52
53 def TestIntegration(args):
54 options = telemetry.BrowserOptions()
55 parser = options.CreateParser('telemetry_extension_test.py')
56 options, args = parser.parse_args(args)
57 browser_to_create = telemetry.FindBrowser(options)
58 assert browser_to_create
59 with browser_to_create.Create() as browser:
60 # Get us through OOBE first.
61 RunOOBE(browser)
62 auto = FindAutomationExtension(browser)
63 # Load somethin' in a tab once we are in session.
64 t1 = LoadTab(auto, 'chrome://settings')
65 t2 = LoadTab(auto, 'http://www.google.com/')
66 RemoveTab(auto, t1["id"])
67 RemoveTab(auto, t2["id"])
68
69 def Main(args):
70 for i in range(1, 10000):
71 print "Test pass %d" % i
72 TestIntegration(args)
73 return 0
74
75 if __name__ == '__main__':
76 sys.exit(Main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « tools/telemetry_auto/data/auto_provider/manifest.json ('k') | tools/telemetry_auto/telemetry_auto/__init__.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698