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/service_manager/service_manager.h" | 9 #include "mojo/service_manager/service_manager.h" |
10 #include "mojo/services/public/cpp/view_manager/node.h" | 10 #include "mojo/services/public/cpp/view_manager/node.h" |
11 #include "mojo/services/public/cpp/view_manager/types.h" | 11 #include "mojo/services/public/cpp/view_manager/types.h" |
12 #include "mojo/services/public/cpp/view_manager/view_manager.h" | 12 #include "mojo/services/public/cpp/view_manager/view_manager.h" |
| 13 #include "mojo/services/public/cpp/view_manager/view_manager_client_factory.h" |
13 #include "mojo/services/public/cpp/view_manager/view_manager_delegate.h" | 14 #include "mojo/services/public/cpp/view_manager/view_manager_delegate.h" |
14 #include "mojo/services/public/interfaces/view_manager/view_manager.mojom.h" | 15 #include "mojo/services/public/interfaces/view_manager/view_manager.mojom.h" |
15 #include "mojo/services/public/interfaces/window_manager/window_manager.mojom.h" | 16 #include "mojo/services/public/interfaces/window_manager/window_manager.mojom.h" |
16 #include "mojo/shell/shell_test_helper.h" | 17 #include "mojo/shell/shell_test_helper.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
18 | 19 |
19 namespace mojo { | 20 namespace mojo { |
20 namespace { | 21 namespace { |
21 | 22 |
22 const char kTestServiceURL[] = "mojo:test_url"; | 23 const char kTestServiceURL[] = "mojo:test_url"; |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 DISALLOW_COPY_AND_ASSIGN(TestWindowManagerClient); | 115 DISALLOW_COPY_AND_ASSIGN(TestWindowManagerClient); |
115 }; | 116 }; |
116 | 117 |
117 class TestServiceLoader : public ServiceLoader, | 118 class TestServiceLoader : public ServiceLoader, |
118 public ApplicationDelegate, | 119 public ApplicationDelegate, |
119 public view_manager::ViewManagerDelegate { | 120 public view_manager::ViewManagerDelegate { |
120 public: | 121 public: |
121 typedef base::Callback<void(view_manager::Node*)> RootAddedCallback; | 122 typedef base::Callback<void(view_manager::Node*)> RootAddedCallback; |
122 | 123 |
123 explicit TestServiceLoader(const RootAddedCallback& root_added_callback) | 124 explicit TestServiceLoader(const RootAddedCallback& root_added_callback) |
124 : root_added_callback_(root_added_callback) {} | 125 : root_added_callback_(root_added_callback), |
| 126 view_manager_client_factory_(this) {} |
125 virtual ~TestServiceLoader() {} | 127 virtual ~TestServiceLoader() {} |
126 | 128 |
127 private: | 129 private: |
128 // Overridden from ServiceLoader: | 130 // Overridden from ServiceLoader: |
129 virtual void LoadService(ServiceManager* service_manager, | 131 virtual void LoadService(ServiceManager* service_manager, |
130 const GURL& url, | 132 const GURL& url, |
131 ScopedMessagePipeHandle shell_handle) MOJO_OVERRIDE { | 133 ScopedMessagePipeHandle shell_handle) MOJO_OVERRIDE { |
132 scoped_ptr<ApplicationImpl> app( | 134 scoped_ptr<ApplicationImpl> app( |
133 new ApplicationImpl(this, shell_handle.Pass())); | 135 new ApplicationImpl(this, shell_handle.Pass())); |
134 apps_.push_back(app.release()); | 136 apps_.push_back(app.release()); |
135 } | 137 } |
136 virtual void OnServiceError(ServiceManager* service_manager, | 138 virtual void OnServiceError(ServiceManager* service_manager, |
137 const GURL& url) MOJO_OVERRIDE { | 139 const GURL& url) MOJO_OVERRIDE { |
138 } | 140 } |
139 | 141 |
140 // Overridden from ApplicationDelegate: | 142 // Overridden from ApplicationDelegate: |
141 virtual bool ConfigureIncomingConnection( | 143 virtual bool ConfigureIncomingConnection( |
142 ApplicationConnection* connection) MOJO_OVERRIDE { | 144 ApplicationConnection* connection) MOJO_OVERRIDE { |
143 view_manager::ViewManager::ConfigureIncomingConnection(connection, this); | 145 connection->AddService(&view_manager_client_factory_); |
144 return true; | 146 return true; |
145 } | 147 } |
146 | 148 |
147 // Overridden from ViewManagerDelegate: | 149 // Overridden from ViewManagerDelegate: |
148 virtual void OnRootAdded(view_manager::ViewManager* view_manager, | 150 virtual void OnRootAdded(view_manager::ViewManager* view_manager, |
149 view_manager::Node* root) MOJO_OVERRIDE { | 151 view_manager::Node* root) MOJO_OVERRIDE { |
150 root_added_callback_.Run(root); | 152 root_added_callback_.Run(root); |
151 } | 153 } |
152 virtual void OnViewManagerDisconnected( | 154 virtual void OnViewManagerDisconnected( |
153 view_manager::ViewManager* view_manager) MOJO_OVERRIDE { | 155 view_manager::ViewManager* view_manager) MOJO_OVERRIDE { |
154 } | 156 } |
155 | 157 |
156 RootAddedCallback root_added_callback_; | 158 RootAddedCallback root_added_callback_; |
157 | 159 |
158 ScopedVector<ApplicationImpl> apps_; | 160 ScopedVector<ApplicationImpl> apps_; |
| 161 view_manager::ViewManagerClientFactory view_manager_client_factory_; |
159 | 162 |
160 DISALLOW_COPY_AND_ASSIGN(TestServiceLoader); | 163 DISALLOW_COPY_AND_ASSIGN(TestServiceLoader); |
161 }; | 164 }; |
162 | 165 |
163 } // namespace | 166 } // namespace |
164 | 167 |
165 class WindowManagerApiTest : public testing::Test { | 168 class WindowManagerApiTest : public testing::Test { |
166 public: | 169 public: |
167 WindowManagerApiTest() {} | 170 WindowManagerApiTest() {} |
168 virtual ~WindowManagerApiTest() {} | 171 virtual ~WindowManagerApiTest() {} |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 void OnActiveWindowChanged(TwoIds* old_and_new, | 261 void OnActiveWindowChanged(TwoIds* old_and_new, |
259 base::RunLoop* run_loop, | 262 base::RunLoop* run_loop, |
260 view_manager::Id old_focused_node_id, | 263 view_manager::Id old_focused_node_id, |
261 view_manager::Id new_focused_node_id) { | 264 view_manager::Id new_focused_node_id) { |
262 DCHECK(old_and_new); | 265 DCHECK(old_and_new); |
263 old_and_new->first = old_focused_node_id; | 266 old_and_new->first = old_focused_node_id; |
264 old_and_new->second = new_focused_node_id; | 267 old_and_new->second = new_focused_node_id; |
265 run_loop->Quit(); | 268 run_loop->Quit(); |
266 } | 269 } |
267 | 270 |
| 271 shell::ShellTestHelper test_helper_; |
268 base::MessageLoop loop_; | 272 base::MessageLoop loop_; |
269 shell::ShellTestHelper test_helper_; | |
270 view_manager::ViewManagerInitServicePtr view_manager_init_; | 273 view_manager::ViewManagerInitServicePtr view_manager_init_; |
271 scoped_ptr<TestWindowManagerClient> window_manager_client_; | 274 scoped_ptr<TestWindowManagerClient> window_manager_client_; |
272 TestServiceLoader::RootAddedCallback root_added_callback_; | 275 TestServiceLoader::RootAddedCallback root_added_callback_; |
273 | 276 |
274 DISALLOW_COPY_AND_ASSIGN(WindowManagerApiTest); | 277 DISALLOW_COPY_AND_ASSIGN(WindowManagerApiTest); |
275 }; | 278 }; |
276 | 279 |
277 TEST_F(WindowManagerApiTest, OpenWindow) { | 280 // http://crbug.com/396295 |
| 281 TEST_F(WindowManagerApiTest, DISABLED_OpenWindow) { |
278 OpenWindow(window_manager_.get()); | 282 OpenWindow(window_manager_.get()); |
279 view_manager::Id created_node = | 283 view_manager::Id created_node = |
280 OpenWindowWithURL(window_manager_.get(), kTestServiceURL); | 284 OpenWindowWithURL(window_manager_.get(), kTestServiceURL); |
281 view_manager::Id embed_node = WaitForEmbed(); | 285 view_manager::Id embed_node = WaitForEmbed(); |
282 EXPECT_EQ(created_node, embed_node); | 286 EXPECT_EQ(created_node, embed_node); |
283 } | 287 } |
284 | 288 |
285 TEST_F(WindowManagerApiTest, FocusAndActivateWindow) { | 289 // http://crbug.com/396295 |
| 290 TEST_F(WindowManagerApiTest, DISABLED_FocusAndActivateWindow) { |
286 view_manager::Id first_window = OpenWindow(window_manager_.get()); | 291 view_manager::Id first_window = OpenWindow(window_manager_.get()); |
287 window_manager_->FocusWindow(first_window, | 292 window_manager_->FocusWindow(first_window, |
288 base::Bind(&EmptyResultCallback)); | 293 base::Bind(&EmptyResultCallback)); |
289 TwoIds ids = WaitForFocusChange(); | 294 TwoIds ids = WaitForFocusChange(); |
290 EXPECT_TRUE(ids.first == 0); | 295 EXPECT_TRUE(ids.first == 0); |
291 EXPECT_EQ(ids.second, first_window); | 296 EXPECT_EQ(ids.second, first_window); |
292 | 297 |
293 view_manager::Id second_window = OpenWindow(window_manager_.get()); | 298 view_manager::Id second_window = OpenWindow(window_manager_.get()); |
294 window_manager_->ActivateWindow(second_window, | 299 window_manager_->ActivateWindow(second_window, |
295 base::Bind(&EmptyResultCallback)); | 300 base::Bind(&EmptyResultCallback)); |
296 ids = WaitForActiveWindowChange(); | 301 ids = WaitForActiveWindowChange(); |
297 EXPECT_EQ(ids.first, first_window); | 302 EXPECT_EQ(ids.first, first_window); |
298 EXPECT_EQ(ids.second, second_window); | 303 EXPECT_EQ(ids.second, second_window); |
299 } | 304 } |
300 | 305 |
301 } // namespace mojo | 306 } // namespace mojo |
OLD | NEW |