| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/test_shell_delegate.h" | 5 #include "wm/test/test_shell_delegate.h" |
| 6 | |
| 7 #include <algorithm> | |
| 8 | 6 |
| 9 #include "ash/caps_lock_delegate_stub.h" | 7 #include "ash/caps_lock_delegate_stub.h" |
| 10 #include "ash/host/root_window_host_factory.h" | |
| 11 #include "ash/shell.h" | |
| 12 #include "ash/shell_window_ids.h" | |
| 13 #include "ash/test/test_launcher_delegate.h" | 8 #include "ash/test/test_launcher_delegate.h" |
| 14 #include "ash/wm/window_util.h" | |
| 15 #include "content/public/test/test_browser_context.h" | 9 #include "content/public/test/test_browser_context.h" |
| 16 #include "ui/aura/window.h" | 10 #include "wm/host/root_window_host_factory.h" |
| 17 | 11 |
| 18 namespace ash { | 12 namespace wm { |
| 19 namespace test { | 13 namespace test { |
| 20 | 14 |
| 21 TestShellDelegate::TestShellDelegate() | 15 TestShellDelegate::TestShellDelegate() |
| 22 : locked_(false), | 16 : screen_magnifier_enabled_(false), |
| 23 session_started_(true), | 17 screen_magnifier_type_(ash::kDefaultMagnifierType) { |
| 24 spoken_feedback_enabled_(false), | |
| 25 high_contrast_enabled_(false), | |
| 26 screen_magnifier_enabled_(false), | |
| 27 screen_magnifier_type_(kDefaultMagnifierType), | |
| 28 user_logged_in_(true), | |
| 29 can_lock_screen_(true), | |
| 30 num_exit_requests_(0) { | |
| 31 } | 18 } |
| 32 | 19 |
| 33 TestShellDelegate::~TestShellDelegate() { | 20 TestShellDelegate::~TestShellDelegate() { |
| 34 } | 21 } |
| 35 | 22 |
| 36 bool TestShellDelegate::IsUserLoggedIn() const { | 23 bool TestShellDelegate::IsUserLoggedIn() const { |
| 37 return user_logged_in_; | 24 return true; |
| 38 } | 25 } |
| 39 | 26 |
| 40 bool TestShellDelegate::IsSessionStarted() const { | 27 bool TestShellDelegate::IsSessionStarted() const { |
| 41 return session_started_; | 28 return true; |
| 42 } | 29 } |
| 43 | 30 |
| 44 bool TestShellDelegate::IsFirstRunAfterBoot() const { | 31 bool TestShellDelegate::IsFirstRunAfterBoot() const { |
| 45 return false; | 32 return false; |
| 46 } | 33 } |
| 47 | 34 |
| 48 bool TestShellDelegate::CanLockScreen() const { | 35 bool TestShellDelegate::CanLockScreen() const { |
| 49 return user_logged_in_ && can_lock_screen_; | 36 return false; |
| 50 } | 37 } |
| 51 | 38 |
| 52 void TestShellDelegate::LockScreen() { | 39 void TestShellDelegate::LockScreen() { |
| 53 locked_ = true; | |
| 54 } | 40 } |
| 55 | 41 |
| 56 void TestShellDelegate::UnlockScreen() { | 42 void TestShellDelegate::UnlockScreen() { |
| 57 locked_ = false; | |
| 58 } | 43 } |
| 59 | 44 |
| 60 bool TestShellDelegate::IsScreenLocked() const { | 45 bool TestShellDelegate::IsScreenLocked() const { |
| 61 return locked_; | 46 return false; |
| 62 } | 47 } |
| 63 | 48 |
| 64 void TestShellDelegate::Shutdown() { | 49 void TestShellDelegate::Shutdown() { |
| 65 } | 50 } |
| 66 | 51 |
| 67 void TestShellDelegate::Exit() { | 52 void TestShellDelegate::Exit() { |
| 68 num_exit_requests_++; | |
| 69 } | 53 } |
| 70 | 54 |
| 71 void TestShellDelegate::NewTab() { | 55 void TestShellDelegate::NewTab() { |
| 72 } | 56 } |
| 73 | 57 |
| 74 void TestShellDelegate::NewWindow(bool incognito) { | 58 void TestShellDelegate::NewWindow(bool incognito) { |
| 75 } | 59 } |
| 76 | 60 |
| 77 void TestShellDelegate::ToggleMaximized() { | 61 void TestShellDelegate::ToggleMaximized() { |
| 78 aura::Window* window = ash::wm::GetActiveWindow(); | |
| 79 if (window) | |
| 80 ash::wm::ToggleMaximizedWindow(window); | |
| 81 } | 62 } |
| 82 | 63 |
| 83 void TestShellDelegate::OpenFileManager() { | 64 void TestShellDelegate::OpenFileManager() { |
| 84 } | 65 } |
| 85 | 66 |
| 86 void TestShellDelegate::OpenCrosh() { | 67 void TestShellDelegate::OpenCrosh() { |
| 87 } | 68 } |
| 88 | 69 |
| 89 void TestShellDelegate::OpenMobileSetup(const std::string& service_path) { | 70 void TestShellDelegate::OpenMobileSetup(const std::string& service_path) { |
| 90 } | 71 } |
| 91 | 72 |
| 92 void TestShellDelegate::RestoreTab() { | 73 void TestShellDelegate::RestoreTab() { |
| 93 } | 74 } |
| 94 | 75 |
| 95 bool TestShellDelegate::RotatePaneFocus(Shell::Direction direction) { | 76 bool TestShellDelegate::RotatePaneFocus(ash::Shell::Direction direction) { |
| 96 return true; | 77 return true; |
| 97 } | 78 } |
| 98 | 79 |
| 99 void TestShellDelegate::ShowKeyboardOverlay() { | 80 void TestShellDelegate::ShowKeyboardOverlay() { |
| 100 } | 81 } |
| 101 | 82 |
| 102 void TestShellDelegate::ShowTaskManager() { | 83 void TestShellDelegate::ShowTaskManager() { |
| 103 } | 84 } |
| 104 | 85 |
| 105 content::BrowserContext* TestShellDelegate::GetCurrentBrowserContext() { | 86 content::BrowserContext* TestShellDelegate::GetCurrentBrowserContext() { |
| 106 current_browser_context_.reset(new content::TestBrowserContext()); | 87 current_browser_context_.reset(new content::TestBrowserContext()); |
| 107 return current_browser_context_.get(); | 88 return current_browser_context_.get(); |
| 108 } | 89 } |
| 109 | 90 |
| 110 void TestShellDelegate::ToggleSpokenFeedback( | 91 void TestShellDelegate::ToggleSpokenFeedback( |
| 111 AccessibilityNotificationVisibility notify) { | 92 ash::AccessibilityNotificationVisibility notify) { |
| 112 spoken_feedback_enabled_ = !spoken_feedback_enabled_; | |
| 113 } | 93 } |
| 114 | 94 |
| 115 bool TestShellDelegate::IsSpokenFeedbackEnabled() const { | 95 bool TestShellDelegate::IsSpokenFeedbackEnabled() const { |
| 116 return spoken_feedback_enabled_; | 96 return false; |
| 117 } | 97 } |
| 118 | 98 |
| 119 void TestShellDelegate::ToggleHighContrast() { | 99 void TestShellDelegate::ToggleHighContrast() { |
| 120 high_contrast_enabled_ = !high_contrast_enabled_; | |
| 121 } | 100 } |
| 122 | 101 |
| 123 bool TestShellDelegate::IsHighContrastEnabled() const { | 102 bool TestShellDelegate::IsHighContrastEnabled() const { |
| 124 return high_contrast_enabled_; | 103 return false; |
| 125 } | 104 } |
| 126 | 105 |
| 127 void TestShellDelegate::SetMagnifierEnabled(bool enabled) { | 106 void TestShellDelegate::SetMagnifierEnabled(bool enabled) { |
| 128 screen_magnifier_enabled_ = enabled; | 107 screen_magnifier_enabled_ = enabled; |
| 129 } | 108 } |
| 130 | 109 |
| 131 void TestShellDelegate::SetMagnifierType(MagnifierType type) { | 110 void TestShellDelegate::SetMagnifierType(ash::MagnifierType type) { |
| 132 screen_magnifier_type_ = type; | 111 screen_magnifier_type_ = type; |
| 133 } | 112 } |
| 134 | 113 |
| 135 bool TestShellDelegate::IsMagnifierEnabled() const { | 114 bool TestShellDelegate::IsMagnifierEnabled() const { |
| 136 return screen_magnifier_enabled_; | 115 return screen_magnifier_enabled_; |
| 137 } | 116 } |
| 138 | 117 |
| 139 MagnifierType TestShellDelegate::GetMagnifierType() const { | 118 ash::MagnifierType TestShellDelegate::GetMagnifierType() const { |
| 140 return screen_magnifier_type_; | 119 return screen_magnifier_type_; |
| 141 } | 120 } |
| 142 | 121 |
| 143 bool TestShellDelegate::ShouldAlwaysShowAccessibilityMenu() const { | 122 bool TestShellDelegate::ShouldAlwaysShowAccessibilityMenu() const { |
| 144 return false; | 123 return false; |
| 145 } | 124 } |
| 146 | 125 |
| 147 app_list::AppListViewDelegate* TestShellDelegate::CreateAppListViewDelegate() { | 126 app_list::AppListViewDelegate* TestShellDelegate::CreateAppListViewDelegate() { |
| 148 return NULL; | 127 return NULL; |
| 149 } | 128 } |
| 150 | 129 |
| 151 LauncherDelegate* TestShellDelegate::CreateLauncherDelegate( | 130 ash::LauncherDelegate* TestShellDelegate::CreateLauncherDelegate( |
| 152 ash::LauncherModel* model) { | 131 ash::LauncherModel* model) { |
| 153 return new TestLauncherDelegate(model); | 132 return new ash::test::TestLauncherDelegate(model); |
| 154 } | 133 } |
| 155 | 134 |
| 156 SystemTrayDelegate* TestShellDelegate::CreateSystemTrayDelegate() { | 135 ash::SystemTrayDelegate* TestShellDelegate::CreateSystemTrayDelegate() { |
| 157 return NULL; | 136 return NULL; |
| 158 } | 137 } |
| 159 | 138 |
| 160 UserWallpaperDelegate* TestShellDelegate::CreateUserWallpaperDelegate() { | 139 ash::UserWallpaperDelegate* TestShellDelegate::CreateUserWallpaperDelegate() { |
| 161 return NULL; | 140 return NULL; |
| 162 } | 141 } |
| 163 | 142 |
| 164 CapsLockDelegate* TestShellDelegate::CreateCapsLockDelegate() { | 143 ash::CapsLockDelegate* TestShellDelegate::CreateCapsLockDelegate() { |
| 165 return new CapsLockDelegateStub; | 144 return new ash::CapsLockDelegateStub; |
| 166 } | 145 } |
| 167 | 146 |
| 168 aura::client::UserActionClient* TestShellDelegate::CreateUserActionClient() { | 147 aura::client::UserActionClient* TestShellDelegate::CreateUserActionClient() { |
| 169 return NULL; | 148 return NULL; |
| 170 } | 149 } |
| 171 | 150 |
| 172 void TestShellDelegate::OpenFeedbackPage() { | 151 void TestShellDelegate::OpenFeedbackPage() { |
| 173 } | 152 } |
| 174 | 153 |
| 175 void TestShellDelegate::RecordUserMetricsAction(UserMetricsAction action) { | 154 void TestShellDelegate::RecordUserMetricsAction( |
| 155 ash::UserMetricsAction action) { |
| 176 } | 156 } |
| 177 | 157 |
| 178 void TestShellDelegate::HandleMediaNextTrack() { | 158 void TestShellDelegate::HandleMediaNextTrack() { |
| 179 } | 159 } |
| 180 | 160 |
| 181 void TestShellDelegate::HandleMediaPlayPause() { | 161 void TestShellDelegate::HandleMediaPlayPause() { |
| 182 } | 162 } |
| 183 | 163 |
| 184 void TestShellDelegate::HandleMediaPrevTrack() { | 164 void TestShellDelegate::HandleMediaPrevTrack() { |
| 185 } | 165 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 196 } | 176 } |
| 197 | 177 |
| 198 ui::MenuModel* TestShellDelegate::CreateContextMenu(aura::RootWindow* root) { | 178 ui::MenuModel* TestShellDelegate::CreateContextMenu(aura::RootWindow* root) { |
| 199 return NULL; | 179 return NULL; |
| 200 } | 180 } |
| 201 | 181 |
| 202 double TestShellDelegate::GetSavedScreenMagnifierScale() { | 182 double TestShellDelegate::GetSavedScreenMagnifierScale() { |
| 203 return std::numeric_limits<double>::min(); | 183 return std::numeric_limits<double>::min(); |
| 204 } | 184 } |
| 205 | 185 |
| 206 RootWindowHostFactory* TestShellDelegate::CreateRootWindowHostFactory() { | 186 ash::RootWindowHostFactory* TestShellDelegate::CreateRootWindowHostFactory() { |
| 207 return RootWindowHostFactory::Create(); | 187 return RootWindowHostFactory::Create(); |
| 208 } | 188 } |
| 209 | 189 |
| 210 void TestShellDelegate::SetSessionStarted(bool session_started) { | |
| 211 session_started_ = session_started; | |
| 212 if (session_started) | |
| 213 user_logged_in_ = true; | |
| 214 } | |
| 215 | |
| 216 void TestShellDelegate::SetUserLoggedIn(bool user_logged_in) { | |
| 217 user_logged_in_ = user_logged_in; | |
| 218 if (!user_logged_in) | |
| 219 session_started_ = false; | |
| 220 } | |
| 221 | |
| 222 void TestShellDelegate::SetCanLockScreen(bool can_lock_screen) { | |
| 223 can_lock_screen_ = can_lock_screen; | |
| 224 } | |
| 225 | |
| 226 string16 TestShellDelegate::GetProductName() const { | 190 string16 TestShellDelegate::GetProductName() const { |
| 227 return string16(); | 191 return string16(); |
| 228 } | 192 } |
| 229 | 193 |
| 230 | |
| 231 } // namespace test | 194 } // namespace test |
| 232 } // namespace ash | 195 } // namespace wm |
| OLD | NEW |