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() {}
27 DrawWaiterForTest::~DrawWaiterForTest() {}
29 void DrawWaiterForTest::WaitImpl(Compositor
* compositor
) {
30 compositor
->AddObserver(this);
31 wait_run_loop_
.reset(new base::RunLoop());
32 wait_run_loop_
->Run();
33 compositor
->RemoveObserver(this);
36 void DrawWaiterForTest::OnCompositingDidCommit(Compositor
* compositor
) {
38 wait_run_loop_
->Quit();
41 void DrawWaiterForTest::OnCompositingStarted(Compositor
* compositor
,
42 base::TimeTicks start_time
) {}
44 void DrawWaiterForTest::OnCompositingEnded(Compositor
* compositor
) {
45 if (!wait_for_commit_
)
46 wait_run_loop_
->Quit();
49 void DrawWaiterForTest::OnCompositingAborted(Compositor
* compositor
) {}
51 void DrawWaiterForTest::OnCompositingLockStateChanged(Compositor
* compositor
) {}