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

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

Issue 10784009: screenshot disabling policy tests (Closed) Base URL: http://git.chromium.org/chromium/src.git@disable_screenshots
Patch Set: Addressed comments (1) Created 8 years, 5 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
Index: chrome/test/functional/policy.py
diff --git a/chrome/test/functional/policy.py b/chrome/test/functional/policy.py
index 5908a176b00a30cfed41c1e0ce2adf2cc75ab14b..5c3dc491a8893a66c253bef02ab755dea69d7767 100755
--- a/chrome/test/functional/policy.py
+++ b/chrome/test/functional/policy.py
@@ -688,6 +688,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():
+ return len(os.listdir(download_dir))
+
+ # Make sure screenshots actually go to downloads directory.
+ expected_count = FilesCount() + 1
+ self.assertTrue(self.ApplyAshAccelerator(pyauto.TAKE_SCREENSHOT))
+ 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.ApplyAshAccelerator(TAKE_SCREENSHOT))
+ self.assertFalse(self.WaitUntil(lambda: files_count() != 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()

Powered by Google App Engine
This is Rietveld 408576698