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 3 // found in the LICENSE file. 4 5 #include "ash/test/test_shell_delegate.h" 6 7 #include <limits> 8 9 #include "ash/caps_lock_delegate_stub.h" 10 #include "ash/host/root_window_host_factory.h" 11 #include "ash/session_state_delegate.h" 12 #include "ash/shell.h" 13 #include "ash/shell_window_ids.h" 14 #include "ash/test/test_launcher_delegate.h" 15 #include "ash/test/test_session_state_delegate.h" 16 #include "ash/wm/window_util.h" 17 #include "base/logging.h" 18 #include "content/public/test/test_browser_context.h" 19 #include "ui/aura/window.h" 20 #include "ui/compositor/compositor.h" 21 22 namespace ash { 23 namespace test { 24 25 TestShellDelegate::TestShellDelegate() 26 : spoken_feedback_enabled_(false), 27 high_contrast_enabled_(false), 28 screen_magnifier_enabled_(false), 29 screen_magnifier_type_(kDefaultMagnifierType), 30 large_cursor_enabled_(false), 31 num_exit_requests_(0), 32 multi_profiles_enabled_(false), 33 test_session_state_delegate_(NULL) { 34 } 35 36 TestShellDelegate::~TestShellDelegate() { 37 } 38 39 bool TestShellDelegate::IsFirstRunAfterBoot() const { 40 return false; 41 } 42 43 bool TestShellDelegate::IsMultiProfilesEnabled() const { 44 return multi_profiles_enabled_; 45 } 46 47 bool TestShellDelegate::IsRunningInForcedAppMode() const { 48 return false; 49 } 50 51 void TestShellDelegate::PreInit() { 52 } 53 54 void TestShellDelegate::Shutdown() { 55 } 56 57 void TestShellDelegate::Exit() { 58 num_exit_requests_++; 59 } 60 61 void TestShellDelegate::NewTab() { 62 } 63 64 void TestShellDelegate::NewWindow(bool incognito) { 65 } 66 67 void TestShellDelegate::ToggleMaximized() { 68 aura::Window* window = ash::wm::GetActiveWindow(); 69 if (window) 70 ash::wm::ToggleMaximizedWindow(window); 71 } 72 73 void TestShellDelegate::ToggleFullscreen() { 74 } 75 76 void TestShellDelegate::OpenFileManager(bool as_dialog) { 77 } 78 79 void TestShellDelegate::OpenCrosh() { 80 } 81 82 void TestShellDelegate::RestoreTab() { 83 } 84 85 void TestShellDelegate::ShowKeyboardOverlay() { 86 } 87 88 keyboard::KeyboardControllerProxy* 89 TestShellDelegate::CreateKeyboardControllerProxy() { 90 return NULL; 91 } 92 93 void TestShellDelegate::ShowTaskManager() { 94 } 95 96 content::BrowserContext* TestShellDelegate::GetCurrentBrowserContext() { 97 current_browser_context_.reset(new content::TestBrowserContext()); 98 return current_browser_context_.get(); 99 } 100 101 void TestShellDelegate::ToggleSpokenFeedback( 102 AccessibilityNotificationVisibility notify) { 103 spoken_feedback_enabled_ = !spoken_feedback_enabled_; 104 } 105 106 bool TestShellDelegate::IsSpokenFeedbackEnabled() const { 107 return spoken_feedback_enabled_; 108 } 109 110 void TestShellDelegate::ToggleHighContrast() { 111 high_contrast_enabled_ = !high_contrast_enabled_; 112 } 113 114 bool TestShellDelegate::IsHighContrastEnabled() const { 115 return high_contrast_enabled_; 116 } 117 118 void TestShellDelegate::SetMagnifierEnabled(bool enabled) { 119 screen_magnifier_enabled_ = enabled; 120 } 121 122 void TestShellDelegate::SetMagnifierType(MagnifierType type) { 123 screen_magnifier_type_ = type; 124 } 125 126 bool TestShellDelegate::IsMagnifierEnabled() const { 127 return screen_magnifier_enabled_; 128 } 129 130 MagnifierType TestShellDelegate::GetMagnifierType() const { 131 return screen_magnifier_type_; 132 } 133 134 void TestShellDelegate::SetLargeCursorEnabled(bool enabled) { 135 large_cursor_enabled_ = enabled; 136 } 137 138 bool TestShellDelegate::IsLargeCursorEnabled() const { 139 return large_cursor_enabled_; 140 } 141 142 bool TestShellDelegate::ShouldAlwaysShowAccessibilityMenu() const { 143 return false; 144 } 145 146 void TestShellDelegate::SilenceSpokenFeedback() const { 147 } 148 149 app_list::AppListViewDelegate* TestShellDelegate::CreateAppListViewDelegate() { 150 return NULL; 151 } 152 153 LauncherDelegate* TestShellDelegate::CreateLauncherDelegate( 154 ash::LauncherModel* model) { 155 return new TestLauncherDelegate(model); 156 } 157 158 SystemTrayDelegate* TestShellDelegate::CreateSystemTrayDelegate() { 159 return NULL; 160 } 161 162 UserWallpaperDelegate* TestShellDelegate::CreateUserWallpaperDelegate() { 163 return NULL; 164 } 165 166 CapsLockDelegate* TestShellDelegate::CreateCapsLockDelegate() { 167 return new CapsLockDelegateStub; 168 } 169 170 SessionStateDelegate* TestShellDelegate::CreateSessionStateDelegate() { 171 DCHECK(!test_session_state_delegate_); 172 test_session_state_delegate_ = new TestSessionStateDelegate(); 173 return test_session_state_delegate_; 174 } 175 176 aura::client::UserActionClient* TestShellDelegate::CreateUserActionClient() { 177 return NULL; 178 } 179 180 void TestShellDelegate::OpenFeedbackPage() { 181 } 182 183 void TestShellDelegate::RecordUserMetricsAction(UserMetricsAction action) { 184 } 185 186 void TestShellDelegate::HandleMediaNextTrack() { 187 } 188 189 void TestShellDelegate::HandleMediaPlayPause() { 190 } 191 192 void TestShellDelegate::HandleMediaPrevTrack() { 193 } 194 195 void TestShellDelegate::SaveScreenMagnifierScale(double scale) { 196 } 197 198 ui::MenuModel* TestShellDelegate::CreateContextMenu(aura::RootWindow* root) { 199 return NULL; 200 } 201 202 double TestShellDelegate::GetSavedScreenMagnifierScale() { 203 return std::numeric_limits<double>::min(); 204 } 205 206 RootWindowHostFactory* TestShellDelegate::CreateRootWindowHostFactory() { 207 // The ContextFactory must exist before any Compositors are created. 208 bool allow_test_contexts = true; 209 ui::Compositor::InitializeContextFactoryForTests(allow_test_contexts); 210 211 return RootWindowHostFactory::Create(); 212 } 213 214 base::string16 TestShellDelegate::GetProductName() const { 215 return base::string16(); 216 } 217 218 TestSessionStateDelegate* TestShellDelegate::test_session_state_delegate() { 219 return test_session_state_delegate_; 220 } 221 222 } // namespace test 223 } // namespace ash 224