| 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/ash_switches.h" | 10 #include "ash/common/ash_switches.h" |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 #if defined(OS_WIN) | 130 #if defined(OS_WIN) |
| 131 ui::test::SetUsePopupAsRootWindowForTest(true); | 131 ui::test::SetUsePopupAsRootWindowForTest(true); |
| 132 #endif | 132 #endif |
| 133 ash_test_helper_->SetUp(start_session_); | 133 ash_test_helper_->SetUp(start_session_); |
| 134 | 134 |
| 135 Shell::GetPrimaryRootWindow()->Show(); | 135 Shell::GetPrimaryRootWindow()->Show(); |
| 136 Shell::GetPrimaryRootWindow()->GetHost()->Show(); | 136 Shell::GetPrimaryRootWindow()->GetHost()->Show(); |
| 137 // 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 |
| 138 // interfere test expectations. | 138 // interfere test expectations. |
| 139 Shell::GetPrimaryRootWindow()->MoveCursorTo(gfx::Point(-1000, -1000)); | 139 Shell::GetPrimaryRootWindow()->MoveCursorTo(gfx::Point(-1000, -1000)); |
| 140 ash::Shell::GetInstance()->cursor_manager()->EnableMouseEvents(); | 140 Shell::GetInstance()->cursor_manager()->EnableMouseEvents(); |
| 141 | 141 |
| 142 // Changing GestureConfiguration shouldn't make tests fail. These values | 142 // Changing GestureConfiguration shouldn't make tests fail. These values |
| 143 // prevent unexpected events from being generated during tests. Such as | 143 // prevent unexpected events from being generated during tests. Such as |
| 144 // delayed events which create race conditions on slower tests. | 144 // delayed events which create race conditions on slower tests. |
| 145 ui::GestureConfiguration* gesture_config = | 145 ui::GestureConfiguration* gesture_config = |
| 146 ui::GestureConfiguration::GetInstance(); | 146 ui::GestureConfiguration::GetInstance(); |
| 147 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); |
| 148 gesture_config->set_long_press_time_in_ms(1000); | 148 gesture_config->set_long_press_time_in_ms(1000); |
| 149 gesture_config->set_max_touch_move_in_pixels_for_click(5); | 149 gesture_config->set_max_touch_move_in_pixels_for_click(5); |
| 150 | 150 |
| 151 #if defined(OS_WIN) | 151 #if defined(OS_WIN) |
| 152 if (!command_line->HasSwitch(ash::switches::kForceAshToDesktop)) | 152 if (!command_line->HasSwitch(switches::kForceAshToDesktop)) |
| 153 ash::WindowPositioner::SetMaximizeFirstWindow(true); | 153 WindowPositioner::SetMaximizeFirstWindow(true); |
| 154 #endif | 154 #endif |
| 155 } | 155 } |
| 156 | 156 |
| 157 void AshTestBase::TearDown() { | 157 void AshTestBase::TearDown() { |
| 158 teardown_called_ = true; | 158 teardown_called_ = true; |
| 159 Shell::GetInstance()->OnAppTerminating(); | 159 Shell::GetInstance()->OnAppTerminating(); |
| 160 // Flush the message loop to finish pending release tasks. | 160 // Flush the message loop to finish pending release tasks. |
| 161 RunAllPendingInMessageLoop(); | 161 RunAllPendingInMessageLoop(); |
| 162 | 162 |
| 163 ash_test_helper_->TearDown(); | 163 ash_test_helper_->TearDown(); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 window->set_id(id); | 256 window->set_id(id); |
| 257 window->SetType(type); | 257 window->SetType(type); |
| 258 window->Init(ui::LAYER_TEXTURED); | 258 window->Init(ui::LAYER_TEXTURED); |
| 259 window->Show(); | 259 window->Show(); |
| 260 | 260 |
| 261 if (bounds.IsEmpty()) { | 261 if (bounds.IsEmpty()) { |
| 262 ParentWindowInPrimaryRootWindow(window); | 262 ParentWindowInPrimaryRootWindow(window); |
| 263 } else { | 263 } else { |
| 264 display::Display display = | 264 display::Display display = |
| 265 display::Screen::GetScreen()->GetDisplayMatching(bounds); | 265 display::Screen::GetScreen()->GetDisplayMatching(bounds); |
| 266 aura::Window* root = ash::Shell::GetInstance() | 266 aura::Window* root = Shell::GetInstance() |
| 267 ->window_tree_host_manager() | 267 ->window_tree_host_manager() |
| 268 ->GetRootWindowForDisplayId(display.id()); | 268 ->GetRootWindowForDisplayId(display.id()); |
| 269 gfx::Point origin = bounds.origin(); | 269 gfx::Point origin = bounds.origin(); |
| 270 ::wm::ConvertPointFromScreen(root, &origin); | 270 ::wm::ConvertPointFromScreen(root, &origin); |
| 271 window->SetBounds(gfx::Rect(origin, bounds.size())); | 271 window->SetBounds(gfx::Rect(origin, bounds.size())); |
| 272 aura::client::ParentWindowWithContext(window, root, bounds); | 272 aura::client::ParentWindowWithContext(window, root, bounds); |
| 273 } | 273 } |
| 274 window->SetProperty(aura::client::kCanMaximizeKey, true); | 274 window->SetProperty(aura::client::kCanMaximizeKey, true); |
| 275 window->SetProperty(aura::client::kCanMinimizeKey, true); | 275 window->SetProperty(aura::client::kCanMinimizeKey, true); |
| 276 return window; | 276 return window; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 void AshTestBase::SetUserAddingScreenRunning(bool user_adding_screen_running) { | 322 void AshTestBase::SetUserAddingScreenRunning(bool user_adding_screen_running) { |
| 323 AshTestHelper::GetTestSessionStateDelegate()->SetUserAddingScreenRunning( | 323 AshTestHelper::GetTestSessionStateDelegate()->SetUserAddingScreenRunning( |
| 324 user_adding_screen_running); | 324 user_adding_screen_running); |
| 325 } | 325 } |
| 326 | 326 |
| 327 void AshTestBase::BlockUserSession(UserSessionBlockReason block_reason) { | 327 void AshTestBase::BlockUserSession(UserSessionBlockReason block_reason) { |
| 328 switch (block_reason) { | 328 switch (block_reason) { |
| 329 case BLOCKED_BY_LOCK_SCREEN: | 329 case BLOCKED_BY_LOCK_SCREEN: |
| 330 SetSessionStarted(true); | 330 SetSessionStarted(true); |
| 331 SetUserAddingScreenRunning(false); | 331 SetUserAddingScreenRunning(false); |
| 332 Shell::GetInstance()->session_state_delegate()->LockScreen(); | 332 WmShell::Get()->GetSessionStateDelegate()->LockScreen(); |
| 333 Shell::GetInstance()->OnLockStateChanged(true); | 333 Shell::GetInstance()->OnLockStateChanged(true); |
| 334 break; | 334 break; |
| 335 case BLOCKED_BY_LOGIN_SCREEN: | 335 case BLOCKED_BY_LOGIN_SCREEN: |
| 336 SetUserAddingScreenRunning(false); | 336 SetUserAddingScreenRunning(false); |
| 337 SetSessionStarted(false); | 337 SetSessionStarted(false); |
| 338 break; | 338 break; |
| 339 case BLOCKED_BY_USER_ADDING_SCREEN: | 339 case BLOCKED_BY_USER_ADDING_SCREEN: |
| 340 SetUserAddingScreenRunning(true); | 340 SetUserAddingScreenRunning(true); |
| 341 SetSessionStarted(true); | 341 SetSessionStarted(true); |
| 342 break; | 342 break; |
| 343 default: | 343 default: |
| 344 NOTREACHED(); | 344 NOTREACHED(); |
| 345 break; | 345 break; |
| 346 } | 346 } |
| 347 } | 347 } |
| 348 | 348 |
| 349 void AshTestBase::UnblockUserSession() { | 349 void AshTestBase::UnblockUserSession() { |
| 350 Shell::GetInstance()->session_state_delegate()->UnlockScreen(); | 350 WmShell::Get()->GetSessionStateDelegate()->UnlockScreen(); |
| 351 SetSessionStarted(true); | 351 SetSessionStarted(true); |
| 352 SetUserAddingScreenRunning(false); | 352 SetUserAddingScreenRunning(false); |
| 353 } | 353 } |
| 354 | 354 |
| 355 void AshTestBase::DisableIME() { | 355 void AshTestBase::DisableIME() { |
| 356 Shell::GetInstance()->RemovePreTargetHandler( | 356 Shell::GetInstance()->RemovePreTargetHandler( |
| 357 Shell::GetInstance() | 357 Shell::GetInstance() |
| 358 ->window_tree_host_manager() | 358 ->window_tree_host_manager() |
| 359 ->input_method_event_handler()); | 359 ->input_method_event_handler()); |
| 360 } | 360 } |
| 361 | 361 |
| 362 } // namespace test | 362 } // namespace test |
| 363 } // namespace ash | 363 } // namespace ash |
| OLD | NEW |