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