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

Side by Side Diff: ui/compositor/test/draw_waiter_for_test.cc

Issue 2144733005: [WIP] cc: Plumb SurfaceId from clients Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Ensure only SurfaceFactoy and tests can update hierarchy Created 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/compositor/test/draw_waiter_for_test.h" 5 #include "ui/compositor/test/draw_waiter_for_test.h"
6 6
7 #include "ui/compositor/compositor.h" 7 #include "ui/compositor/compositor.h"
8 8
9 namespace ui { 9 namespace ui {
10 10
11 // static 11 // static
12 void DrawWaiterForTest::WaitForCompositingInitialized(Compositor* compositor) {
13 DrawWaiterForTest waiter(WAIT_FOR_COMPOSITING_INITIALIZED);
14 waiter.WaitImpl(compositor);
15 }
16
17 // static
12 void DrawWaiterForTest::WaitForCompositingStarted(Compositor* compositor) { 18 void DrawWaiterForTest::WaitForCompositingStarted(Compositor* compositor) {
13 DrawWaiterForTest waiter(WAIT_FOR_COMPOSITING_STARTED); 19 DrawWaiterForTest waiter(WAIT_FOR_COMPOSITING_STARTED);
14 waiter.WaitImpl(compositor); 20 waiter.WaitImpl(compositor);
15 } 21 }
16 22
17 void DrawWaiterForTest::WaitForCompositingEnded(Compositor* compositor) { 23 void DrawWaiterForTest::WaitForCompositingEnded(Compositor* compositor) {
18 DrawWaiterForTest waiter(WAIT_FOR_COMPOSITING_ENDED); 24 DrawWaiterForTest waiter(WAIT_FOR_COMPOSITING_ENDED);
19 waiter.WaitImpl(compositor); 25 waiter.WaitImpl(compositor);
20 } 26 }
21 27
22 // static 28 // static
23 void DrawWaiterForTest::WaitForCommit(Compositor* compositor) { 29 void DrawWaiterForTest::WaitForCommit(Compositor* compositor) {
24 DrawWaiterForTest waiter(WAIT_FOR_COMMIT); 30 DrawWaiterForTest waiter(WAIT_FOR_COMMIT);
25 waiter.WaitImpl(compositor); 31 waiter.WaitImpl(compositor);
26 } 32 }
27 33
28 DrawWaiterForTest::DrawWaiterForTest(WaitEvent wait_event) 34 DrawWaiterForTest::DrawWaiterForTest(WaitEvent wait_event)
29 : wait_event_(wait_event) { 35 : wait_event_(wait_event) {
30 } 36 }
31 37
32 DrawWaiterForTest::~DrawWaiterForTest() {} 38 DrawWaiterForTest::~DrawWaiterForTest() {}
33 39
34 void DrawWaiterForTest::WaitImpl(Compositor* compositor) { 40 void DrawWaiterForTest::WaitImpl(Compositor* compositor) {
35 compositor->AddObserver(this); 41 compositor->AddObserver(this);
36 wait_run_loop_.reset(new base::RunLoop()); 42 wait_run_loop_.reset(new base::RunLoop());
37 wait_run_loop_->Run(); 43 wait_run_loop_->Run();
38 compositor->RemoveObserver(this); 44 compositor->RemoveObserver(this);
39 } 45 }
40 46
47 void DrawWaiterForTest::OnCompositingInitialized(Compositor* compositor) {
48 if (wait_event_ == WAIT_FOR_COMPOSITING_INITIALIZED)
49 wait_run_loop_->Quit();
50 }
51
41 void DrawWaiterForTest::OnCompositingDidCommit(Compositor* compositor) { 52 void DrawWaiterForTest::OnCompositingDidCommit(Compositor* compositor) {
42 if (wait_event_ == WAIT_FOR_COMMIT) 53 if (wait_event_ == WAIT_FOR_COMMIT)
43 wait_run_loop_->Quit(); 54 wait_run_loop_->Quit();
44 } 55 }
45 56
46 void DrawWaiterForTest::OnCompositingStarted(Compositor* compositor, 57 void DrawWaiterForTest::OnCompositingStarted(Compositor* compositor,
47 base::TimeTicks start_time) { 58 base::TimeTicks start_time) {
48 if (wait_event_ == WAIT_FOR_COMPOSITING_STARTED) 59 if (wait_event_ == WAIT_FOR_COMPOSITING_STARTED)
49 wait_run_loop_->Quit(); 60 wait_run_loop_->Quit();
50 } 61 }
51 62
52 void DrawWaiterForTest::OnCompositingEnded(Compositor* compositor) { 63 void DrawWaiterForTest::OnCompositingEnded(Compositor* compositor) {
53 if (wait_event_ == WAIT_FOR_COMPOSITING_ENDED) 64 if (wait_event_ == WAIT_FOR_COMPOSITING_ENDED)
54 wait_run_loop_->Quit(); 65 wait_run_loop_->Quit();
55 } 66 }
56 67
57 void DrawWaiterForTest::OnCompositingAborted(Compositor* compositor) { 68 void DrawWaiterForTest::OnCompositingAborted(Compositor* compositor) {
58 } 69 }
59 70
60 void DrawWaiterForTest::OnCompositingLockStateChanged(Compositor* compositor) {} 71 void DrawWaiterForTest::OnCompositingLockStateChanged(Compositor* compositor) {}
61 72
62 void DrawWaiterForTest::OnCompositingShuttingDown(Compositor* compositor) {} 73 void DrawWaiterForTest::OnCompositingShuttingDown(Compositor* compositor) {}
63 74
64 } // namespace ui 75 } // namespace ui
OLDNEW
« no previous file with comments | « ui/compositor/test/draw_waiter_for_test.h ('k') | ui/compositor/test/in_process_context_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698