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

Side by Side Diff: chrome/test/functional/protector.py

Issue 10298012: [protector] Disable the UI by default, flip --no-protector to --protector. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/common/chrome_switches.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 import pyauto_functional # Must be imported first 6 import pyauto_functional # Must be imported first
7 import pyauto 7 import pyauto
8 import test_utils 8 import test_utils
9 9
10 import json 10 import json
(...skipping 16 matching lines...) Expand all
27 pyauto.PyUITest.setUp(self) 27 pyauto.PyUITest.setUp(self)
28 # Get the profile path of the first profile. 28 # Get the profile path of the first profile.
29 profiles = self.GetMultiProfileInfo() 29 profiles = self.GetMultiProfileInfo()
30 self.assertTrue(profiles['profiles']) 30 self.assertTrue(profiles['profiles'])
31 self._profile_path = profiles['profiles'][0]['path'] 31 self._profile_path = profiles['profiles'][0]['path']
32 self.assertTrue(self._profile_path) 32 self.assertTrue(self._profile_path)
33 # Set to the keyword of the new default search engine after a successful 33 # Set to the keyword of the new default search engine after a successful
34 # _GetDefaultSearchEngine call. 34 # _GetDefaultSearchEngine call.
35 self._new_default_search_keyword = None 35 self._new_default_search_keyword = None
36 36
37 def _IsEnabled(self):
38 """Whether protector should be enabled for the test suite."""
39 return True
40
41 def ExtraChromeFlags(self):
42 """Adds required Protector-related flags.
43
44 Returns:
45 A list of extra flags to pass to Chrome when it is launched.
46 """
47 return super(BaseProtectorTest, self).ExtraChromeFlags() + [
48 '--protector' if self._IsEnabled() else '--no-protector'
49 ]
50
37 def _GetDefaultSearchEngine(self): 51 def _GetDefaultSearchEngine(self):
38 """Returns the default search engine, if any; None otherwise. 52 """Returns the default search engine, if any; None otherwise.
39 53
40 Returns: 54 Returns:
41 Dictionary describing the default search engine. See GetSearchEngineInfo 55 Dictionary describing the default search engine. See GetSearchEngineInfo
42 for an example. 56 for an example.
43 """ 57 """
44 for search_engine in self.GetSearchEngineInfo(): 58 for search_engine in self.GetSearchEngineInfo():
45 if search_engine['is_default']: 59 if search_engine['is_default']:
46 return search_engine 60 return search_engine
(...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 self.assertEquals(previous_homepage, 666 self.assertEquals(previous_homepage,
653 self.GetPrefsInfo().Prefs(pyauto.kHomePage)) 667 self.GetPrefsInfo().Prefs(pyauto.kHomePage))
654 self.assertEquals(False, self.GetPrefsInfo().Prefs(pyauto.kShowHomeButton)) 668 self.assertEquals(False, self.GetPrefsInfo().Prefs(pyauto.kShowHomeButton))
655 # No longer showing the change 669 # No longer showing the change
656 self.assertFalse(self.GetProtectorState()['showing_change']) 670 self.assertFalse(self.GetProtectorState()['showing_change'])
657 671
658 672
659 class ProtectorDisabledTest(BaseProtectorTest): 673 class ProtectorDisabledTest(BaseProtectorTest):
660 """Test suite for Protector in disabled state.""" 674 """Test suite for Protector in disabled state."""
661 675
662 def ExtraChromeFlags(self): 676 def _IsEnabled(self):
663 """Ensures Protector is disabled. 677 """Overriden from BaseProtectorTest to disable Protector."""
664 678 return False
665 Returns:
666 A list of extra flags to pass to Chrome when it is launched.
667 """
668 return super(ProtectorDisabledTest, self).ExtraChromeFlags() + [
669 '--no-protector'
670 ]
671
672 def testInfobarIsPresent(self):
673 """Verify that an infobar is present when running Chrome with --no-protector
674 flag.
675 """
676 self.assertTrue(self.GetBrowserInfo()['windows'][0]['tabs'][0]['infobars'])
677 679
678 def testNoSearchEngineChangeReported(self): 680 def testNoSearchEngineChangeReported(self):
679 """Test that the default search engine change is neither reported to user 681 """Test that the default search engine change is neither reported to user
680 nor reverted. 682 nor reverted.
681 """ 683 """
682 # Get current search engine. 684 # Get current search engine.
683 old_default_search = self._GetDefaultSearchEngine() 685 old_default_search = self._GetDefaultSearchEngine()
684 self.assertTrue(old_default_search) 686 self.assertTrue(old_default_search)
685 # Close browser, change the search engine and start it again. 687 # Close browser, change the search engine and start it again.
686 self.RestartBrowser(clear_profile=False, 688 self.RestartBrowser(clear_profile=False,
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
739 pre_launch_hook=lambda: self._ChangeHomepage(new_homepage, False, True)) 741 pre_launch_hook=lambda: self._ChangeHomepage(new_homepage, False, True))
740 # Not showing the change. 742 # Not showing the change.
741 self.assertFalse(self.GetProtectorState()['showing_change']) 743 self.assertFalse(self.GetProtectorState()['showing_change'])
742 # New values must be active. 744 # New values must be active.
743 self.assertEquals(new_homepage, self.GetPrefsInfo().Prefs(pyauto.kHomePage)) 745 self.assertEquals(new_homepage, self.GetPrefsInfo().Prefs(pyauto.kHomePage))
744 self.assertEquals(True, self.GetPrefsInfo().Prefs(pyauto.kShowHomeButton)) 746 self.assertEquals(True, self.GetPrefsInfo().Prefs(pyauto.kShowHomeButton))
745 747
746 748
747 if __name__ == '__main__': 749 if __name__ == '__main__':
748 pyauto_functional.Main() 750 pyauto_functional.Main()
OLDNEW
« no previous file with comments | « chrome/common/chrome_switches.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698