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 "ash/test/ash_test_base.h" | 5 #include "ash/test/ash_test_base.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "ash/common/test/test_session_state_delegate.h" | 10 #include "ash/common/test/test_session_state_delegate.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 #include "ui/base/ime/input_method_initializer.h" | 37 #include "ui/base/ime/input_method_initializer.h" |
38 #include "ui/display/display.h" | 38 #include "ui/display/display.h" |
39 #include "ui/display/display_switches.h" | 39 #include "ui/display/display_switches.h" |
40 #include "ui/display/screen.h" | 40 #include "ui/display/screen.h" |
41 #include "ui/display/test/display_manager_test_api.h" | 41 #include "ui/display/test/display_manager_test_api.h" |
42 #include "ui/display/types/display_constants.h" | 42 #include "ui/display/types/display_constants.h" |
43 #include "ui/events/gesture_detection/gesture_configuration.h" | 43 #include "ui/events/gesture_detection/gesture_configuration.h" |
44 #include "ui/gfx/geometry/point.h" | 44 #include "ui/gfx/geometry/point.h" |
45 #include "ui/wm/core/coordinate_conversion.h" | 45 #include "ui/wm/core/coordinate_conversion.h" |
46 | 46 |
47 #if defined(OS_WIN) | |
48 #include "base/win/windows_version.h" | |
49 #include "ui/platform_window/win/win_window.h" | |
50 #endif | |
51 | |
52 #if defined(USE_X11) | 47 #if defined(USE_X11) |
53 #include "ui/gfx/x/x11_connection.h" // nogncheck | 48 #include "ui/gfx/x/x11_connection.h" // nogncheck |
54 #endif | 49 #endif |
55 | 50 |
56 namespace ash { | 51 namespace ash { |
57 namespace test { | 52 namespace test { |
58 namespace { | 53 namespace { |
59 | 54 |
60 class AshEventGeneratorDelegate | 55 class AshEventGeneratorDelegate |
61 : public aura::test::EventGeneratorDelegateAura { | 56 : public aura::test::EventGeneratorDelegateAura { |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 shell::ToplevelWindow::ClearSavedStateForTest(); | 122 shell::ToplevelWindow::ClearSavedStateForTest(); |
128 | 123 |
129 // TODO(jamescook): Can we do this without changing command line? | 124 // TODO(jamescook): Can we do this without changing command line? |
130 // Use the origin (1,1) so that it doesn't over | 125 // Use the origin (1,1) so that it doesn't over |
131 // lap with the native mouse cursor. | 126 // lap with the native mouse cursor. |
132 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 127 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
133 if (!command_line->HasSwitch(::switches::kHostWindowBounds)) { | 128 if (!command_line->HasSwitch(::switches::kHostWindowBounds)) { |
134 command_line->AppendSwitchASCII(::switches::kHostWindowBounds, | 129 command_line->AppendSwitchASCII(::switches::kHostWindowBounds, |
135 "1+1-800x600"); | 130 "1+1-800x600"); |
136 } | 131 } |
137 #if defined(OS_WIN) | |
138 ui::test::SetUsePopupAsRootWindowForTest(true); | |
139 #endif | |
140 | 132 |
141 ash_test_helper_->SetUp(start_session_, material_mode_); | 133 ash_test_helper_->SetUp(start_session_, material_mode_); |
142 | 134 |
143 Shell::GetPrimaryRootWindow()->Show(); | 135 Shell::GetPrimaryRootWindow()->Show(); |
144 Shell::GetPrimaryRootWindow()->GetHost()->Show(); | 136 Shell::GetPrimaryRootWindow()->GetHost()->Show(); |
145 // Move the mouse cursor to far away so that native events doesn't | 137 // Move the mouse cursor to far away so that native events doesn't |
146 // interfere test expectations. | 138 // interfere test expectations. |
147 Shell::GetPrimaryRootWindow()->MoveCursorTo(gfx::Point(-1000, -1000)); | 139 Shell::GetPrimaryRootWindow()->MoveCursorTo(gfx::Point(-1000, -1000)); |
148 Shell::GetInstance()->cursor_manager()->EnableMouseEvents(); | 140 Shell::GetInstance()->cursor_manager()->EnableMouseEvents(); |
149 | 141 |
150 // Changing GestureConfiguration shouldn't make tests fail. These values | 142 // Changing GestureConfiguration shouldn't make tests fail. These values |
151 // prevent unexpected events from being generated during tests. Such as | 143 // prevent unexpected events from being generated during tests. Such as |
152 // delayed events which create race conditions on slower tests. | 144 // delayed events which create race conditions on slower tests. |
153 ui::GestureConfiguration* gesture_config = | 145 ui::GestureConfiguration* gesture_config = |
154 ui::GestureConfiguration::GetInstance(); | 146 ui::GestureConfiguration::GetInstance(); |
155 gesture_config->set_max_touch_down_duration_for_click_in_ms(800); | 147 gesture_config->set_max_touch_down_duration_for_click_in_ms(800); |
156 gesture_config->set_long_press_time_in_ms(1000); | 148 gesture_config->set_long_press_time_in_ms(1000); |
157 gesture_config->set_max_touch_move_in_pixels_for_click(5); | 149 gesture_config->set_max_touch_move_in_pixels_for_click(5); |
158 } | 150 } |
159 | 151 |
160 void AshTestBase::TearDown() { | 152 void AshTestBase::TearDown() { |
161 teardown_called_ = true; | 153 teardown_called_ = true; |
162 Shell::GetInstance()->OnAppTerminating(); | 154 Shell::GetInstance()->OnAppTerminating(); |
163 // Flush the message loop to finish pending release tasks. | 155 // Flush the message loop to finish pending release tasks. |
164 RunAllPendingInMessageLoop(); | 156 RunAllPendingInMessageLoop(); |
165 | 157 |
166 ash_test_helper_->TearDown(); | 158 ash_test_helper_->TearDown(); |
167 #if defined(OS_WIN) | |
168 ui::test::SetUsePopupAsRootWindowForTest(false); | |
169 #endif | |
170 | 159 |
171 event_generator_.reset(); | 160 event_generator_.reset(); |
172 // Some tests set an internal display id, | 161 // Some tests set an internal display id, |
173 // reset it here, so other tests will continue in a clean environment. | 162 // reset it here, so other tests will continue in a clean environment. |
174 display::Display::SetInternalDisplayId(display::kInvalidDisplayId); | 163 display::Display::SetInternalDisplayId(display::kInvalidDisplayId); |
175 } | 164 } |
176 | 165 |
177 // static | 166 // static |
178 WmShelf* AshTestBase::GetPrimaryShelf() { | 167 WmShelf* AshTestBase::GetPrimaryShelf() { |
179 return WmShell::Get() | 168 return WmShell::Get() |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 | 391 |
403 void AshTestBase::SwapPrimaryDisplay() { | 392 void AshTestBase::SwapPrimaryDisplay() { |
404 if (display::Screen::GetScreen()->GetNumDisplays() <= 1) | 393 if (display::Screen::GetScreen()->GetNumDisplays() <= 1) |
405 return; | 394 return; |
406 Shell::GetInstance()->window_tree_host_manager()->SetPrimaryDisplayId( | 395 Shell::GetInstance()->window_tree_host_manager()->SetPrimaryDisplayId( |
407 display_manager()->GetSecondaryDisplay().id()); | 396 display_manager()->GetSecondaryDisplay().id()); |
408 } | 397 } |
409 | 398 |
410 } // namespace test | 399 } // namespace test |
411 } // namespace ash | 400 } // namespace ash |
OLD | NEW |