Suppression for crbug/241044.
[chromium-blink-merge.git] / chrome / test / install_test / theme_updater.py
blob190eabf0cdbc519491210dd21d6c6dce169fd508
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
5 """Update tests for themes."""
6 import os
8 from common import util
10 import chrome_options
11 import install_test
14 class ThemeUpdater(install_test.InstallTest):
15 """Theme update tests."""
16 _DIRECTORY = os.path.dirname(os.path.abspath(__file__))
17 _EXTENSIONS_DIR = os.path.join(_DIRECTORY, os.path.pardir, 'data',
18 'extensions')
19 camo_theme = os.path.join(_EXTENSIONS_DIR, 'theme.crx')
20 camo_img = ('chrome://theme/IDR_THEME_NTP_BACKGROUND?'
21 'iamefpfkojoapidjnbafmgkgncegbkad')
23 def setUp(self):
24 super(ThemeUpdater, self).setUp()
25 self._user_data_dir = util.MakeTempDir()
27 def _CheckThemeApplied(self):
28 """Loads the New Tab Page and asserts that the theme is applied."""
29 self._driver.get('chrome://newtab')
30 html = self._driver.find_element_by_xpath('html')
31 html_background = html.value_of_css_property('background-image')
32 self.assertTrue(self.camo_img in html_background,
33 msg='Did not find expected theme background-image')
35 def _StartChromeProfile(self, incognito=False):
36 """Start Chrome with a temp profile.
38 Args:
39 incognito: Boolean flag for starting Chrome in incognito.
40 """
41 options = chrome_options.ChromeOptions()
42 options.SetUserDataDir(self._user_data_dir)
43 if incognito:
44 options.AddSwitch('incognito')
45 self.StartChrome(options.GetCapabilities())
47 def _StartChromeProfileExtension(self, extension):
48 """Start Chrome with a temp profile and with specified extension.
50 Args:
51 extension: Paths to extension to be installed.
52 """
53 options = chrome_options.ChromeOptions()
54 options.AddExtension(extension)
55 options.SetUserDataDir(self._user_data_dir)
56 self.StartChrome(options.GetCapabilities())
58 def testInstallTheme(self):
59 """Install a theme and check it is still applied after update."""
60 self.Install(self.GetUpdateBuilds()[0])
61 self._StartChromeProfileExtension(self.camo_theme)
62 self._CheckThemeApplied()
64 # Update and relaunch without extension.
65 self.Install(self.GetUpdateBuilds()[1])
66 self._StartChromeProfile()
67 self._CheckThemeApplied()
69 def testInstallThemeIncognito(self):
70 """Install a theme and check it still applies to incognito after update."""
71 self.Install(self.GetUpdateBuilds()[0])
72 self._StartChromeProfileExtension(self.camo_theme)
73 self._CheckThemeApplied()
75 # Relaunch without extension in incognito.
76 self._driver.quit()
77 self._StartChromeProfile(incognito=True)
78 self._CheckThemeApplied()
80 # Update and relaunch without extension in incognito.
81 self.Install(self.GetUpdateBuilds()[1])
82 self._StartChromeProfile(incognito=True)
83 self._CheckThemeApplied()