OLD | NEW |
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 |
OLD | NEW |