Chromium Code Reviews| 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_MANDOLINE_UI_SERVICES_TEST_BASE_H_ |
| 6 #define COMPONENTS_MUS_PUBLIC_CPP_TESTS_VIEW_MANAGER_TEST_BASE_H_ | 6 #define COMPONENTS_MUS_PUBLIC_CPP_TESTS_MANDOLINE_UI_SERVICES_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 // MandolineUIServicesTestBase is a base class for use with app tests that use |
| 19 // ViewManager. SetUp() connects to the ViewManager and blocks until OnEmbed() | 19 // MandolineUIServices. SetUp() connects to the MandolineUIServices and blocks |
| 20 // has been invoked. window_manager() can be used to access the ViewManager | 20 // until OnEmbed() |
| 21 // has been invoked. window_manager() can be used to access the | |
| 22 // MandolineUIServices | |
| 21 // established as part of SetUp(). | 23 // established as part of SetUp(). |
| 22 class ViewManagerTestBase : public test::ApplicationTestBase, | 24 class MandolineUIServicesTestBase |
|
sky
2015/09/15 21:51:56
This test is targeted at the ViewManager. I would
Fady Samuel
2015/09/15 22:18:50
Done.
| |
| 23 public ApplicationDelegate, | 25 : public mojo::test::ApplicationTestBase, |
| 24 public ViewTreeDelegate, | 26 public mojo::ApplicationDelegate, |
| 25 public InterfaceFactory<ViewTreeClient> { | 27 public ViewTreeDelegate, |
| 28 public mojo::InterfaceFactory<mojo::ViewTreeClient> { | |
| 26 public: | 29 public: |
| 27 ViewManagerTestBase(); | 30 MandolineUIServicesTestBase(); |
| 28 ~ViewManagerTestBase() override; | 31 ~MandolineUIServicesTestBase() override; |
| 29 | 32 |
| 30 // True if ViewTreeDelegate::OnConnectionLost() was called. | 33 // True if ViewTreeDelegate::OnConnectionLost() was called. |
| 31 bool view_tree_connection_destroyed() const { | 34 bool view_tree_connection_destroyed() const { |
| 32 return view_tree_connection_destroyed_; | 35 return view_tree_connection_destroyed_; |
| 33 } | 36 } |
| 34 | 37 |
| 35 // Runs the MessageLoop until QuitRunLoop() is called, or a timeout occurs. | 38 // Runs the MessageLoop until QuitRunLoop() is called, or a timeout occurs. |
| 36 // Returns true on success. Generally prefer running a RunLoop and | 39 // Returns true on success. Generally prefer running a RunLoop and |
| 37 // explicitly quiting that, but use this for times when that is not possible. | 40 // explicitly quiting that, but use this for times when that is not possible. |
| 38 static bool DoRunLoopWithTimeout() WARN_UNUSED_RESULT; | 41 static bool DoRunLoopWithTimeout() WARN_UNUSED_RESULT; |
| 39 | 42 |
| 40 // Quits a run loop started by DoRunLoopWithTimeout(). Returns true on | 43 // Quits a run loop started by DoRunLoopWithTimeout(). Returns true on |
| 41 // success, false if a RunLoop isn't running. | 44 // success, false if a RunLoop isn't running. |
| 42 static bool QuitRunLoop() WARN_UNUSED_RESULT; | 45 static bool QuitRunLoop() WARN_UNUSED_RESULT; |
| 43 | 46 |
| 44 ViewTreeConnection* window_manager() { return window_manager_; } | 47 ViewTreeConnection* window_manager() { return window_manager_; } |
| 45 | 48 |
| 46 protected: | 49 protected: |
| 47 ViewTreeConnection* most_recent_connection() { | 50 ViewTreeConnection* most_recent_connection() { |
| 48 return most_recent_connection_; | 51 return most_recent_connection_; |
| 49 } | 52 } |
| 50 | 53 |
| 51 // testing::Test: | 54 // testing::Test: |
| 52 void SetUp() override; | 55 void SetUp() override; |
| 53 void TearDown() override; | 56 void TearDown() override; |
| 54 | 57 |
| 55 // test::ApplicationTestBase: | 58 // test::ApplicationTestBase: |
| 56 ApplicationDelegate* GetApplicationDelegate() override; | 59 mojo::ApplicationDelegate* GetApplicationDelegate() override; |
| 57 | 60 |
| 58 // ApplicationDelegate: | 61 // ApplicationDelegate: |
| 59 bool ConfigureIncomingConnection(ApplicationConnection* connection) override; | 62 bool ConfigureIncomingConnection( |
| 63 mojo::ApplicationConnection* connection) override; | |
| 60 | 64 |
| 61 // ViewTreeDelegate: | 65 // ViewTreeDelegate: |
| 62 void OnEmbed(View* root) override; | 66 void OnEmbed(View* root) override; |
| 63 void OnConnectionLost(ViewTreeConnection* connection) override; | 67 void OnConnectionLost(ViewTreeConnection* connection) override; |
| 64 | 68 |
| 65 // InterfaceFactory<ViewTreeClient>: | 69 // InterfaceFactory<ViewTreeClient>: |
| 66 void Create(ApplicationConnection* connection, | 70 void Create(mojo::ApplicationConnection* connection, |
| 67 InterfaceRequest<ViewTreeClient> request) override; | 71 mojo::InterfaceRequest<mojo::ViewTreeClient> request) override; |
| 68 | 72 |
| 69 // Used to receive the most recent view tree connection loaded by an embed | 73 // Used to receive the most recent view tree connection loaded by an embed |
| 70 // action. | 74 // action. |
| 71 ViewTreeConnection* most_recent_connection_; | 75 ViewTreeConnection* most_recent_connection_; |
| 72 | 76 |
| 73 private: | 77 private: |
| 74 ViewTreeHostPtr host_; | 78 mojo::ViewTreeHostPtr host_; |
| 75 | 79 |
| 76 // The View Manager connection held by the window manager (app running at the | 80 // The View Manager connection held by the window manager (app running at the |
| 77 // root view). | 81 // root view). |
| 78 ViewTreeConnection* window_manager_; | 82 ViewTreeConnection* window_manager_; |
| 79 | 83 |
| 80 bool view_tree_connection_destroyed_; | 84 bool view_tree_connection_destroyed_; |
| 81 | 85 |
| 82 MOJO_DISALLOW_COPY_AND_ASSIGN(ViewManagerTestBase); | 86 MOJO_DISALLOW_COPY_AND_ASSIGN(MandolineUIServicesTestBase); |
| 83 }; | 87 }; |
| 84 | 88 |
| 85 } // namespace mojo | 89 } // namespace mus |
| 86 | 90 |
| 87 #endif // COMPONENTS_MUS_PUBLIC_CPP_TESTS_VIEW_MANAGER_TEST_BASE_H_ | 91 #endif // COMPONENTS_MUS_PUBLIC_CPP_TESTS_MANDOLINE_UI_SERVICES_TEST_BASE_H_ |
| OLD | NEW |