Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 logging | 6 import logging |
| 7 import os | 7 import os |
| 8 | 8 |
| 9 import pyauto_functional # must come before pyauto. | 9 import pyauto_functional # must come before pyauto. |
| 10 import policy_base | 10 import policy_base |
| (...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 681 | 681 |
| 682 # With the policy set, the cookie should be gone after a restart. | 682 # With the policy set, the cookie should be gone after a restart. |
| 683 self.SetUserPolicy({ | 683 self.SetUserPolicy({ |
| 684 'ClearSiteDataOnExit': True | 684 'ClearSiteDataOnExit': True |
| 685 }) | 685 }) |
| 686 self.RestartBrowser(clear_profile=False) | 686 self.RestartBrowser(clear_profile=False) |
| 687 self.assertFalse( | 687 self.assertFalse( |
| 688 self.GetCookie(pyauto.GURL(cookie_url)), | 688 self.GetCookie(pyauto.GURL(cookie_url)), |
| 689 msg='Cookie present on ' + cookie_url + '.'); | 689 msg='Cookie present on ' + cookie_url + '.'); |
| 690 | 690 |
| 691 def testDisableScreenshotFile(self): | |
|
Nirnimesh
2012/07/16 20:01:50
one-line docstring please
qfel
2012/07/17 10:07:25
Done.
| |
| 692 if not self.IsChromeOS(): | |
| 693 return # Screenshot accelerator available only on ChromeOS | |
| 694 | |
| 695 TAKE_SCREENSHOT = 34 # See AcceleratorAction enum in accelerator_table.h | |
|
Nirnimesh
2012/07/16 20:01:50
This seems bad. Can you try to swig out the accele
qfel
2012/07/17 10:07:25
Done.
| |
| 696 | |
| 697 def files_count(): | |
| 698 return len(os.listdir(download_dir)) | |
|
Nirnimesh
2012/07/16 20:01:50
It's bad to have a function use vars defined after
qfel
2012/07/17 10:07:25
Done.
| |
| 699 | |
| 700 download_dir = self.GetDownloadDirectory().value() | |
| 701 original_count = files_count() | |
| 702 | |
| 703 # Make sure screenshots actually go to downloads directory. | |
| 704 self.assertTrue(self.ApplyAshAccelerator(TAKE_SCREENSHOT)) | |
| 705 self.assertTrue(self.WaitUntil(files_count, | |
| 706 expect_retval=original_count + 1)) | |
| 707 | |
| 708 # Real testing here: check if disabling screenshots works. | |
| 709 policy = { | |
| 710 'DisableScreenshots': True | |
| 711 } | |
| 712 self.SetUserPolicy(policy) | |
| 713 self.assertTrue(self.ApplyAshAccelerator(TAKE_SCREENSHOT)) | |
| 714 self.assertFalse(self.WaitUntil(lambda: files_count() != original_count + 1, | |
| 715 timeout=5, expect_retval=True)) | |
|
Mattias Nissler (ping if slow)
2012/07/16 10:51:55
nirnimesh: I'm unhappy with these timeouts, but es
Nirnimesh
2012/07/16 20:01:50
Unfortunately, I don't have a good solution for th
qfel
2012/07/17 10:07:25
The accelerator is always considered handled. Its
| |
| 716 | |
| 717 def testDisableScreenshotFeedback(self): | |
|
Nirnimesh
2012/07/16 20:01:50
docstring please
qfel
2012/07/17 10:07:25
Done.
| |
| 718 # Make sure screenshot is normally displayed in feedback form. | |
| 719 self.assertTrue(self.ApplyAccelerator(pyauto.IDC_FEEDBACK)) | |
| 720 self.WaitUntilNavigationCompletes(tab_index=1) | |
|
Nirnimesh
2012/07/16 20:01:50
you might want to wait for tab count to become 2 b
qfel
2012/07/17 10:07:25
Done.
| |
| 721 self.WaitForDomNode('//img[starts-with(@id, "current-screenshots")]', | |
| 722 tab_index=1) | |
| 723 | |
| 724 # The feedback tab is a singleton tab, so close it first before trying to | |
| 725 # reopen. Otherwise it might not reload. | |
| 726 self.GetBrowserWindow(0).GetTab(1).Close(True) | |
| 727 | |
| 728 # Real testing here: check if disabling screenshots works. | |
| 729 policy = { | |
| 730 'DisableScreenshots': True | |
| 731 } | |
| 732 self.SetUserPolicy(policy) | |
| 733 self.assertTrue(self.ApplyAccelerator(pyauto.IDC_FEEDBACK)) | |
| 734 self.WaitUntilNavigationCompletes(tab_index=1) | |
| 735 self.assertRaises(pyauto.JSONInterfaceError, lambda: self.WaitForDomNode( | |
| 736 '//img[starts-with(@id, "current-screenshots")]', tab_index=1, | |
| 737 timeout=3)) | |
| 738 | |
| 691 | 739 |
| 692 if __name__ == '__main__': | 740 if __name__ == '__main__': |
| 693 pyauto_functional.Main() | 741 pyauto_functional.Main() |
| OLD | NEW |