| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_helper.h" | 5 #include "ash/test/ash_test_helper.h" |
| 6 | 6 |
| 7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
| 8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
| 9 #include "ash/test/display_manager_test_api.h" | 9 #include "ash/test/display_manager_test_api.h" |
| 10 #include "ash/test/shell_test_api.h" | 10 #include "ash/test/shell_test_api.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 test_shell_delegate_(NULL) { | 32 test_shell_delegate_(NULL) { |
| 33 CHECK(message_loop_); | 33 CHECK(message_loop_); |
| 34 #if defined(USE_X11) | 34 #if defined(USE_X11) |
| 35 aura::test::SetUseOverrideRedirectWindowByDefault(true); | 35 aura::test::SetUseOverrideRedirectWindowByDefault(true); |
| 36 #endif | 36 #endif |
| 37 } | 37 } |
| 38 | 38 |
| 39 AshTestHelper::~AshTestHelper() { | 39 AshTestHelper::~AshTestHelper() { |
| 40 } | 40 } |
| 41 | 41 |
| 42 void AshTestHelper::SetUp() { | 42 void AshTestHelper::SetUp(bool start_session) { |
| 43 // Disable animations during tests. | 43 // Disable animations during tests. |
| 44 zero_duration_mode_.reset(new ui::ScopedAnimationDurationScaleMode( | 44 zero_duration_mode_.reset(new ui::ScopedAnimationDurationScaleMode( |
| 45 ui::ScopedAnimationDurationScaleMode::ZERO_DURATION)); | 45 ui::ScopedAnimationDurationScaleMode::ZERO_DURATION)); |
| 46 ui::InitializeInputMethodForTesting(); | 46 ui::InitializeInputMethodForTesting(); |
| 47 | 47 |
| 48 // Creates Shell and hook with Desktop. | 48 // Creates Shell and hook with Desktop. |
| 49 test_shell_delegate_ = new TestShellDelegate; | 49 test_shell_delegate_ = new TestShellDelegate; |
| 50 | 50 |
| 51 // Creates MessageCenter since g_browser_process is not created in AshTestBase | 51 // Creates MessageCenter since g_browser_process is not created in AshTestBase |
| 52 // tests. | 52 // tests. |
| 53 message_center::MessageCenter::Initialize(); | 53 message_center::MessageCenter::Initialize(); |
| 54 | 54 |
| 55 #if defined(OS_CHROMEOS) | 55 #if defined(OS_CHROMEOS) |
| 56 // Create CrasAudioHandler for testing since g_browser_process is not | 56 // Create CrasAudioHandler for testing since g_browser_process is not |
| 57 // created in AshTestBase tests. | 57 // created in AshTestBase tests. |
| 58 chromeos::CrasAudioHandler::InitializeForTesting(); | 58 chromeos::CrasAudioHandler::InitializeForTesting(); |
| 59 #endif | 59 #endif |
| 60 | 60 |
| 61 ash::Shell::CreateInstance(test_shell_delegate_); | 61 ash::Shell::CreateInstance(test_shell_delegate_); |
| 62 Shell* shell = Shell::GetInstance(); | 62 Shell* shell = Shell::GetInstance(); |
| 63 test_shell_delegate_->test_session_state_delegate()-> | 63 if (start_session) { |
| 64 SetActiveUserSessionStarted(true); | 64 test_shell_delegate_->test_session_state_delegate()-> |
| 65 test_shell_delegate_->test_session_state_delegate()->SetHasActiveUser(true); | 65 SetActiveUserSessionStarted(true); |
| 66 test_shell_delegate_->test_session_state_delegate()-> |
| 67 SetHasActiveUser(true); |
| 68 } |
| 66 | 69 |
| 67 test::DisplayManagerTestApi(shell->display_manager()). | 70 test::DisplayManagerTestApi(shell->display_manager()). |
| 68 DisableChangeDisplayUponHostResize(); | 71 DisableChangeDisplayUponHostResize(); |
| 69 ShellTestApi(shell).DisableOutputConfiguratorAnimation(); | 72 ShellTestApi(shell).DisableOutputConfiguratorAnimation(); |
| 70 } | 73 } |
| 71 | 74 |
| 72 void AshTestHelper::TearDown() { | 75 void AshTestHelper::TearDown() { |
| 73 // Tear down the shell. | 76 // Tear down the shell. |
| 74 Shell::DeleteInstance(); | 77 Shell::DeleteInstance(); |
| 75 | 78 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 97 aura::RootWindow* AshTestHelper::CurrentContext() { | 100 aura::RootWindow* AshTestHelper::CurrentContext() { |
| 98 aura::RootWindow* root_window = Shell::GetActiveRootWindow(); | 101 aura::RootWindow* root_window = Shell::GetActiveRootWindow(); |
| 99 if (!root_window) | 102 if (!root_window) |
| 100 root_window = Shell::GetPrimaryRootWindow(); | 103 root_window = Shell::GetPrimaryRootWindow(); |
| 101 DCHECK(root_window); | 104 DCHECK(root_window); |
| 102 return root_window; | 105 return root_window; |
| 103 } | 106 } |
| 104 | 107 |
| 105 } // namespace test | 108 } // namespace test |
| 106 } // namespace ash | 109 } // namespace ash |
| OLD | NEW |