| 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/types.h" | 12 #include "mojo/services/public/cpp/view_manager/types.h" |
| 13 #include "mojo/services/public/cpp/view_manager/view.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_manager2/window_manager2.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 { |
| 24 | 24 |
| 25 const char kTestServiceURL[] = "mojo:test_url"; | 25 const char kTestServiceURL[] = "mojo:test_url"; |
| 26 | 26 |
| 27 void EmptyResultCallback(bool result) {} | 27 void EmptyResultCallback(bool result) {} |
| 28 | 28 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 40 bool result = false; | 40 bool result = false; |
| 41 base::RunLoop run_loop; | 41 base::RunLoop run_loop; |
| 42 ServiceProviderPtr sp; | 42 ServiceProviderPtr sp; |
| 43 BindToProxy(new ServiceProviderImpl, &sp); | 43 BindToProxy(new ServiceProviderImpl, &sp); |
| 44 view_manager_init->Embed(url, sp.Pass(), | 44 view_manager_init->Embed(url, sp.Pass(), |
| 45 base::Bind(&ResultCallback, &result, &run_loop)); | 45 base::Bind(&ResultCallback, &result, &run_loop)); |
| 46 run_loop.Run(); | 46 run_loop.Run(); |
| 47 return result; | 47 return result; |
| 48 } | 48 } |
| 49 | 49 |
| 50 class TestWindowManagerClient : public WindowManagerClient { | 50 class TestWindowManagerClient : public WindowManagerClient2 { |
| 51 public: | 51 public: |
| 52 typedef base::Callback<void(Id, Id)> | 52 typedef base::Callback<void(Id, Id)> |
| 53 TwoNodeCallback; | 53 TwoNodeCallback; |
| 54 | 54 |
| 55 explicit TestWindowManagerClient(base::RunLoop* run_loop) | 55 explicit TestWindowManagerClient(base::RunLoop* run_loop) |
| 56 : run_loop_(run_loop) {} | 56 : run_loop_(run_loop) {} |
| 57 virtual ~TestWindowManagerClient() {} | 57 virtual ~TestWindowManagerClient() {} |
| 58 | 58 |
| 59 void set_focus_changed_callback(const TwoNodeCallback& callback) { | 59 void set_focus_changed_callback(const TwoNodeCallback& callback) { |
| 60 focus_changed_callback_ = callback; | 60 focus_changed_callback_ = callback; |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 | 185 |
| 186 Id OpenWindowWithURL(const std::string& url) { | 186 Id OpenWindowWithURL(const std::string& url) { |
| 187 InitEmbed(view_manager_init_.get(), url); | 187 InitEmbed(view_manager_init_.get(), url); |
| 188 return WaitForEmbed(); | 188 return WaitForEmbed(); |
| 189 } | 189 } |
| 190 | 190 |
| 191 TestWindowManagerClient* window_manager_client() { | 191 TestWindowManagerClient* window_manager_client() { |
| 192 return window_manager_client_.get(); | 192 return window_manager_client_.get(); |
| 193 } | 193 } |
| 194 | 194 |
| 195 WindowManagerServicePtr window_manager_; | 195 WindowManagerService2Ptr window_manager_; |
| 196 | 196 |
| 197 private: | 197 private: |
| 198 // Overridden from testing::Test: | 198 // Overridden from testing::Test: |
| 199 virtual void SetUp() override { | 199 virtual void SetUp() override { |
| 200 test_helper_.Init(); | 200 test_helper_.Init(); |
| 201 test_helper_.SetLoaderForURL( | 201 test_helper_.SetLoaderForURL( |
| 202 scoped_ptr<ApplicationLoader>(new TestApplicationLoader(base::Bind( | 202 scoped_ptr<ApplicationLoader>(new TestApplicationLoader(base::Bind( |
| 203 &WindowManagerApiTest::OnRootAdded, base::Unretained(this)))), | 203 &WindowManagerApiTest::OnRootAdded, base::Unretained(this)))), |
| 204 GURL(kTestServiceURL)); | 204 GURL(kTestServiceURL)); |
| 205 test_helper_.application_manager()->ConnectToService( | 205 test_helper_.application_manager()->ConnectToService( |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 | 269 |
| 270 Id second_window = OpenWindow(); | 270 Id second_window = OpenWindow(); |
| 271 window_manager_->ActivateWindow(second_window, | 271 window_manager_->ActivateWindow(second_window, |
| 272 base::Bind(&EmptyResultCallback)); | 272 base::Bind(&EmptyResultCallback)); |
| 273 ids = WaitForActiveWindowChange(); | 273 ids = WaitForActiveWindowChange(); |
| 274 EXPECT_EQ(ids.first, first_window); | 274 EXPECT_EQ(ids.first, first_window); |
| 275 EXPECT_EQ(ids.second, second_window); | 275 EXPECT_EQ(ids.second, second_window); |
| 276 } | 276 } |
| 277 | 277 |
| 278 } // namespace mojo | 278 } // namespace mojo |
| OLD | NEW |