| OLD | NEW |
| 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 10 matching lines...) Expand all Loading... |
| 21 """ | 21 """ |
| 22 while True: | 22 while True: |
| 23 raw_input('Hit <enter> to dump info.. ') | 23 raw_input('Hit <enter> to dump info.. ') |
| 24 self.pprint(self.GetThemeInfo()) | 24 self.pprint(self.GetThemeInfo()) |
| 25 | 25 |
| 26 def testSetTheme(self): | 26 def testSetTheme(self): |
| 27 """Verify theme install.""" | 27 """Verify theme install.""" |
| 28 self.assertFalse(self.GetThemeInfo()) # Verify there's no theme at startup | 28 self.assertFalse(self.GetThemeInfo()) # Verify there's no theme at startup |
| 29 crx_file = os.path.abspath( | 29 crx_file = os.path.abspath( |
| 30 os.path.join(self.DataDir(), 'extensions', 'theme.crx')) | 30 os.path.join(self.DataDir(), 'extensions', 'theme.crx')) |
| 31 self.assertTrue(self.SetTheme(crx_file)) | 31 self.SetTheme(crx_file) |
| 32 # Verify "theme installed" infobar shows up | 32 # Verify "theme installed" infobar shows up |
| 33 self.assertTrue(self.WaitForInfobarCount(1)) | 33 self.assertTrue(self.WaitForInfobarCount(1)) |
| 34 theme = self.GetThemeInfo() | 34 theme = self.GetThemeInfo() |
| 35 self.assertEqual('camo theme', theme['name']) | 35 self.assertEqual('camo theme', theme['name']) |
| 36 self.assertTrue(self.GetBrowserInfo()['windows'][0]['tabs'][0]['infobars']) | 36 self.assertTrue(self.GetBrowserInfo()['windows'][0]['tabs'][0]['infobars']) |
| 37 | 37 |
| 38 def testThemeInFullScreen(self): | 38 def testThemeInFullScreen(self): |
| 39 """Verify theme can be installed in FullScreen mode.""" | 39 """Verify theme can be installed in FullScreen mode.""" |
| 40 self.ApplyAccelerator(pyauto.IDC_FULLSCREEN ) | 40 self.ApplyAccelerator(pyauto.IDC_FULLSCREEN ) |
| 41 self.assertFalse(self.GetThemeInfo()) # Verify there's no theme at startup | 41 self.assertFalse(self.GetThemeInfo()) # Verify there's no theme at startup |
| 42 crx_file = os.path.abspath( | 42 crx_file = os.path.abspath( |
| 43 os.path.join(self.DataDir(), 'extensions', 'theme.crx')) | 43 os.path.join(self.DataDir(), 'extensions', 'theme.crx')) |
| 44 self.assertTrue(self.SetTheme(crx_file)) | 44 self.SetTheme(crx_file) |
| 45 # Verify "theme installed" infobar shows up | 45 # Verify "theme installed" infobar shows up |
| 46 self.assertTrue(self.WaitForInfobarCount(1)) | 46 self.assertTrue(self.WaitForInfobarCount(1)) |
| 47 theme = self.GetThemeInfo() | 47 theme = self.GetThemeInfo() |
| 48 self.assertEqual('camo theme', theme['name']) | 48 self.assertEqual('camo theme', theme['name']) |
| 49 | 49 |
| 50 def testThemeReset(self): | 50 def testThemeReset(self): |
| 51 """Verify theme reset.""" | 51 """Verify theme reset.""" |
| 52 crx_file = os.path.abspath( | 52 crx_file = os.path.abspath( |
| 53 os.path.join(self.DataDir(), 'extensions', 'theme.crx')) | 53 os.path.join(self.DataDir(), 'extensions', 'theme.crx')) |
| 54 self.assertTrue(self.SetTheme(crx_file)) | 54 self.SetTheme(crx_file) |
| 55 self.assertTrue(self.ResetToDefaultTheme()) | 55 self.assertTrue(self.ResetToDefaultTheme()) |
| 56 self.assertFalse(self.GetThemeInfo()) | 56 self.assertFalse(self.GetThemeInfo()) |
| 57 | 57 |
| 58 def _ReturnCrashingThemes(self, themes, group_size, urls): | 58 def _ReturnCrashingThemes(self, themes, group_size, urls): |
| 59 """Install the given themes in groups of group_size and return the | 59 """Install the given themes in groups of group_size and return the |
| 60 group of themes that crashes (if any). | 60 group of themes that crashes (if any). |
| 61 | 61 |
| 62 Note: restarts the browser at the beginning of the function. | 62 Note: restarts the browser at the beginning of the function. |
| 63 | 63 |
| 64 Args: | 64 Args: |
| 65 themes: A list of themes to install. | 65 themes: A list of themes to install. |
| 66 group_size: The number of themes to install at one time. | 66 group_size: The number of themes to install at one time. |
| 67 urls: The list of urls to visit. | 67 urls: The list of urls to visit. |
| 68 """ | 68 """ |
| 69 self.RestartBrowser() | 69 self.RestartBrowser() |
| 70 curr_theme = 0 | 70 curr_theme = 0 |
| 71 num_themes = len(themes) | 71 num_themes = len(themes) |
| 72 | 72 |
| 73 while curr_theme < num_themes: | 73 while curr_theme < num_themes: |
| 74 logging.debug('New group of %d themes.' % group_size) | 74 logging.debug('New group of %d themes.' % group_size) |
| 75 group_end = curr_theme + group_size | 75 group_end = curr_theme + group_size |
| 76 this_group = themes[curr_theme:group_end] | 76 this_group = themes[curr_theme:group_end] |
| 77 | 77 |
| 78 # Apply each theme in this group. | 78 # Apply each theme in this group. |
| 79 for theme in this_group: | 79 for theme in this_group: |
| 80 logging.debug('Applying theme: %s' % theme) | 80 logging.debug('Applying theme: %s' % theme) |
| 81 self.assertTrue(self.SetTheme(theme), | 81 self.SetTheme(theme) |
| 82 'Theme %s not installed.' % theme) | |
| 83 | 82 |
| 84 for url in urls: | 83 for url in urls: |
| 85 self.NavigateToURL(url) | 84 self.NavigateToURL(url) |
| 86 | 85 |
| 87 def _LogAndReturnCrashing(): | 86 def _LogAndReturnCrashing(): |
| 88 logging.debug('Crashing themes: %s' % this_group) | 87 logging.debug('Crashing themes: %s' % this_group) |
| 89 return this_group | 88 return this_group |
| 90 | 89 |
| 91 # Assert that there is at least 1 browser window. | 90 # Assert that there is at least 1 browser window. |
| 92 try: | 91 try: |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 failed_themes = self._ReturnCrashingThemes(failed_themes, group_size, | 128 failed_themes = self._ReturnCrashingThemes(failed_themes, group_size, |
| 130 urls) | 129 urls) |
| 131 group_size = group_size // 2 | 130 group_size = group_size // 2 |
| 132 | 131 |
| 133 self.assertFalse(failed_themes, | 132 self.assertFalse(failed_themes, |
| 134 'Theme(s) in failing group: %s' % failed_themes) | 133 'Theme(s) in failing group: %s' % failed_themes) |
| 135 | 134 |
| 136 | 135 |
| 137 if __name__ == '__main__': | 136 if __name__ == '__main__': |
| 138 pyauto_functional.Main() | 137 pyauto_functional.Main() |
| OLD | NEW |