diff options
author | nirnimesh@chromium.org <nirnimesh@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-10 00:09:03 +0000 |
---|---|---|
committer | nirnimesh@chromium.org <nirnimesh@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-10 00:09:03 +0000 |
commit | 4d1929f16b8c00f304fdc291cd4672c61ae5f400 (patch) | |
tree | 08ba2870510d8d11c5bffc0764a0d5968fda2b9d /chrome/test/pyautolib | |
parent | b7ca76b51d7a8c3f28d068a70b7b607be814c63e (diff) | |
download | chromium_src-4d1929f16b8c00f304fdc291cd4672c61ae5f400.zip chromium_src-4d1929f16b8c00f304fdc291cd4672c61ae5f400.tar.gz chromium_src-4d1929f16b8c00f304fdc291cd4672c61ae5f400.tar.bz2 |
PyAuto: Automation hooks to get/set theme
Add automation hooks to:
- install a given theme
- fetch info about the current theme
- reset to default theme
Add a test exercising the above.
BUG=36215
TEST=python chrome/test/functional/themes.py
Review URL: http://codereview.chromium.org/2827048
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@52024 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/pyautolib')
-rw-r--r-- | chrome/test/pyautolib/pyauto.py | 62 | ||||
-rw-r--r-- | chrome/test/pyautolib/pyautolib.cc | 4 | ||||
-rw-r--r-- | chrome/test/pyautolib/pyautolib.h | 3 | ||||
-rw-r--r-- | chrome/test/pyautolib/pyautolib.i | 6 |
4 files changed, 74 insertions, 1 deletions
diff --git a/chrome/test/pyautolib/pyauto.py b/chrome/test/pyautolib/pyauto.py index e2c64c5..4b94b3d 100644 --- a/chrome/test/pyautolib/pyauto.py +++ b/chrome/test/pyautolib/pyauto.py @@ -757,6 +757,68 @@ class PyUITest(pyautolib.PyUITestBase, unittest.TestCase): finally: shutil.rmtree(tempdir) + def SetTheme(self, crx_file_path): + """Installs the given theme synchronously. + + A theme file is file with .crx suffix, like an extension. + This method call waits until theme is installed and will trigger the + "theme installed" infobar. + + Uses InstallExtension(). + + Returns: + True, on success. + """ + return self.InstallExtension(crx_file_path, True) + + 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', + } + ret_dict = json.loads(self._SendJSONRequest(0, json.dumps(cmd_dict))) + if ret_dict.has_key('error'): + raise JSONInterfaceError(ret_dict['error']) + return ret_dict + + def GetThemeInfo(self): + """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', + } + ret_dict = json.loads(self._SendJSONRequest(0, json.dumps(cmd_dict))) + if ret_dict.has_key('error'): + raise JSONInterfaceError(ret_dict['error']) + return ret_dict + class PyUITestSuite(pyautolib.PyUITestSuiteBase, unittest.TestSuite): """Base TestSuite for PyAuto UI tests.""" diff --git a/chrome/test/pyautolib/pyautolib.cc b/chrome/test/pyautolib/pyautolib.cc index 452727b..0ae5b55 100644 --- a/chrome/test/pyautolib/pyautolib.cc +++ b/chrome/test/pyautolib/pyautolib.cc @@ -294,3 +294,7 @@ std::string PyUITestBase::_SendJSONRequest(int window_index, } return response; } + +bool PyUITestBase::ResetToDefaultTheme() { + return automation()->ResetToDefaultTheme(); +} diff --git a/chrome/test/pyautolib/pyautolib.h b/chrome/test/pyautolib/pyautolib.h index d293370..6c6fc35 100644 --- a/chrome/test/pyautolib/pyautolib.h +++ b/chrome/test/pyautolib/pyautolib.h @@ -147,6 +147,9 @@ class PyUITestBase : public UITestBase { // automation proxy additions. Returns response as JSON dict. std::string _SendJSONRequest(int window_index, std::string& request); + // Resets to the default theme. Returns true on success. + bool ResetToDefaultTheme(); + private: // Enables PostTask to main thread. // Should be shared across multiple instances of PyUITestBase so that this diff --git a/chrome/test/pyautolib/pyautolib.i b/chrome/test/pyautolib/pyautolib.i index 1b011a2..889f989 100644 --- a/chrome/test/pyautolib/pyautolib.i +++ b/chrome/test/pyautolib/pyautolib.i @@ -330,9 +330,13 @@ class PyUITestBase { // Meta-method %feature("docstring", "Send a sync JSON request to Chrome. " "Returns a JSON dict as a response. " - "Internal method.") + "Internal method.") _SendJSONRequest; std::string _SendJSONRequest(int window_index, std::string request); + %feature("docstring", "Resets to the default theme. " + "Returns true on success.") ResetToDefaultTheme; + bool ResetToDefaultTheme(); + }; |