| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #include "ui/compositor/test/draw_waiter_for_test.h" | |
| 6 | |
| 7 #include "ui/compositor/compositor.h" | |
| 8 | |
| 9 namespace ui { | |
| 10 | |
| 11 // static | |
| 12 void DrawWaiterForTest::Wait(Compositor* compositor) { | |
| 13 DrawWaiterForTest waiter; | |
| 14 waiter.wait_for_commit_ = false; | |
| 15 waiter.WaitImpl(compositor); | |
| 16 } | |
| 17 | |
| 18 // static | |
| 19 void DrawWaiterForTest::WaitForCommit(Compositor* compositor) { | |
| 20 DrawWaiterForTest waiter; | |
| 21 waiter.wait_for_commit_ = true; | |
| 22 waiter.WaitImpl(compositor); | |
| 23 } | |
| 24 | |
| 25 DrawWaiterForTest::DrawWaiterForTest() { | |
| 26 } | |
| 27 | |
| 28 DrawWaiterForTest::~DrawWaiterForTest() {} | |
| 29 | |
| 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); | |
| 35 } | |
| 36 | |
| 37 void DrawWaiterForTest::OnCompositingDidCommit(Compositor* compositor) { | |
| 38 if (wait_for_commit_) | |
| 39 wait_run_loop_->Quit(); | |
| 40 } | |
| 41 | |
| 42 void DrawWaiterForTest::OnCompositingStarted(Compositor* compositor, | |
| 43 base::TimeTicks start_time) { | |
| 44 } | |
| 45 | |
| 46 void DrawWaiterForTest::OnCompositingEnded(Compositor* compositor) { | |
| 47 if (!wait_for_commit_) | |
| 48 wait_run_loop_->Quit(); | |
| 49 } | |
| 50 | |
| 51 void DrawWaiterForTest::OnCompositingAborted(Compositor* compositor) { | |
| 52 } | |
| 53 | |
| 54 void DrawWaiterForTest::OnCompositingLockStateChanged(Compositor* compositor) {} | |
| 55 | |
| 56 } // namespace ui | |
| OLD | NEW |