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/accelerators/accelerator_controller_delegate_aura.h" | 7 #include "ash/accelerators/accelerator_controller_delegate_aura.h" |
8 #include "ash/common/ash_switches.h" | 8 #include "ash/common/ash_switches.h" |
9 #include "ash/common/display/display_info.h" | 9 #include "ash/common/display/display_info.h" |
10 #include "ash/common/material_design/material_design_controller.h" | |
11 #include "ash/common/test/material_design_controller_test_api.h" | |
12 #include "ash/common/wm_shell.h" | 10 #include "ash/common/wm_shell.h" |
13 #include "ash/shell.h" | 11 #include "ash/shell.h" |
14 #include "ash/shell_init_params.h" | 12 #include "ash/shell_init_params.h" |
15 #include "ash/test/ash_test_views_delegate.h" | 13 #include "ash/test/ash_test_views_delegate.h" |
16 #include "ash/test/content/test_shell_content_state.h" | 14 #include "ash/test/content/test_shell_content_state.h" |
17 #include "ash/test/display_manager_test_api.h" | 15 #include "ash/test/display_manager_test_api.h" |
18 #include "ash/test/shell_test_api.h" | 16 #include "ash/test/shell_test_api.h" |
19 #include "ash/test/test_screenshot_delegate.h" | 17 #include "ash/test/test_screenshot_delegate.h" |
20 #include "ash/test/test_session_state_delegate.h" | 18 #include "ash/test/test_session_state_delegate.h" |
21 #include "ash/test/test_shell_delegate.h" | 19 #include "ash/test/test_shell_delegate.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
64 bluez_dbus_manager_initialized_ = false; | 62 bluez_dbus_manager_initialized_ = false; |
65 #endif | 63 #endif |
66 #if defined(USE_X11) | 64 #if defined(USE_X11) |
67 aura::test::SetUseOverrideRedirectWindowByDefault(true); | 65 aura::test::SetUseOverrideRedirectWindowByDefault(true); |
68 #endif | 66 #endif |
69 aura::test::InitializeAuraEventGeneratorDelegate(); | 67 aura::test::InitializeAuraEventGeneratorDelegate(); |
70 } | 68 } |
71 | 69 |
72 AshTestHelper::~AshTestHelper() {} | 70 AshTestHelper::~AshTestHelper() {} |
73 | 71 |
74 void AshTestHelper::SetUp(bool start_session) { | 72 void AshTestHelper::SetUp(bool start_session, |
73 MaterialDesignController::Mode material_mode) { | |
75 ResetDisplayIdForTest(); | 74 ResetDisplayIdForTest(); |
76 views_delegate_.reset(new AshTestViewsDelegate); | 75 views_delegate_.reset(new AshTestViewsDelegate); |
77 | 76 |
78 // Disable animations during tests. | 77 // Disable animations during tests. |
79 zero_duration_mode_.reset(new ui::ScopedAnimationDurationScaleMode( | 78 zero_duration_mode_.reset(new ui::ScopedAnimationDurationScaleMode( |
80 ui::ScopedAnimationDurationScaleMode::ZERO_DURATION)); | 79 ui::ScopedAnimationDurationScaleMode::ZERO_DURATION)); |
81 ui::InitializeInputMethodForTesting(); | 80 ui::InitializeInputMethodForTesting(); |
82 | 81 |
83 bool enable_pixel_output = false; | 82 bool enable_pixel_output = false; |
84 ui::ContextFactory* context_factory = | 83 ui::ContextFactory* context_factory = |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
120 | 119 |
121 // Reset the global state for the cursor manager. This includes the | 120 // Reset the global state for the cursor manager. This includes the |
122 // last cursor visibility state, etc. | 121 // last cursor visibility state, etc. |
123 ::wm::CursorManager::ResetCursorVisibilityStateForTest(); | 122 ::wm::CursorManager::ResetCursorVisibilityStateForTest(); |
124 | 123 |
125 // ContentTestSuiteBase might have already initialized | 124 // ContentTestSuiteBase might have already initialized |
126 // MaterialDesignController in unit_tests suite. | 125 // MaterialDesignController in unit_tests suite. |
127 ui::test::MaterialDesignControllerTestAPI::Uninitialize(); | 126 ui::test::MaterialDesignControllerTestAPI::Uninitialize(); |
128 ui::MaterialDesignController::Initialize(); | 127 ui::MaterialDesignController::Initialize(); |
129 ash::MaterialDesignController::Initialize(); | 128 ash::MaterialDesignController::Initialize(); |
129 // If |material_mode| is not set, use the value from command line switches. | |
tdanderson
2016/07/29 15:16:50
I think it would be better to have this documented
mohsen
2016/07/29 18:05:19
Right. Done.
| |
130 if (material_mode == MaterialDesignController::Mode::UNINITIALIZED) | |
131 material_mode = MaterialDesignController::GetMode(); | |
132 material_design_state_.reset( | |
133 new test::MaterialDesignControllerTestAPI(material_mode)); | |
134 | |
130 ShellInitParams init_params; | 135 ShellInitParams init_params; |
131 init_params.delegate = test_shell_delegate_; | 136 init_params.delegate = test_shell_delegate_; |
132 init_params.context_factory = context_factory; | 137 init_params.context_factory = context_factory; |
133 init_params.blocking_pool = content::BrowserThread::GetBlockingPool(); | 138 init_params.blocking_pool = content::BrowserThread::GetBlockingPool(); |
134 Shell::CreateInstance(init_params); | 139 Shell::CreateInstance(init_params); |
135 aura::test::EnvTestHelper(aura::Env::GetInstance()) | 140 aura::test::EnvTestHelper(aura::Env::GetInstance()) |
136 .SetInputStateLookup(std::unique_ptr<aura::InputStateLookup>()); | 141 .SetInputStateLookup(std::unique_ptr<aura::InputStateLookup>()); |
137 | 142 |
138 Shell* shell = Shell::GetInstance(); | 143 Shell* shell = Shell::GetInstance(); |
139 if (start_session) { | 144 if (start_session) { |
140 GetTestSessionStateDelegate()->SetActiveUserSessionStarted(true); | 145 GetTestSessionStateDelegate()->SetActiveUserSessionStarted(true); |
141 GetTestSessionStateDelegate()->SetHasActiveUser(true); | 146 GetTestSessionStateDelegate()->SetHasActiveUser(true); |
142 } | 147 } |
143 | 148 |
144 test::DisplayManagerTestApi().DisableChangeDisplayUponHostResize(); | 149 test::DisplayManagerTestApi().DisableChangeDisplayUponHostResize(); |
145 ShellTestApi(shell).DisableDisplayAnimator(); | 150 ShellTestApi(shell).DisableDisplayAnimator(); |
146 | 151 |
147 test_screenshot_delegate_ = new TestScreenshotDelegate(); | 152 test_screenshot_delegate_ = new TestScreenshotDelegate(); |
148 shell->accelerator_controller_delegate()->SetScreenshotDelegate( | 153 shell->accelerator_controller_delegate()->SetScreenshotDelegate( |
149 std::unique_ptr<ScreenshotDelegate>(test_screenshot_delegate_)); | 154 std::unique_ptr<ScreenshotDelegate>(test_screenshot_delegate_)); |
150 } | 155 } |
151 | 156 |
152 void AshTestHelper::TearDown() { | 157 void AshTestHelper::TearDown() { |
153 // Tear down the shell. | 158 // Tear down the shell. |
154 Shell::DeleteInstance(); | 159 Shell::DeleteInstance(); |
160 material_design_state_.reset(); | |
155 test::MaterialDesignControllerTestAPI::Uninitialize(); | 161 test::MaterialDesignControllerTestAPI::Uninitialize(); |
156 ShellContentState::DestroyInstance(); | 162 ShellContentState::DestroyInstance(); |
157 | 163 |
158 test_screenshot_delegate_ = NULL; | 164 test_screenshot_delegate_ = NULL; |
159 | 165 |
160 // Remove global message center state. | 166 // Remove global message center state. |
161 message_center::MessageCenter::Shutdown(); | 167 message_center::MessageCenter::Shutdown(); |
162 | 168 |
163 #if defined(OS_CHROMEOS) | 169 #if defined(OS_CHROMEOS) |
164 chromeos::CrasAudioHandler::Shutdown(); | 170 chromeos::CrasAudioHandler::Shutdown(); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
220 bool AshTestHelper::SupportsHostWindowResize() { | 226 bool AshTestHelper::SupportsHostWindowResize() { |
221 #if defined(OS_WIN) | 227 #if defined(OS_WIN) |
222 return false; | 228 return false; |
223 #else | 229 #else |
224 return true; | 230 return true; |
225 #endif | 231 #endif |
226 } | 232 } |
227 | 233 |
228 } // namespace test | 234 } // namespace test |
229 } // namespace ash | 235 } // namespace ash |
OLD | NEW |