| 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_HELPER_H_ | 5 #ifndef UI_AURA_TEST_AURA_TEST_HELPER_H_ |
| 6 #define UI_AURA_TEST_AURA_TEST_HELPER_H_ | 6 #define UI_AURA_TEST_AURA_TEST_HELPER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "ui/aura/env.h" |
| 11 #include "ui/aura/window_event_dispatcher.h" | 12 #include "ui/aura/window_event_dispatcher.h" |
| 12 #include "ui/aura/window_tree_host.h" | 13 #include "ui/aura/window_tree_host.h" |
| 13 | 14 |
| 14 namespace aura { | |
| 15 class Env; | |
| 16 } | |
| 17 | |
| 18 namespace base { | 15 namespace base { |
| 19 class MessageLoopForUI; | 16 class MessageLoopForUI; |
| 20 } | 17 } |
| 21 | 18 |
| 22 namespace ui { | 19 namespace ui { |
| 23 class ContextFactory; | 20 class ContextFactory; |
| 24 class InputMethod; | 21 class InputMethod; |
| 25 class ScopedAnimationDurationScaleMode; | 22 class ScopedAnimationDurationScaleMode; |
| 26 } | 23 } |
| 27 | 24 |
| 28 namespace aura { | 25 namespace aura { |
| 29 class TestScreen; | 26 class TestScreen; |
| 27 class TestWindowTree; |
| 28 class TestWindowTreeClientSetup; |
| 29 class Window; |
| 30 class WindowPort; |
| 31 class WindowManagerDelegate; |
| 32 class WindowTreeClient; |
| 33 class WindowTreeClientDelegate; |
| 34 |
| 30 namespace client { | 35 namespace client { |
| 36 class CaptureClient; |
| 31 class DefaultCaptureClient; | 37 class DefaultCaptureClient; |
| 32 class FocusClient; | 38 class FocusClient; |
| 33 } | 39 } |
| 34 namespace test { | 40 namespace test { |
| 35 class TestWindowParentingClient; | 41 class TestWindowParentingClient; |
| 36 | 42 |
| 37 // A helper class owned by tests that does common initialization required for | 43 // A helper class owned by tests that does common initialization required for |
| 38 // Aura use. This class creates a root window with clients and other objects | 44 // Aura use. This class creates a root window with clients and other objects |
| 39 // that are necessary to run test on Aura. | 45 // that are necessary to run test on Aura. |
| 40 class AuraTestHelper { | 46 class AuraTestHelper { |
| 41 public: | 47 public: |
| 42 explicit AuraTestHelper(base::MessageLoopForUI* message_loop); | 48 explicit AuraTestHelper(base::MessageLoopForUI* message_loop); |
| 43 ~AuraTestHelper(); | 49 ~AuraTestHelper(); |
| 44 | 50 |
| 51 void EnableMus(WindowTreeClientDelegate* window_tree_delegate, |
| 52 WindowManagerDelegate* window_manager_delegate); |
| 53 |
| 45 // Creates and initializes (shows and sizes) the RootWindow for use in tests. | 54 // Creates and initializes (shows and sizes) the RootWindow for use in tests. |
| 46 void SetUp(ui::ContextFactory* context_factory); | 55 void SetUp(ui::ContextFactory* context_factory); |
| 47 | 56 |
| 48 // Clean up objects that are created for tests. This also deletes the Env | 57 // Clean up objects that are created for tests. This also deletes the Env |
| 49 // object. | 58 // object. |
| 50 void TearDown(); | 59 void TearDown(); |
| 51 | 60 |
| 52 // Flushes message loop. | 61 // Flushes message loop. |
| 53 void RunAllPendingInMessageLoop(); | 62 void RunAllPendingInMessageLoop(); |
| 54 | 63 |
| 55 Window* root_window() { return host_->window(); } | 64 Window* root_window() { return host_->window(); } |
| 56 ui::EventProcessor* event_processor() { return host_->event_processor(); } | 65 ui::EventProcessor* event_processor() { return host_->event_processor(); } |
| 57 WindowTreeHost* host() { return host_.get(); } | 66 WindowTreeHost* host() { return host_.get(); } |
| 58 | 67 |
| 59 TestScreen* test_screen() { return test_screen_.get(); } | 68 TestScreen* test_screen() { return test_screen_.get(); } |
| 60 | 69 |
| 70 TestWindowTree* window_tree(); |
| 71 WindowTreeClient* window_tree_client(); |
| 72 |
| 73 client::FocusClient* focus_client() { return focus_client_.get(); } |
| 74 client::CaptureClient* capture_client(); |
| 75 |
| 61 private: | 76 private: |
| 77 Env::WindowPortFactory InitMus(); |
| 78 |
| 79 std::unique_ptr<WindowPort> CreateWindowPortMus(Window* window); |
| 80 |
| 62 base::MessageLoopForUI* message_loop_; | 81 base::MessageLoopForUI* message_loop_; |
| 82 bool use_mus_ = false; |
| 63 bool setup_called_; | 83 bool setup_called_; |
| 64 bool teardown_called_; | 84 bool teardown_called_; |
| 85 std::unique_ptr<TestWindowTreeClientSetup> window_tree_client_setup_; |
| 65 std::unique_ptr<aura::Env> env_; | 86 std::unique_ptr<aura::Env> env_; |
| 66 std::unique_ptr<WindowTreeHost> host_; | 87 std::unique_ptr<WindowTreeHost> host_; |
| 67 std::unique_ptr<TestWindowParentingClient> parenting_client_; | 88 std::unique_ptr<TestWindowParentingClient> parenting_client_; |
| 68 std::unique_ptr<client::DefaultCaptureClient> capture_client_; | 89 std::unique_ptr<client::DefaultCaptureClient> capture_client_; |
| 69 std::unique_ptr<client::FocusClient> focus_client_; | 90 std::unique_ptr<client::FocusClient> focus_client_; |
| 70 std::unique_ptr<TestScreen> test_screen_; | 91 std::unique_ptr<TestScreen> test_screen_; |
| 71 std::unique_ptr<ui::ScopedAnimationDurationScaleMode> zero_duration_mode_; | 92 std::unique_ptr<ui::ScopedAnimationDurationScaleMode> zero_duration_mode_; |
| 93 WindowTreeClientDelegate* window_tree_delegate_ = nullptr; |
| 94 WindowManagerDelegate* window_manager_delegate_ = nullptr; |
| 72 | 95 |
| 73 DISALLOW_COPY_AND_ASSIGN(AuraTestHelper); | 96 DISALLOW_COPY_AND_ASSIGN(AuraTestHelper); |
| 74 }; | 97 }; |
| 75 | 98 |
| 76 } // namespace test | 99 } // namespace test |
| 77 } // namespace aura | 100 } // namespace aura |
| 78 | 101 |
| 79 #endif // UI_AURA_TEST_AURA_TEST_HELPER_H_ | 102 #endif // UI_AURA_TEST_AURA_TEST_HELPER_H_ |
| OLD | NEW |