| 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_VIEW_MANAGER_PUBLIC_CPP_TESTS_VIEW_MANAGER_TEST_BASE_H_ | 5 #ifndef COMPONENTS_VIEW_MANAGER_PUBLIC_CPP_TESTS_VIEW_MANAGER_TEST_BASE_H_ |
| 6 #define COMPONENTS_VIEW_MANAGER_PUBLIC_CPP_TESTS_VIEW_MANAGER_TEST_BASE_H_ | 6 #define COMPONENTS_VIEW_MANAGER_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/view_manager/public/cpp/view_manager_delegate.h" | 9 #include "components/view_manager/public/cpp/view_manager_delegate.h" |
| 10 #include "components/view_manager/public/interfaces/view_manager.mojom.h" | 10 #include "components/view_manager/public/interfaces/view_tree.mojom.h" |
| 11 #include "mojo/application/public/cpp/application_delegate.h" | 11 #include "mojo/application/public/cpp/application_delegate.h" |
| 12 #include "mojo/application/public/cpp/application_test_base.h" | 12 #include "mojo/application/public/cpp/application_test_base.h" |
| 13 #include "mojo/application/public/cpp/interface_factory.h" | 13 #include "mojo/application/public/cpp/interface_factory.h" |
| 14 | 14 |
| 15 namespace mojo { | 15 namespace mojo { |
| 16 | 16 |
| 17 class ViewManagerInit; | 17 class ViewManagerInit; |
| 18 | 18 |
| 19 // ViewManagerTestBase is a base class for use with app tests that use | 19 // ViewManagerTestBase is a base class for use with app tests that use |
| 20 // ViewManager. SetUp() connects to the ViewManager and blocks until OnEmbed() | 20 // ViewManager. SetUp() connects to the ViewManager and blocks until OnEmbed() |
| 21 // has been invoked. window_manager() can be used to access the ViewManager | 21 // has been invoked. window_manager() can be used to access the ViewManager |
| 22 // established as part of SetUp(). | 22 // established as part of SetUp(). |
| 23 class ViewManagerTestBase : public test::ApplicationTestBase, | 23 class ViewManagerTestBase : public test::ApplicationTestBase, |
| 24 public ApplicationDelegate, | 24 public ApplicationDelegate, |
| 25 public ViewManagerDelegate, | 25 public ViewManagerDelegate, |
| 26 public InterfaceFactory<ViewManagerClient> { | 26 public InterfaceFactory<ViewTreeClient> { |
| 27 public: | 27 public: |
| 28 ViewManagerTestBase(); | 28 ViewManagerTestBase(); |
| 29 ~ViewManagerTestBase() override; | 29 ~ViewManagerTestBase() override; |
| 30 | 30 |
| 31 // True if OnViewManagerDestroyed() was called. | 31 // True if OnViewManagerDestroyed() was called. |
| 32 bool view_manager_destroyed() const { return view_manager_destroyed_; } | 32 bool view_manager_destroyed() const { return view_manager_destroyed_; } |
| 33 | 33 |
| 34 // Runs the MessageLoop until QuitRunLoop() is called, or a timeout occurs. | 34 // Runs the MessageLoop until QuitRunLoop() is called, or a timeout occurs. |
| 35 // Returns true on success. Generally prefer running a RunLoop and | 35 // Returns true on success. Generally prefer running a RunLoop and |
| 36 // explicitly quiting that, but use this for times when that is not possible. | 36 // explicitly quiting that, but use this for times when that is not possible. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 52 // test::ApplicationTestBase: | 52 // test::ApplicationTestBase: |
| 53 ApplicationDelegate* GetApplicationDelegate() override; | 53 ApplicationDelegate* GetApplicationDelegate() override; |
| 54 | 54 |
| 55 // ApplicationDelegate: | 55 // ApplicationDelegate: |
| 56 bool ConfigureIncomingConnection(ApplicationConnection* connection) override; | 56 bool ConfigureIncomingConnection(ApplicationConnection* connection) override; |
| 57 | 57 |
| 58 // ViewManagerDelegate: | 58 // ViewManagerDelegate: |
| 59 void OnEmbed(View* root) override; | 59 void OnEmbed(View* root) override; |
| 60 void OnViewManagerDestroyed(ViewManager* view_manager) override; | 60 void OnViewManagerDestroyed(ViewManager* view_manager) override; |
| 61 | 61 |
| 62 // InterfaceFactory<ViewManagerClient>: | 62 // InterfaceFactory<ViewTreeClient>: |
| 63 void Create(ApplicationConnection* connection, | 63 void Create(ApplicationConnection* connection, |
| 64 InterfaceRequest<ViewManagerClient> request) override; | 64 InterfaceRequest<ViewTreeClient> request) override; |
| 65 | 65 |
| 66 // Used to receive the most recent view manager loaded by an embed action. | 66 // Used to receive the most recent view manager loaded by an embed action. |
| 67 ViewManager* most_recent_view_manager_; | 67 ViewManager* most_recent_view_manager_; |
| 68 | 68 |
| 69 private: | 69 private: |
| 70 scoped_ptr<ViewManagerInit> view_manager_init_; | 70 scoped_ptr<ViewManagerInit> view_manager_init_; |
| 71 | 71 |
| 72 // The View Manager connection held by the window manager (app running at the | 72 // The View Manager connection held by the window manager (app running at the |
| 73 // root view). | 73 // root view). |
| 74 ViewManager* window_manager_; | 74 ViewManager* window_manager_; |
| 75 | 75 |
| 76 bool view_manager_destroyed_; | 76 bool view_manager_destroyed_; |
| 77 | 77 |
| 78 MOJO_DISALLOW_COPY_AND_ASSIGN(ViewManagerTestBase); | 78 MOJO_DISALLOW_COPY_AND_ASSIGN(ViewManagerTestBase); |
| 79 }; | 79 }; |
| 80 | 80 |
| 81 } // namespace mojo | 81 } // namespace mojo |
| 82 | 82 |
| 83 #endif // COMPONENTS_VIEW_MANAGER_PUBLIC_CPP_TESTS_VIEW_MANAGER_TEST_BASE_H_ | 83 #endif // COMPONENTS_VIEW_MANAGER_PUBLIC_CPP_TESTS_VIEW_MANAGER_TEST_BASE_H_ |
| OLD | NEW |