diff options
author | nirnimesh@chromium.org <nirnimesh@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-23 22:37:31 +0000 |
---|---|---|
committer | nirnimesh@chromium.org <nirnimesh@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-23 22:37:31 +0000 |
commit | 128b36e512bd470527559584e24868974feadf7a (patch) | |
tree | 5b7a4084b507b565a01979ac6e5aeb0fa1634467 /chrome/test/functional/extensions.py | |
parent | 1cd5f75fcb5c382330778bffffc4f950aff488de (diff) | |
download | chromium_src-128b36e512bd470527559584e24868974feadf7a.zip chromium_src-128b36e512bd470527559584e24868974feadf7a.tar.gz chromium_src-128b36e512bd470527559584e24868974feadf7a.tar.bz2 |
A qa-tool to check that the browser does not crash after extensions are installed.
Review URL: http://codereview.chromium.org/2831020
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@50656 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/functional/extensions.py')
-rw-r--r-- | chrome/test/functional/extensions.py | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/chrome/test/functional/extensions.py b/chrome/test/functional/extensions.py new file mode 100644 index 0000000..df46224 --- /dev/null +++ b/chrome/test/functional/extensions.py @@ -0,0 +1,65 @@ +#!/usr/bin/python +# Copyright (c) 2010 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +""" +This module is a simple qa tool that installs extensions and tests whether the +browser crashes while visiting a list of urls. + +Usage: python extensions.py -v + +Note: This assumes that there is a directory of extensions in called +'extensions' and that there is a file of newline-separated urls to visit called +'urls.txt' in the same directory as the script. +""" + +import glob +import logging +import os +import sys + +import pyauto_functional # must be imported before pyauto +import pyauto + + +class ExtensionsTest(pyauto.PyUITest): + """Test of extensions.""" + # TODO: provide a way in pyauto to pass args to a test and take these as args + extensions_dir_ = 'extensions' # The directory of extensions + urls_file_ = 'urls.txt' # The file which holds a list of urls to visit + + def testExtensionCrashes(self): + """Add top extensions; confirm browser stays up when visiting top urls""" + self.assertTrue(os.path.exists(self.extensions_dir_), + 'The dir "%s" must exist' % os.path.abspath(self.extensions_dir_)) + self.assertTrue(os.path.exists(self.urls_file_), + 'The file "%s" must exist' % os.path.abspath(self.urls_file_)) + + extensions_group_size = 20 + num_urls_to_visit = 100 + + extensions = glob.glob(os.path.join(self.extensions_dir_, '*.crx')) + top_urls = [l.rstrip() for l in open(self.urls_file_).readlines()] + + curr_extension = 0 + num_extensions = len(extensions) + + while curr_extension < num_extensions: + logging.debug('New group of %d extensions.' % extensions_group_size) + group_end = curr_extension + extensions_group_size + for extension in extensions[curr_extension:group_end]: + logging.debug('Installing extension: %s' % extension) + self.InstallExtension(pyauto.FilePath(extension), False) + + # Navigate to the top urls and verify there is still one window + for url in top_urls[:num_urls_to_visit]: + self.NavigateToURL(url) + self.assertEqual(1, self.GetBrowserWindowCount(), + 'Extensions in failing group: %s' % + extensions[curr_extension:group_end]) + curr_extension = group_end + + +if __name__ == '__main__': + pyauto_functional.Main() |