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/mus/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/mus/public/cpp/view.h" | 11 #include "components/mus/public/cpp/view.h" |
12 #include "components/mus/public/cpp/view_tree_connection.h" | 12 #include "components/mus/public/cpp/view_tree_connection.h" |
13 #include "components/mus/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 mus { | 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 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 CreateSingleViewTreeHost(application_impl(), this, &host_); | 66 CreateSingleViewTreeHost(application_impl(), this, &host_); |
67 | 67 |
68 ASSERT_TRUE(DoRunLoopWithTimeout()); // RunLoop should be quit by OnEmbed(). | 68 ASSERT_TRUE(DoRunLoopWithTimeout()); // RunLoop should be quit by OnEmbed(). |
69 std::swap(window_manager_, most_recent_connection_); | 69 std::swap(window_manager_, most_recent_connection_); |
70 } | 70 } |
71 | 71 |
72 void ViewManagerTestBase::TearDown() { | 72 void ViewManagerTestBase::TearDown() { |
73 ApplicationTestBase::TearDown(); | 73 ApplicationTestBase::TearDown(); |
74 } | 74 } |
75 | 75 |
76 mojo::ApplicationDelegate* ViewManagerTestBase::GetApplicationDelegate() { | 76 ApplicationDelegate* ViewManagerTestBase::GetApplicationDelegate() { |
77 return this; | 77 return this; |
78 } | 78 } |
79 | 79 |
80 bool ViewManagerTestBase::ConfigureIncomingConnection( | 80 bool ViewManagerTestBase::ConfigureIncomingConnection( |
81 mojo::ApplicationConnection* connection) { | 81 ApplicationConnection* connection) { |
82 connection->AddService<mojo::ViewTreeClient>(this); | 82 connection->AddService<ViewTreeClient>(this); |
83 return true; | 83 return true; |
84 } | 84 } |
85 | 85 |
86 void ViewManagerTestBase::OnEmbed(View* root) { | 86 void ViewManagerTestBase::OnEmbed(View* root) { |
87 most_recent_connection_ = root->connection(); | 87 most_recent_connection_ = root->connection(); |
88 EXPECT_TRUE(QuitRunLoop()); | 88 EXPECT_TRUE(QuitRunLoop()); |
89 } | 89 } |
90 | 90 |
91 void ViewManagerTestBase::OnConnectionLost(ViewTreeConnection* connection) { | 91 void ViewManagerTestBase::OnConnectionLost(ViewTreeConnection* connection) { |
92 view_tree_connection_destroyed_ = true; | 92 view_tree_connection_destroyed_ = true; |
93 } | 93 } |
94 | 94 |
95 void ViewManagerTestBase::Create( | 95 void ViewManagerTestBase::Create(ApplicationConnection* connection, |
96 mojo::ApplicationConnection* connection, | 96 InterfaceRequest<ViewTreeClient> request) { |
97 mojo::InterfaceRequest<mojo::ViewTreeClient> request) { | |
98 ViewTreeConnection::Create(this, request.Pass()); | 97 ViewTreeConnection::Create(this, request.Pass()); |
99 } | 98 } |
100 | 99 |
101 } // namespace mus | 100 } // namespace mojo |
OLD | NEW |