Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(80)

Side by Side Diff: ash/test/ash_test_base.cc

Issue 2694623016: chromeos: Makes AshTestBase/Helper target mash when appropriate (Closed)
Patch Set: format Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 #include "ash/common/test/test_system_tray_delegate.h" 11 #include "ash/common/test/test_system_tray_delegate.h"
12 #include "ash/common/wm/window_positioner.h" 12 #include "ash/common/wm/window_positioner.h"
13 #include "ash/common/wm_lookup.h"
msw 2017/02/22 06:25:48 nit: no longer needed
sky 2017/02/22 16:32:05 Done.
13 #include "ash/common/wm_shell.h" 14 #include "ash/common/wm_shell.h"
14 #include "ash/common/wm_window.h" 15 #include "ash/common/wm_window.h"
15 #include "ash/display/extended_mouse_warp_controller.h" 16 #include "ash/display/extended_mouse_warp_controller.h"
16 #include "ash/display/mouse_cursor_event_filter.h" 17 #include "ash/display/mouse_cursor_event_filter.h"
17 #include "ash/display/unified_mouse_warp_controller.h" 18 #include "ash/display/unified_mouse_warp_controller.h"
18 #include "ash/display/window_tree_host_manager.h" 19 #include "ash/display/window_tree_host_manager.h"
19 #include "ash/ime/input_method_event_handler.h" 20 #include "ash/ime/input_method_event_handler.h"
20 #include "ash/root_window_controller.h" 21 #include "ash/root_window_controller.h"
21 #include "ash/shell.h" 22 #include "ash/shell.h"
22 #include "ash/shell/toplevel_window.h" 23 #include "ash/shell/toplevel_window.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 : public aura::test::EventGeneratorDelegateAura { 57 : public aura::test::EventGeneratorDelegateAura {
57 public: 58 public:
58 AshEventGeneratorDelegate() {} 59 AshEventGeneratorDelegate() {}
59 ~AshEventGeneratorDelegate() override {} 60 ~AshEventGeneratorDelegate() override {}
60 61
61 // aura::test::EventGeneratorDelegateAura overrides: 62 // aura::test::EventGeneratorDelegateAura overrides:
62 aura::WindowTreeHost* GetHostAt( 63 aura::WindowTreeHost* GetHostAt(
63 const gfx::Point& point_in_screen) const override { 64 const gfx::Point& point_in_screen) const override {
64 display::Screen* screen = display::Screen::GetScreen(); 65 display::Screen* screen = display::Screen::GetScreen();
65 display::Display display = screen->GetDisplayNearestPoint(point_in_screen); 66 display::Display display = screen->GetDisplayNearestPoint(point_in_screen);
66 return Shell::GetInstance() 67 return WmShell::Get()
67 ->window_tree_host_manager()
68 ->GetRootWindowForDisplayId(display.id()) 68 ->GetRootWindowForDisplayId(display.id())
69 ->aura_window()
69 ->GetHost(); 70 ->GetHost();
70 } 71 }
71 72
72 aura::client::ScreenPositionClient* GetScreenPositionClient( 73 aura::client::ScreenPositionClient* GetScreenPositionClient(
73 const aura::Window* window) const override { 74 const aura::Window* window) const override {
74 return aura::client::GetScreenPositionClient(window->GetRootWindow()); 75 return aura::client::GetScreenPositionClient(window->GetRootWindow());
75 } 76 }
76 77
77 void DispatchKeyEventToIME(ui::EventTarget* target, 78 void DispatchKeyEventToIME(ui::EventTarget* target,
78 ui::KeyEvent* event) override { 79 ui::KeyEvent* event) override {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 "1+1-800x600"); 128 "1+1-800x600");
128 } 129 }
129 130
130 ash_test_helper_->SetUp(start_session_); 131 ash_test_helper_->SetUp(start_session_);
131 132
132 Shell::GetPrimaryRootWindow()->Show(); 133 Shell::GetPrimaryRootWindow()->Show();
133 Shell::GetPrimaryRootWindow()->GetHost()->Show(); 134 Shell::GetPrimaryRootWindow()->GetHost()->Show();
134 // Move the mouse cursor to far away so that native events doesn't 135 // Move the mouse cursor to far away so that native events doesn't
135 // interfere test expectations. 136 // interfere test expectations.
136 Shell::GetPrimaryRootWindow()->MoveCursorTo(gfx::Point(-1000, -1000)); 137 Shell::GetPrimaryRootWindow()->MoveCursorTo(gfx::Point(-1000, -1000));
137 Shell::GetInstance()->cursor_manager()->EnableMouseEvents(); 138 // TODO: mash needs to support CursorManager. http://crbug.com/637853.
139 if (!WmShell::Get()->IsRunningInMash())
140 Shell::GetInstance()->cursor_manager()->EnableMouseEvents();
138 141
139 // Changing GestureConfiguration shouldn't make tests fail. These values 142 // Changing GestureConfiguration shouldn't make tests fail. These values
140 // prevent unexpected events from being generated during tests. Such as 143 // prevent unexpected events from being generated during tests. Such as
141 // delayed events which create race conditions on slower tests. 144 // delayed events which create race conditions on slower tests.
142 ui::GestureConfiguration* gesture_config = 145 ui::GestureConfiguration* gesture_config =
143 ui::GestureConfiguration::GetInstance(); 146 ui::GestureConfiguration::GetInstance();
144 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);
145 gesture_config->set_long_press_time_in_ms(1000); 148 gesture_config->set_long_press_time_in_ms(1000);
146 gesture_config->set_max_touch_move_in_pixels_for_click(5); 149 gesture_config->set_max_touch_move_in_pixels_for_click(5);
147 } 150 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 .GetActiveRotation(); 192 .GetActiveRotation();
190 } 193 }
191 194
192 // static 195 // static
193 display::Display::Rotation AshTestBase::GetCurrentInternalDisplayRotation() { 196 display::Display::Rotation AshTestBase::GetCurrentInternalDisplayRotation() {
194 return GetActiveDisplayRotation(display::Display::InternalDisplayId()); 197 return GetActiveDisplayRotation(display::Display::InternalDisplayId());
195 } 198 }
196 199
197 // static 200 // static
198 void AshTestBase::UpdateDisplay(const std::string& display_specs) { 201 void AshTestBase::UpdateDisplay(const std::string& display_specs) {
199 display::test::DisplayManagerTestApi(Shell::GetInstance()->display_manager()) 202 if (WmShell::Get()->IsRunningInMash()) {
200 .UpdateDisplay(display_specs); 203 ash_test_helper_->UpdateDisplayForMash(display_specs);
204 } else {
205 display::test::DisplayManagerTestApi(
206 Shell::GetInstance()->display_manager())
207 .UpdateDisplay(display_specs);
208 }
201 } 209 }
202 210
203 aura::Window* AshTestBase::CurrentContext() { 211 aura::Window* AshTestBase::CurrentContext() {
204 return ash_test_helper_->CurrentContext(); 212 return ash_test_helper_->CurrentContext();
205 } 213 }
206 214
207 // static 215 // static
208 std::unique_ptr<views::Widget> AshTestBase::CreateTestWidget( 216 std::unique_ptr<views::Widget> AshTestBase::CreateTestWidget(
209 views::WidgetDelegate* delegate, 217 views::WidgetDelegate* delegate,
210 int container_id, 218 int container_id,
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 window->set_id(id); 265 window->set_id(id);
258 window->SetType(type); 266 window->SetType(type);
259 window->Init(ui::LAYER_TEXTURED); 267 window->Init(ui::LAYER_TEXTURED);
260 window->Show(); 268 window->Show();
261 269
262 if (bounds.IsEmpty()) { 270 if (bounds.IsEmpty()) {
263 ParentWindowInPrimaryRootWindow(window); 271 ParentWindowInPrimaryRootWindow(window);
264 } else { 272 } else {
265 display::Display display = 273 display::Display display =
266 display::Screen::GetScreen()->GetDisplayMatching(bounds); 274 display::Screen::GetScreen()->GetDisplayMatching(bounds);
267 aura::Window* root = Shell::GetInstance() 275 aura::Window* root =
268 ->window_tree_host_manager() 276 WmShell::Get()->GetRootWindowForDisplayId(display.id())->aura_window();
269 ->GetRootWindowForDisplayId(display.id());
270 gfx::Point origin = bounds.origin(); 277 gfx::Point origin = bounds.origin();
271 ::wm::ConvertPointFromScreen(root, &origin); 278 ::wm::ConvertPointFromScreen(root, &origin);
272 window->SetBounds(gfx::Rect(origin, bounds.size())); 279 window->SetBounds(gfx::Rect(origin, bounds.size()));
273 aura::client::ParentWindowWithContext(window, root, bounds); 280 aura::client::ParentWindowWithContext(window, root, bounds);
274 } 281 }
275 window->SetProperty(aura::client::kResizeBehaviorKey, 282 window->SetProperty(aura::client::kResizeBehaviorKey,
276 ui::mojom::kResizeBehaviorCanMaximize | 283 ui::mojom::kResizeBehaviorCanMaximize |
277 ui::mojom::kResizeBehaviorCanMinimize | 284 ui::mojom::kResizeBehaviorCanMinimize |
278 ui::mojom::kResizeBehaviorCanResize); 285 ui::mojom::kResizeBehaviorCanResize);
279 286
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 .id(); 388 .id();
382 } 389 }
383 390
384 void AshTestBase::SwapPrimaryDisplay() { 391 void AshTestBase::SwapPrimaryDisplay() {
385 if (display::Screen::GetScreen()->GetNumDisplays() <= 1) 392 if (display::Screen::GetScreen()->GetNumDisplays() <= 1)
386 return; 393 return;
387 Shell::GetInstance()->window_tree_host_manager()->SetPrimaryDisplayId( 394 Shell::GetInstance()->window_tree_host_manager()->SetPrimaryDisplayId(
388 display_manager()->GetSecondaryDisplay().id()); 395 display_manager()->GetSecondaryDisplay().id());
389 } 396 }
390 397
398 display::Display AshTestBase::GetSecondaryDisplay() {
399 return ash_test_helper_->GetSecondaryDisplay();
400 }
401
391 } // namespace test 402 } // namespace test
392 } // namespace ash 403 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698