| 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/application_manager/application_manager.h" | 7 #include "mojo/application_manager/application_manager.h" |
| 8 #include "mojo/public/cpp/application/application_delegate.h" | 8 #include "mojo/public/cpp/application/application_delegate.h" |
| 9 #include "mojo/public/cpp/application/application_impl.h" | 9 #include "mojo/public/cpp/application/application_impl.h" |
| 10 #include "mojo/public/cpp/application/service_provider_impl.h" | 10 #include "mojo/public/cpp/application/service_provider_impl.h" |
| 11 #include "mojo/public/interfaces/application/service_provider.mojom.h" | 11 #include "mojo/public/interfaces/application/service_provider.mojom.h" |
| 12 #include "mojo/services/public/cpp/view_manager/node.h" | |
| 13 #include "mojo/services/public/cpp/view_manager/types.h" | 12 #include "mojo/services/public/cpp/view_manager/types.h" |
| 13 #include "mojo/services/public/cpp/view_manager/view.h" |
| 14 #include "mojo/services/public/cpp/view_manager/view_manager.h" | 14 #include "mojo/services/public/cpp/view_manager/view_manager.h" |
| 15 #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" |
| 16 #include "mojo/services/public/cpp/view_manager/view_manager_delegate.h" | 16 #include "mojo/services/public/cpp/view_manager/view_manager_delegate.h" |
| 17 #include "mojo/services/public/interfaces/view_manager/view_manager.mojom.h" | 17 #include "mojo/services/public/interfaces/view_manager/view_manager.mojom.h" |
| 18 #include "mojo/services/public/interfaces/window_manager/window_manager.mojom.h" | 18 #include "mojo/services/public/interfaces/window_manager/window_manager.mojom.h" |
| 19 #include "mojo/shell/shell_test_helper.h" | 19 #include "mojo/shell/shell_test_helper.h" |
| 20 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
| 21 | 21 |
| 22 namespace mojo { | 22 namespace mojo { |
| 23 namespace { | 23 namespace { |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 TwoNodeCallback focus_changed_callback_; | 116 TwoNodeCallback focus_changed_callback_; |
| 117 TwoNodeCallback active_window_changed_callback_; | 117 TwoNodeCallback active_window_changed_callback_; |
| 118 | 118 |
| 119 DISALLOW_COPY_AND_ASSIGN(TestWindowManagerClient); | 119 DISALLOW_COPY_AND_ASSIGN(TestWindowManagerClient); |
| 120 }; | 120 }; |
| 121 | 121 |
| 122 class TestApplicationLoader : public ApplicationLoader, | 122 class TestApplicationLoader : public ApplicationLoader, |
| 123 public ApplicationDelegate, | 123 public ApplicationDelegate, |
| 124 public ViewManagerDelegate { | 124 public ViewManagerDelegate { |
| 125 public: | 125 public: |
| 126 typedef base::Callback<void(Node*)> RootAddedCallback; | 126 typedef base::Callback<void(View*)> RootAddedCallback; |
| 127 | 127 |
| 128 explicit TestApplicationLoader(const RootAddedCallback& root_added_callback) | 128 explicit TestApplicationLoader(const RootAddedCallback& root_added_callback) |
| 129 : root_added_callback_(root_added_callback), | 129 : root_added_callback_(root_added_callback), |
| 130 view_manager_client_factory_(this) {} | 130 view_manager_client_factory_(this) {} |
| 131 virtual ~TestApplicationLoader() {} | 131 virtual ~TestApplicationLoader() {} |
| 132 | 132 |
| 133 private: | 133 private: |
| 134 // Overridden from ApplicationLoader: | 134 // Overridden from ApplicationLoader: |
| 135 virtual void Load(ApplicationManager* application_manager, | 135 virtual void Load(ApplicationManager* application_manager, |
| 136 const GURL& url, | 136 const GURL& url, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 148 // Overridden from ApplicationDelegate: | 148 // Overridden from ApplicationDelegate: |
| 149 virtual bool ConfigureIncomingConnection( | 149 virtual bool ConfigureIncomingConnection( |
| 150 ApplicationConnection* connection) MOJO_OVERRIDE { | 150 ApplicationConnection* connection) MOJO_OVERRIDE { |
| 151 connection->AddService(&view_manager_client_factory_); | 151 connection->AddService(&view_manager_client_factory_); |
| 152 return true; | 152 return true; |
| 153 } | 153 } |
| 154 | 154 |
| 155 // Overridden from ViewManagerDelegate: | 155 // Overridden from ViewManagerDelegate: |
| 156 virtual void OnEmbed( | 156 virtual void OnEmbed( |
| 157 ViewManager* view_manager, | 157 ViewManager* view_manager, |
| 158 Node* root, | 158 View* root, |
| 159 ServiceProviderImpl* exported_services, | 159 ServiceProviderImpl* exported_services, |
| 160 scoped_ptr<ServiceProvider> imported_services) MOJO_OVERRIDE { | 160 scoped_ptr<ServiceProvider> imported_services) MOJO_OVERRIDE { |
| 161 root_added_callback_.Run(root); | 161 root_added_callback_.Run(root); |
| 162 } | 162 } |
| 163 virtual void OnViewManagerDisconnected( | 163 virtual void OnViewManagerDisconnected( |
| 164 ViewManager* view_manager) MOJO_OVERRIDE { | 164 ViewManager* view_manager) MOJO_OVERRIDE { |
| 165 } | 165 } |
| 166 | 166 |
| 167 RootAddedCallback root_added_callback_; | 167 RootAddedCallback root_added_callback_; |
| 168 | 168 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 | 235 |
| 236 void ConnectToWindowManager() { | 236 void ConnectToWindowManager() { |
| 237 test_helper_.application_manager()->ConnectToService( | 237 test_helper_.application_manager()->ConnectToService( |
| 238 GURL("mojo:mojo_core_window_manager"), &window_manager_); | 238 GURL("mojo:mojo_core_window_manager"), &window_manager_); |
| 239 base::RunLoop connect_loop; | 239 base::RunLoop connect_loop; |
| 240 window_manager_client_.reset(new TestWindowManagerClient(&connect_loop)); | 240 window_manager_client_.reset(new TestWindowManagerClient(&connect_loop)); |
| 241 window_manager_.set_client(window_manager_client()); | 241 window_manager_.set_client(window_manager_client()); |
| 242 connect_loop.Run(); | 242 connect_loop.Run(); |
| 243 } | 243 } |
| 244 | 244 |
| 245 void OnRootAdded(Node* root) { | 245 void OnRootAdded(View* root) { |
| 246 if (!root_added_callback_.is_null()) | 246 if (!root_added_callback_.is_null()) |
| 247 root_added_callback_.Run(root); | 247 root_added_callback_.Run(root); |
| 248 } | 248 } |
| 249 | 249 |
| 250 void OnEmbed(Id* root_id, | 250 void OnEmbed(Id* root_id, |
| 251 base::RunLoop* loop, | 251 base::RunLoop* loop, |
| 252 Node* root) { | 252 View* root) { |
| 253 *root_id = root->id(); | 253 *root_id = root->id(); |
| 254 loop->Quit(); | 254 loop->Quit(); |
| 255 } | 255 } |
| 256 | 256 |
| 257 void OnFocusChanged(TwoIds* old_and_new, | 257 void OnFocusChanged(TwoIds* old_and_new, |
| 258 base::RunLoop* run_loop, | 258 base::RunLoop* run_loop, |
| 259 Id old_focused_node_id, | 259 Id old_focused_node_id, |
| 260 Id new_focused_node_id) { | 260 Id new_focused_node_id) { |
| 261 DCHECK(old_and_new); | 261 DCHECK(old_and_new); |
| 262 old_and_new->first = old_focused_node_id; | 262 old_and_new->first = old_focused_node_id; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 | 300 |
| 301 Id second_window = OpenWindow(window_manager_.get()); | 301 Id second_window = OpenWindow(window_manager_.get()); |
| 302 window_manager_->ActivateWindow(second_window, | 302 window_manager_->ActivateWindow(second_window, |
| 303 base::Bind(&EmptyResultCallback)); | 303 base::Bind(&EmptyResultCallback)); |
| 304 ids = WaitForActiveWindowChange(); | 304 ids = WaitForActiveWindowChange(); |
| 305 EXPECT_EQ(ids.first, first_window); | 305 EXPECT_EQ(ids.first, first_window); |
| 306 EXPECT_EQ(ids.second, second_window); | 306 EXPECT_EQ(ids.second, second_window); |
| 307 } | 307 } |
| 308 | 308 |
| 309 } // namespace mojo | 309 } // namespace mojo |
| OLD | NEW |