| 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 : public aura::test::EventGeneratorDelegateAura { | 56 : public aura::test::EventGeneratorDelegateAura { |
| 57 public: | 57 public: |
| 58 AshEventGeneratorDelegate() {} | 58 AshEventGeneratorDelegate() {} |
| 59 ~AshEventGeneratorDelegate() override {} | 59 ~AshEventGeneratorDelegate() override {} |
| 60 | 60 |
| 61 // aura::test::EventGeneratorDelegateAura overrides: | 61 // aura::test::EventGeneratorDelegateAura overrides: |
| 62 aura::WindowTreeHost* GetHostAt( | 62 aura::WindowTreeHost* GetHostAt( |
| 63 const gfx::Point& point_in_screen) const override { | 63 const gfx::Point& point_in_screen) const override { |
| 64 display::Screen* screen = display::Screen::GetScreen(); | 64 display::Screen* screen = display::Screen::GetScreen(); |
| 65 display::Display display = screen->GetDisplayNearestPoint(point_in_screen); | 65 display::Display display = screen->GetDisplayNearestPoint(point_in_screen); |
| 66 return Shell::GetInstance() | 66 return WmShell::Get() |
| 67 ->window_tree_host_manager() | |
| 68 ->GetRootWindowForDisplayId(display.id()) | 67 ->GetRootWindowForDisplayId(display.id()) |
| 68 ->aura_window() |
| 69 ->GetHost(); | 69 ->GetHost(); |
| 70 } | 70 } |
| 71 | 71 |
| 72 aura::client::ScreenPositionClient* GetScreenPositionClient( | 72 aura::client::ScreenPositionClient* GetScreenPositionClient( |
| 73 const aura::Window* window) const override { | 73 const aura::Window* window) const override { |
| 74 return aura::client::GetScreenPositionClient(window->GetRootWindow()); | 74 return aura::client::GetScreenPositionClient(window->GetRootWindow()); |
| 75 } | 75 } |
| 76 | 76 |
| 77 void DispatchKeyEventToIME(ui::EventTarget* target, | 77 void DispatchKeyEventToIME(ui::EventTarget* target, |
| 78 ui::KeyEvent* event) override { | 78 ui::KeyEvent* event) override { |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 "1+1-800x600"); | 127 "1+1-800x600"); |
| 128 } | 128 } |
| 129 | 129 |
| 130 ash_test_helper_->SetUp(start_session_); | 130 ash_test_helper_->SetUp(start_session_); |
| 131 | 131 |
| 132 Shell::GetPrimaryRootWindow()->Show(); | 132 Shell::GetPrimaryRootWindow()->Show(); |
| 133 Shell::GetPrimaryRootWindow()->GetHost()->Show(); | 133 Shell::GetPrimaryRootWindow()->GetHost()->Show(); |
| 134 // Move the mouse cursor to far away so that native events doesn't | 134 // Move the mouse cursor to far away so that native events doesn't |
| 135 // interfere test expectations. | 135 // interfere test expectations. |
| 136 Shell::GetPrimaryRootWindow()->MoveCursorTo(gfx::Point(-1000, -1000)); | 136 Shell::GetPrimaryRootWindow()->MoveCursorTo(gfx::Point(-1000, -1000)); |
| 137 Shell::GetInstance()->cursor_manager()->EnableMouseEvents(); | 137 // TODO: mash needs to support CursorManager. http://crbug.com/637853. |
| 138 if (!WmShell::Get()->IsRunningInMash()) |
| 139 Shell::GetInstance()->cursor_manager()->EnableMouseEvents(); |
| 138 | 140 |
| 139 // Changing GestureConfiguration shouldn't make tests fail. These values | 141 // Changing GestureConfiguration shouldn't make tests fail. These values |
| 140 // prevent unexpected events from being generated during tests. Such as | 142 // prevent unexpected events from being generated during tests. Such as |
| 141 // delayed events which create race conditions on slower tests. | 143 // delayed events which create race conditions on slower tests. |
| 142 ui::GestureConfiguration* gesture_config = | 144 ui::GestureConfiguration* gesture_config = |
| 143 ui::GestureConfiguration::GetInstance(); | 145 ui::GestureConfiguration::GetInstance(); |
| 144 gesture_config->set_max_touch_down_duration_for_click_in_ms(800); | 146 gesture_config->set_max_touch_down_duration_for_click_in_ms(800); |
| 145 gesture_config->set_long_press_time_in_ms(1000); | 147 gesture_config->set_long_press_time_in_ms(1000); |
| 146 gesture_config->set_max_touch_move_in_pixels_for_click(5); | 148 gesture_config->set_max_touch_move_in_pixels_for_click(5); |
| 147 } | 149 } |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 .GetActiveRotation(); | 191 .GetActiveRotation(); |
| 190 } | 192 } |
| 191 | 193 |
| 192 // static | 194 // static |
| 193 display::Display::Rotation AshTestBase::GetCurrentInternalDisplayRotation() { | 195 display::Display::Rotation AshTestBase::GetCurrentInternalDisplayRotation() { |
| 194 return GetActiveDisplayRotation(display::Display::InternalDisplayId()); | 196 return GetActiveDisplayRotation(display::Display::InternalDisplayId()); |
| 195 } | 197 } |
| 196 | 198 |
| 197 // static | 199 // static |
| 198 void AshTestBase::UpdateDisplay(const std::string& display_specs) { | 200 void AshTestBase::UpdateDisplay(const std::string& display_specs) { |
| 199 display::test::DisplayManagerTestApi(Shell::GetInstance()->display_manager()) | 201 if (WmShell::Get()->IsRunningInMash()) { |
| 200 .UpdateDisplay(display_specs); | 202 ash_test_helper_->UpdateDisplayForMash(display_specs); |
| 203 } else { |
| 204 display::test::DisplayManagerTestApi( |
| 205 Shell::GetInstance()->display_manager()) |
| 206 .UpdateDisplay(display_specs); |
| 207 } |
| 201 } | 208 } |
| 202 | 209 |
| 203 aura::Window* AshTestBase::CurrentContext() { | 210 aura::Window* AshTestBase::CurrentContext() { |
| 204 return ash_test_helper_->CurrentContext(); | 211 return ash_test_helper_->CurrentContext(); |
| 205 } | 212 } |
| 206 | 213 |
| 207 // static | 214 // static |
| 208 std::unique_ptr<views::Widget> AshTestBase::CreateTestWidget( | 215 std::unique_ptr<views::Widget> AshTestBase::CreateTestWidget( |
| 209 views::WidgetDelegate* delegate, | 216 views::WidgetDelegate* delegate, |
| 210 int container_id, | 217 int container_id, |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 window->set_id(id); | 264 window->set_id(id); |
| 258 window->SetType(type); | 265 window->SetType(type); |
| 259 window->Init(ui::LAYER_TEXTURED); | 266 window->Init(ui::LAYER_TEXTURED); |
| 260 window->Show(); | 267 window->Show(); |
| 261 | 268 |
| 262 if (bounds.IsEmpty()) { | 269 if (bounds.IsEmpty()) { |
| 263 ParentWindowInPrimaryRootWindow(window); | 270 ParentWindowInPrimaryRootWindow(window); |
| 264 } else { | 271 } else { |
| 265 display::Display display = | 272 display::Display display = |
| 266 display::Screen::GetScreen()->GetDisplayMatching(bounds); | 273 display::Screen::GetScreen()->GetDisplayMatching(bounds); |
| 267 aura::Window* root = Shell::GetInstance() | 274 aura::Window* root = |
| 268 ->window_tree_host_manager() | 275 WmShell::Get()->GetRootWindowForDisplayId(display.id())->aura_window(); |
| 269 ->GetRootWindowForDisplayId(display.id()); | |
| 270 gfx::Point origin = bounds.origin(); | 276 gfx::Point origin = bounds.origin(); |
| 271 ::wm::ConvertPointFromScreen(root, &origin); | 277 ::wm::ConvertPointFromScreen(root, &origin); |
| 272 window->SetBounds(gfx::Rect(origin, bounds.size())); | 278 window->SetBounds(gfx::Rect(origin, bounds.size())); |
| 273 aura::client::ParentWindowWithContext(window, root, bounds); | 279 aura::client::ParentWindowWithContext(window, root, bounds); |
| 274 } | 280 } |
| 275 window->SetProperty(aura::client::kResizeBehaviorKey, | 281 window->SetProperty(aura::client::kResizeBehaviorKey, |
| 276 ui::mojom::kResizeBehaviorCanMaximize | | 282 ui::mojom::kResizeBehaviorCanMaximize | |
| 277 ui::mojom::kResizeBehaviorCanMinimize | | 283 ui::mojom::kResizeBehaviorCanMinimize | |
| 278 ui::mojom::kResizeBehaviorCanResize); | 284 ui::mojom::kResizeBehaviorCanResize); |
| 279 | 285 |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 .id(); | 387 .id(); |
| 382 } | 388 } |
| 383 | 389 |
| 384 void AshTestBase::SwapPrimaryDisplay() { | 390 void AshTestBase::SwapPrimaryDisplay() { |
| 385 if (display::Screen::GetScreen()->GetNumDisplays() <= 1) | 391 if (display::Screen::GetScreen()->GetNumDisplays() <= 1) |
| 386 return; | 392 return; |
| 387 Shell::GetInstance()->window_tree_host_manager()->SetPrimaryDisplayId( | 393 Shell::GetInstance()->window_tree_host_manager()->SetPrimaryDisplayId( |
| 388 display_manager()->GetSecondaryDisplay().id()); | 394 display_manager()->GetSecondaryDisplay().id()); |
| 389 } | 395 } |
| 390 | 396 |
| 397 display::Display AshTestBase::GetSecondaryDisplay() { |
| 398 return ash_test_helper_->GetSecondaryDisplay(); |
| 399 } |
| 400 |
| 391 } // namespace test | 401 } // namespace test |
| 392 } // namespace ash | 402 } // namespace ash |
| OLD | NEW |