| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 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 logging | 6 import logging |
| 7 import os | 7 import os |
| 8 import subprocess | 8 import subprocess |
| 9 import re | 9 import re |
| 10 | 10 |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 """Verify popups are not allowed if policy disables popups.""" | 329 """Verify popups are not allowed if policy disables popups.""" |
| 330 if self.GetBrowserInfo()['properties']['branding'] != 'Google Chrome': | 330 if self.GetBrowserInfo()['properties']['branding'] != 'Google Chrome': |
| 331 return | 331 return |
| 332 url = self.GetFileURLForDataPath('popup_blocker', 'popup-window-open.html') | 332 url = self.GetFileURLForDataPath('popup_blocker', 'popup-window-open.html') |
| 333 self.NavigateToURL(url) | 333 self.NavigateToURL(url) |
| 334 self.assertEqual(1, len(self.GetBlockedPopupsInfo()), | 334 self.assertEqual(1, len(self.GetBlockedPopupsInfo()), |
| 335 msg='Popup not blocked') | 335 msg='Popup not blocked') |
| 336 self.assertRaises(pyauto.JSONInterfaceError, | 336 self.assertRaises(pyauto.JSONInterfaceError, |
| 337 lambda: self.SetPrefs(pyauto.kManagedDefaultPopupsSetting, 1)) | 337 lambda: self.SetPrefs(pyauto.kManagedDefaultPopupsSetting, 1)) |
| 338 | 338 |
| 339 def testTranslateEnabled(self): |
| 340 """Verify that translate happens if policy enables it.""" |
| 341 if self.GetBrowserInfo()['properties']['branding'] != 'Google Chrome': |
| 342 return |
| 343 self.assertTrue(self.GetPrefsInfo().Prefs(pyauto.kEnableTranslate)) |
| 344 url = self.GetFileURLForDataPath('translate', 'es', 'google.html') |
| 345 self.NavigateToURL(url) |
| 346 self.assertTrue(self.WaitForInfobarCount(1)) |
| 347 translate_info = self.GetTranslateInfo() |
| 348 self.assertEqual('es', translate_info['original_language']) |
| 349 self.assertFalse(translate_info['page_translated']) |
| 350 self.assertTrue(translate_info['can_translate_page']) |
| 351 self.assertTrue('translate_bar' in translate_info) |
| 352 self._CheckIfPrefCanBeModified(pyauto.kEnableTranslate, True, False) |
| 353 |
| 339 class EnterpriseTestReverse(pyauto.PyUITest): | 354 class EnterpriseTestReverse(pyauto.PyUITest): |
| 340 """Test for the Enterprise features that uses the opposite values of the | 355 """Test for the Enterprise features that uses the opposite values of the |
| 341 policies used by above test class 'EnterpriseTest'. | 356 policies used by above test class 'EnterpriseTest'. |
| 342 | 357 |
| 343 Browser preferences will be managed using policies. These managed preferences | 358 Browser preferences will be managed using policies. These managed preferences |
| 344 cannot be modified by user. This works only for Google Chrome, not Chromium. | 359 cannot be modified by user. This works only for Google Chrome, not Chromium. |
| 345 | 360 |
| 346 On Linux, assume that 'suid-python' (a python binary setuid root) is | 361 On Linux, assume that 'suid-python' (a python binary setuid root) is |
| 347 available on the machine under /usr/local/bin directory. | 362 available on the machine under /usr/local/bin directory. |
| 348 """ | 363 """ |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 601 """Verify popups are allowed if policy enables popups.""" | 616 """Verify popups are allowed if policy enables popups.""" |
| 602 if self.GetBrowserInfo()['properties']['branding'] != 'Google Chrome': | 617 if self.GetBrowserInfo()['properties']['branding'] != 'Google Chrome': |
| 603 return | 618 return |
| 604 url = self.GetFileURLForDataPath('popup_blocker', 'popup-window-open.html') | 619 url = self.GetFileURLForDataPath('popup_blocker', 'popup-window-open.html') |
| 605 self.NavigateToURL(url) | 620 self.NavigateToURL(url) |
| 606 self.assertEqual(2, self.GetBrowserWindowCount(), | 621 self.assertEqual(2, self.GetBrowserWindowCount(), |
| 607 msg='Popup could not be launched'); | 622 msg='Popup could not be launched'); |
| 608 self.assertRaises(pyauto.JSONInterfaceError, | 623 self.assertRaises(pyauto.JSONInterfaceError, |
| 609 lambda: self.SetPrefs(pyauto.kManagedDefaultPopupsSetting, 2)) | 624 lambda: self.SetPrefs(pyauto.kManagedDefaultPopupsSetting, 2)) |
| 610 | 625 |
| 626 def testTranslateDisabled(self): |
| 627 """Verify that translate does not happen if policy disables it.""" |
| 628 if self.GetBrowserInfo()['properties']['branding'] != 'Google Chrome': |
| 629 return |
| 630 self.assertFalse(self.GetPrefsInfo().Prefs(pyauto.kEnableTranslate)) |
| 631 url = self.GetFileURLForDataPath('translate', 'es', 'google.html') |
| 632 self.NavigateToURL(url) |
| 633 self.assertFalse(self.WaitForInfobarCount(1)) |
| 634 self._CheckIfPrefCanBeModified(pyauto.kEnableTranslate, False, True) |
| 635 |
| 611 | 636 |
| 612 if __name__ == '__main__': | 637 if __name__ == '__main__': |
| 613 pyauto_functional.Main() | 638 pyauto_functional.Main() |
| OLD | NEW |