Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3662)

Unified Diff: chrome/test/functional/protector.py

Issue 9748016: [protector] Added UI for invalid Preferences backup case. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix unit-test. Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/chrome_tests.gypi ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/functional/protector.py
diff --git a/chrome/test/functional/protector.py b/chrome/test/functional/protector.py
index 20b0d84bf779026181230b3fc299a51ccba1a8c8..6f8b4407260c25c837a99bcaee7489f56e3a8465 100644
--- a/chrome/test/functional/protector.py
+++ b/chrome/test/functional/protector.py
@@ -145,6 +145,12 @@ class BaseProtectorTest(pyauto.PyUITest):
with open(os.path.join(self._profile_path, 'Preferences'), 'w') as f:
json.dump(prefs, f)
+ def _InvalidatePreferencesBackup(self):
+ """Makes the Preferences backup invalid by clearing the signature."""
+ prefs = self._LoadPreferences()
+ prefs['backup']['_signature'] = 'INVALID'
+ self._WritePreferences(prefs)
+
def _ChangeSessionStartupPrefs(self, startup_type, startup_urls=None,
homepage=None):
"""Changes the session startup type and the list of URLs to load on startup.
@@ -279,6 +285,41 @@ class ProtectorSearchEngineTest(BaseProtectorTest):
# add new search engines to the list, invalidate backup, etc).
+class ProtectorPreferencesTest(BaseProtectorTest):
+ """Generic test suite for Preferences protection."""
+
+ def testPreferencesBackupInvalid(self):
+ """Test for detecting invalid Preferences backup."""
+ self.RestartBrowser(
+ clear_profile=False,
+ pre_launch_hook=self._InvalidatePreferencesBackup)
+ # The change must be detected by Protector.
+ self.assertTrue(self.GetProtectorState()['showing_change'])
+ self.DiscardProtectorChange()
+ # Verify that a new tab with settings is opened.
+ info = self.GetBrowserInfo()
+ self.assertEqual(1, len(info['windows'])) # one window
+ self.assertEqual(2, len(info['windows'][0]['tabs'])) # 2 tabs
+ self.assertEqual('chrome://settings/', info['windows'][0]['tabs'][1]['url'])
+ # No longer showing the change.
+ self.assertFalse(self.GetProtectorState()['showing_change'])
+ self.RestartBrowser(clear_profile=False)
+ # Not showing the change after a restart
+ self.assertFalse(self.GetProtectorState()['showing_change'])
+
+ def testPreferencesBackupInvalidChangeDismissedOnEdit(self):
+ """Test that editing protected prefs dismisses the invalid backup bubble."""
+ self.RestartBrowser(
+ clear_profile=False,
+ pre_launch_hook=self._InvalidatePreferencesBackup)
+ # The change must be detected by Protector.
+ self.assertTrue(self.GetProtectorState()['showing_change'])
+ # Change some protected setting manually.
+ self.SetPrefs(pyauto.kHomePage, 'http://example.com/')
+ # No longer showing the change.
+ self.assertFalse(self.GetProtectorState()['showing_change'])
+
+
class ProtectorSessionStartupTest(BaseProtectorTest):
"""Test suite for session startup changes detection with Protector enabled.
"""
« no previous file with comments | « chrome/chrome_tests.gypi ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698