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.
5 #include "ui/compositor/test/draw_waiter_for_test.h"
7 #include "ui/compositor/compositor.h"
12 void DrawWaiterForTest::Wait(Compositor
* compositor
) {
13 DrawWaiterForTest waiter
;
14 waiter
.wait_for_commit_
= false;
15 waiter
.WaitImpl(compositor
);
19 void DrawWaiterForTest::WaitForCommit(Compositor
* compositor
) {
20 DrawWaiterForTest waiter
;
21 waiter
.wait_for_commit_
= true;
22 waiter
.WaitImpl(compositor
);
25 DrawWaiterForTest::DrawWaiterForTest() {
28 DrawWaiterForTest::~DrawWaiterForTest() {}
30 void DrawWaiterForTest::WaitImpl(Compositor
* compositor
) {
31 compositor
->AddObserver(this);
32 wait_run_loop_
.reset(new base::RunLoop());
33 wait_run_loop_
->Run();
34 compositor
->RemoveObserver(this);
37 void DrawWaiterForTest::OnCompositingDidCommit(Compositor
* compositor
) {
39 wait_run_loop_
->Quit();
42 void DrawWaiterForTest::OnCompositingStarted(Compositor
* compositor
,
43 base::TimeTicks start_time
) {
46 void DrawWaiterForTest::OnCompositingEnded(Compositor
* compositor
) {
47 if (!wait_for_commit_
)
48 wait_run_loop_
->Quit();
51 void DrawWaiterForTest::OnCompositingAborted(Compositor
* compositor
) {
54 void DrawWaiterForTest::OnCompositingLockStateChanged(Compositor
* compositor
) {}