diff options
author | nirnimesh@chromium.org <nirnimesh@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-18 22:08:47 +0000 |
---|---|---|
committer | nirnimesh@chromium.org <nirnimesh@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-18 22:08:47 +0000 |
commit | 972e125511e6197981b5198d7775bcf4da9411c6 (patch) | |
tree | 575f407f26c28db1b44a1c7e7afb50e7fd38d289 | |
parent | 307aec7a614d8e4507f221198e666f6d139a989b (diff) | |
download | chromium_src-972e125511e6197981b5198d7775bcf4da9411c6.zip chromium_src-972e125511e6197981b5198d7775bcf4da9411c6.tar.gz chromium_src-972e125511e6197981b5198d7775bcf4da9411c6.tar.bz2 |
- testSetTheme was already covered (after adding theme name verification).
- testThemeUndo was already covered
- testThemeOverInstall was already covered
- testThemeInFullScreen -> TestInstallThemeInFullScreen
- testThemeReset -> TestThemeReset
- Runner was not running by default and is missing data files so it doesn't
look like it has run in a while.
Remove automation hooks: GetThemeInfo, ResetToDefaultTheme
BUG=143637
TEST=browser_tests --gtest_filter=ExtensionInstallUIBrowserTest.*
Review URL: https://chromiumcodereview.appspot.com/10916328
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@157427 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/automation/testing_automation_provider.cc | 40 | ||||
-rw-r--r-- | chrome/browser/automation/testing_automation_provider.h | 10 | ||||
-rw-r--r-- | chrome/browser/extensions/extension_install_ui_browsertest.cc | 40 | ||||
-rw-r--r-- | chrome/test/functional/PYAUTO_TESTS | 1 | ||||
-rwxr-xr-x | chrome/test/functional/themes.py | 177 | ||||
-rwxr-xr-x | chrome/test/pyautolib/pyauto.py | 73 |
6 files changed, 30 insertions, 311 deletions
diff --git a/chrome/browser/automation/testing_automation_provider.cc b/chrome/browser/automation/testing_automation_provider.cc index 9bb6dad..6e72e53 100644 --- a/chrome/browser/automation/testing_automation_provider.cc +++ b/chrome/browser/automation/testing_automation_provider.cc @@ -87,8 +87,6 @@ #include "chrome/browser/sessions/session_tab_helper.h" #include "chrome/browser/sync/profile_sync_service.h" #include "chrome/browser/sync/profile_sync_service_factory.h" -#include "chrome/browser/themes/theme_service.h" -#include "chrome/browser/themes/theme_service_factory.h" #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog.h" #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.h" #include "chrome/browser/ui/app_modal_dialogs/javascript_app_modal_dialog.h" @@ -1957,13 +1955,6 @@ void TestingAutomationProvider::BuildJSONHandlerMaps() { browser_handler_map_["GetSavedPasswords"] = &TestingAutomationProvider::GetSavedPasswords; - handler_map_["ResetToDefaultTheme"] = - &TestingAutomationProvider::ResetToDefaultTheme; - - // SetTheme() implemented using InstallExtension(). - browser_handler_map_["GetThemeInfo"] = - &TestingAutomationProvider::GetThemeInfo; - browser_handler_map_["FindInPage"] = &TestingAutomationProvider::FindInPage; browser_handler_map_["GetAllNotifications"] = @@ -3691,23 +3682,6 @@ void TestingAutomationProvider::IsFindInPageVisible( reply.SendSuccess(&dict); } -// Sample json input: { "command": "GetThemeInfo" } -// Refer GetThemeInfo() in chrome/test/pyautolib/pyauto.py for sample output. -void TestingAutomationProvider::GetThemeInfo( - Browser* browser, - DictionaryValue* args, - IPC::Message* reply_message) { - scoped_ptr<DictionaryValue> return_value(new DictionaryValue); - const Extension* theme = ThemeServiceFactory::GetThemeForProfile(profile()); - if (theme) { - return_value->SetString("name", theme->name()); - return_value->Set("images", theme->GetThemeImages()->DeepCopy()); - return_value->Set("colors", theme->GetThemeColors()->DeepCopy()); - return_value->Set("tints", theme->GetThemeTints()->DeepCopy()); - } - AutomationJSONReply(this, reply_message).SendSuccess(return_value.get()); -} - void TestingAutomationProvider::InstallExtension( DictionaryValue* args, IPC::Message* reply_message) { FilePath::StringType path_string; @@ -6244,20 +6218,6 @@ void TestingAutomationProvider::ActivateTabJSON( reply.SendSuccess(NULL); } -void TestingAutomationProvider::ResetToDefaultTheme( - base::DictionaryValue* args, - IPC::Message* reply_message) { - AutomationJSONReply reply(this, reply_message); - Browser* browser; - std::string error_msg; - if (!GetBrowserFromJSONArgs(args, &browser, &error_msg)) { - reply.SendError(error_msg); - return; - } - ThemeServiceFactory::GetForProfile(browser->profile())->UseDefaultTheme(); - reply.SendSuccess(NULL); -} - void TestingAutomationProvider::IsPageActionVisible( base::DictionaryValue* args, IPC::Message* reply_message) { diff --git a/chrome/browser/automation/testing_automation_provider.h b/chrome/browser/automation/testing_automation_provider.h index b820269..6e6e9c97 100644 --- a/chrome/browser/automation/testing_automation_provider.h +++ b/chrome/browser/automation/testing_automation_provider.h @@ -271,10 +271,6 @@ class TestingAutomationProvider : public AutomationProvider, // Uses the JSON interface for input/output. void CloseBrowserWindow(base::DictionaryValue* args, IPC::Message* reply_message); - // Reset to the default theme. - // Uses the JSON interface for input/output. - void ResetToDefaultTheme(base::DictionaryValue* args, - IPC::Message* reply_message); // Get info about multi-profile users. // Uses the JSON interface for input/output. @@ -516,12 +512,6 @@ class TestingAutomationProvider : public AutomationProvider, base::DictionaryValue* args, IPC::Message* reply_message); - // Get info about theme. - // Uses the JSON interface for input/output. - void GetThemeInfo(Browser* browser, - base::DictionaryValue* args, - IPC::Message* reply_message); - // Install the given unpacked/packed extension. // Uses the JSON interface for input/output. void InstallExtension(base::DictionaryValue* args, diff --git a/chrome/browser/extensions/extension_install_ui_browsertest.cc b/chrome/browser/extensions/extension_install_ui_browsertest.cc index ff388d3..1179988 100644 --- a/chrome/browser/extensions/extension_install_ui_browsertest.cc +++ b/chrome/browser/extensions/extension_install_ui_browsertest.cc @@ -3,13 +3,16 @@ // found in the LICENSE file. #include "base/string_util.h" +#include "chrome/app/chrome_command_ids.h" #include "chrome/browser/extensions/extension_browsertest.h" #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/theme_installed_infobar_delegate.h" #include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/profiles/profile.h" +#include "chrome/browser/themes/theme_service.h" #include "chrome/browser/themes/theme_service_factory.h" #include "chrome/browser/ui/browser.h" +#include "chrome/browser/ui/browser_commands.h" #include "chrome/browser/ui/browser_finder.h" #include "chrome/browser/ui/browser_tabstrip.h" #include "chrome/browser/ui/tab_contents/tab_contents.h" @@ -36,6 +39,16 @@ class ExtensionInstallUIBrowserTest : public ExtensionBrowserTest { ASSERT_EQ(0U, infobar_helper->GetInfoBarCount()); } + // Install the given theme from the data dir and verify expected name. + void InstallThemeAndVerify(const char* theme_name, + const std::string& expected_name) { + const FilePath theme_path = test_data_dir_.AppendASCII(theme_name); + ASSERT_TRUE(InstallExtensionWithUIAutoConfirm(theme_path, 1, browser())); + const Extension* theme = GetTheme(); + ASSERT_TRUE(theme); + ASSERT_EQ(theme->name(), expected_name); + } + const Extension* GetTheme() const { return ThemeServiceFactory::GetThemeForProfile(browser()->profile()); } @@ -51,8 +64,6 @@ class ExtensionInstallUIBrowserTest : public ExtensionBrowserTest { IN_PROC_BROWSER_TEST_F(ExtensionInstallUIBrowserTest, MAYBE_TestThemeInstallUndoResetsToDefault) { - ui_test_utils::CloseAllInfoBars(chrome::GetActiveTabContents(browser())); - // Install theme once and undo to verify we go back to default theme. FilePath theme_crx = PackExtension(test_data_dir_.AppendASCII("theme")); ASSERT_TRUE(InstallExtensionWithUIAutoConfirm(theme_crx, 1, browser())); @@ -80,20 +91,14 @@ IN_PROC_BROWSER_TEST_F(ExtensionInstallUIBrowserTest, IN_PROC_BROWSER_TEST_F(ExtensionInstallUIBrowserTest, TestThemeInstallUndoResetsToPreviousTheme) { - ui_test_utils::CloseAllInfoBars(chrome::GetActiveTabContents(browser())); - // Install first theme. - FilePath theme_path = test_data_dir_.AppendASCII("theme"); - ASSERT_TRUE(InstallExtensionWithUIAutoConfirm(theme_path, 1, browser())); + InstallThemeAndVerify("theme", "camo theme"); const Extension* theme = GetTheme(); - ASSERT_TRUE(theme); std::string theme_id = theme->id(); // Then install second theme. - FilePath theme_path2 = test_data_dir_.AppendASCII("theme2"); - ASSERT_TRUE(InstallExtensionWithUIAutoConfirm(theme_path2, 1, browser())); + InstallThemeAndVerify("theme2", "snowflake theme"); const Extension* theme2 = GetTheme(); - ASSERT_TRUE(theme2); EXPECT_FALSE(theme_id == theme2->id()); // Undo second theme will revert to first theme. @@ -101,6 +106,21 @@ IN_PROC_BROWSER_TEST_F(ExtensionInstallUIBrowserTest, EXPECT_EQ(theme, GetTheme()); } +IN_PROC_BROWSER_TEST_F(ExtensionInstallUIBrowserTest, + TestThemeReset) { + InstallThemeAndVerify("theme", "camo theme"); + + // Reset to default theme. + ThemeServiceFactory::GetForProfile(browser()->profile())->UseDefaultTheme(); + ASSERT_FALSE(GetTheme()); +} + +IN_PROC_BROWSER_TEST_F(ExtensionInstallUIBrowserTest, + TestInstallThemeInFullScreen) { + EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_FULLSCREEN)); + InstallThemeAndVerify("theme", "camo theme"); +} + #if defined(OS_WIN) // http://crbug.com/141854 #define MAYBE_AppInstallConfirmation FLAKY_AppInstallConfirmation diff --git a/chrome/test/functional/PYAUTO_TESTS b/chrome/test/functional/PYAUTO_TESTS index e981543..e70bcbb 100644 --- a/chrome/test/functional/PYAUTO_TESTS +++ b/chrome/test/functional/PYAUTO_TESTS @@ -62,7 +62,6 @@ 'special_tabs', 'sync.SyncTest', 'test_pyauto', - 'themes', # ================================================== # Disabled tests that need to be investigated/fixed. diff --git a/chrome/test/functional/themes.py b/chrome/test/functional/themes.py deleted file mode 100755 index 0936bf2..0000000 --- a/chrome/test/functional/themes.py +++ /dev/null @@ -1,177 +0,0 @@ -#!/usr/bin/env python -# Copyright (c) 2012 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. - -import glob -import logging -import os - -import pyauto_functional # Must be imported before pyauto -import pyauto - - -class ThemesTest(pyauto.PyUITest): - """TestCase for Themes.""" - - def Debug(self): - """Test method for experimentation. - - This method will not run automatically. - """ - while True: - raw_input('Hit <enter> to dump info.. ') - self.pprint(self.GetThemeInfo()) - - def _SetThemeAndVerify(self, crx_file, theme_name): - """Set theme and verify infobar appears and the theme name is correct. - - Args: - crx_file: Path to .crx file to be set as theme. - theme_name: String to be compared to GetThemeInfo()['name']. - """ - # Starting infobar count is the number of non-themes infobars. - infobars = self.GetBrowserInfo()['windows'][0]['tabs'][0]['infobars'] - infobar_count = 0 - for infobar in infobars: - if not (('text' in infobar) and - infobar['text'].startswith('Installed theme')): - infobar_count += 1 - self.SetTheme(crx_file) - # Verify infobar shows up. - self.assertTrue(self.WaitForInfobarCount(infobar_count + 1)) - self.assertTrue(self.GetBrowserInfo()['windows'][0]['tabs'][0]['infobars']) - # Verify theme name is correct. - self.assertEqual(theme_name, self.GetThemeInfo()['name']) - - def testSetTheme(self): - """Verify theme install.""" - self.assertFalse(self.GetThemeInfo()) # Verify there's no theme at startup - crx_file = os.path.abspath( - os.path.join(self.DataDir(), 'extensions', 'theme.crx')) - self._SetThemeAndVerify(crx_file, 'camo theme') - - def testThemeInFullScreen(self): - """Verify theme can be installed in FullScreen mode.""" - self.ApplyAccelerator(pyauto.IDC_FULLSCREEN) - self.assertFalse(self.GetThemeInfo()) # Verify there's no theme at startup - crx_file = os.path.abspath( - os.path.join(self.DataDir(), 'extensions', 'theme.crx')) - self._SetThemeAndVerify(crx_file, 'camo theme') - - def testThemeReset(self): - """Verify theme reset.""" - crx_file = os.path.abspath( - os.path.join(self.DataDir(), 'extensions', 'theme.crx')) - self.SetTheme(crx_file) - self.ResetToDefaultTheme() - self.assertFalse(self.GetThemeInfo()) - - def testThemeUndo(self): - """Verify theme undo.""" - crx_file = os.path.abspath( - os.path.join(self.DataDir(), 'extensions', 'theme.crx')) - self._SetThemeAndVerify(crx_file, 'camo theme') - # Undo theme install. - infobars = self.GetBrowserInfo()['windows'][0]['tabs'][0]['infobars'] - for index, infobar in enumerate(infobars): - if (('text' in infobar) and - infobar['text'].startswith('Installed theme')): - theme_index = index - break - self.PerformActionOnInfobar('cancel', infobar_index=theme_index) - self.assertFalse(self.GetThemeInfo()) - - def testThemeOverInstall(self): - """Verify that can install a theme over an existing theme.""" - crx_file = os.path.abspath( - os.path.join(self.DataDir(), 'extensions', 'theme.crx')) - self._SetThemeAndVerify(crx_file, 'camo theme') - # Install a different theme. - crx_file = os.path.abspath( - os.path.join(self.DataDir(), 'extensions', 'theme2.crx')) - self._SetThemeAndVerify(crx_file, 'snowflake theme') - - 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. - - Returns: - Group of themes that crashed (if any). - """ - 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.SetTheme(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() diff --git a/chrome/test/pyautolib/pyauto.py b/chrome/test/pyautolib/pyauto.py index b0adc57..010595d 100755 --- a/chrome/test/pyautolib/pyauto.py +++ b/chrome/test/pyautolib/pyauto.py @@ -3188,21 +3188,6 @@ class PyUITest(pyautolib.PyUITestBase, unittest.TestCase): } return self._GetResultFromJSONRequest(cmd_dict)['passwords'] - def ResetToDefaultTheme(self, windex=0): - """Reset to default theme. - - Args: - windex: Index of the window to reset; defaults to 0. - - Raises: - pyauto_errors.JSONInterfaceError if the automation call returns an error. - """ - cmd_dict = { - 'command': 'ResetToDefaultTheme', - 'windex': windex, - } - self._GetResultFromJSONRequest(cmd_dict, windex=None) - def SetTheme(self, crx_file_path, windex=0): """Installs the given theme synchronously. @@ -3221,64 +3206,6 @@ class PyUITest(pyautolib.PyUITestBase, unittest.TestCase): """ return self.InstallExtension(crx_file_path, True, windex) - def WaitUntilDownloadedThemeSet(self, theme_name): - """Waits until the theme has been set. - - This should not be called after SetTheme(). It only needs to be called after - downloading a theme file (which will automatically set the theme). - - Uses WaitUntil so timeout is capped by automation timeout. - - Args: - theme_name: The name that the theme will have once it is installed. - """ - def _ReturnThemeSet(name): - theme_info = self.GetThemeInfo() - return theme_info and theme_info['name'] == name - return self.WaitUntil(_ReturnThemeSet, args=[theme_name]) - - def ClearTheme(self): - """Clear the theme. Resets to default. - - Has no effect when the theme is already the default one. - This is a blocking call. - - Raises: - pyauto_errors.JSONInterfaceError if the automation call returns an error. - """ - cmd_dict = { - 'command': 'ClearTheme', - } - self._GetResultFromJSONRequest(cmd_dict) - - def GetThemeInfo(self, windex=0): - """Get info about theme. - - This includes info about the theme name, its colors, images, etc. - - Returns: - a dictionary containing info about the theme. - empty dictionary if no theme has been applied (default theme). - SAMPLE: - { u'colors': { u'frame': [71, 105, 91], - u'ntp_link': [36, 70, 0], - u'ntp_section': [207, 221, 192], - u'ntp_text': [20, 40, 0], - u'toolbar': [207, 221, 192]}, - u'images': { u'theme_frame': u'images/theme_frame_camo.png', - u'theme_ntp_background': u'images/theme_ntp_background.png', - u'theme_toolbar': u'images/theme_toolbar_camo.png'}, - u'name': u'camo theme', - u'tints': {u'buttons': [0.33000000000000002, 0.5, 0.46999999999999997]}} - - Raises: - pyauto_errors.JSONInterfaceError if the automation call returns an error. - """ - cmd_dict = { - 'command': 'GetThemeInfo', - } - return self._GetResultFromJSONRequest(cmd_dict, windex=windex) - def GetActiveNotifications(self): """Gets a list of the currently active/shown HTML5 notifications. |