| 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 <stdint.h> |    7 #include <stdint.h> | 
|    8 #include <utility> |    8 #include <utility> | 
|    9  |    9  | 
|   10 #include "base/bind.h" |   10 #include "base/bind.h" | 
|   11 #include "base/location.h" |   11 #include "base/location.h" | 
|   12 #include "base/logging.h" |   12 #include "base/logging.h" | 
|   13 #include "base/macros.h" |   13 #include "base/macros.h" | 
|   14 #include "base/message_loop/message_loop.h" |   14 #include "base/message_loop/message_loop.h" | 
|   15 #include "base/run_loop.h" |   15 #include "base/run_loop.h" | 
|   16 #include "base/test/test_timeouts.h" |   16 #include "base/test/test_timeouts.h" | 
|   17 #include "base/time/time.h" |   17 #include "base/time/time.h" | 
|   18 #include "build/build_config.h" |   18 #include "build/build_config.h" | 
|   19 #include "components/mus/public/cpp/window_observer.h" |   19 #include "components/mus/public/cpp/window_observer.h" | 
|   20 #include "components/mus/public/cpp/window_tree_connection.h" |   20 #include "components/mus/public/cpp/window_tree_connection.h" | 
|   21 #include "components/mus/public/cpp/window_tree_delegate.h" |   21 #include "components/mus/public/cpp/window_tree_delegate.h" | 
|   22 #include "components/mus/public/cpp/window_tree_host_factory.h" |   22 #include "components/mus/public/cpp/window_tree_host_factory.h" | 
|   23 #include "components/mus/public/interfaces/window_tree_host.mojom.h" |   23 #include "components/mus/public/interfaces/window_tree_host.mojom.h" | 
|   24 #include "components/web_view/frame_connection.h" |   24 #include "components/web_view/frame_connection.h" | 
|   25 #include "components/web_view/frame_tree.h" |   25 #include "components/web_view/frame_tree.h" | 
|   26 #include "components/web_view/frame_tree_delegate.h" |   26 #include "components/web_view/frame_tree_delegate.h" | 
|   27 #include "components/web_view/frame_user_data.h" |   27 #include "components/web_view/frame_user_data.h" | 
|   28 #include "components/web_view/test_frame_tree_delegate.h" |   28 #include "components/web_view/test_frame_tree_delegate.h" | 
|   29 #include "mojo/shell/public/cpp/application_connection.h" |  | 
|   30 #include "mojo/shell/public/cpp/application_delegate.h" |  | 
|   31 #include "mojo/shell/public/cpp/application_test_base.h" |   29 #include "mojo/shell/public/cpp/application_test_base.h" | 
|   32 #include "mojo/shell/public/cpp/service_provider_impl.h" |  | 
|   33  |   30  | 
|   34 using mus::Window; |   31 using mus::Window; | 
|   35 using mus::WindowTreeConnection; |   32 using mus::WindowTreeConnection; | 
|   36  |   33  | 
|   37 namespace web_view { |   34 namespace web_view { | 
|   38  |   35  | 
|   39 namespace { |   36 namespace { | 
|   40  |   37  | 
|   41 base::RunLoop* current_run_loop = nullptr; |   38 base::RunLoop* current_run_loop = nullptr; | 
|   42  |   39  | 
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  279  |  276  | 
|  280   mus::Window* window_; |  277   mus::Window* window_; | 
|  281   base::RunLoop run_loop_; |  278   base::RunLoop run_loop_; | 
|  282   TestFrameClient test_frame_tree_client_; |  279   TestFrameClient test_frame_tree_client_; | 
|  283   mojo::Binding<mojom::FrameClient> frame_client_binding_; |  280   mojo::Binding<mojom::FrameClient> frame_client_binding_; | 
|  284  |  281  | 
|  285   DISALLOW_COPY_AND_ASSIGN(WindowAndFrame); |  282   DISALLOW_COPY_AND_ASSIGN(WindowAndFrame); | 
|  286 }; |  283 }; | 
|  287  |  284  | 
|  288 class FrameTest : public mojo::test::ApplicationTestBase, |  285 class FrameTest : public mojo::test::ApplicationTestBase, | 
|  289                   public mojo::ApplicationDelegate, |  286                   public mojo::ShellClient, | 
|  290                   public mus::WindowTreeDelegate, |  287                   public mus::WindowTreeDelegate, | 
|  291                   public mojo::InterfaceFactory<mus::mojom::WindowTreeClient>, |  288                   public mojo::InterfaceFactory<mus::mojom::WindowTreeClient>, | 
|  292                   public mojo::InterfaceFactory<mojom::FrameClient> { |  289                   public mojo::InterfaceFactory<mojom::FrameClient> { | 
|  293  public: |  290  public: | 
|  294   FrameTest() : most_recent_connection_(nullptr), window_manager_(nullptr) {} |  291   FrameTest() : most_recent_connection_(nullptr), window_manager_(nullptr) {} | 
|  295  |  292  | 
|  296   WindowTreeConnection* most_recent_connection() { |  293   WindowTreeConnection* most_recent_connection() { | 
|  297     return most_recent_connection_; |  294     return most_recent_connection_; | 
|  298   } |  295   } | 
|  299  |  296  | 
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  346   // frame has been obtained. |  343   // frame has been obtained. | 
|  347   scoped_ptr<WindowAndFrame> WaitForViewAndFrame() { |  344   scoped_ptr<WindowAndFrame> WaitForViewAndFrame() { | 
|  348     DCHECK(!window_and_frame_); |  345     DCHECK(!window_and_frame_); | 
|  349     window_and_frame_.reset(new WindowAndFrame); |  346     window_and_frame_.reset(new WindowAndFrame); | 
|  350     window_and_frame_->WaitForViewAndFrame(); |  347     window_and_frame_->WaitForViewAndFrame(); | 
|  351     return std::move(window_and_frame_); |  348     return std::move(window_and_frame_); | 
|  352   } |  349   } | 
|  353  |  350  | 
|  354  private: |  351  private: | 
|  355   // ApplicationTestBase: |  352   // ApplicationTestBase: | 
|  356   ApplicationDelegate* GetApplicationDelegate() override { return this; } |  353   mojo::ShellClient* GetShellClient() override { return this; } | 
|  357  |  354  | 
|  358   // ApplicationDelegate implementation. |  355   // mojo::ShellClient implementation. | 
|  359   bool AcceptConnection( |  356   bool AcceptConnection(mojo::Connection* connection) override { | 
|  360       mojo::ApplicationConnection* connection) override { |  | 
|  361     connection->AddService<mus::mojom::WindowTreeClient>(this); |  357     connection->AddService<mus::mojom::WindowTreeClient>(this); | 
|  362     connection->AddService<mojom::FrameClient>(this); |  358     connection->AddService<mojom::FrameClient>(this); | 
|  363     return true; |  359     return true; | 
|  364   } |  360   } | 
|  365  |  361  | 
|  366   // Overridden from WindowTreeDelegate: |  362   // Overridden from WindowTreeDelegate: | 
|  367   void OnEmbed(Window* root) override { |  363   void OnEmbed(Window* root) override { | 
|  368     most_recent_connection_ = root->connection(); |  364     most_recent_connection_ = root->connection(); | 
|  369     QuitRunLoop(); |  365     QuitRunLoop(); | 
|  370   } |  366   } | 
| (...skipping 28 matching lines...) Expand all  Loading... | 
|  399   // Overridden from testing::Test: |  395   // Overridden from testing::Test: | 
|  400   void TearDown() override { |  396   void TearDown() override { | 
|  401     root_window_and_frame_.reset(); |  397     root_window_and_frame_.reset(); | 
|  402     frame_tree_.reset(); |  398     frame_tree_.reset(); | 
|  403     frame_tree_delegate_.reset(); |  399     frame_tree_delegate_.reset(); | 
|  404     ApplicationTestBase::TearDown(); |  400     ApplicationTestBase::TearDown(); | 
|  405   } |  401   } | 
|  406  |  402  | 
|  407   // Overridden from mojo::InterfaceFactory<mus::mojom::WindowTreeClient>: |  403   // Overridden from mojo::InterfaceFactory<mus::mojom::WindowTreeClient>: | 
|  408   void Create( |  404   void Create( | 
|  409       mojo::ApplicationConnection* connection, |  405       mojo::Connection* connection, | 
|  410       mojo::InterfaceRequest<mus::mojom::WindowTreeClient> request) override { |  406       mojo::InterfaceRequest<mus::mojom::WindowTreeClient> request) override { | 
|  411     if (window_and_frame_) { |  407     if (window_and_frame_) { | 
|  412       mus::WindowTreeConnection::Create( |  408       mus::WindowTreeConnection::Create( | 
|  413           window_and_frame_.get(), std::move(request), |  409           window_and_frame_.get(), std::move(request), | 
|  414           mus::WindowTreeConnection::CreateType::DONT_WAIT_FOR_EMBED); |  410           mus::WindowTreeConnection::CreateType::DONT_WAIT_FOR_EMBED); | 
|  415     } else { |  411     } else { | 
|  416       mus::WindowTreeConnection::Create( |  412       mus::WindowTreeConnection::Create( | 
|  417           this, std::move(request), |  413           this, std::move(request), | 
|  418           mus::WindowTreeConnection::CreateType::DONT_WAIT_FOR_EMBED); |  414           mus::WindowTreeConnection::CreateType::DONT_WAIT_FOR_EMBED); | 
|  419     } |  415     } | 
|  420   } |  416   } | 
|  421  |  417  | 
|  422   // Overridden from mojo::InterfaceFactory<mojom::FrameClient>: |  418   // Overridden from mojo::InterfaceFactory<mojom::FrameClient>: | 
|  423   void Create(mojo::ApplicationConnection* connection, |  419   void Create(mojo::Connection* connection, | 
|  424               mojo::InterfaceRequest<mojom::FrameClient> request) override { |  420               mojo::InterfaceRequest<mojom::FrameClient> request) override { | 
|  425     ASSERT_TRUE(window_and_frame_); |  421     ASSERT_TRUE(window_and_frame_); | 
|  426     window_and_frame_->Bind(std::move(request)); |  422     window_and_frame_->Bind(std::move(request)); | 
|  427   } |  423   } | 
|  428  |  424  | 
|  429   scoped_ptr<TestFrameTreeDelegate> frame_tree_delegate_; |  425   scoped_ptr<TestFrameTreeDelegate> frame_tree_delegate_; | 
|  430   scoped_ptr<FrameTree> frame_tree_; |  426   scoped_ptr<FrameTree> frame_tree_; | 
|  431   scoped_ptr<WindowAndFrame> root_window_and_frame_; |  427   scoped_ptr<WindowAndFrame> root_window_and_frame_; | 
|  432  |  428  | 
|  433   mus::mojom::WindowTreeHostPtr host_; |  429   mus::mojom::WindowTreeHostPtr host_; | 
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  574   base::TimeTicks navigation_start_time = base::TimeTicks::FromInternalValue(1); |  570   base::TimeTicks navigation_start_time = base::TimeTicks::FromInternalValue(1); | 
|  575   scoped_ptr<WindowAndFrame> navigated_child_view_and_frame = |  571   scoped_ptr<WindowAndFrame> navigated_child_view_and_frame = | 
|  576       NavigateFrameWithStartTime(child_view_and_frame.get(), |  572       NavigateFrameWithStartTime(child_view_and_frame.get(), | 
|  577                                  navigation_start_time); |  573                                  navigation_start_time); | 
|  578   EXPECT_EQ(navigation_start_time, |  574   EXPECT_EQ(navigation_start_time, | 
|  579             navigated_child_view_and_frame->test_frame_client() |  575             navigated_child_view_and_frame->test_frame_client() | 
|  580                 ->last_navigation_start_time()); |  576                 ->last_navigation_start_time()); | 
|  581 } |  577 } | 
|  582  |  578  | 
|  583 }  // namespace web_view |  579 }  // namespace web_view | 
| OLD | NEW |