Index: chrome/test/functional/policy.py |
diff --git a/chrome/test/functional/policy.py b/chrome/test/functional/policy.py |
index 875bee68b19ea210a94af00a35eb43bf858d344a..23be3c7125ebb5ca8e6887934402258d659dd3a4 100755 |
--- a/chrome/test/functional/policy.py |
+++ b/chrome/test/functional/policy.py |
@@ -695,6 +695,59 @@ class PolicyTest(policy_base.PolicyTestBase): |
self.GetCookie(pyauto.GURL(cookie_url)), |
msg='Cookie present on ' + cookie_url + '.'); |
+ def testDisableScreenshotFile(self): |
+ """Verify screenshot keyboard shortcut can be disabled by policy.""" |
+ if not self.IsChromeOS(): |
+ return # Screenshot accelerator available only on ChromeOS |
+ |
+ download_dir = self.GetDownloadDirectory().value() |
+ |
+ def FilesCount(): |
xot
2012/08/03 15:40:36
Can you make FilesCount() only count files that be
qfel
2012/08/07 09:23:15
Done.
|
+ return len(os.listdir(download_dir)) |
+ |
+ # Make sure screenshots actually go to downloads directory. |
+ expected_count = FilesCount() + 1 |
+ self.assertTrue(self.RunAshCommand(pyauto.TAKE_SCREENSHOT)) |
xot
2012/08/03 15:40:36
Shouldn't you first make sure that DisableScreensh
qfel
2012/08/07 09:23:15
I assumed it's not set = false by default, but I s
|
+ self.assertTrue(self.WaitUntil(FilesCount, expect_retval=expected_count)) |
+ |
+ # Real testing here: check if disabling screenshots works. |
+ policy = { |
+ 'DisableScreenshots': True |
+ } |
+ self.SetUserPolicy(policy) |
+ self.assertTrue(self.RunAshCommand(pyauto.TAKE_SCREENSHOT)) |
+ self.assertFalse(self.WaitUntil(lambda: FilesCount() != expected_count, |
+ timeout=5, expect_retval=True)) |
+ |
+ def testDisableScreenshotFeedback(self): |
+ """Verify screenshot in feedback form can be disabled by policy.""" |
+ |
+ def SafeWaitUntilNavigationCompletes(tab_index): |
+ self.assertTrue(self.WaitUntil(lambda: self.GetTabCount() > tab_index, |
+ expect_retval=True)) |
+ self.WaitUntilNavigationCompletes(tab_index=tab_index) |
+ |
+ # Make sure screenshot is normally displayed in feedback form. |
+ self.assertTrue(self.ApplyAccelerator(pyauto.IDC_FEEDBACK)) |
+ SafeWaitUntilNavigationCompletes(1) |
+ self.WaitForDomNode('//img[starts-with(@id, "current-screenshots")]', |
+ tab_index=1) |
+ |
+ # The feedback tab is a singleton tab, so close it first before trying to |
+ # reopen. Otherwise it might not reload. |
+ self.GetBrowserWindow(0).GetTab(1).Close(True) |
+ |
+ # Real testing here: check if disabling screenshots works. |
+ policy = { |
+ 'DisableScreenshots': True |
+ } |
+ self.SetUserPolicy(policy) |
+ self.assertTrue(self.ApplyAccelerator(pyauto.IDC_FEEDBACK)) |
+ SafeWaitUntilNavigationCompletes(1) |
+ self.assertRaises(pyauto.JSONInterfaceError, lambda: self.WaitForDomNode( |
+ '//img[starts-with(@id, "current-screenshots")]', tab_index=1, |
+ timeout=3)) |
+ |
if __name__ == '__main__': |
pyauto_functional.Main() |