OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/memory/scoped_vector.h" | 6 #include "base/memory/scoped_vector.h" |
7 #include "mojo/public/cpp/application/application_delegate.h" | 7 #include "mojo/public/cpp/application/application_delegate.h" |
8 #include "mojo/public/cpp/application/application_impl.h" | 8 #include "mojo/public/cpp/application/application_impl.h" |
| 9 #include "mojo/public/cpp/application/service_provider_impl.h" |
| 10 #include "mojo/public/interfaces/application/service_provider.mojom.h" |
9 #include "mojo/service_manager/service_manager.h" | 11 #include "mojo/service_manager/service_manager.h" |
10 #include "mojo/services/public/cpp/view_manager/node.h" | 12 #include "mojo/services/public/cpp/view_manager/node.h" |
11 #include "mojo/services/public/cpp/view_manager/types.h" | 13 #include "mojo/services/public/cpp/view_manager/types.h" |
12 #include "mojo/services/public/cpp/view_manager/view_manager.h" | 14 #include "mojo/services/public/cpp/view_manager/view_manager.h" |
13 #include "mojo/services/public/cpp/view_manager/view_manager_client_factory.h" | 15 #include "mojo/services/public/cpp/view_manager/view_manager_client_factory.h" |
14 #include "mojo/services/public/cpp/view_manager/view_manager_delegate.h" | 16 #include "mojo/services/public/cpp/view_manager/view_manager_delegate.h" |
15 #include "mojo/services/public/interfaces/view_manager/view_manager.mojom.h" | 17 #include "mojo/services/public/interfaces/view_manager/view_manager.mojom.h" |
16 #include "mojo/services/public/interfaces/window_manager/window_manager.mojom.h" | 18 #include "mojo/services/public/interfaces/window_manager/window_manager.mojom.h" |
17 #include "mojo/shell/shell_test_helper.h" | 19 #include "mojo/shell/shell_test_helper.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 11 matching lines...) Expand all Loading... |
30 *result_cache = result; | 32 *result_cache = result; |
31 run_loop->Quit(); | 33 run_loop->Quit(); |
32 } | 34 } |
33 | 35 |
34 // Responsible for establishing the initial ViewManagerService connection. | 36 // Responsible for establishing the initial ViewManagerService connection. |
35 // Blocks until result is determined. | 37 // Blocks until result is determined. |
36 bool InitEmbed(ViewManagerInitService* view_manager_init, | 38 bool InitEmbed(ViewManagerInitService* view_manager_init, |
37 const std::string& url) { | 39 const std::string& url) { |
38 bool result = false; | 40 bool result = false; |
39 base::RunLoop run_loop; | 41 base::RunLoop run_loop; |
40 view_manager_init->Embed(url, | 42 ServiceProviderPtr sp; |
| 43 BindToProxy(new ServiceProviderImpl, &sp); |
| 44 view_manager_init->Embed(url, sp.Pass(), |
41 base::Bind(&ResultCallback, &result, &run_loop)); | 45 base::Bind(&ResultCallback, &result, &run_loop)); |
42 run_loop.Run(); | 46 run_loop.Run(); |
43 return result; | 47 return result; |
44 } | 48 } |
45 | 49 |
46 void OpenWindowCallback(Id* id, | 50 void OpenWindowCallback(Id* id, |
47 base::RunLoop* run_loop, | 51 base::RunLoop* run_loop, |
48 Id window_id) { | 52 Id window_id) { |
49 *id = window_id; | 53 *id = window_id; |
50 run_loop->Quit(); | 54 run_loop->Quit(); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 } | 144 } |
141 | 145 |
142 // Overridden from ApplicationDelegate: | 146 // Overridden from ApplicationDelegate: |
143 virtual bool ConfigureIncomingConnection( | 147 virtual bool ConfigureIncomingConnection( |
144 ApplicationConnection* connection) MOJO_OVERRIDE { | 148 ApplicationConnection* connection) MOJO_OVERRIDE { |
145 connection->AddService(&view_manager_client_factory_); | 149 connection->AddService(&view_manager_client_factory_); |
146 return true; | 150 return true; |
147 } | 151 } |
148 | 152 |
149 // Overridden from ViewManagerDelegate: | 153 // Overridden from ViewManagerDelegate: |
150 virtual void OnEmbed(ViewManager* view_manager, Node* root) MOJO_OVERRIDE { | 154 virtual void OnEmbed( |
| 155 ViewManager* view_manager, |
| 156 Node* root, |
| 157 ServiceProviderImpl* exported_services, |
| 158 scoped_ptr<ServiceProvider> imported_services) MOJO_OVERRIDE { |
151 root_added_callback_.Run(root); | 159 root_added_callback_.Run(root); |
152 } | 160 } |
153 virtual void OnViewManagerDisconnected( | 161 virtual void OnViewManagerDisconnected( |
154 ViewManager* view_manager) MOJO_OVERRIDE { | 162 ViewManager* view_manager) MOJO_OVERRIDE { |
155 } | 163 } |
156 | 164 |
157 RootAddedCallback root_added_callback_; | 165 RootAddedCallback root_added_callback_; |
158 | 166 |
159 ScopedVector<ApplicationImpl> apps_; | 167 ScopedVector<ApplicationImpl> apps_; |
160 ViewManagerClientFactory view_manager_client_factory_; | 168 ViewManagerClientFactory view_manager_client_factory_; |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 | 301 |
294 Id second_window = OpenWindow(window_manager_.get()); | 302 Id second_window = OpenWindow(window_manager_.get()); |
295 window_manager_->ActivateWindow(second_window, | 303 window_manager_->ActivateWindow(second_window, |
296 base::Bind(&EmptyResultCallback)); | 304 base::Bind(&EmptyResultCallback)); |
297 ids = WaitForActiveWindowChange(); | 305 ids = WaitForActiveWindowChange(); |
298 EXPECT_EQ(ids.first, first_window); | 306 EXPECT_EQ(ids.first, first_window); |
299 EXPECT_EQ(ids.second, second_window); | 307 EXPECT_EQ(ids.second, second_window); |
300 } | 308 } |
301 | 309 |
302 } // namespace mojo | 310 } // namespace mojo |
OLD | NEW |