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

Side by Side Diff: chrome/test/functional/themes.py

Issue 7548024: Refactor: Make PyAuto InstallExtension() take a string. Delete dead code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixup per kkania. Created 9 years, 4 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
« no previous file with comments | « chrome/test/functional/ntp.py ('k') | chrome/test/pyautolib/pyautolib.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 import glob 6 import glob
7 import logging 7 import logging
8 import os 8 import os
9 9
10 import pyauto_functional # Must be imported before pyauto 10 import pyauto_functional # Must be imported before pyauto
(...skipping 12 matching lines...) Expand all
23 pp = pprint.PrettyPrinter(indent=2) 23 pp = pprint.PrettyPrinter(indent=2)
24 while True: 24 while True:
25 raw_input('Hit <enter> to dump info.. ') 25 raw_input('Hit <enter> to dump info.. ')
26 pp.pprint(self.GetThemeInfo()) 26 pp.pprint(self.GetThemeInfo())
27 27
28 def testSetTheme(self): 28 def testSetTheme(self):
29 """Verify theme install.""" 29 """Verify theme install."""
30 self.assertFalse(self.GetThemeInfo()) # Verify there's no theme at startup 30 self.assertFalse(self.GetThemeInfo()) # Verify there's no theme at startup
31 crx_file = os.path.abspath( 31 crx_file = os.path.abspath(
32 os.path.join(self.DataDir(), 'extensions', 'theme.crx')) 32 os.path.join(self.DataDir(), 'extensions', 'theme.crx'))
33 self.assertTrue(self.SetTheme(pyauto.FilePath(crx_file))) 33 self.assertTrue(self.SetTheme(crx_file))
34 # Verify "theme installed" infobar shows up 34 # Verify "theme installed" infobar shows up
35 self.assertTrue(self.WaitForInfobarCount(1)) 35 self.assertTrue(self.WaitForInfobarCount(1))
36 theme = self.GetThemeInfo() 36 theme = self.GetThemeInfo()
37 self.assertEqual('camo theme', theme['name']) 37 self.assertEqual('camo theme', theme['name'])
38 self.assertTrue(self.GetBrowserInfo()['windows'][0]['tabs'][0]['infobars']) 38 self.assertTrue(self.GetBrowserInfo()['windows'][0]['tabs'][0]['infobars'])
39 39
40 def testThemeInFullScreen(self): 40 def testThemeInFullScreen(self):
41 """Verify theme can be installed in FullScreen mode.""" 41 """Verify theme can be installed in FullScreen mode."""
42 self.ApplyAccelerator(pyauto.IDC_FULLSCREEN ) 42 self.ApplyAccelerator(pyauto.IDC_FULLSCREEN )
43 self.assertFalse(self.GetThemeInfo()) # Verify there's no theme at startup 43 self.assertFalse(self.GetThemeInfo()) # Verify there's no theme at startup
44 crx_file = os.path.abspath( 44 crx_file = os.path.abspath(
45 os.path.join(self.DataDir(), 'extensions', 'theme.crx')) 45 os.path.join(self.DataDir(), 'extensions', 'theme.crx'))
46 self.assertTrue(self.SetTheme(pyauto.FilePath(crx_file))) 46 self.assertTrue(self.SetTheme(crx_file))
47 # Verify "theme installed" infobar shows up 47 # Verify "theme installed" infobar shows up
48 self.assertTrue(self.WaitForInfobarCount(1)) 48 self.assertTrue(self.WaitForInfobarCount(1))
49 theme = self.GetThemeInfo() 49 theme = self.GetThemeInfo()
50 self.assertEqual('camo theme', theme['name']) 50 self.assertEqual('camo theme', theme['name'])
51 51
52 def testThemeReset(self): 52 def testThemeReset(self):
53 """Verify theme reset.""" 53 """Verify theme reset."""
54 crx_file = os.path.abspath( 54 crx_file = os.path.abspath(
55 os.path.join(self.DataDir(), 'extensions', 'theme.crx')) 55 os.path.join(self.DataDir(), 'extensions', 'theme.crx'))
56 self.assertTrue(self.SetTheme(pyauto.FilePath(crx_file))) 56 self.assertTrue(self.SetTheme(crx_file))
57 self.assertTrue(self.ResetToDefaultTheme()) 57 self.assertTrue(self.ResetToDefaultTheme())
58 self.assertFalse(self.GetThemeInfo()) 58 self.assertFalse(self.GetThemeInfo())
59 59
60 def _ReturnCrashingThemes(self, themes, group_size, urls): 60 def _ReturnCrashingThemes(self, themes, group_size, urls):
61 """Install the given themes in groups of group_size and return the 61 """Install the given themes in groups of group_size and return the
62 group of themes that crashes (if any). 62 group of themes that crashes (if any).
63 63
64 Note: restarts the browser at the beginning of the function. 64 Note: restarts the browser at the beginning of the function.
65 65
66 Args: 66 Args:
67 themes: A list of themes to install. 67 themes: A list of themes to install.
68 group_size: The number of themes to install at one time. 68 group_size: The number of themes to install at one time.
69 urls: The list of urls to visit. 69 urls: The list of urls to visit.
70 """ 70 """
71 self.RestartBrowser() 71 self.RestartBrowser()
72 curr_theme = 0 72 curr_theme = 0
73 num_themes = len(themes) 73 num_themes = len(themes)
74 74
75 while curr_theme < num_themes: 75 while curr_theme < num_themes:
76 logging.debug('New group of %d themes.' % group_size) 76 logging.debug('New group of %d themes.' % group_size)
77 group_end = curr_theme + group_size 77 group_end = curr_theme + group_size
78 this_group = themes[curr_theme:group_end] 78 this_group = themes[curr_theme:group_end]
79 79
80 # Apply each theme in this group. 80 # Apply each theme in this group.
81 for theme in this_group: 81 for theme in this_group:
82 logging.debug('Applying theme: %s' % theme) 82 logging.debug('Applying theme: %s' % theme)
83 self.assertTrue(self.SetTheme(pyauto.FilePath(theme)), 83 self.assertTrue(self.SetTheme(theme),
84 'Theme %s not installed.' % theme) 84 'Theme %s not installed.' % theme)
85 85
86 for url in urls: 86 for url in urls:
87 self.NavigateToURL(url) 87 self.NavigateToURL(url)
88 88
89 def _LogAndReturnCrashing(): 89 def _LogAndReturnCrashing():
90 logging.debug('Crashing themes: %s' % this_group) 90 logging.debug('Crashing themes: %s' % this_group)
91 return this_group 91 return this_group
92 92
93 # Assert that there is at least 1 browser window. 93 # Assert that there is at least 1 browser window.
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 failed_themes = self._ReturnCrashingThemes(failed_themes, group_size, 131 failed_themes = self._ReturnCrashingThemes(failed_themes, group_size,
132 urls) 132 urls)
133 group_size = group_size // 2 133 group_size = group_size // 2
134 134
135 self.assertFalse(failed_themes, 135 self.assertFalse(failed_themes,
136 'Theme(s) in failing group: %s' % failed_themes) 136 'Theme(s) in failing group: %s' % failed_themes)
137 137
138 138
139 if __name__ == '__main__': 139 if __name__ == '__main__':
140 pyauto_functional.Main() 140 pyauto_functional.Main()
141
OLDNEW
« no previous file with comments | « chrome/test/functional/ntp.py ('k') | chrome/test/pyautolib/pyautolib.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698