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 #ifndef UI_COMPOSITOR_TEST_DRAW_WAITER_H_ | 5 #ifndef UI_COMPOSITOR_TEST_DRAW_WAITER_H_ |
6 #define UI_COMPOSITOR_TEST_DRAW_WAITER_H_ | 6 #define UI_COMPOSITOR_TEST_DRAW_WAITER_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/run_loop.h" | 11 #include "base/run_loop.h" |
12 #include "ui/compositor/compositor_observer.h" | 12 #include "ui/compositor/compositor_observer.h" |
13 | 13 |
14 class Compositor; | 14 class Compositor; |
15 | 15 |
16 namespace ui { | 16 namespace ui { |
17 | 17 |
18 // This is only to be used for test. It allows execution of other tasks on | 18 // This is only to be used for test. It allows execution of other tasks on |
19 // the current message loop before the current task finishs (there is a | 19 // the current message loop before the current task finishs (there is a |
20 // potential for re-entrancy). | 20 // potential for re-entrancy). |
21 class DrawWaiterForTest : public CompositorObserver { | 21 class DrawWaiterForTest : public CompositorObserver { |
22 public: | 22 public: |
| 23 // Waits for the compositor to get an OutputSurface. |
| 24 static void WaitForCompositingInitialized(Compositor* compositor); |
| 25 |
23 // Waits for a draw to be issued by the compositor. If the test times out | 26 // Waits for a draw to be issued by the compositor. If the test times out |
24 // here, there may be a logic error in the compositor code causing it | 27 // here, there may be a logic error in the compositor code causing it |
25 // not to draw. | 28 // not to draw. |
26 static void WaitForCompositingStarted(Compositor* compositor); | 29 static void WaitForCompositingStarted(Compositor* compositor); |
27 | 30 |
28 // Waits for a swap to be completed from the compositor. | 31 // Waits for a swap to be completed from the compositor. |
29 static void WaitForCompositingEnded(Compositor* compositor); | 32 static void WaitForCompositingEnded(Compositor* compositor); |
30 | 33 |
31 // Waits for a commit instead of a draw. | 34 // Waits for a commit instead of a draw. |
32 static void WaitForCommit(Compositor* compositor); | 35 static void WaitForCommit(Compositor* compositor); |
33 | 36 |
34 private: | 37 private: |
35 enum WaitEvent { | 38 enum WaitEvent { |
36 WAIT_FOR_COMMIT, | 39 WAIT_FOR_COMMIT, |
| 40 WAIT_FOR_COMPOSITING_INITIALIZED, |
37 WAIT_FOR_COMPOSITING_STARTED, | 41 WAIT_FOR_COMPOSITING_STARTED, |
38 WAIT_FOR_COMPOSITING_ENDED, | 42 WAIT_FOR_COMPOSITING_ENDED, |
39 }; | 43 }; |
40 DrawWaiterForTest(WaitEvent wait_event); | 44 DrawWaiterForTest(WaitEvent wait_event); |
41 ~DrawWaiterForTest(); | 45 ~DrawWaiterForTest(); |
42 | 46 |
43 void WaitImpl(Compositor* compositor); | 47 void WaitImpl(Compositor* compositor); |
44 | 48 |
45 // CompositorObserver implementation. | 49 // CompositorObserver implementation. |
| 50 void OnCompositingInitialized(Compositor* compositor) override; |
46 void OnCompositingDidCommit(Compositor* compositor) override; | 51 void OnCompositingDidCommit(Compositor* compositor) override; |
47 void OnCompositingStarted(Compositor* compositor, | 52 void OnCompositingStarted(Compositor* compositor, |
48 base::TimeTicks start_time) override; | 53 base::TimeTicks start_time) override; |
49 void OnCompositingEnded(Compositor* compositor) override; | 54 void OnCompositingEnded(Compositor* compositor) override; |
50 void OnCompositingAborted(Compositor* compositor) override; | 55 void OnCompositingAborted(Compositor* compositor) override; |
51 void OnCompositingLockStateChanged(Compositor* compositor) override; | 56 void OnCompositingLockStateChanged(Compositor* compositor) override; |
52 void OnCompositingShuttingDown(Compositor* compositor) override; | 57 void OnCompositingShuttingDown(Compositor* compositor) override; |
53 | 58 |
54 std::unique_ptr<base::RunLoop> wait_run_loop_; | 59 std::unique_ptr<base::RunLoop> wait_run_loop_; |
55 | 60 |
56 WaitEvent wait_event_; | 61 WaitEvent wait_event_; |
57 | 62 |
58 DISALLOW_COPY_AND_ASSIGN(DrawWaiterForTest); | 63 DISALLOW_COPY_AND_ASSIGN(DrawWaiterForTest); |
59 }; | 64 }; |
60 | 65 |
61 } // namespace ui | 66 } // namespace ui |
62 | 67 |
63 #endif // UI_COMPOSITOR_TEST_DRAW_WAITER_H_ | 68 #endif // UI_COMPOSITOR_TEST_DRAW_WAITER_H_ |
OLD | NEW |