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

Side by Side Diff: chrome/browser/chromeos/login/screenshot_test.cc

Issue 441263002: Generalizing architecture for screenshot testing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: commented line removed Created 6 years, 4 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 unified diff | Download patch
OLDNEW
(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_test.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 ScreenshotTest::ScreenshotTest() : LoginManagerTest(false) {
17 waiter_loop_is_on_ = false;
18 }
dzhioev (left Google) 2014/08/07 11:23:55 Add a new line.
19 ScreenshotTest::~ScreenshotTest() {
20 }
21
22 void ScreenshotTest::SetUpOnMainThread() {
23 enable_test_screenshots_ = screenshot_tester.TryInitialize();
24 if (enable_test_screenshots_) {
25 InitializeAnimationHandler();
26 }
27 LoginManagerTest::SetUpOnMainThread();
28 }
29
30 void ScreenshotTest::SetUpCommandLine(base::CommandLine* command_line) {
31 LoginManagerTest::SetUpCommandLine(command_line);
32 if (enable_test_screenshots_) {
33 command_line->AppendSwitch(switches::kEnablePixelOutputInTests);
34 command_line->AppendSwitch(switches::kUIEnableImplSidePainting);
35 }
36 }
37
38 void ScreenshotTest::Observe(int type,
dzhioev (left Google) 2014/08/07 11:23:55 Why do we need this method?
39 const content::NotificationSource& source,
40 const content::NotificationDetails& details) {
41 }
42
43 void ScreenshotTest::WaitUntilAnimationLoads() {
44 if (!IsAnimationLoaded()) {
45 base::RunLoop animation_waiter;
46 PrepareForAnimationWaiting(animation_waiter.QuitClosure());
47 animation_waiter.Run();
48 }
49 SynchronizeAnimationLoadWithCompositor();
50 }
51
52 void ScreenshotTest::InitializeAnimationHandler() {
53 }
54
55 void ScreenshotTest::RunScreenshotTesting(const std::string& test_name) {
56 if (enable_test_screenshots_) {
57 WaitUntilAnimationLoads();
58 screenshot_tester.Run(test_name);
59 }
60 }
61
62 bool ScreenshotTest::IsAnimationLoaded() {
63 return true;
64 }
65
66 void ScreenshotTest::PrepareForAnimationWaiting(const base::Closure& quitter) {
67 waiter_loop_is_on_ = true;
68 animation_waiter_quitter_ = quitter;
69 }
70
71 // Current implementation is a mockup.
72 // It simply waits for 5 seconds, assuming that this time is enough for
73 // animation to load completely.
74 // TODO(elizavetai): Replace this temporary hack with getting a
75 // valid notification from compositor.
76 void ScreenshotTest::SynchronizeAnimationLoadWithCompositor() {
77 base::RunLoop waiter;
78 animation_waiter_quitter_ = waiter.QuitClosure();
79 timer_.Start(FROM_HERE,
80 base::TimeDelta::FromSeconds(5),
81 this,
82 &ScreenshotTest::HandleAnimationLoad);
83 waiter.Run();
84 }
85
86 void ScreenshotTest::HandleAnimationLoad() {
87 timer_.Stop();
88 content::BrowserThread::PostTask(
89 content::BrowserThread::UI, FROM_HERE, animation_waiter_quitter_);
90 }
91
92 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698