| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/web_view/frame.h" | 5 #include "components/web_view/frame.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 base::RunLoop run_loop_; | 278 base::RunLoop run_loop_; |
| 279 TestFrameClient test_frame_tree_client_; | 279 TestFrameClient test_frame_tree_client_; |
| 280 mojo::Binding<mojom::FrameClient> frame_client_binding_; | 280 mojo::Binding<mojom::FrameClient> frame_client_binding_; |
| 281 | 281 |
| 282 DISALLOW_COPY_AND_ASSIGN(ViewAndFrame); | 282 DISALLOW_COPY_AND_ASSIGN(ViewAndFrame); |
| 283 }; | 283 }; |
| 284 | 284 |
| 285 class FrameTest : public mojo::test::ApplicationTestBase, | 285 class FrameTest : public mojo::test::ApplicationTestBase, |
| 286 public mojo::ApplicationDelegate, | 286 public mojo::ApplicationDelegate, |
| 287 public mus::WindowTreeDelegate, | 287 public mus::WindowTreeDelegate, |
| 288 public mojo::InterfaceFactory<mojo::ViewTreeClient>, | 288 public mojo::InterfaceFactory<mus::mojom::WindowTreeClient>, |
| 289 public mojo::InterfaceFactory<mojom::FrameClient> { | 289 public mojo::InterfaceFactory<mojom::FrameClient> { |
| 290 public: | 290 public: |
| 291 FrameTest() : most_recent_connection_(nullptr), window_manager_(nullptr) {} | 291 FrameTest() : most_recent_connection_(nullptr), window_manager_(nullptr) {} |
| 292 | 292 |
| 293 WindowTreeConnection* most_recent_connection() { | 293 WindowTreeConnection* most_recent_connection() { |
| 294 return most_recent_connection_; | 294 return most_recent_connection_; |
| 295 } | 295 } |
| 296 | 296 |
| 297 protected: | 297 protected: |
| 298 WindowTreeConnection* window_manager() { return window_manager_; } | 298 WindowTreeConnection* window_manager() { return window_manager_; } |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 return view_and_frame_.Pass(); | 346 return view_and_frame_.Pass(); |
| 347 } | 347 } |
| 348 | 348 |
| 349 private: | 349 private: |
| 350 // ApplicationTestBase: | 350 // ApplicationTestBase: |
| 351 ApplicationDelegate* GetApplicationDelegate() override { return this; } | 351 ApplicationDelegate* GetApplicationDelegate() override { return this; } |
| 352 | 352 |
| 353 // ApplicationDelegate implementation. | 353 // ApplicationDelegate implementation. |
| 354 bool ConfigureIncomingConnection( | 354 bool ConfigureIncomingConnection( |
| 355 mojo::ApplicationConnection* connection) override { | 355 mojo::ApplicationConnection* connection) override { |
| 356 connection->AddService<mojo::ViewTreeClient>(this); | 356 connection->AddService<mus::mojom::WindowTreeClient>(this); |
| 357 connection->AddService<mojom::FrameClient>(this); | 357 connection->AddService<mojom::FrameClient>(this); |
| 358 return true; | 358 return true; |
| 359 } | 359 } |
| 360 | 360 |
| 361 // Overridden from WindowTreeDelegate: | 361 // Overridden from WindowTreeDelegate: |
| 362 void OnEmbed(Window* root) override { | 362 void OnEmbed(Window* root) override { |
| 363 most_recent_connection_ = root->connection(); | 363 most_recent_connection_ = root->connection(); |
| 364 QuitRunLoop(); | 364 QuitRunLoop(); |
| 365 } | 365 } |
| 366 void OnConnectionLost(WindowTreeConnection* connection) override {} | 366 void OnConnectionLost(WindowTreeConnection* connection) override {} |
| 367 | 367 |
| 368 // Overridden from testing::Test: | 368 // Overridden from testing::Test: |
| 369 void SetUp() override { | 369 void SetUp() override { |
| 370 ApplicationTestBase::SetUp(); | 370 ApplicationTestBase::SetUp(); |
| 371 | 371 |
| 372 mus::CreateSingleWindowTreeHost(application_impl(), this, &host_); | 372 mus::CreateSingleWindowTreeHost(application_impl(), this, &host_); |
| 373 | 373 |
| 374 ASSERT_TRUE(DoRunLoopWithTimeout()); | 374 ASSERT_TRUE(DoRunLoopWithTimeout()); |
| 375 std::swap(window_manager_, most_recent_connection_); | 375 std::swap(window_manager_, most_recent_connection_); |
| 376 | 376 |
| 377 // Creates a FrameTree, which creates a single frame. Wait for the | 377 // Creates a FrameTree, which creates a single frame. Wait for the |
| 378 // FrameClient to be connected to. | 378 // FrameClient to be connected to. |
| 379 frame_tree_delegate_.reset(new TestFrameTreeDelegate(application_impl())); | 379 frame_tree_delegate_.reset(new TestFrameTreeDelegate(application_impl())); |
| 380 scoped_ptr<FrameConnection> frame_connection = | 380 scoped_ptr<FrameConnection> frame_connection = |
| 381 CreateFrameConnection(application_impl()); | 381 CreateFrameConnection(application_impl()); |
| 382 mojom::FrameClient* frame_client = frame_connection->frame_client(); | 382 mojom::FrameClient* frame_client = frame_connection->frame_client(); |
| 383 mojo::ViewTreeClientPtr view_tree_client = | 383 mus::mojom::WindowTreeClientPtr view_tree_client = |
| 384 frame_connection->GetViewTreeClient(); | 384 frame_connection->GetWindowTreeClient(); |
| 385 mus::Window* frame_root_view = window_manager()->CreateWindow(); | 385 mus::Window* frame_root_view = window_manager()->CreateWindow(); |
| 386 window_manager()->GetRoot()->AddChild(frame_root_view); | 386 window_manager()->GetRoot()->AddChild(frame_root_view); |
| 387 frame_tree_.reset(new FrameTree( | 387 frame_tree_.reset(new FrameTree( |
| 388 0u, frame_root_view, view_tree_client.Pass(), | 388 0u, frame_root_view, view_tree_client.Pass(), |
| 389 frame_tree_delegate_.get(), frame_client, frame_connection.Pass(), | 389 frame_tree_delegate_.get(), frame_client, frame_connection.Pass(), |
| 390 Frame::ClientPropertyMap(), base::TimeTicks::Now())); | 390 Frame::ClientPropertyMap(), base::TimeTicks::Now())); |
| 391 root_view_and_frame_ = WaitForViewAndFrame(); | 391 root_view_and_frame_ = WaitForViewAndFrame(); |
| 392 } | 392 } |
| 393 | 393 |
| 394 // Overridden from testing::Test: | 394 // Overridden from testing::Test: |
| 395 void TearDown() override { | 395 void TearDown() override { |
| 396 root_view_and_frame_.reset(); | 396 root_view_and_frame_.reset(); |
| 397 frame_tree_.reset(); | 397 frame_tree_.reset(); |
| 398 frame_tree_delegate_.reset(); | 398 frame_tree_delegate_.reset(); |
| 399 ApplicationTestBase::TearDown(); | 399 ApplicationTestBase::TearDown(); |
| 400 } | 400 } |
| 401 | 401 |
| 402 // Overridden from mojo::InterfaceFactory<mojo::ViewTreeClient>: | 402 // Overridden from mojo::InterfaceFactory<mus::mojom::WindowTreeClient>: |
| 403 void Create( | 403 void Create( |
| 404 mojo::ApplicationConnection* connection, | 404 mojo::ApplicationConnection* connection, |
| 405 mojo::InterfaceRequest<mojo::ViewTreeClient> request) override { | 405 mojo::InterfaceRequest<mus::mojom::WindowTreeClient> request) override { |
| 406 if (view_and_frame_) { | 406 if (view_and_frame_) { |
| 407 mus::WindowTreeConnection::Create( | 407 mus::WindowTreeConnection::Create( |
| 408 view_and_frame_.get(), request.Pass(), | 408 view_and_frame_.get(), request.Pass(), |
| 409 mus::WindowTreeConnection::CreateType::DONT_WAIT_FOR_EMBED); | 409 mus::WindowTreeConnection::CreateType::DONT_WAIT_FOR_EMBED); |
| 410 } else { | 410 } else { |
| 411 mus::WindowTreeConnection::Create( | 411 mus::WindowTreeConnection::Create( |
| 412 this, request.Pass(), | 412 this, request.Pass(), |
| 413 mus::WindowTreeConnection::CreateType::DONT_WAIT_FOR_EMBED); | 413 mus::WindowTreeConnection::CreateType::DONT_WAIT_FOR_EMBED); |
| 414 } | 414 } |
| 415 } | 415 } |
| 416 | 416 |
| 417 // Overridden from mojo::InterfaceFactory<mojom::FrameClient>: | 417 // Overridden from mojo::InterfaceFactory<mojom::FrameClient>: |
| 418 void Create(mojo::ApplicationConnection* connection, | 418 void Create(mojo::ApplicationConnection* connection, |
| 419 mojo::InterfaceRequest<mojom::FrameClient> request) override { | 419 mojo::InterfaceRequest<mojom::FrameClient> request) override { |
| 420 ASSERT_TRUE(view_and_frame_); | 420 ASSERT_TRUE(view_and_frame_); |
| 421 view_and_frame_->Bind(request.Pass()); | 421 view_and_frame_->Bind(request.Pass()); |
| 422 } | 422 } |
| 423 | 423 |
| 424 scoped_ptr<TestFrameTreeDelegate> frame_tree_delegate_; | 424 scoped_ptr<TestFrameTreeDelegate> frame_tree_delegate_; |
| 425 scoped_ptr<FrameTree> frame_tree_; | 425 scoped_ptr<FrameTree> frame_tree_; |
| 426 scoped_ptr<ViewAndFrame> root_view_and_frame_; | 426 scoped_ptr<ViewAndFrame> root_view_and_frame_; |
| 427 | 427 |
| 428 mojo::ViewTreeHostPtr host_; | 428 mus::mojom::WindowTreeHostPtr host_; |
| 429 | 429 |
| 430 // Used to receive the most recent view manager loaded by an embed action. | 430 // Used to receive the most recent view manager loaded by an embed action. |
| 431 WindowTreeConnection* most_recent_connection_; | 431 WindowTreeConnection* most_recent_connection_; |
| 432 // The View Manager connection held by the window manager (app running at the | 432 // The View Manager connection held by the window manager (app running at the |
| 433 // root view). | 433 // root view). |
| 434 WindowTreeConnection* window_manager_; | 434 WindowTreeConnection* window_manager_; |
| 435 | 435 |
| 436 scoped_ptr<ViewAndFrame> view_and_frame_; | 436 scoped_ptr<ViewAndFrame> view_and_frame_; |
| 437 | 437 |
| 438 MOJO_DISALLOW_COPY_AND_ASSIGN(FrameTest); | 438 MOJO_DISALLOW_COPY_AND_ASSIGN(FrameTest); |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 563 scoped_ptr<ViewAndFrame> navigated_child_view_and_frame = | 563 scoped_ptr<ViewAndFrame> navigated_child_view_and_frame = |
| 564 NavigateFrameWithStartTime(child_view_and_frame.get(), | 564 NavigateFrameWithStartTime(child_view_and_frame.get(), |
| 565 navigation_start_time) | 565 navigation_start_time) |
| 566 .Pass(); | 566 .Pass(); |
| 567 EXPECT_EQ(navigation_start_time, | 567 EXPECT_EQ(navigation_start_time, |
| 568 navigated_child_view_and_frame->test_frame_client() | 568 navigated_child_view_and_frame->test_frame_client() |
| 569 ->last_navigation_start_time()); | 569 ->last_navigation_start_time()); |
| 570 } | 570 } |
| 571 | 571 |
| 572 } // namespace web_view | 572 } // namespace web_view |
| OLD | NEW |