OLD | NEW |
---|---|
(Empty) | |
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. | |
4 | |
5 #include "chrome/browser/chromeos/login/screenshot_testing_mixin.h" | |
6 | |
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" | |
13 | |
14 namespace chromeos { | |
15 | |
16 ScreenshotTestingMixin::ScreenshotTestingMixin() { | |
17 } | |
18 | |
19 ScreenshotTestingMixin::~ScreenshotTestingMixin() { | |
20 } | |
21 | |
22 void ScreenshotTestingMixin::SetUpInProcessBrowserTestFixture() { | |
23 VLOG(0) << "setting up!"; | |
dzhioev (left Google)
2014/09/18 04:18:25
nit: Please remove this log message. Or make it mo
| |
24 enable_test_screenshots_ = screenshot_tester_.TryInitialize(); | |
25 } | |
26 | |
27 void ScreenshotTestingMixin::SetUpCommandLine(base::CommandLine* command_line) { | |
28 if (enable_test_screenshots_) { | |
29 command_line->AppendSwitch(switches::kEnablePixelOutputInTests); | |
30 command_line->AppendSwitch(switches::kUIEnableImplSidePainting); | |
31 } | |
32 } | |
33 | |
34 void ScreenshotTestingMixin::RunScreenshotTesting( | |
35 const std::string& test_name) { | |
36 if (enable_test_screenshots_) { | |
37 SynchronizeAnimationLoadWithCompositor(); | |
38 screenshot_tester_.Run(test_name); | |
39 } | |
40 } | |
41 | |
42 // Current implementation is a mockup. | |
43 // It simply waits for 5 seconds, assuming that this time is enough for | |
44 // animation to load completely. | |
45 // TODO(elizavetai): Replace this temporary hack with getting a | |
46 // valid notification from compositor. | |
47 void ScreenshotTestingMixin::SynchronizeAnimationLoadWithCompositor() { | |
48 base::RunLoop waiter; | |
49 animation_waiter_quitter_ = waiter.QuitClosure(); | |
50 timer_.Start(FROM_HERE, | |
51 base::TimeDelta::FromSeconds(5), | |
52 this, | |
53 &ScreenshotTestingMixin::HandleAnimationLoad); | |
54 waiter.Run(); | |
55 } | |
56 | |
57 void ScreenshotTestingMixin::HandleAnimationLoad() { | |
58 timer_.Stop(); | |
59 content::BrowserThread::PostTask( | |
60 content::BrowserThread::UI, FROM_HERE, animation_waiter_quitter_); | |
61 } | |
62 | |
63 } // namespace chromeos | |
OLD | NEW |