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

Unified Diff: chrome/browser/policy/policy_browsertest.cc

Issue 126373002: Make ChromeOS screenshots use async readback path (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix rebase error Created 6 years, 11 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
« no previous file with comments | « no previous file | chrome/browser/ui/ash/screenshot_taker.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/policy/policy_browsertest.cc
diff --git a/chrome/browser/policy/policy_browsertest.cc b/chrome/browser/policy/policy_browsertest.cc
index 37d5ebbc8d80f8001db9c636b3085a9cb628cb70..8e191c2752a07d4b3ecc3c889f3ec7583727ca46 100644
--- a/chrome/browser/policy/policy_browsertest.cc
+++ b/chrome/browser/policy/policy_browsertest.cc
@@ -146,6 +146,7 @@
#include "chrome/browser/chromeos/accessibility/accessibility_manager.h"
#include "chrome/browser/chromeos/accessibility/magnification_manager.h"
#include "chrome/browser/profiles/profile_manager.h"
+#include "chrome/browser/ui/ash/screenshot_taker.h"
#include "chromeos/audio/cras_audio_handler.h"
#endif
@@ -626,17 +627,34 @@ class PolicyTest : public InProcessBrowserTest {
}
#if defined(OS_CHROMEOS)
+ class QuitMessageLoopAfterScreenshot : public ScreenshotTakerObserver {
+ public:
+ virtual void OnScreenshotCompleted(
+ ScreenshotTakerObserver::Result screenshot_result,
+ const base::FilePath& screenshot_path) OVERRIDE {
+ BrowserThread::PostTaskAndReply(BrowserThread::IO,
+ FROM_HERE,
+ base::Bind(base::DoNothing),
+ base::MessageLoop::QuitClosure());
+ }
+
+ virtual ~QuitMessageLoopAfterScreenshot() {}
+ };
+
void TestScreenshotFile(bool enabled) {
+ // AddObserver is an ash-specific method, so just replace the screenshot
+ // taker with one we've created here.
+ scoped_ptr<ScreenshotTaker> screenshot_taker(new ScreenshotTaker);
+ // ScreenshotTaker doesn't own this observer, so the observer's lifetime
+ // is tied to the test instead.
+ screenshot_taker->AddObserver(&observer_);
+ ash::Shell::GetInstance()->accelerator_controller()->SetScreenshotDelegate(
+ screenshot_taker.PassAs<ash::ScreenshotDelegate>());
+
SetScreenshotPolicy(enabled);
ash::Shell::GetInstance()->accelerator_controller()->PerformAction(
ash::TAKE_SCREENSHOT, ui::Accelerator());
- // TAKE_SCREENSHOT handler posts write file task on success, wait for it.
- BrowserThread::PostTaskAndReply(
- BrowserThread::IO,
- FROM_HERE,
- base::Bind(base::DoNothing),
- base::MessageLoop::QuitClosure());
content::RunMessageLoop();
}
#endif
@@ -721,6 +739,9 @@ class PolicyTest : public InProcessBrowserTest {
}
MockConfigurationPolicyProvider provider_;
+#if defined(OS_CHROMEOS)
+ QuitMessageLoopAfterScreenshot observer_;
+#endif
};
#if defined(OS_WIN)
« no previous file with comments | « no previous file | chrome/browser/ui/ash/screenshot_taker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698