| 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" |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 scoped_ptr<ViewManagerClientFactory> view_manager_client_factory_; | 136 scoped_ptr<ViewManagerClientFactory> view_manager_client_factory_; |
| 137 | 137 |
| 138 DISALLOW_COPY_AND_ASSIGN(TestApplicationLoader); | 138 DISALLOW_COPY_AND_ASSIGN(TestApplicationLoader); |
| 139 }; | 139 }; |
| 140 | 140 |
| 141 } // namespace | 141 } // namespace |
| 142 | 142 |
| 143 class WindowManagerApiTest : public testing::Test { | 143 class WindowManagerApiTest : public testing::Test { |
| 144 public: | 144 public: |
| 145 WindowManagerApiTest() {} | 145 WindowManagerApiTest() {} |
| 146 virtual ~WindowManagerApiTest() {} | 146 ~WindowManagerApiTest() override {} |
| 147 | 147 |
| 148 protected: | 148 protected: |
| 149 typedef std::pair<Id, Id> TwoIds; | 149 typedef std::pair<Id, Id> TwoIds; |
| 150 | 150 |
| 151 Id WaitForEmbed() { | 151 Id WaitForEmbed() { |
| 152 Id id; | 152 Id id; |
| 153 base::RunLoop run_loop; | 153 base::RunLoop run_loop; |
| 154 root_added_callback_ = base::Bind(&WindowManagerApiTest::OnEmbed, | 154 root_added_callback_ = base::Bind(&WindowManagerApiTest::OnEmbed, |
| 155 base::Unretained(this), &id, &run_loop); | 155 base::Unretained(this), &id, &run_loop); |
| 156 run_loop.Run(); | 156 run_loop.Run(); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 187 } | 187 } |
| 188 | 188 |
| 189 TestWindowManagerClient* window_manager_client() { | 189 TestWindowManagerClient* window_manager_client() { |
| 190 return window_manager_client_.get(); | 190 return window_manager_client_.get(); |
| 191 } | 191 } |
| 192 | 192 |
| 193 WindowManagerService2Ptr window_manager_; | 193 WindowManagerService2Ptr window_manager_; |
| 194 | 194 |
| 195 private: | 195 private: |
| 196 // Overridden from testing::Test: | 196 // Overridden from testing::Test: |
| 197 virtual void SetUp() override { | 197 void SetUp() override { |
| 198 test_helper_.Init(); | 198 test_helper_.Init(); |
| 199 test_helper_.SetLoaderForURL( | 199 test_helper_.SetLoaderForURL( |
| 200 scoped_ptr<ApplicationLoader>(new TestApplicationLoader(base::Bind( | 200 scoped_ptr<ApplicationLoader>(new TestApplicationLoader(base::Bind( |
| 201 &WindowManagerApiTest::OnRootAdded, base::Unretained(this)))), | 201 &WindowManagerApiTest::OnRootAdded, base::Unretained(this)))), |
| 202 GURL(kTestServiceURL)); | 202 GURL(kTestServiceURL)); |
| 203 test_helper_.application_manager()->ConnectToService( | 203 test_helper_.application_manager()->ConnectToService( |
| 204 GURL("mojo:view_manager"), &view_manager_init_); | 204 GURL("mojo:view_manager"), &view_manager_init_); |
| 205 ASSERT_TRUE( | 205 ASSERT_TRUE( |
| 206 InitEmbed(view_manager_init_.get(), "mojo:core_window_manager")); | 206 InitEmbed(view_manager_init_.get(), "mojo:core_window_manager")); |
| 207 ConnectToWindowManager(); | 207 ConnectToWindowManager(); |
| 208 } | 208 } |
| 209 virtual void TearDown() override {} | 209 void TearDown() override {} |
| 210 | 210 |
| 211 void ConnectToWindowManager() { | 211 void ConnectToWindowManager() { |
| 212 test_helper_.application_manager()->ConnectToService( | 212 test_helper_.application_manager()->ConnectToService( |
| 213 GURL("mojo:core_window_manager"), &window_manager_); | 213 GURL("mojo:core_window_manager"), &window_manager_); |
| 214 base::RunLoop connect_loop; | 214 base::RunLoop connect_loop; |
| 215 window_manager_client_.reset(new TestWindowManagerClient(&connect_loop)); | 215 window_manager_client_.reset(new TestWindowManagerClient(&connect_loop)); |
| 216 window_manager_.set_client(window_manager_client()); | 216 window_manager_.set_client(window_manager_client()); |
| 217 connect_loop.Run(); | 217 connect_loop.Run(); |
| 218 } | 218 } |
| 219 | 219 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 | 267 |
| 268 Id second_window = OpenWindow(); | 268 Id second_window = OpenWindow(); |
| 269 window_manager_->ActivateWindow(second_window, | 269 window_manager_->ActivateWindow(second_window, |
| 270 base::Bind(&EmptyResultCallback)); | 270 base::Bind(&EmptyResultCallback)); |
| 271 ids = WaitForActiveWindowChange(); | 271 ids = WaitForActiveWindowChange(); |
| 272 EXPECT_EQ(ids.first, first_window); | 272 EXPECT_EQ(ids.first, first_window); |
| 273 EXPECT_EQ(ids.second, second_window); | 273 EXPECT_EQ(ids.second, second_window); |
| 274 } | 274 } |
| 275 | 275 |
| 276 } // namespace mojo | 276 } // namespace mojo |
| OLD | NEW |