Switch global error menu icon to vectorized MD asset
[chromium-blink-merge.git] / chrome / browser / chromeos / login / screenshot_testing / screenshot_testing_mixin.cc
blobdcace4daae349cca35b5ea84a0c9812cbbad7705
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/chromeos/login/screenshot_testing/screenshot_testing_mixin.h"
7 #include "chrome/browser/browser_process.h"
8 #include "chrome/browser/chrome_notification_types.h"
9 #include "content/public/browser/browser_thread.h"
10 #include "content/public/browser/notification_service.h"
11 #include "content/public/browser/notification_types.h"
12 #include "ui/compositor/compositor_switches.h"
14 namespace chromeos {
16 ScreenshotTestingMixin::ScreenshotTestingMixin()
17 : enable_test_screenshots_(false) {
20 ScreenshotTestingMixin::~ScreenshotTestingMixin() {
23 void ScreenshotTestingMixin::SetUpInProcessBrowserTestFixture() {
24 enable_test_screenshots_ = screenshot_tester_.TryInitialize();
27 void ScreenshotTestingMixin::SetUpCommandLine(base::CommandLine* command_line) {
28 if (enable_test_screenshots_) {
29 command_line->AppendSwitch(switches::kEnablePixelOutputInTests);
33 void ScreenshotTestingMixin::RunScreenshotTesting(
34 const std::string& test_name) {
35 if (enable_test_screenshots_) {
36 SynchronizeAnimationLoadWithCompositor();
37 screenshot_tester_.Run(test_name);
41 void ScreenshotTestingMixin::IgnoreArea(const SkIRect& area) {
42 screenshot_tester_.IgnoreArea(area);
45 // Current implementation is a mockup.
46 // It simply waits for 5 seconds, assuming that this time is enough for
47 // animation to load completely.
48 // TODO(elizavetai): Replace this temporary hack with getting a
49 // valid notification from compositor.
50 void ScreenshotTestingMixin::SynchronizeAnimationLoadWithCompositor() {
51 base::RunLoop waiter;
52 animation_waiter_quitter_ = waiter.QuitClosure();
53 timer_.Start(FROM_HERE,
54 base::TimeDelta::FromSeconds(2),
55 this,
56 &ScreenshotTestingMixin::HandleAnimationLoad);
57 waiter.Run();
60 void ScreenshotTestingMixin::HandleAnimationLoad() {
61 timer_.Stop();
62 content::BrowserThread::PostTask(
63 content::BrowserThread::UI, FROM_HERE, animation_waiter_quitter_);
66 } // namespace chromeos