Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(393)

Side by Side Diff: ash/test/ash_test_helper.cc

Issue 693643004: Make UserActivityDetector a singleton (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@athena_do_not_use_ash45
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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.h" 7 #include "ash/accelerators/accelerator_controller.h"
8 #include "ash/ash_switches.h" 8 #include "ash/ash_switches.h"
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "ash/shell_init_params.h" 10 #include "ash/shell_init_params.h"
11 #include "ash/test/ash_test_views_delegate.h" 11 #include "ash/test/ash_test_views_delegate.h"
12 #include "ash/test/display_manager_test_api.h" 12 #include "ash/test/display_manager_test_api.h"
13 #include "ash/test/shell_test_api.h" 13 #include "ash/test/shell_test_api.h"
14 #include "ash/test/test_screenshot_delegate.h" 14 #include "ash/test/test_screenshot_delegate.h"
15 #include "ash/test/test_session_state_delegate.h" 15 #include "ash/test/test_session_state_delegate.h"
16 #include "ash/test/test_shell_delegate.h" 16 #include "ash/test/test_shell_delegate.h"
17 #include "ash/test/test_system_tray_delegate.h" 17 #include "ash/test/test_system_tray_delegate.h"
18 #include "base/run_loop.h" 18 #include "base/run_loop.h"
19 #include "ui/aura/env.h" 19 #include "ui/aura/env.h"
20 #include "ui/aura/input_state_lookup.h" 20 #include "ui/aura/input_state_lookup.h"
21 #include "ui/aura/test/env_test_helper.h" 21 #include "ui/aura/test/env_test_helper.h"
22 #include "ui/aura/test/event_generator_delegate_aura.h" 22 #include "ui/aura/test/event_generator_delegate_aura.h"
23 #include "ui/base/ime/input_method_initializer.h" 23 #include "ui/base/ime/input_method_initializer.h"
24 #include "ui/compositor/scoped_animation_duration_scale_mode.h" 24 #include "ui/compositor/scoped_animation_duration_scale_mode.h"
25 #include "ui/compositor/test/context_factories_for_test.h" 25 #include "ui/compositor/test/context_factories_for_test.h"
26 #include "ui/message_center/message_center.h" 26 #include "ui/message_center/message_center.h"
27 #include "ui/wm/core/capture_controller.h" 27 #include "ui/wm/core/capture_controller.h"
28 #include "ui/wm/core/user_activity_detector.h"
28 29
29 #if defined(OS_CHROMEOS) 30 #if defined(OS_CHROMEOS)
30 #include "chromeos/audio/cras_audio_handler.h" 31 #include "chromeos/audio/cras_audio_handler.h"
31 #include "chromeos/dbus/dbus_thread_manager.h" 32 #include "chromeos/dbus/dbus_thread_manager.h"
32 #include "ui/keyboard/keyboard.h" 33 #include "ui/keyboard/keyboard.h"
33 #endif 34 #endif
34 35
35 #if defined(OS_WIN) 36 #if defined(OS_WIN)
36 #include "base/win/windows_version.h" 37 #include "base/win/windows_version.h"
37 #endif 38 #endif
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 81
81 #if defined(OS_CHROMEOS) 82 #if defined(OS_CHROMEOS)
82 // Create DBusThreadManager for testing. 83 // Create DBusThreadManager for testing.
83 if (!chromeos::DBusThreadManager::IsInitialized()) { 84 if (!chromeos::DBusThreadManager::IsInitialized()) {
84 chromeos::DBusThreadManager::Initialize(); 85 chromeos::DBusThreadManager::Initialize();
85 dbus_thread_manager_initialized_ = true; 86 dbus_thread_manager_initialized_ = true;
86 } 87 }
87 // Create CrasAudioHandler for testing since g_browser_process is not 88 // Create CrasAudioHandler for testing since g_browser_process is not
88 // created in AshTestBase tests. 89 // created in AshTestBase tests.
89 chromeos::CrasAudioHandler::InitializeForTesting(); 90 chromeos::CrasAudioHandler::InitializeForTesting();
91
92 // The UserActivityDetector must be created before the shell is created.
93 wm::UserActivityDetector::Create();
90 #endif 94 #endif
91 ShellInitParams init_params; 95 ShellInitParams init_params;
92 init_params.delegate = test_shell_delegate_; 96 init_params.delegate = test_shell_delegate_;
93 init_params.context_factory = context_factory; 97 init_params.context_factory = context_factory;
94 ash::Shell::CreateInstance(init_params); 98 ash::Shell::CreateInstance(init_params);
95 aura::test::EnvTestHelper(aura::Env::GetInstance()).SetInputStateLookup( 99 aura::test::EnvTestHelper(aura::Env::GetInstance()).SetInputStateLookup(
96 scoped_ptr<aura::InputStateLookup>()); 100 scoped_ptr<aura::InputStateLookup>());
97 101
98 Shell* shell = Shell::GetInstance(); 102 Shell* shell = Shell::GetInstance();
99 if (start_session) { 103 if (start_session) {
(...skipping 14 matching lines...) Expand all
114 118
115 void AshTestHelper::TearDown() { 119 void AshTestHelper::TearDown() {
116 // Tear down the shell. 120 // Tear down the shell.
117 Shell::DeleteInstance(); 121 Shell::DeleteInstance();
118 test_screenshot_delegate_ = NULL; 122 test_screenshot_delegate_ = NULL;
119 123
120 // Remove global message center state. 124 // Remove global message center state.
121 message_center::MessageCenter::Shutdown(); 125 message_center::MessageCenter::Shutdown();
122 126
123 #if defined(OS_CHROMEOS) 127 #if defined(OS_CHROMEOS)
128 wm::UserActivityDetector::Shutdown();
129
124 chromeos::CrasAudioHandler::Shutdown(); 130 chromeos::CrasAudioHandler::Shutdown();
125 if (dbus_thread_manager_initialized_) { 131 if (dbus_thread_manager_initialized_) {
126 chromeos::DBusThreadManager::Shutdown(); 132 chromeos::DBusThreadManager::Shutdown();
127 dbus_thread_manager_initialized_ = false; 133 dbus_thread_manager_initialized_ = false;
128 } 134 }
129 keyboard::ResetKeyboardForTesting(); 135 keyboard::ResetKeyboardForTesting();
130 #endif 136 #endif
131 137
132 aura::Env::DeleteInstance(); 138 aura::Env::DeleteInstance();
133 ui::TerminateContextFactoryForTests(); 139 ui::TerminateContextFactoryForTests();
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 bool AshTestHelper::SupportsHostWindowResize() { 177 bool AshTestHelper::SupportsHostWindowResize() {
172 #if defined(OS_WIN) 178 #if defined(OS_WIN)
173 return false; 179 return false;
174 #else 180 #else
175 return true; 181 return true;
176 #endif 182 #endif
177 } 183 }
178 184
179 } // namespace test 185 } // namespace test
180 } // namespace ash 186 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698