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

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: Tests 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..eaba0e7d74a4e6a242fba538081ea3476d55dac2 100755
--- a/chrome/test/functional/policy.py
+++ b/chrome/test/functional/policy.py
@@ -688,6 +688,54 @@ class PolicyTest(policy_base.PolicyTestBase):
self.GetCookie(pyauto.GURL(cookie_url)),
msg='Cookie present on ' + cookie_url + '.');
+ def testDisableScreenshotFile(self):
Nirnimesh 2012/07/16 20:01:50 one-line docstring please
qfel 2012/07/17 10:07:25 Done.
+ if not self.IsChromeOS():
+ return # Screenshot accelerator available only on ChromeOS
+
+ 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.
+
+ def files_count():
+ 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.
+
+ download_dir = self.GetDownloadDirectory().value()
+ original_count = files_count()
+
+ # Make sure screenshots actually go to downloads directory.
+ self.assertTrue(self.ApplyAshAccelerator(TAKE_SCREENSHOT))
+ self.assertTrue(self.WaitUntil(files_count,
+ expect_retval=original_count + 1))
+
+ # 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() != original_count + 1,
+ 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
+
+ def testDisableScreenshotFeedback(self):
Nirnimesh 2012/07/16 20:01:50 docstring please
qfel 2012/07/17 10:07:25 Done.
+ # Make sure screenshot is normally displayed in feedback form.
+ self.assertTrue(self.ApplyAccelerator(pyauto.IDC_FEEDBACK))
+ 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.
+ 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))
+ self.WaitUntilNavigationCompletes(tab_index=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