| 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/ash_switches.h" | 10 #include "ash/ash_switches.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #include "base/command_line.h" | 21 #include "base/command_line.h" |
| 22 #include "ui/aura/client/aura_constants.h" | 22 #include "ui/aura/client/aura_constants.h" |
| 23 #include "ui/aura/client/screen_position_client.h" | 23 #include "ui/aura/client/screen_position_client.h" |
| 24 #include "ui/aura/client/window_tree_client.h" | 24 #include "ui/aura/client/window_tree_client.h" |
| 25 #include "ui/aura/test/event_generator_delegate_aura.h" | 25 #include "ui/aura/test/event_generator_delegate_aura.h" |
| 26 #include "ui/aura/test/test_window_delegate.h" | 26 #include "ui/aura/test/test_window_delegate.h" |
| 27 #include "ui/aura/window.h" | 27 #include "ui/aura/window.h" |
| 28 #include "ui/aura/window_delegate.h" | 28 #include "ui/aura/window_delegate.h" |
| 29 #include "ui/aura/window_tree_host.h" | 29 #include "ui/aura/window_tree_host.h" |
| 30 #include "ui/base/ime/input_method_initializer.h" | 30 #include "ui/base/ime/input_method_initializer.h" |
| 31 #include "ui/display/display.h" |
| 32 #include "ui/display/screen.h" |
| 31 #include "ui/events/gesture_detection/gesture_configuration.h" | 33 #include "ui/events/gesture_detection/gesture_configuration.h" |
| 32 #include "ui/gfx/display.h" | |
| 33 #include "ui/gfx/geometry/point.h" | 34 #include "ui/gfx/geometry/point.h" |
| 34 #include "ui/gfx/screen.h" | |
| 35 #include "ui/wm/core/coordinate_conversion.h" | 35 #include "ui/wm/core/coordinate_conversion.h" |
| 36 | 36 |
| 37 #if defined(OS_CHROMEOS) | 37 #if defined(OS_CHROMEOS) |
| 38 #include "ash/system/chromeos/tray_display.h" | 38 #include "ash/system/chromeos/tray_display.h" |
| 39 #endif | 39 #endif |
| 40 | 40 |
| 41 #if defined(OS_WIN) | 41 #if defined(OS_WIN) |
| 42 #include "base/win/windows_version.h" | 42 #include "base/win/windows_version.h" |
| 43 #include "ui/platform_window/win/win_window.h" | 43 #include "ui/platform_window/win/win_window.h" |
| 44 #endif | 44 #endif |
| 45 | 45 |
| 46 #if defined(USE_X11) | 46 #if defined(USE_X11) |
| 47 #include "ui/gfx/x/x11_connection.h" // nogncheck | 47 #include "ui/gfx/x/x11_connection.h" // nogncheck |
| 48 #endif | 48 #endif |
| 49 | 49 |
| 50 namespace ash { | 50 namespace ash { |
| 51 namespace test { | 51 namespace test { |
| 52 namespace { | 52 namespace { |
| 53 | 53 |
| 54 class AshEventGeneratorDelegate | 54 class AshEventGeneratorDelegate |
| 55 : public aura::test::EventGeneratorDelegateAura { | 55 : public aura::test::EventGeneratorDelegateAura { |
| 56 public: | 56 public: |
| 57 AshEventGeneratorDelegate() {} | 57 AshEventGeneratorDelegate() {} |
| 58 ~AshEventGeneratorDelegate() override {} | 58 ~AshEventGeneratorDelegate() override {} |
| 59 | 59 |
| 60 // aura::test::EventGeneratorDelegateAura overrides: | 60 // aura::test::EventGeneratorDelegateAura overrides: |
| 61 aura::WindowTreeHost* GetHostAt( | 61 aura::WindowTreeHost* GetHostAt( |
| 62 const gfx::Point& point_in_screen) const override { | 62 const gfx::Point& point_in_screen) const override { |
| 63 gfx::Screen* screen = gfx::Screen::GetScreen(); | 63 display::Screen* screen = display::Screen::GetScreen(); |
| 64 gfx::Display display = screen->GetDisplayNearestPoint(point_in_screen); | 64 display::Display display = screen->GetDisplayNearestPoint(point_in_screen); |
| 65 return Shell::GetInstance() | 65 return Shell::GetInstance() |
| 66 ->window_tree_host_manager() | 66 ->window_tree_host_manager() |
| 67 ->GetRootWindowForDisplayId(display.id()) | 67 ->GetRootWindowForDisplayId(display.id()) |
| 68 ->GetHost(); | 68 ->GetHost(); |
| 69 } | 69 } |
| 70 | 70 |
| 71 aura::client::ScreenPositionClient* GetScreenPositionClient( | 71 aura::client::ScreenPositionClient* GetScreenPositionClient( |
| 72 const aura::Window* window) const override { | 72 const aura::Window* window) const override { |
| 73 return aura::client::GetScreenPositionClient(window->GetRootWindow()); | 73 return aura::client::GetScreenPositionClient(window->GetRootWindow()); |
| 74 } | 74 } |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 RunAllPendingInMessageLoop(); | 160 RunAllPendingInMessageLoop(); |
| 161 | 161 |
| 162 ash_test_helper_->TearDown(); | 162 ash_test_helper_->TearDown(); |
| 163 #if defined(OS_WIN) | 163 #if defined(OS_WIN) |
| 164 ui::test::SetUsePopupAsRootWindowForTest(false); | 164 ui::test::SetUsePopupAsRootWindowForTest(false); |
| 165 #endif | 165 #endif |
| 166 | 166 |
| 167 event_generator_.reset(); | 167 event_generator_.reset(); |
| 168 // Some tests set an internal display id, | 168 // Some tests set an internal display id, |
| 169 // reset it here, so other tests will continue in a clean environment. | 169 // reset it here, so other tests will continue in a clean environment. |
| 170 gfx::Display::SetInternalDisplayId(gfx::Display::kInvalidDisplayID); | 170 display::Display::SetInternalDisplayId(display::Display::kInvalidDisplayID); |
| 171 } | 171 } |
| 172 | 172 |
| 173 ui::test::EventGenerator& AshTestBase::GetEventGenerator() { | 173 ui::test::EventGenerator& AshTestBase::GetEventGenerator() { |
| 174 if (!event_generator_) { | 174 if (!event_generator_) { |
| 175 event_generator_.reset( | 175 event_generator_.reset( |
| 176 new ui::test::EventGenerator(new AshEventGeneratorDelegate())); | 176 new ui::test::EventGenerator(new AshEventGeneratorDelegate())); |
| 177 } | 177 } |
| 178 return *event_generator_.get(); | 178 return *event_generator_.get(); |
| 179 } | 179 } |
| 180 | 180 |
| 181 gfx::Display::Rotation AshTestBase::GetActiveDisplayRotation(int64_t id) { | 181 display::Display::Rotation AshTestBase::GetActiveDisplayRotation(int64_t id) { |
| 182 return Shell::GetInstance() | 182 return Shell::GetInstance() |
| 183 ->display_manager() | 183 ->display_manager() |
| 184 ->GetDisplayInfo(id) | 184 ->GetDisplayInfo(id) |
| 185 .GetActiveRotation(); | 185 .GetActiveRotation(); |
| 186 } | 186 } |
| 187 | 187 |
| 188 gfx::Display::Rotation AshTestBase::GetCurrentInternalDisplayRotation() { | 188 display::Display::Rotation AshTestBase::GetCurrentInternalDisplayRotation() { |
| 189 return GetActiveDisplayRotation(gfx::Display::InternalDisplayId()); | 189 return GetActiveDisplayRotation(display::Display::InternalDisplayId()); |
| 190 } | 190 } |
| 191 | 191 |
| 192 bool AshTestBase::SupportsMultipleDisplays() { | 192 bool AshTestBase::SupportsMultipleDisplays() { |
| 193 return AshTestHelper::SupportsMultipleDisplays(); | 193 return AshTestHelper::SupportsMultipleDisplays(); |
| 194 } | 194 } |
| 195 | 195 |
| 196 bool AshTestBase::SupportsHostWindowResize() { | 196 bool AshTestBase::SupportsHostWindowResize() { |
| 197 return AshTestHelper::SupportsHostWindowResize(); | 197 return AshTestHelper::SupportsHostWindowResize(); |
| 198 } | 198 } |
| 199 | 199 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 const gfx::Rect& bounds) { | 236 const gfx::Rect& bounds) { |
| 237 aura::Window* window = new aura::Window(delegate); | 237 aura::Window* window = new aura::Window(delegate); |
| 238 window->set_id(id); | 238 window->set_id(id); |
| 239 window->SetType(type); | 239 window->SetType(type); |
| 240 window->Init(ui::LAYER_TEXTURED); | 240 window->Init(ui::LAYER_TEXTURED); |
| 241 window->Show(); | 241 window->Show(); |
| 242 | 242 |
| 243 if (bounds.IsEmpty()) { | 243 if (bounds.IsEmpty()) { |
| 244 ParentWindowInPrimaryRootWindow(window); | 244 ParentWindowInPrimaryRootWindow(window); |
| 245 } else { | 245 } else { |
| 246 gfx::Display display = gfx::Screen::GetScreen()->GetDisplayMatching(bounds); | 246 display::Display display = |
| 247 display::Screen::GetScreen()->GetDisplayMatching(bounds); |
| 247 aura::Window* root = ash::Shell::GetInstance() | 248 aura::Window* root = ash::Shell::GetInstance() |
| 248 ->window_tree_host_manager() | 249 ->window_tree_host_manager() |
| 249 ->GetRootWindowForDisplayId(display.id()); | 250 ->GetRootWindowForDisplayId(display.id()); |
| 250 gfx::Point origin = bounds.origin(); | 251 gfx::Point origin = bounds.origin(); |
| 251 ::wm::ConvertPointFromScreen(root, &origin); | 252 ::wm::ConvertPointFromScreen(root, &origin); |
| 252 window->SetBounds(gfx::Rect(origin, bounds.size())); | 253 window->SetBounds(gfx::Rect(origin, bounds.size())); |
| 253 aura::client::ParentWindowWithContext(window, root, bounds); | 254 aura::client::ParentWindowWithContext(window, root, bounds); |
| 254 } | 255 } |
| 255 window->SetProperty(aura::client::kCanMaximizeKey, true); | 256 window->SetProperty(aura::client::kCanMaximizeKey, true); |
| 256 window->SetProperty(aura::client::kCanMinimizeKey, true); | 257 window->SetProperty(aura::client::kCanMinimizeKey, true); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 | 336 |
| 336 void AshTestBase::DisableIME() { | 337 void AshTestBase::DisableIME() { |
| 337 Shell::GetInstance()->RemovePreTargetHandler( | 338 Shell::GetInstance()->RemovePreTargetHandler( |
| 338 Shell::GetInstance() | 339 Shell::GetInstance() |
| 339 ->window_tree_host_manager() | 340 ->window_tree_host_manager() |
| 340 ->input_method_event_handler()); | 341 ->input_method_event_handler()); |
| 341 } | 342 } |
| 342 | 343 |
| 343 } // namespace test | 344 } // namespace test |
| 344 } // namespace ash | 345 } // namespace ash |
| OLD | NEW |