| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 UI_AURA_TEST_AURA_TEST_BASE_H_ | 5 #ifndef UI_AURA_TEST_AURA_TEST_BASE_H_ |
| 6 #define UI_AURA_TEST_AURA_TEST_BASE_H_ | 6 #define UI_AURA_TEST_AURA_TEST_BASE_H_ |
| 7 | 7 |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 #include "ui/aura/mus/window_manager_delegate.h" | 12 #include "ui/aura/mus/window_manager_delegate.h" |
| 13 #include "ui/aura/mus/window_tree_client_delegate.h" | 13 #include "ui/aura/mus/window_tree_client_delegate.h" |
| 14 #include "ui/aura/test/aura_test_helper.h" | 14 #include "ui/aura/test/aura_test_helper.h" |
| 15 | 15 |
| 16 namespace ui { | 16 namespace ui { |
| 17 namespace mojom { | 17 namespace mojom { |
| 18 class WindowTreeClient; | 18 class WindowTreeClient; |
| 19 } | 19 } |
| 20 } | 20 } |
| 21 | 21 |
| 22 namespace aura { | 22 namespace aura { |
| 23 class Window; | 23 class Window; |
| 24 class WindowDelegate; | 24 class WindowDelegate; |
| 25 class WindowManagerDelegate; | 25 class WindowManagerDelegate; |
| 26 class WindowTreeClientDelegate; | 26 class WindowTreeClientDelegate; |
| 27 | 27 |
| 28 namespace test { | 28 namespace test { |
| 29 | 29 |
| 30 enum class BackendType { CLASSIC, MUS }; |
| 31 |
| 30 // A base class for aura unit tests. | 32 // A base class for aura unit tests. |
| 31 // TODO(beng): Instances of this test will create and own a RootWindow. | 33 // TODO(beng): Instances of this test will create and own a RootWindow. |
| 32 class AuraTestBase : public testing::Test, | 34 class AuraTestBase : public testing::Test, |
| 33 public WindowTreeClientDelegate, | 35 public WindowTreeClientDelegate, |
| 34 public WindowManagerDelegate { | 36 public WindowManagerDelegate { |
| 35 public: | 37 public: |
| 36 AuraTestBase(); | 38 AuraTestBase(); |
| 37 ~AuraTestBase() override; | 39 ~AuraTestBase() override; |
| 38 | 40 |
| 39 // testing::Test: | 41 // testing::Test: |
| (...skipping 11 matching lines...) Expand all Loading... |
| 51 } | 53 } |
| 52 | 54 |
| 53 void set_window_tree_client_delegate( | 55 void set_window_tree_client_delegate( |
| 54 WindowTreeClientDelegate* window_tree_client_delegate) { | 56 WindowTreeClientDelegate* window_tree_client_delegate) { |
| 55 window_tree_client_delegate_ = window_tree_client_delegate; | 57 window_tree_client_delegate_ = window_tree_client_delegate; |
| 56 } | 58 } |
| 57 | 59 |
| 58 // Turns on mus. Must be called before SetUp(). | 60 // Turns on mus. Must be called before SetUp(). |
| 59 void EnableMus(); | 61 void EnableMus(); |
| 60 | 62 |
| 63 // Used to configure the backend. This is exposed to make parameterized tests |
| 64 // easy to write. This *must* be called from SetUp(). |
| 65 void ConfigureBackend(BackendType type); |
| 66 |
| 61 void RunAllPendingInMessageLoop(); | 67 void RunAllPendingInMessageLoop(); |
| 62 | 68 |
| 63 void ParentWindow(Window* window); | 69 void ParentWindow(Window* window); |
| 64 | 70 |
| 65 // A convenience function for dispatching an event to |dispatcher()|. | 71 // A convenience function for dispatching an event to |dispatcher()|. |
| 66 // Returns whether |event| was handled. | 72 // Returns whether |event| was handled. |
| 67 bool DispatchEventUsingWindowDispatcher(ui::Event* event); | 73 bool DispatchEventUsingWindowDispatcher(ui::Event* event); |
| 68 | 74 |
| 69 Window* root_window() { return helper_->root_window(); } | 75 Window* root_window() { return helper_->root_window(); } |
| 70 WindowTreeHost* host() { return helper_->host(); } | 76 WindowTreeHost* host() { return helper_->host(); } |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 bool use_mus_ = false; | 127 bool use_mus_ = false; |
| 122 bool setup_called_ = false; | 128 bool setup_called_ = false; |
| 123 bool teardown_called_ = false; | 129 bool teardown_called_ = false; |
| 124 base::MessageLoopForUI message_loop_; | 130 base::MessageLoopForUI message_loop_; |
| 125 std::unique_ptr<PropertyConverter> property_converter_; | 131 std::unique_ptr<PropertyConverter> property_converter_; |
| 126 std::unique_ptr<AuraTestHelper> helper_; | 132 std::unique_ptr<AuraTestHelper> helper_; |
| 127 | 133 |
| 128 DISALLOW_COPY_AND_ASSIGN(AuraTestBase); | 134 DISALLOW_COPY_AND_ASSIGN(AuraTestBase); |
| 129 }; | 135 }; |
| 130 | 136 |
| 137 // Use as a base class for tests that want to target both backends. |
| 138 class AuraTestBaseWithType : public AuraTestBase, |
| 139 public ::testing::WithParamInterface<BackendType> { |
| 140 public: |
| 141 AuraTestBaseWithType(); |
| 142 ~AuraTestBaseWithType() override; |
| 143 |
| 144 // AuraTestBase: |
| 145 void SetUp() override; |
| 146 |
| 147 private: |
| 148 bool setup_called_ = false; |
| 149 |
| 150 DISALLOW_COPY_AND_ASSIGN(AuraTestBaseWithType); |
| 151 }; |
| 152 |
| 131 } // namespace test | 153 } // namespace test |
| 132 } // namespace aura | 154 } // namespace aura |
| 133 | 155 |
| 134 #endif // UI_AURA_TEST_AURA_TEST_BASE_H_ | 156 #endif // UI_AURA_TEST_AURA_TEST_BASE_H_ |
| OLD | NEW |