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/display/extended_mouse_warp_controller.h" | 10 #include "ash/display/extended_mouse_warp_controller.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 AshEventGeneratorDelegate() {} | 65 AshEventGeneratorDelegate() {} |
66 ~AshEventGeneratorDelegate() override {} | 66 ~AshEventGeneratorDelegate() override {} |
67 | 67 |
68 // aura::test::EventGeneratorDelegateAura overrides: | 68 // aura::test::EventGeneratorDelegateAura overrides: |
69 aura::WindowTreeHost* GetHostAt( | 69 aura::WindowTreeHost* GetHostAt( |
70 const gfx::Point& point_in_screen) const override { | 70 const gfx::Point& point_in_screen) const override { |
71 display::Screen* screen = display::Screen::GetScreen(); | 71 display::Screen* screen = display::Screen::GetScreen(); |
72 display::Display display = screen->GetDisplayNearestPoint(point_in_screen); | 72 display::Display display = screen->GetDisplayNearestPoint(point_in_screen); |
73 return ShellPort::Get() | 73 return ShellPort::Get() |
74 ->GetRootWindowForDisplayId(display.id()) | 74 ->GetRootWindowForDisplayId(display.id()) |
75 ->aura_window() | |
76 ->GetHost(); | 75 ->GetHost(); |
77 } | 76 } |
78 | 77 |
79 aura::client::ScreenPositionClient* GetScreenPositionClient( | 78 aura::client::ScreenPositionClient* GetScreenPositionClient( |
80 const aura::Window* window) const override { | 79 const aura::Window* window) const override { |
81 return aura::client::GetScreenPositionClient(window->GetRootWindow()); | 80 return aura::client::GetScreenPositionClient(window->GetRootWindow()); |
82 } | 81 } |
83 | 82 |
84 void DispatchKeyEventToIME(ui::EventTarget* target, | 83 void DispatchKeyEventToIME(ui::EventTarget* target, |
85 ui::KeyEvent* event) override { | 84 ui::KeyEvent* event) override { |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 ash_test_helper_->TearDown(); | 183 ash_test_helper_->TearDown(); |
185 | 184 |
186 event_generator_.reset(); | 185 event_generator_.reset(); |
187 // Some tests set an internal display id, | 186 // Some tests set an internal display id, |
188 // reset it here, so other tests will continue in a clean environment. | 187 // reset it here, so other tests will continue in a clean environment. |
189 display::Display::SetInternalDisplayId(display::kInvalidDisplayId); | 188 display::Display::SetInternalDisplayId(display::kInvalidDisplayId); |
190 } | 189 } |
191 | 190 |
192 // static | 191 // static |
193 WmShelf* AshTestBase::GetPrimaryShelf() { | 192 WmShelf* AshTestBase::GetPrimaryShelf() { |
194 return ShellPort::Get() | 193 return Shell::GetPrimaryRootWindowController()->GetShelf(); |
195 ->GetPrimaryRootWindow() | |
196 ->GetRootWindowController() | |
197 ->GetShelf(); | |
198 } | 194 } |
199 | 195 |
200 // static | 196 // static |
201 SystemTray* AshTestBase::GetPrimarySystemTray() { | 197 SystemTray* AshTestBase::GetPrimarySystemTray() { |
202 return Shell::Get()->GetPrimarySystemTray(); | 198 return Shell::Get()->GetPrimarySystemTray(); |
203 } | 199 } |
204 | 200 |
205 ui::test::EventGenerator& AshTestBase::GetEventGenerator() { | 201 ui::test::EventGenerator& AshTestBase::GetEventGenerator() { |
206 if (!event_generator_) { | 202 if (!event_generator_) { |
207 event_generator_.reset( | 203 event_generator_.reset( |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 // static | 236 // static |
241 std::unique_ptr<views::Widget> AshTestBase::CreateTestWidget( | 237 std::unique_ptr<views::Widget> AshTestBase::CreateTestWidget( |
242 views::WidgetDelegate* delegate, | 238 views::WidgetDelegate* delegate, |
243 int container_id, | 239 int container_id, |
244 const gfx::Rect& bounds) { | 240 const gfx::Rect& bounds) { |
245 std::unique_ptr<views::Widget> widget(new views::Widget); | 241 std::unique_ptr<views::Widget> widget(new views::Widget); |
246 views::Widget::InitParams params; | 242 views::Widget::InitParams params; |
247 params.delegate = delegate; | 243 params.delegate = delegate; |
248 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 244 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
249 params.bounds = bounds; | 245 params.bounds = bounds; |
250 ShellPort::Get() | 246 Shell::GetPrimaryRootWindowController() |
251 ->GetPrimaryRootWindow() | |
252 ->GetRootWindowController() | |
253 ->ConfigureWidgetInitParamsForContainer(widget.get(), container_id, | 247 ->ConfigureWidgetInitParamsForContainer(widget.get(), container_id, |
254 ¶ms); | 248 ¶ms); |
255 widget->Init(params); | 249 widget->Init(params); |
256 widget->Show(); | 250 widget->Show(); |
257 return widget; | 251 return widget; |
258 } | 252 } |
259 | 253 |
260 std::unique_ptr<aura::Window> AshTestBase::CreateTestWindow( | 254 std::unique_ptr<aura::Window> AshTestBase::CreateTestWindow( |
261 const gfx::Rect& bounds_in_screen, | 255 const gfx::Rect& bounds_in_screen, |
262 ui::wm::WindowType type, | 256 ui::wm::WindowType type, |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 window->set_id(id); | 350 window->set_id(id); |
357 window->SetType(type); | 351 window->SetType(type); |
358 window->Init(ui::LAYER_TEXTURED); | 352 window->Init(ui::LAYER_TEXTURED); |
359 window->Show(); | 353 window->Show(); |
360 | 354 |
361 if (bounds.IsEmpty()) { | 355 if (bounds.IsEmpty()) { |
362 ParentWindowInPrimaryRootWindow(window); | 356 ParentWindowInPrimaryRootWindow(window); |
363 } else { | 357 } else { |
364 display::Display display = | 358 display::Display display = |
365 display::Screen::GetScreen()->GetDisplayMatching(bounds); | 359 display::Screen::GetScreen()->GetDisplayMatching(bounds); |
366 aura::Window* root = ShellPort::Get() | 360 aura::Window* root = |
367 ->GetRootWindowForDisplayId(display.id()) | 361 ShellPort::Get()->GetRootWindowForDisplayId(display.id()); |
368 ->aura_window(); | |
369 gfx::Point origin = bounds.origin(); | 362 gfx::Point origin = bounds.origin(); |
370 ::wm::ConvertPointFromScreen(root, &origin); | 363 ::wm::ConvertPointFromScreen(root, &origin); |
371 window->SetBounds(gfx::Rect(origin, bounds.size())); | 364 window->SetBounds(gfx::Rect(origin, bounds.size())); |
372 aura::client::ParentWindowWithContext(window, root, bounds); | 365 aura::client::ParentWindowWithContext(window, root, bounds); |
373 } | 366 } |
374 window->SetProperty(aura::client::kResizeBehaviorKey, | 367 window->SetProperty(aura::client::kResizeBehaviorKey, |
375 ui::mojom::kResizeBehaviorCanMaximize | | 368 ui::mojom::kResizeBehaviorCanMaximize | |
376 ui::mojom::kResizeBehaviorCanMinimize | | 369 ui::mojom::kResizeBehaviorCanMinimize | |
377 ui::mojom::kResizeBehaviorCanResize); | 370 ui::mojom::kResizeBehaviorCanResize); |
378 // Setting the item type triggers ShelfWindowWatcher to create a shelf item. | 371 // Setting the item type triggers ShelfWindowWatcher to create a shelf item. |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
495 return display::Screen::GetScreen()->GetDisplayNearestWindow( | 488 return display::Screen::GetScreen()->GetDisplayNearestWindow( |
496 Shell::GetPrimaryRootWindow()); | 489 Shell::GetPrimaryRootWindow()); |
497 } | 490 } |
498 | 491 |
499 display::Display AshTestBase::GetSecondaryDisplay() { | 492 display::Display AshTestBase::GetSecondaryDisplay() { |
500 return ash_test_helper_->GetSecondaryDisplay(); | 493 return ash_test_helper_->GetSecondaryDisplay(); |
501 } | 494 } |
502 | 495 |
503 } // namespace test | 496 } // namespace test |
504 } // namespace ash | 497 } // namespace ash |
OLD | NEW |