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 #include "ui/aura/test/aura_test_helper.h" | 5 #include "ui/aura/test/aura_test_helper.h" |
6 | 6 |
7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
9 #include "ui/aura/client/aura_constants.h" | |
10 #include "ui/aura/client/default_capture_client.h" | 9 #include "ui/aura/client/default_capture_client.h" |
11 #include "ui/aura/client/focus_client.h" | 10 #include "ui/aura/client/focus_client.h" |
12 #include "ui/aura/env.h" | 11 #include "ui/aura/env.h" |
13 #include "ui/aura/input_state_lookup.h" | 12 #include "ui/aura/input_state_lookup.h" |
14 #include "ui/aura/test/env_test_helper.h" | 13 #include "ui/aura/test/env_test_helper.h" |
15 #include "ui/aura/test/event_generator_delegate_aura.h" | 14 #include "ui/aura/test/event_generator_delegate_aura.h" |
16 #include "ui/aura/test/test_focus_client.h" | 15 #include "ui/aura/test/test_focus_client.h" |
17 #include "ui/aura/test/test_screen.h" | 16 #include "ui/aura/test/test_screen.h" |
18 #include "ui/aura/test/test_window_tree_client.h" | 17 #include "ui/aura/test/test_window_tree_client.h" |
| 18 #include "ui/aura/window.h" |
19 #include "ui/aura/window_event_dispatcher.h" | 19 #include "ui/aura/window_event_dispatcher.h" |
20 #include "ui/base/ime/dummy_input_method.h" | 20 #include "ui/base/ime/input_method_factory.h" |
21 #include "ui/base/ime/input_method_initializer.h" | 21 #include "ui/base/ime/input_method_initializer.h" |
22 #include "ui/compositor/compositor.h" | 22 #include "ui/compositor/compositor.h" |
23 #include "ui/compositor/layer_animator.h" | 23 #include "ui/compositor/layer_animator.h" |
24 #include "ui/compositor/scoped_animation_duration_scale_mode.h" | 24 #include "ui/compositor/scoped_animation_duration_scale_mode.h" |
25 #include "ui/gfx/screen.h" | 25 #include "ui/gfx/screen.h" |
26 | 26 |
27 #if defined(USE_X11) | 27 #if defined(USE_X11) |
28 #include "ui/aura/window_tree_host_x11.h" | 28 #include "ui/aura/window_tree_host_x11.h" |
29 #include "ui/base/x/x11_util.h" | 29 #include "ui/base/x/x11_util.h" |
30 #endif | 30 #endif |
(...skipping 24 matching lines...) Expand all Loading... |
55 | 55 |
56 void AuraTestHelper::SetUp(ui::ContextFactory* context_factory) { | 56 void AuraTestHelper::SetUp(ui::ContextFactory* context_factory) { |
57 setup_called_ = true; | 57 setup_called_ = true; |
58 | 58 |
59 Env::CreateInstance(true); | 59 Env::CreateInstance(true); |
60 Env::GetInstance()->set_context_factory(context_factory); | 60 Env::GetInstance()->set_context_factory(context_factory); |
61 // Unit tests generally don't want to query the system, rather use the state | 61 // Unit tests generally don't want to query the system, rather use the state |
62 // from RootWindow. | 62 // from RootWindow. |
63 EnvTestHelper(Env::GetInstance()).SetInputStateLookup(nullptr); | 63 EnvTestHelper(Env::GetInstance()).SetInputStateLookup(nullptr); |
64 | 64 |
| 65 ui::SetUpInputMethodFactoryForTesting(); |
65 ui::InitializeInputMethodForTesting(); | 66 ui::InitializeInputMethodForTesting(); |
66 | 67 |
67 gfx::Size host_size(800, 600); | 68 gfx::Size host_size(800, 600); |
68 test_screen_.reset(TestScreen::Create(host_size)); | 69 test_screen_.reset(TestScreen::Create(host_size)); |
69 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, test_screen_.get()); | 70 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, test_screen_.get()); |
70 host_.reset(test_screen_->CreateHostForPrimaryDisplay()); | 71 host_.reset(test_screen_->CreateHostForPrimaryDisplay()); |
71 | 72 |
72 focus_client_.reset(new TestFocusClient); | 73 focus_client_.reset(new TestFocusClient); |
73 client::SetFocusClient(root_window(), focus_client_.get()); | 74 client::SetFocusClient(root_window(), focus_client_.get()); |
74 stacking_client_.reset(new TestWindowTreeClient(root_window())); | 75 stacking_client_.reset(new TestWindowTreeClient(root_window())); |
75 capture_client_.reset(new client::DefaultCaptureClient(root_window())); | 76 capture_client_.reset(new client::DefaultCaptureClient(root_window())); |
76 test_input_method_.reset(new ui::DummyInputMethod); | |
77 root_window()->SetProperty( | |
78 client::kRootWindowInputMethodKey, | |
79 test_input_method_.get()); | |
80 | 77 |
81 root_window()->Show(); | 78 root_window()->Show(); |
82 // Ensure width != height so tests won't confuse them. | 79 // Ensure width != height so tests won't confuse them. |
83 host()->SetBounds(gfx::Rect(host_size)); | 80 host()->SetBounds(gfx::Rect(host_size)); |
84 } | 81 } |
85 | 82 |
86 void AuraTestHelper::TearDown() { | 83 void AuraTestHelper::TearDown() { |
87 teardown_called_ = true; | 84 teardown_called_ = true; |
88 test_input_method_.reset(); | |
89 stacking_client_.reset(); | 85 stacking_client_.reset(); |
90 capture_client_.reset(); | 86 capture_client_.reset(); |
91 focus_client_.reset(); | 87 focus_client_.reset(); |
92 client::SetFocusClient(root_window(), NULL); | 88 client::SetFocusClient(root_window(), NULL); |
93 host_.reset(); | 89 host_.reset(); |
94 ui::GestureRecognizer::Reset(); | 90 ui::GestureRecognizer::Reset(); |
95 test_screen_.reset(); | 91 test_screen_.reset(); |
96 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, NULL); | 92 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, NULL); |
97 | 93 |
98 #if defined(USE_X11) | 94 #if defined(USE_X11) |
99 ui::test::ResetXCursorCache(); | 95 ui::test::ResetXCursorCache(); |
100 #endif | 96 #endif |
101 | 97 |
102 ui::ShutdownInputMethodForTesting(); | 98 ui::ShutdownInputMethodForTesting(); |
103 | 99 |
104 Env::DeleteInstance(); | 100 Env::DeleteInstance(); |
105 } | 101 } |
106 | 102 |
107 void AuraTestHelper::RunAllPendingInMessageLoop() { | 103 void AuraTestHelper::RunAllPendingInMessageLoop() { |
108 // TODO(jbates) crbug.com/134753 Find quitters of this RunLoop and have them | 104 // TODO(jbates) crbug.com/134753 Find quitters of this RunLoop and have them |
109 // use run_loop.QuitClosure(). | 105 // use run_loop.QuitClosure(). |
110 base::RunLoop run_loop; | 106 base::RunLoop run_loop; |
111 run_loop.RunUntilIdle(); | 107 run_loop.RunUntilIdle(); |
112 } | 108 } |
113 | 109 |
114 } // namespace test | 110 } // namespace test |
115 } // namespace aura | 111 } // namespace aura |
OLD | NEW |