| 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 #ifndef COMPONENTS_MUS_PUBLIC_CPP_TESTS_VIEW_MANAGER_TEST_BASE_H_ | 5 #ifndef COMPONENTS_MUS_PUBLIC_CPP_TESTS_VIEW_MANAGER_TEST_BASE_H_ |
| 6 #define COMPONENTS_MUS_PUBLIC_CPP_TESTS_VIEW_MANAGER_TEST_BASE_H_ | 6 #define COMPONENTS_MUS_PUBLIC_CPP_TESTS_VIEW_MANAGER_TEST_BASE_H_ |
| 7 | 7 |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "components/mus/public/cpp/view_tree_delegate.h" | 9 #include "components/mus/public/cpp/view_tree_delegate.h" |
| 10 #include "components/mus/public/interfaces/view_tree.mojom.h" | 10 #include "components/mus/public/interfaces/view_tree.mojom.h" |
| 11 #include "components/mus/public/interfaces/view_tree_host.mojom.h" | 11 #include "components/mus/public/interfaces/view_tree_host.mojom.h" |
| 12 #include "mojo/application/public/cpp/application_delegate.h" | 12 #include "mojo/application/public/cpp/application_delegate.h" |
| 13 #include "mojo/application/public/cpp/application_test_base.h" | 13 #include "mojo/application/public/cpp/application_test_base.h" |
| 14 #include "mojo/application/public/cpp/interface_factory.h" | 14 #include "mojo/application/public/cpp/interface_factory.h" |
| 15 | 15 |
| 16 namespace mojo { | 16 namespace mus { |
| 17 | 17 |
| 18 // ViewManagerTestBase is a base class for use with app tests that use | 18 // ViewManagerTestBase is a base class for use with app tests that use |
| 19 // ViewManager. SetUp() connects to the ViewManager and blocks until OnEmbed() | 19 // ViewManager. SetUp() connects to the ViewManager and blocks until OnEmbed() |
| 20 // has been invoked. window_manager() can be used to access the ViewManager | 20 // has been invoked. window_manager() can be used to access the ViewManager |
| 21 // established as part of SetUp(). | 21 // established as part of SetUp(). |
| 22 class ViewManagerTestBase : public test::ApplicationTestBase, | 22 class ViewManagerTestBase |
| 23 public ApplicationDelegate, | 23 : public mojo::test::ApplicationTestBase, |
| 24 public ViewTreeDelegate, | 24 public mojo::ApplicationDelegate, |
| 25 public InterfaceFactory<ViewTreeClient> { | 25 public ViewTreeDelegate, |
| 26 public mojo::InterfaceFactory<mojo::ViewTreeClient> { |
| 26 public: | 27 public: |
| 27 ViewManagerTestBase(); | 28 ViewManagerTestBase(); |
| 28 ~ViewManagerTestBase() override; | 29 ~ViewManagerTestBase() override; |
| 29 | 30 |
| 30 // True if ViewTreeDelegate::OnConnectionLost() was called. | 31 // True if ViewTreeDelegate::OnConnectionLost() was called. |
| 31 bool view_tree_connection_destroyed() const { | 32 bool view_tree_connection_destroyed() const { |
| 32 return view_tree_connection_destroyed_; | 33 return view_tree_connection_destroyed_; |
| 33 } | 34 } |
| 34 | 35 |
| 35 // Runs the MessageLoop until QuitRunLoop() is called, or a timeout occurs. | 36 // Runs the MessageLoop until QuitRunLoop() is called, or a timeout occurs. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 46 protected: | 47 protected: |
| 47 ViewTreeConnection* most_recent_connection() { | 48 ViewTreeConnection* most_recent_connection() { |
| 48 return most_recent_connection_; | 49 return most_recent_connection_; |
| 49 } | 50 } |
| 50 | 51 |
| 51 // testing::Test: | 52 // testing::Test: |
| 52 void SetUp() override; | 53 void SetUp() override; |
| 53 void TearDown() override; | 54 void TearDown() override; |
| 54 | 55 |
| 55 // test::ApplicationTestBase: | 56 // test::ApplicationTestBase: |
| 56 ApplicationDelegate* GetApplicationDelegate() override; | 57 mojo::ApplicationDelegate* GetApplicationDelegate() override; |
| 57 | 58 |
| 58 // ApplicationDelegate: | 59 // ApplicationDelegate: |
| 59 bool ConfigureIncomingConnection(ApplicationConnection* connection) override; | 60 bool ConfigureIncomingConnection( |
| 61 mojo::ApplicationConnection* connection) override; |
| 60 | 62 |
| 61 // ViewTreeDelegate: | 63 // ViewTreeDelegate: |
| 62 void OnEmbed(View* root) override; | 64 void OnEmbed(View* root) override; |
| 63 void OnConnectionLost(ViewTreeConnection* connection) override; | 65 void OnConnectionLost(ViewTreeConnection* connection) override; |
| 64 | 66 |
| 65 // InterfaceFactory<ViewTreeClient>: | 67 // InterfaceFactory<ViewTreeClient>: |
| 66 void Create(ApplicationConnection* connection, | 68 void Create(mojo::ApplicationConnection* connection, |
| 67 InterfaceRequest<ViewTreeClient> request) override; | 69 mojo::InterfaceRequest<mojo::ViewTreeClient> request) override; |
| 68 | 70 |
| 69 // Used to receive the most recent view tree connection loaded by an embed | 71 // Used to receive the most recent view tree connection loaded by an embed |
| 70 // action. | 72 // action. |
| 71 ViewTreeConnection* most_recent_connection_; | 73 ViewTreeConnection* most_recent_connection_; |
| 72 | 74 |
| 73 private: | 75 private: |
| 74 ViewTreeHostPtr host_; | 76 mojo::ViewTreeHostPtr host_; |
| 75 | 77 |
| 76 // The View Manager connection held by the window manager (app running at the | 78 // The View Manager connection held by the window manager (app running at the |
| 77 // root view). | 79 // root view). |
| 78 ViewTreeConnection* window_manager_; | 80 ViewTreeConnection* window_manager_; |
| 79 | 81 |
| 80 bool view_tree_connection_destroyed_; | 82 bool view_tree_connection_destroyed_; |
| 81 | 83 |
| 82 MOJO_DISALLOW_COPY_AND_ASSIGN(ViewManagerTestBase); | 84 MOJO_DISALLOW_COPY_AND_ASSIGN(ViewManagerTestBase); |
| 83 }; | 85 }; |
| 84 | 86 |
| 85 } // namespace mojo | 87 } // namespace mus |
| 86 | 88 |
| 87 #endif // COMPONENTS_MUS_PUBLIC_CPP_TESTS_VIEW_MANAGER_TEST_BASE_H_ | 89 #endif // COMPONENTS_MUS_PUBLIC_CPP_TESTS_VIEW_MANAGER_TEST_BASE_H_ |
| OLD | NEW |