| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #include "components/view_manager/public/cpp/tests/view_manager_test_base.h" | 5 #include "components/mus/public/cpp/tests/view_manager_test_base.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "base/test/test_timeouts.h" | 10 #include "base/test/test_timeouts.h" |
| 11 #include "components/view_manager/public/cpp/view.h" | 11 #include "components/mus/public/cpp/view.h" |
| 12 #include "components/view_manager/public/cpp/view_tree_connection.h" | 12 #include "components/mus/public/cpp/view_tree_connection.h" |
| 13 #include "components/view_manager/public/cpp/view_tree_host_factory.h" | 13 #include "components/mus/public/cpp/view_tree_host_factory.h" |
| 14 #include "mojo/application/public/cpp/application_impl.h" | 14 #include "mojo/application/public/cpp/application_impl.h" |
| 15 | 15 |
| 16 namespace mojo { | 16 namespace mojo { |
| 17 namespace { | 17 namespace { |
| 18 | 18 |
| 19 base::RunLoop* current_run_loop = nullptr; | 19 base::RunLoop* current_run_loop = nullptr; |
| 20 | 20 |
| 21 void TimeoutRunLoop(const base::Closure& timeout_task, bool* timeout) { | 21 void TimeoutRunLoop(const base::Closure& timeout_task, bool* timeout) { |
| 22 CHECK(current_run_loop); | 22 CHECK(current_run_loop); |
| 23 *timeout = true; | 23 *timeout = true; |
| 24 timeout_task.Run(); | 24 timeout_task.Run(); |
| 25 } | 25 } |
| 26 | 26 |
| 27 } // namespace | 27 } // namespace |
| 28 | 28 |
| 29 ViewManagerTestBase::ViewManagerTestBase() | 29 ViewManagerTestBase::ViewManagerTestBase() |
| 30 : most_recent_connection_(nullptr), | 30 : most_recent_connection_(nullptr), |
| 31 window_manager_(nullptr), | 31 window_manager_(nullptr), |
| 32 view_tree_connection_destroyed_(false) { | 32 view_tree_connection_destroyed_(false) {} |
| 33 } | |
| 34 | 33 |
| 35 ViewManagerTestBase::~ViewManagerTestBase() { | 34 ViewManagerTestBase::~ViewManagerTestBase() {} |
| 36 } | |
| 37 | 35 |
| 38 // static | 36 // static |
| 39 bool ViewManagerTestBase::DoRunLoopWithTimeout() { | 37 bool ViewManagerTestBase::DoRunLoopWithTimeout() { |
| 40 if (current_run_loop != nullptr) | 38 if (current_run_loop != nullptr) |
| 41 return false; | 39 return false; |
| 42 | 40 |
| 43 bool timeout = false; | 41 bool timeout = false; |
| 44 base::RunLoop run_loop; | 42 base::RunLoop run_loop; |
| 45 base::MessageLoop::current()->PostDelayedTask( | 43 base::MessageLoop::current()->PostDelayedTask( |
| 46 FROM_HERE, base::Bind(&TimeoutRunLoop, run_loop.QuitClosure(), &timeout), | 44 FROM_HERE, base::Bind(&TimeoutRunLoop, run_loop.QuitClosure(), &timeout), |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 void ViewManagerTestBase::OnConnectionLost(ViewTreeConnection* connection) { | 91 void ViewManagerTestBase::OnConnectionLost(ViewTreeConnection* connection) { |
| 94 view_tree_connection_destroyed_ = true; | 92 view_tree_connection_destroyed_ = true; |
| 95 } | 93 } |
| 96 | 94 |
| 97 void ViewManagerTestBase::Create(ApplicationConnection* connection, | 95 void ViewManagerTestBase::Create(ApplicationConnection* connection, |
| 98 InterfaceRequest<ViewTreeClient> request) { | 96 InterfaceRequest<ViewTreeClient> request) { |
| 99 ViewTreeConnection::Create(this, request.Pass()); | 97 ViewTreeConnection::Create(this, request.Pass()); |
| 100 } | 98 } |
| 101 | 99 |
| 102 } // namespace mojo | 100 } // namespace mojo |
| OLD | NEW |