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

Side by Side Diff: chrome/browser/chromeos/login/kiosk_browsertest.cc

Issue 856493004: Update {virtual,override,final} to follow C++11 style in chrome/browser/chromeos/login. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 months 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 (c) 2013 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/desktop_background/desktop_background_controller.h" 5 #include "ash/desktop_background/desktop_background_controller.h"
6 #include "ash/desktop_background/desktop_background_controller_observer.h" 6 #include "ash/desktop_background/desktop_background_controller_observer.h"
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/bind_helpers.h" 9 #include "base/bind_helpers.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 const std::string js_; 257 const std::string js_;
258 scoped_refptr<content::MessageLoopRunner> runner_; 258 scoped_refptr<content::MessageLoopRunner> runner_;
259 259
260 DISALLOW_COPY_AND_ASSIGN(JsConditionWaiter); 260 DISALLOW_COPY_AND_ASSIGN(JsConditionWaiter);
261 }; 261 };
262 262
263 class KioskFakeDiskMountManager : public file_manager::FakeDiskMountManager { 263 class KioskFakeDiskMountManager : public file_manager::FakeDiskMountManager {
264 public: 264 public:
265 KioskFakeDiskMountManager() {} 265 KioskFakeDiskMountManager() {}
266 266
267 virtual ~KioskFakeDiskMountManager() {} 267 ~KioskFakeDiskMountManager() override {}
268 268
269 void set_usb_mount_path(const std::string& usb_mount_path) { 269 void set_usb_mount_path(const std::string& usb_mount_path) {
270 usb_mount_path_ = usb_mount_path; 270 usb_mount_path_ = usb_mount_path;
271 } 271 }
272 272
273 void MountUsbStick() { 273 void MountUsbStick() {
274 DCHECK(!usb_mount_path_.empty()); 274 DCHECK(!usb_mount_path_.empty());
275 MountPath(usb_mount_path_, "", "", chromeos::MOUNT_TYPE_DEVICE); 275 MountPath(usb_mount_path_, "", "", chromeos::MOUNT_TYPE_DEVICE);
276 } 276 }
277 277
(...skipping 12 matching lines...) Expand all
290 290
291 } // namespace 291 } // namespace
292 292
293 class KioskTest : public OobeBaseTest { 293 class KioskTest : public OobeBaseTest {
294 public: 294 public:
295 KioskTest() : use_consumer_kiosk_mode_(true), 295 KioskTest() : use_consumer_kiosk_mode_(true),
296 fake_cws_(new FakeCWS) { 296 fake_cws_(new FakeCWS) {
297 set_exit_when_last_browser_closes(false); 297 set_exit_when_last_browser_closes(false);
298 } 298 }
299 299
300 virtual ~KioskTest() {} 300 ~KioskTest() override {}
301 301
302 protected: 302 protected:
303 virtual void SetUp() override { 303 void SetUp() override {
304 test_app_id_ = kTestKioskApp; 304 test_app_id_ = kTestKioskApp;
305 set_test_app_version("1.0.0"); 305 set_test_app_version("1.0.0");
306 set_test_crx_file(test_app_id() + ".crx"); 306 set_test_crx_file(test_app_id() + ".crx");
307 needs_background_networking_ = true; 307 needs_background_networking_ = true;
308 mock_user_manager_.reset(new MockUserManager); 308 mock_user_manager_.reset(new MockUserManager);
309 ProfileHelper::SetAlwaysReturnPrimaryUserForTesting(true); 309 ProfileHelper::SetAlwaysReturnPrimaryUserForTesting(true);
310 AppLaunchController::SkipSplashWaitForTesting(); 310 AppLaunchController::SkipSplashWaitForTesting();
311 AppLaunchController::SetNetworkWaitForTesting(kTestNetworkTimeoutSeconds); 311 AppLaunchController::SetNetworkWaitForTesting(kTestNetworkTimeoutSeconds);
312 312
313 OobeBaseTest::SetUp(); 313 OobeBaseTest::SetUp();
314 } 314 }
315 315
316 virtual void TearDown() override { 316 void TearDown() override {
317 ProfileHelper::SetAlwaysReturnPrimaryUserForTesting(false); 317 ProfileHelper::SetAlwaysReturnPrimaryUserForTesting(false);
318 OobeBaseTest::TearDown(); 318 OobeBaseTest::TearDown();
319 } 319 }
320 320
321 virtual void SetUpOnMainThread() override { 321 void SetUpOnMainThread() override {
322 OobeBaseTest::SetUpOnMainThread(); 322 OobeBaseTest::SetUpOnMainThread();
323 // Needed to avoid showing Gaia screen instead of owner signin for 323 // Needed to avoid showing Gaia screen instead of owner signin for
324 // consumer network down test cases. 324 // consumer network down test cases.
325 StartupUtils::MarkDeviceRegistered(base::Closure()); 325 StartupUtils::MarkDeviceRegistered(base::Closure());
326 } 326 }
327 327
328 virtual void TearDownOnMainThread() override { 328 void TearDownOnMainThread() override {
329 AppLaunchController::SetNetworkTimeoutCallbackForTesting(NULL); 329 AppLaunchController::SetNetworkTimeoutCallbackForTesting(NULL);
330 AppLaunchSigninScreen::SetUserManagerForTesting(NULL); 330 AppLaunchSigninScreen::SetUserManagerForTesting(NULL);
331 331
332 OobeBaseTest::TearDownOnMainThread(); 332 OobeBaseTest::TearDownOnMainThread();
333 333
334 // Clean up while main thread still runs. 334 // Clean up while main thread still runs.
335 // See http://crbug.com/176659. 335 // See http://crbug.com/176659.
336 KioskAppManager::Get()->CleanUp(); 336 KioskAppManager::Get()->CleanUp();
337 } 337 }
338 338
339 virtual void SetUpCommandLine(base::CommandLine* command_line) override { 339 void SetUpCommandLine(base::CommandLine* command_line) override {
340 OobeBaseTest::SetUpCommandLine(command_line); 340 OobeBaseTest::SetUpCommandLine(command_line);
341 fake_cws_->Init(embedded_test_server()); 341 fake_cws_->Init(embedded_test_server());
342 } 342 }
343 343
344 void LaunchApp(const std::string& app_id, bool diagnostic_mode) { 344 void LaunchApp(const std::string& app_id, bool diagnostic_mode) {
345 bool new_kiosk_ui = KioskAppMenuHandler::EnableNewKioskUI(); 345 bool new_kiosk_ui = KioskAppMenuHandler::EnableNewKioskUI();
346 GetLoginUI()->CallJavascriptFunction(new_kiosk_ui ? 346 GetLoginUI()->CallJavascriptFunction(new_kiosk_ui ?
347 kLaunchAppForTestNewAPI : kLaunchAppForTestOldAPI, 347 kLaunchAppForTestNewAPI : kLaunchAppForTestOldAPI,
348 base::StringValue(app_id), 348 base::StringValue(app_id),
349 base::FundamentalValue(diagnostic_mode)); 349 base::FundamentalValue(diagnostic_mode));
(...skipping 717 matching lines...) Expand 10 before | Expand all | Expand 10 after
1067 // Make cros settings untrusted. 1067 // Make cros settings untrusted.
1068 MakeCrosSettingsPermanentlyUntrusted(); 1068 MakeCrosSettingsPermanentlyUntrusted();
1069 1069
1070 // Check that the attempt to auto-launch a kiosk app fails with an error. 1070 // Check that the attempt to auto-launch a kiosk app fails with an error.
1071 OobeScreenWaiter(OobeDisplay::SCREEN_ERROR_MESSAGE).Wait(); 1071 OobeScreenWaiter(OobeDisplay::SCREEN_ERROR_MESSAGE).Wait();
1072 } 1072 }
1073 1073
1074 class KioskUpdateTest : public KioskTest { 1074 class KioskUpdateTest : public KioskTest {
1075 public: 1075 public:
1076 KioskUpdateTest() {} 1076 KioskUpdateTest() {}
1077 virtual ~KioskUpdateTest() {} 1077 ~KioskUpdateTest() override {}
1078 1078
1079 protected: 1079 protected:
1080 virtual void SetUp() override { 1080 void SetUp() override {
1081 fake_disk_mount_manager_ = new KioskFakeDiskMountManager(); 1081 fake_disk_mount_manager_ = new KioskFakeDiskMountManager();
1082 disks::DiskMountManager::InitializeForTesting(fake_disk_mount_manager_); 1082 disks::DiskMountManager::InitializeForTesting(fake_disk_mount_manager_);
1083 1083
1084 KioskTest::SetUp(); 1084 KioskTest::SetUp();
1085 } 1085 }
1086 1086
1087 virtual void TearDown() override { 1087 void TearDown() override {
1088 disks::DiskMountManager::Shutdown(); 1088 disks::DiskMountManager::Shutdown();
1089 1089
1090 KioskTest::TearDown(); 1090 KioskTest::TearDown();
1091 } 1091 }
1092 1092
1093 virtual void SetUpOnMainThread() override { 1093 void SetUpOnMainThread() override { KioskTest::SetUpOnMainThread(); }
1094 KioskTest::SetUpOnMainThread();
1095 }
1096 1094
1097 void PreCacheApp(const std::string& app_id, 1095 void PreCacheApp(const std::string& app_id,
1098 const std::string& version, 1096 const std::string& version,
1099 const std::string& crx_file) { 1097 const std::string& crx_file) {
1100 set_test_app_id(app_id); 1098 set_test_app_id(app_id);
1101 set_test_app_version(version); 1099 set_test_app_version(version);
1102 set_test_crx_file(crx_file); 1100 set_test_crx_file(crx_file);
1103 1101
1104 KioskAppManager* manager = KioskAppManager::Get(); 1102 KioskAppManager* manager = KioskAppManager::Get();
1105 AppDataLoadWaiter waiter(manager, app_id, version); 1103 AppDataLoadWaiter waiter(manager, app_id, version);
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
1169 const std::string& app_id) 1167 const std::string& app_id)
1170 : runner_(NULL), 1168 : runner_(NULL),
1171 manager_(manager), 1169 manager_(manager),
1172 app_id_(app_id), 1170 app_id_(app_id),
1173 quit_(false), 1171 quit_(false),
1174 update_success_(false), 1172 update_success_(false),
1175 app_update_notified_(false) { 1173 app_update_notified_(false) {
1176 manager_->AddObserver(this); 1174 manager_->AddObserver(this);
1177 } 1175 }
1178 1176
1179 virtual ~KioskAppExternalUpdateWaiter() { manager_->RemoveObserver(this); } 1177 ~KioskAppExternalUpdateWaiter() override { manager_->RemoveObserver(this); }
1180 1178
1181 void Wait() { 1179 void Wait() {
1182 if (quit_) 1180 if (quit_)
1183 return; 1181 return;
1184 runner_ = new content::MessageLoopRunner; 1182 runner_ = new content::MessageLoopRunner;
1185 runner_->Run(); 1183 runner_->Run();
1186 } 1184 }
1187 1185
1188 bool update_success() const { return update_success_; } 1186 bool update_success() const { return update_success_; }
1189 1187
1190 bool app_update_notified() const { return app_update_notified_; } 1188 bool app_update_notified() const { return app_update_notified_; }
1191 1189
1192 private: 1190 private:
1193 // KioskAppManagerObserver overrides: 1191 // KioskAppManagerObserver overrides:
1194 virtual void OnKioskAppCacheUpdated(const std::string& app_id) override { 1192 void OnKioskAppCacheUpdated(const std::string& app_id) override {
1195 if (app_id_ != app_id) 1193 if (app_id_ != app_id)
1196 return; 1194 return;
1197 app_update_notified_ = true; 1195 app_update_notified_ = true;
1198 } 1196 }
1199 1197
1200 virtual void OnKioskAppExternalUpdateComplete(bool success) override { 1198 void OnKioskAppExternalUpdateComplete(bool success) override {
1201 quit_ = true; 1199 quit_ = true;
1202 update_success_ = success; 1200 update_success_ = success;
1203 if (runner_.get()) 1201 if (runner_.get())
1204 runner_->Quit(); 1202 runner_->Quit();
1205 } 1203 }
1206 1204
1207 scoped_refptr<content::MessageLoopRunner> runner_; 1205 scoped_refptr<content::MessageLoopRunner> runner_;
1208 KioskAppManager* manager_; 1206 KioskAppManager* manager_;
1209 const std::string app_id_; 1207 const std::string app_id_;
1210 bool quit_; 1208 bool quit_;
(...skipping 10 matching lines...) Expand all
1221 const std::string& version) 1219 const std::string& version)
1222 : runner_(NULL), 1220 : runner_(NULL),
1223 manager_(manager), 1221 manager_(manager),
1224 loaded_(false), 1222 loaded_(false),
1225 quit_(false), 1223 quit_(false),
1226 app_id_(app_id), 1224 app_id_(app_id),
1227 version_(version) { 1225 version_(version) {
1228 manager_->AddObserver(this); 1226 manager_->AddObserver(this);
1229 } 1227 }
1230 1228
1231 virtual ~AppDataLoadWaiter() { manager_->RemoveObserver(this); } 1229 ~AppDataLoadWaiter() override { manager_->RemoveObserver(this); }
1232 1230
1233 void Wait() { 1231 void Wait() {
1234 if (quit_) 1232 if (quit_)
1235 return; 1233 return;
1236 runner_ = new content::MessageLoopRunner; 1234 runner_ = new content::MessageLoopRunner;
1237 runner_->Run(); 1235 runner_->Run();
1238 } 1236 }
1239 1237
1240 bool loaded() const { return loaded_; } 1238 bool loaded() const { return loaded_; }
1241 1239
1242 private: 1240 private:
1243 // KioskAppManagerObserver overrides: 1241 // KioskAppManagerObserver overrides:
1244 virtual void OnKioskExtensionLoadedInCache( 1242 void OnKioskExtensionLoadedInCache(const std::string& app_id) override {
1245 const std::string& app_id) override {
1246 std::string cached_version; 1243 std::string cached_version;
1247 base::FilePath file_path; 1244 base::FilePath file_path;
1248 if (!manager_->GetCachedCrx(app_id_, &file_path, &cached_version)) 1245 if (!manager_->GetCachedCrx(app_id_, &file_path, &cached_version))
1249 return; 1246 return;
1250 if (version_ != cached_version) 1247 if (version_ != cached_version)
1251 return; 1248 return;
1252 loaded_ = true; 1249 loaded_ = true;
1253 quit_ = true; 1250 quit_ = true;
1254 if (runner_.get()) 1251 if (runner_.get())
1255 runner_->Quit(); 1252 runner_->Quit();
1256 } 1253 }
1257 1254
1258 virtual void OnKioskExtensionDownloadFailed( 1255 void OnKioskExtensionDownloadFailed(const std::string& app_id) override {
1259 const std::string& app_id) override {
1260 loaded_ = false; 1256 loaded_ = false;
1261 quit_ = true; 1257 quit_ = true;
1262 if (runner_.get()) 1258 if (runner_.get())
1263 runner_->Quit(); 1259 runner_->Quit();
1264 } 1260 }
1265 1261
1266 scoped_refptr<content::MessageLoopRunner> runner_; 1262 scoped_refptr<content::MessageLoopRunner> runner_;
1267 KioskAppManager* manager_; 1263 KioskAppManager* manager_;
1268 bool loaded_; 1264 bool loaded_;
1269 bool quit_; 1265 bool quit_;
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
1585 EXPECT_EQ("2.0.0", GetInstalledAppVersion().GetString()); 1581 EXPECT_EQ("2.0.0", GetInstalledAppVersion().GetString());
1586 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); 1582 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message();
1587 } 1583 }
1588 1584
1589 class KioskEnterpriseTest : public KioskTest { 1585 class KioskEnterpriseTest : public KioskTest {
1590 protected: 1586 protected:
1591 KioskEnterpriseTest() { 1587 KioskEnterpriseTest() {
1592 set_use_consumer_kiosk_mode(false); 1588 set_use_consumer_kiosk_mode(false);
1593 } 1589 }
1594 1590
1595 virtual void SetUpInProcessBrowserTestFixture() override { 1591 void SetUpInProcessBrowserTestFixture() override {
1596 device_policy_test_helper_.MarkAsEnterpriseOwned(); 1592 device_policy_test_helper_.MarkAsEnterpriseOwned();
1597 device_policy_test_helper_.InstallOwnerKey(); 1593 device_policy_test_helper_.InstallOwnerKey();
1598 1594
1599 KioskTest::SetUpInProcessBrowserTestFixture(); 1595 KioskTest::SetUpInProcessBrowserTestFixture();
1600 } 1596 }
1601 1597
1602 virtual void SetUpOnMainThread() override { 1598 void SetUpOnMainThread() override {
1603 KioskTest::SetUpOnMainThread(); 1599 KioskTest::SetUpOnMainThread();
1604 1600
1605 // Configure OAuth authentication. 1601 // Configure OAuth authentication.
1606 GaiaUrls* gaia_urls = GaiaUrls::GetInstance(); 1602 GaiaUrls* gaia_urls = GaiaUrls::GetInstance();
1607 1603
1608 // This token satisfies the userinfo.email request from 1604 // This token satisfies the userinfo.email request from
1609 // DeviceOAuth2TokenService used in token validation. 1605 // DeviceOAuth2TokenService used in token validation.
1610 FakeGaia::AccessTokenInfo userinfo_token_info; 1606 FakeGaia::AccessTokenInfo userinfo_token_info;
1611 userinfo_token_info.token = kTestUserinfoToken; 1607 userinfo_token_info.token = kTestUserinfoToken;
1612 userinfo_token_info.scopes.insert( 1608 userinfo_token_info.scopes.insert(
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
1766 } 1762 }
1767 1763
1768 // Specialized test fixture for testing kiosk mode on the 1764 // Specialized test fixture for testing kiosk mode on the
1769 // hidden WebUI initialization flow for slow hardware. 1765 // hidden WebUI initialization flow for slow hardware.
1770 class KioskHiddenWebUITest : public KioskTest, 1766 class KioskHiddenWebUITest : public KioskTest,
1771 public ash::DesktopBackgroundControllerObserver { 1767 public ash::DesktopBackgroundControllerObserver {
1772 public: 1768 public:
1773 KioskHiddenWebUITest() : wallpaper_loaded_(false) {} 1769 KioskHiddenWebUITest() : wallpaper_loaded_(false) {}
1774 1770
1775 // KioskTest overrides: 1771 // KioskTest overrides:
1776 virtual void SetUpCommandLine(base::CommandLine* command_line) override { 1772 void SetUpCommandLine(base::CommandLine* command_line) override {
1777 KioskTest::SetUpCommandLine(command_line); 1773 KioskTest::SetUpCommandLine(command_line);
1778 command_line->AppendSwitch(switches::kDisableBootAnimation); 1774 command_line->AppendSwitch(switches::kDisableBootAnimation);
1779 } 1775 }
1780 1776
1781 virtual void SetUpOnMainThread() override { 1777 void SetUpOnMainThread() override {
1782 KioskTest::SetUpOnMainThread(); 1778 KioskTest::SetUpOnMainThread();
1783 ash::Shell::GetInstance()->desktop_background_controller() 1779 ash::Shell::GetInstance()->desktop_background_controller()
1784 ->AddObserver(this); 1780 ->AddObserver(this);
1785 } 1781 }
1786 1782
1787 virtual void TearDownOnMainThread() override { 1783 void TearDownOnMainThread() override {
1788 ash::Shell::GetInstance()->desktop_background_controller() 1784 ash::Shell::GetInstance()->desktop_background_controller()
1789 ->RemoveObserver(this); 1785 ->RemoveObserver(this);
1790 KioskTest::TearDownOnMainThread(); 1786 KioskTest::TearDownOnMainThread();
1791 } 1787 }
1792 1788
1793 void WaitForWallpaper() { 1789 void WaitForWallpaper() {
1794 if (!wallpaper_loaded_) { 1790 if (!wallpaper_loaded_) {
1795 runner_ = new content::MessageLoopRunner; 1791 runner_ = new content::MessageLoopRunner;
1796 runner_->Run(); 1792 runner_->Run();
1797 } 1793 }
1798 } 1794 }
1799 1795
1800 bool wallpaper_loaded() const { return wallpaper_loaded_; } 1796 bool wallpaper_loaded() const { return wallpaper_loaded_; }
1801 1797
1802 // ash::DesktopBackgroundControllerObserver overrides: 1798 // ash::DesktopBackgroundControllerObserver overrides:
1803 virtual void OnWallpaperDataChanged() override { 1799 void OnWallpaperDataChanged() override {
1804 wallpaper_loaded_ = true; 1800 wallpaper_loaded_ = true;
1805 if (runner_.get()) 1801 if (runner_.get())
1806 runner_->Quit(); 1802 runner_->Quit();
1807 } 1803 }
1808 1804
1809 bool wallpaper_loaded_; 1805 bool wallpaper_loaded_;
1810 scoped_refptr<content::MessageLoopRunner> runner_; 1806 scoped_refptr<content::MessageLoopRunner> runner_;
1811 1807
1812 DISALLOW_COPY_AND_ASSIGN(KioskHiddenWebUITest); 1808 DISALLOW_COPY_AND_ASSIGN(KioskHiddenWebUITest);
1813 }; 1809 };
(...skipping 24 matching lines...) Expand all
1838 content::WindowedNotificationObserver( 1834 content::WindowedNotificationObserver(
1839 chrome::NOTIFICATION_KIOSK_AUTOLAUNCH_WARNING_VISIBLE, 1835 chrome::NOTIFICATION_KIOSK_AUTOLAUNCH_WARNING_VISIBLE,
1840 content::NotificationService::AllSources()).Wait(); 1836 content::NotificationService::AllSources()).Wait();
1841 1837
1842 // Wait for the wallpaper to load. 1838 // Wait for the wallpaper to load.
1843 WaitForWallpaper(); 1839 WaitForWallpaper();
1844 EXPECT_TRUE(wallpaper_loaded()); 1840 EXPECT_TRUE(wallpaper_loaded());
1845 } 1841 }
1846 1842
1847 } // namespace chromeos 1843 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/fake_login_utils.h ('k') | chrome/browser/chromeos/login/login_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698