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/command_line.h" | 6 #include "base/command_line.h" |
7 #include "base/memory/scoped_vector.h" | 7 #include "base/memory/scoped_vector.h" |
8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
9 #include "mojo/public/cpp/application/application_delegate.h" | 9 #include "mojo/public/cpp/application/application_delegate.h" |
10 #include "mojo/public/cpp/application/application_impl.h" | 10 #include "mojo/public/cpp/application/application_impl.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 active_window_changed_callback_.Run(active_window); | 60 active_window_changed_callback_.Run(active_window); |
61 } | 61 } |
62 | 62 |
63 NodeIdCallback focus_changed_callback_; | 63 NodeIdCallback focus_changed_callback_; |
64 NodeIdCallback active_window_changed_callback_; | 64 NodeIdCallback active_window_changed_callback_; |
65 mojo::Binding<WindowManagerObserver> binding_; | 65 mojo::Binding<WindowManagerObserver> binding_; |
66 | 66 |
67 DISALLOW_COPY_AND_ASSIGN(TestWindowManagerObserver); | 67 DISALLOW_COPY_AND_ASSIGN(TestWindowManagerObserver); |
68 }; | 68 }; |
69 | 69 |
70 class TestApplicationLoader : public mojo::ApplicationLoader, | 70 class TestApplicationLoader : public mojo::shell::ApplicationLoader, |
71 public mojo::ApplicationDelegate, | 71 public mojo::ApplicationDelegate, |
72 public mojo::ViewManagerDelegate { | 72 public mojo::ViewManagerDelegate { |
73 public: | 73 public: |
74 typedef base::Callback<void(View*)> RootAddedCallback; | 74 typedef base::Callback<void(View*)> RootAddedCallback; |
75 | 75 |
76 explicit TestApplicationLoader(const RootAddedCallback& root_added_callback) | 76 explicit TestApplicationLoader(const RootAddedCallback& root_added_callback) |
77 : root_added_callback_(root_added_callback) {} | 77 : root_added_callback_(root_added_callback) {} |
78 ~TestApplicationLoader() override {} | 78 ~TestApplicationLoader() override {} |
79 | 79 |
80 private: | 80 private: |
81 // Overridden from mojo::ApplicationLoader: | 81 // Overridden from mojo::shell::ApplicationLoader: |
82 void Load( | 82 void Load( |
83 const GURL& url, | 83 const GURL& url, |
84 mojo::InterfaceRequest<mojo::Application> application_request) override { | 84 mojo::InterfaceRequest<mojo::Application> application_request) override { |
85 ASSERT_TRUE(application_request.is_pending()); | 85 ASSERT_TRUE(application_request.is_pending()); |
86 scoped_ptr<ApplicationImpl> app( | 86 scoped_ptr<ApplicationImpl> app( |
87 new ApplicationImpl(this, application_request.Pass())); | 87 new ApplicationImpl(this, application_request.Pass())); |
88 apps_.push_back(app.release()); | 88 apps_.push_back(app.release()); |
89 } | 89 } |
90 | 90 |
91 // Overridden from mojo::ApplicationDelegate: | 91 // Overridden from mojo::ApplicationDelegate: |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 mojo::WindowManagerPtr window_manager_; | 171 mojo::WindowManagerPtr window_manager_; |
172 | 172 |
173 private: | 173 private: |
174 // Overridden from testing::Test: | 174 // Overridden from testing::Test: |
175 void SetUp() override { | 175 void SetUp() override { |
176 test_helper_.reset(new mojo::shell::ShellTestHelper); | 176 test_helper_.reset(new mojo::shell::ShellTestHelper); |
177 test_helper_->Init(); | 177 test_helper_->Init(); |
178 test_helper_->AddURLMapping(GURL("mojo:window_manager"), | 178 test_helper_->AddURLMapping(GURL("mojo:window_manager"), |
179 GURL("mojo:core_window_manager")); | 179 GURL("mojo:core_window_manager")); |
180 test_helper_->SetLoaderForURL( | 180 test_helper_->SetLoaderForURL( |
181 scoped_ptr<mojo::ApplicationLoader>( | 181 scoped_ptr<mojo::shell::ApplicationLoader>( |
182 new TestApplicationLoader(base::Bind( | 182 new TestApplicationLoader(base::Bind( |
183 &WindowManagerApiTest::OnRootAdded, base::Unretained(this)))), | 183 &WindowManagerApiTest::OnRootAdded, base::Unretained(this)))), |
184 GURL(kTestServiceURL)); | 184 GURL(kTestServiceURL)); |
185 ConnectToWindowManager2(); | 185 ConnectToWindowManager2(); |
186 } | 186 } |
187 void TearDown() override {} | 187 void TearDown() override {} |
188 | 188 |
189 void ConnectToWindowManager2() { | 189 void ConnectToWindowManager2() { |
190 test_helper_->application_manager()->ConnectToService( | 190 test_helper_->application_manager()->ConnectToService( |
191 GURL("mojo:window_manager"), &window_manager_); | 191 GURL("mojo:window_manager"), &window_manager_); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 EXPECT_EQ(id, first_window); | 251 EXPECT_EQ(id, first_window); |
252 | 252 |
253 Id second_window = OpenWindow(); | 253 Id second_window = OpenWindow(); |
254 window_manager_->ActivateWindow(second_window, | 254 window_manager_->ActivateWindow(second_window, |
255 base::Bind(&EmptyResultCallback)); | 255 base::Bind(&EmptyResultCallback)); |
256 id = WaitForActiveWindowChange(); | 256 id = WaitForActiveWindowChange(); |
257 EXPECT_EQ(id, second_window); | 257 EXPECT_EQ(id, second_window); |
258 } | 258 } |
259 | 259 |
260 } // namespace window_manager | 260 } // namespace window_manager |
OLD | NEW |