summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/test/functional/downloads.py16
-rw-r--r--chrome/test/pyautolib/pyauto.py16
2 files changed, 32 insertions, 0 deletions
diff --git a/chrome/test/functional/downloads.py b/chrome/test/functional/downloads.py
index 2342694..e70e6cd 100644
--- a/chrome/test/functional/downloads.py
+++ b/chrome/test/functional/downloads.py
@@ -362,6 +362,22 @@ class DownloadsTest(pyauto.PyUITest):
self.assertEqual(file_url, downloads[0]['url'])
os.path.exists(downloaded_pkg) and os.remove(downloaded_pkg)
+ def testDownloadTheme(self):
+ """Verify downloading and saving a theme file installs the theme."""
+ test_dir = os.path.join(os.path.abspath(self.DataDir()), 'extensions')
+ file_url = self.GetFileURLForPath(os.path.join(test_dir, 'theme.crx'))
+ downloaded_pkg = os.path.join(self.GetDownloadDirectory().value(),
+ 'theme.crx')
+ os.path.exists(downloaded_pkg) and os.remove(downloaded_pkg)
+
+ self.DownloadAndWaitForStart(file_url)
+ self.PerformActionOnDownload(self._GetDownloadId(),
+ 'save_dangerous_download')
+ # Wait for the theme to be set automatically.
+ self.assertTrue(self.WaitUntilDownloadedThemeSet('camo theme'))
+ self.assertTrue(self.WaitUntil(lambda path: not os.path.exists(path),
+ args=[downloaded_pkg]))
+
if __name__ == '__main__':
pyauto_functional.Main()
diff --git a/chrome/test/pyautolib/pyauto.py b/chrome/test/pyautolib/pyauto.py
index 555deb0..6aa64a2 100644
--- a/chrome/test/pyautolib/pyauto.py
+++ b/chrome/test/pyautolib/pyauto.py
@@ -1282,6 +1282,22 @@ class PyUITest(pyautolib.PyUITestBase, unittest.TestCase):
"""
return self.InstallExtension(crx_file_path, True)
+ 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.