diff options
author | alyssad@chromium.org <alyssad@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-09 16:36:54 +0000 |
---|---|---|
committer | alyssad@chromium.org <alyssad@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-09 16:36:54 +0000 |
commit | b96d87bfd44a0f36c42e10b6edd9fa6b42ef8539 (patch) | |
tree | 68d641f05645dc03b69d682d34420572938027c9 /chrome/test/functional | |
parent | f3fa4072e0afc0d39ec2293015cd97af9f9e481a (diff) | |
download | chromium_src-b96d87bfd44a0f36c42e10b6edd9fa6b42ef8539.zip chromium_src-b96d87bfd44a0f36c42e10b6edd9fa6b42ef8539.tar.gz chromium_src-b96d87bfd44a0f36c42e10b6edd9fa6b42ef8539.tar.bz2 |
pyauto theme runner
New pyauto tool that installs themes and checks that they are installed correctly and don't crash the browser.
Review URL: http://codereview.chromium.org/3036025
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@55409 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/functional')
-rw-r--r-- | chrome/test/functional/themes.py | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/chrome/test/functional/themes.py b/chrome/test/functional/themes.py index 980c5f6..d0963b3 100644 --- a/chrome/test/functional/themes.py +++ b/chrome/test/functional/themes.py @@ -3,6 +3,8 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. +import glob +import logging import os import pyauto_functional # Must be imported before pyauto @@ -41,6 +43,84 @@ class ThemesTest(pyauto.PyUITest): self.assertTrue(self.ResetToDefaultTheme()) self.assertFalse(self.GetThemeInfo()) + def _ReturnCrashingThemes(self, themes, group_size, urls): + """Install the given themes in groups of group_size and return the + group of themes that crashes (if any). + + Note: restarts the browser at the beginning of the function. + + Args: + themes: A list of themes to install. + group_size: The number of themes to install at one time. + urls: The list of urls to visit. + """ + self.RestartBrowser() + curr_theme = 0 + num_themes = len(themes) + + while curr_theme < num_themes: + logging.debug('New group of %d themes.' % group_size) + group_end = curr_theme + group_size + this_group = themes[curr_theme:group_end] + + # Apply each theme in this group. + for theme in this_group: + logging.debug('Applying theme: %s' % theme) + self.assertTrue(self.SetTheme(pyauto.FilePath(theme)), + 'Theme %s not installed.' % theme) + + for url in urls: + self.NavigateToURL(url) + + def _LogAndReturnCrashing(): + logging.debug('Crashing themes: %s' % this_group) + return this_group + + # Assert that there is at least 1 browser window. + try: + num_browser_windows = self.GetBrowserWindowCount() + except: + return _LogAndReturnCrashing() + else: + if not num_browser_windows: + return _LogAndReturnCrashing() + + curr_theme = group_end + + # None of the themes crashed. + return None + + def Runner(self): + """Apply themes; verify that theme has been applied and browser doesn't + crash. + + This does not get run automatically. To run: + python themes.py themes.ThemesTest.Runner + + Note: this test requires that a directory of crx files called 'themes' + exists in the data directory. + """ + themes_dir = os.path.join(self.DataDir(), 'themes') + urls_file = os.path.join(self.DataDir(), 'urls.txt') + + assert(os.path.exists(themes_dir), + 'The dir "%s" must exist' % os.path.abspath(themes_dir)) + + group_size = 20 + num_urls_to_visit = 100 + + urls = [l.rstrip() for l in + open(urls_file).readlines()[:num_urls_to_visit]] + failed_themes = glob.glob(os.path.join(themes_dir, '*.crx')) + + while failed_themes and group_size: + failed_themes = self._ReturnCrashingThemes(failed_themes, group_size, + urls) + group_size = group_size // 2 + + self.assertFalse(failed_themes, + 'Theme(s) in failing group: %s' % failed_themes) + if __name__ == '__main__': pyauto_functional.Main() |