| 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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 | 295 |
| 293 view_manager::Id second_window = OpenWindow(window_manager_.get()); | 296 view_manager::Id second_window = OpenWindow(window_manager_.get()); |
| 294 window_manager_->ActivateWindow(second_window, | 297 window_manager_->ActivateWindow(second_window, |
| 295 base::Bind(&EmptyResultCallback)); | 298 base::Bind(&EmptyResultCallback)); |
| 296 ids = WaitForActiveWindowChange(); | 299 ids = WaitForActiveWindowChange(); |
| 297 EXPECT_EQ(ids.first, first_window); | 300 EXPECT_EQ(ids.first, first_window); |
| 298 EXPECT_EQ(ids.second, second_window); | 301 EXPECT_EQ(ids.second, second_window); |
| 299 } | 302 } |
| 300 | 303 |
| 301 } // namespace mojo | 304 } // namespace mojo |
| OLD | NEW |