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

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

Issue 1019283004: Switch to direct use of OwnerSettingsServiceChromeOS::Set() in tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Replace inheritance with composition. Created 5 years, 8 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 17 matching lines...) Expand all
28 #include "chrome/browser/chromeos/login/startup_utils.h" 28 #include "chrome/browser/chromeos/login/startup_utils.h"
29 #include "chrome/browser/chromeos/login/test/app_window_waiter.h" 29 #include "chrome/browser/chromeos/login/test/app_window_waiter.h"
30 #include "chrome/browser/chromeos/login/test/oobe_base_test.h" 30 #include "chrome/browser/chromeos/login/test/oobe_base_test.h"
31 #include "chrome/browser/chromeos/login/test/oobe_screen_waiter.h" 31 #include "chrome/browser/chromeos/login/test/oobe_screen_waiter.h"
32 #include "chrome/browser/chromeos/login/ui/login_display_host.h" 32 #include "chrome/browser/chromeos/login/ui/login_display_host.h"
33 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" 33 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h"
34 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" 34 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h"
35 #include "chrome/browser/chromeos/login/users/mock_user_manager.h" 35 #include "chrome/browser/chromeos/login/users/mock_user_manager.h"
36 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" 36 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h"
37 #include "chrome/browser/chromeos/login/wizard_controller.h" 37 #include "chrome/browser/chromeos/login/wizard_controller.h"
38 #include "chrome/browser/chromeos/ownership/fake_owner_settings_service.h"
38 #include "chrome/browser/chromeos/policy/device_policy_cros_browser_test.h" 39 #include "chrome/browser/chromeos/policy/device_policy_cros_browser_test.h"
39 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" 40 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h"
40 #include "chrome/browser/chromeos/profiles/profile_helper.h" 41 #include "chrome/browser/chromeos/profiles/profile_helper.h"
41 #include "chrome/browser/chromeos/settings/cros_settings.h" 42 #include "chrome/browser/chromeos/settings/cros_settings.h"
42 #include "chrome/browser/chromeos/settings/device_oauth2_token_service.h" 43 #include "chrome/browser/chromeos/settings/device_oauth2_token_service.h"
43 #include "chrome/browser/chromeos/settings/device_oauth2_token_service_factory.h " 44 #include "chrome/browser/chromeos/settings/device_oauth2_token_service_factory.h "
44 #include "chrome/browser/chromeos/settings/device_settings_service.h" 45 #include "chrome/browser/chromeos/settings/device_settings_service.h"
46 #include "chrome/browser/chromeos/settings/scoped_cros_settings_test_helper.h"
45 #include "chrome/browser/extensions/extension_service.h" 47 #include "chrome/browser/extensions/extension_service.h"
46 #include "chrome/browser/profiles/profile_impl.h" 48 #include "chrome/browser/profiles/profile_impl.h"
47 #include "chrome/browser/profiles/profile_manager.h" 49 #include "chrome/browser/profiles/profile_manager.h"
48 #include "chrome/browser/profiles/profiles_state.h" 50 #include "chrome/browser/profiles/profiles_state.h"
49 #include "chrome/browser/signin/signin_manager_factory.h" 51 #include "chrome/browser/signin/signin_manager_factory.h"
50 #include "chrome/browser/ui/webui/chromeos/login/kiosk_app_menu_handler.h" 52 #include "chrome/browser/ui/webui/chromeos/login/kiosk_app_menu_handler.h"
51 #include "chrome/common/chrome_constants.h" 53 #include "chrome/common/chrome_constants.h"
52 #include "chrome/common/chrome_paths.h" 54 #include "chrome/common/chrome_paths.h"
53 #include "chrome/common/pref_names.h" 55 #include "chrome/common/pref_names.h"
54 #include "chromeos/chromeos_switches.h" 56 #include "chromeos/chromeos_switches.h"
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 bool untrusted_check_running_; 419 bool untrusted_check_running_;
418 base::RunLoop run_loop_; 420 base::RunLoop run_loop_;
419 421
420 void CheckIfUntrusted(); 422 void CheckIfUntrusted();
421 423
422 DISALLOW_COPY_AND_ASSIGN(CrosSettingsPermanentlyUntrustedMaker); 424 DISALLOW_COPY_AND_ASSIGN(CrosSettingsPermanentlyUntrustedMaker);
423 }; 425 };
424 426
425 CrosSettingsPermanentlyUntrustedMaker::CrosSettingsPermanentlyUntrustedMaker() 427 CrosSettingsPermanentlyUntrustedMaker::CrosSettingsPermanentlyUntrustedMaker()
426 : untrusted_check_running_(false) { 428 : untrusted_check_running_(false) {
427 DeviceSettingsService::Get()->AddObserver(this); 429 DeviceSettingsService::Get()->AddObserver(this);
Ivan Podogov 2015/03/31 14:40:21 I was overly optimistic on using TestingProfile::B
428 430
429 policy::DevicePolicyCrosTestHelper().InstallOwnerKey(); 431 policy::DevicePolicyCrosTestHelper().InstallOwnerKey();
430 DeviceSettingsService::Get()->OwnerKeySet(true); 432 DeviceSettingsService::Get()->OwnerKeySet(true);
431 433
432 run_loop_.Run(); 434 run_loop_.Run();
433 } 435 }
434 436
435 void CrosSettingsPermanentlyUntrustedMaker::OwnershipStatusChanged() { 437 void CrosSettingsPermanentlyUntrustedMaker::OwnershipStatusChanged() {
436 if (untrusted_check_running_) 438 if (untrusted_check_running_)
437 return; 439 return;
(...skipping 24 matching lines...) Expand all
462 return; 464 return;
463 465
464 DeviceSettingsService::Get()->RemoveObserver(this); 466 DeviceSettingsService::Get()->RemoveObserver(this);
465 run_loop_.Quit(); 467 run_loop_.Quit();
466 } 468 }
467 469
468 } // namespace 470 } // namespace
469 471
470 class KioskTest : public OobeBaseTest { 472 class KioskTest : public OobeBaseTest {
471 public: 473 public:
472 KioskTest() : use_consumer_kiosk_mode_(true), 474 KioskTest() : use_consumer_kiosk_mode_(true), fake_cws_(new FakeCWS) {
473 fake_cws_(new FakeCWS) {
474 set_exit_when_last_browser_closes(false); 475 set_exit_when_last_browser_closes(false);
475 } 476 }
476 477
477 ~KioskTest() override {} 478 ~KioskTest() override {}
478 479
479 protected: 480 protected:
480 void SetUp() override { 481 void SetUp() override {
481 test_app_id_ = kTestKioskApp; 482 test_app_id_ = kTestKioskApp;
482 set_test_app_version("1.0.0"); 483 set_test_app_version("1.0.0");
483 set_test_crx_file(test_app_id() + ".crx"); 484 set_test_crx_file(test_app_id() + ".crx");
484 needs_background_networking_ = true; 485 needs_background_networking_ = true;
485 mock_user_manager_.reset(new MockUserManager); 486 mock_user_manager_.reset(new MockUserManager);
486 ProfileHelper::SetAlwaysReturnPrimaryUserForTesting(true); 487 ProfileHelper::SetAlwaysReturnPrimaryUserForTesting(true);
487 AppLaunchController::SkipSplashWaitForTesting(); 488 AppLaunchController::SkipSplashWaitForTesting();
488 AppLaunchController::SetNetworkWaitForTesting(kTestNetworkTimeoutSeconds); 489 AppLaunchController::SetNetworkWaitForTesting(kTestNetworkTimeoutSeconds);
489 490
490 OobeBaseTest::SetUp(); 491 OobeBaseTest::SetUp();
491 } 492 }
492 493
493 void TearDown() override { 494 void TearDown() override {
494 ProfileHelper::SetAlwaysReturnPrimaryUserForTesting(false); 495 ProfileHelper::SetAlwaysReturnPrimaryUserForTesting(false);
495 OobeBaseTest::TearDown(); 496 OobeBaseTest::TearDown();
496 } 497 }
497 498
498 void SetUpOnMainThread() override { 499 void SetUpOnMainThread() override {
499 OobeBaseTest::SetUpOnMainThread(); 500 OobeBaseTest::SetUpOnMainThread();
500 // Needed to avoid showing Gaia screen instead of owner signin for 501 // Needed to avoid showing Gaia screen instead of owner signin for
501 // consumer network down test cases. 502 // consumer network down test cases.
502 StartupUtils::MarkDeviceRegistered(base::Closure()); 503 StartupUtils::MarkDeviceRegistered(base::Closure());
504 owner_settings_service_.reset(
505 new FakeOwnerSettingsService(ProfileManager::GetPrimaryUserProfile()));
503 } 506 }
504 507
505 void TearDownOnMainThread() override { 508 void TearDownOnMainThread() override {
506 AppLaunchController::SetNetworkTimeoutCallbackForTesting(NULL); 509 AppLaunchController::SetNetworkTimeoutCallbackForTesting(NULL);
507 AppLaunchSigninScreen::SetUserManagerForTesting(NULL); 510 AppLaunchSigninScreen::SetUserManagerForTesting(NULL);
508 511
509 OobeBaseTest::TearDownOnMainThread(); 512 OobeBaseTest::TearDownOnMainThread();
510 513
511 // Clean up while main thread still runs. 514 // Clean up while main thread still runs.
512 // See http://crbug.com/176659. 515 // See http://crbug.com/176659.
(...skipping 10 matching lines...) Expand all
523 GetLoginUI()->CallJavascriptFunction(new_kiosk_ui ? 526 GetLoginUI()->CallJavascriptFunction(new_kiosk_ui ?
524 kLaunchAppForTestNewAPI : kLaunchAppForTestOldAPI, 527 kLaunchAppForTestNewAPI : kLaunchAppForTestOldAPI,
525 base::StringValue(app_id), 528 base::StringValue(app_id),
526 base::FundamentalValue(diagnostic_mode)); 529 base::FundamentalValue(diagnostic_mode));
527 } 530 }
528 531
529 void ReloadKioskApps() { 532 void ReloadKioskApps() {
530 SetupTestAppUpdateCheck(); 533 SetupTestAppUpdateCheck();
531 534
532 // Remove then add to ensure NOTIFICATION_KIOSK_APPS_LOADED fires. 535 // Remove then add to ensure NOTIFICATION_KIOSK_APPS_LOADED fires.
533 KioskAppManager::Get()->RemoveApp(test_app_id_); 536 KioskAppManager::Get()->RemoveApp(test_app_id_,
534 KioskAppManager::Get()->AddApp(test_app_id_); 537 owner_settings_service_.get());
538 KioskAppManager::Get()->AddApp(test_app_id_, owner_settings_service_.get());
535 } 539 }
536 540
537 void FireKioskAppSettingsChanged() { 541 void FireKioskAppSettingsChanged() {
538 KioskAppManager::Get()->UpdateAppData(); 542 KioskAppManager::Get()->UpdateAppData();
539 } 543 }
540 544
541 void SetupTestAppUpdateCheck() { 545 void SetupTestAppUpdateCheck() {
542 if (!test_app_version().empty()) { 546 if (!test_app_version().empty()) {
543 fake_cws_->SetUpdateCrx( 547 fake_cws_->SetUpdateCrx(
544 test_app_id(), test_crx_file(), test_app_version()); 548 test_app_id(), test_crx_file(), test_app_version());
545 } 549 }
546 } 550 }
547 551
548 void ReloadAutolaunchKioskApps() { 552 void ReloadAutolaunchKioskApps() {
549 SetupTestAppUpdateCheck(); 553 SetupTestAppUpdateCheck();
550 554
551 KioskAppManager::Get()->AddApp(test_app_id_); 555 KioskAppManager::Get()->AddApp(test_app_id_, owner_settings_service_.get());
552 KioskAppManager::Get()->SetAutoLaunchApp(test_app_id_); 556 KioskAppManager::Get()->SetAutoLaunchApp(test_app_id_,
557 owner_settings_service_.get());
553 } 558 }
554 559
555 void StartUIForAppLaunch() { 560 void StartUIForAppLaunch() {
556 if (use_consumer_kiosk_mode_) 561 if (use_consumer_kiosk_mode_)
557 EnableConsumerKioskMode(); 562 EnableConsumerKioskMode();
558 563
559 // Start UI 564 // Start UI
560 chromeos::WizardController::SkipPostLoginScreensForTesting(); 565 chromeos::WizardController::SkipPostLoginScreensForTesting();
561 chromeos::WizardController* wizard_controller = 566 chromeos::WizardController* wizard_controller =
562 chromeos::WizardController::default_controller(); 567 chromeos::WizardController::default_controller();
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
786 void set_test_crx_file(const std::string& filename) { 791 void set_test_crx_file(const std::string& filename) {
787 test_crx_file_ = filename; 792 test_crx_file_ = filename;
788 } 793 }
789 const std::string& test_crx_file() const { return test_crx_file_; } 794 const std::string& test_crx_file() const { return test_crx_file_; }
790 FakeCWS* fake_cws() { return fake_cws_.get(); } 795 FakeCWS* fake_cws() { return fake_cws_.get(); }
791 796
792 void set_use_consumer_kiosk_mode(bool use) { 797 void set_use_consumer_kiosk_mode(bool use) {
793 use_consumer_kiosk_mode_ = use; 798 use_consumer_kiosk_mode_ = use;
794 } 799 }
795 800
801 scoped_ptr<FakeOwnerSettingsService> owner_settings_service_;
802
796 private: 803 private:
797 bool use_consumer_kiosk_mode_; 804 bool use_consumer_kiosk_mode_;
798 std::string test_app_id_; 805 std::string test_app_id_;
799 std::string test_app_version_; 806 std::string test_app_version_;
800 std::string test_crx_file_; 807 std::string test_crx_file_;
801 scoped_ptr<FakeCWS> fake_cws_; 808 scoped_ptr<FakeCWS> fake_cws_;
802 scoped_ptr<MockUserManager> mock_user_manager_; 809 scoped_ptr<MockUserManager> mock_user_manager_;
803 810
804 DISALLOW_COPY_AND_ASSIGN(KioskTest); 811 DISALLOW_COPY_AND_ASSIGN(KioskTest);
805 }; 812 };
(...skipping 1176 matching lines...) Expand 10 before | Expand all | Expand 10 after
1982 content::WindowedNotificationObserver( 1989 content::WindowedNotificationObserver(
1983 chrome::NOTIFICATION_KIOSK_AUTOLAUNCH_WARNING_VISIBLE, 1990 chrome::NOTIFICATION_KIOSK_AUTOLAUNCH_WARNING_VISIBLE,
1984 content::NotificationService::AllSources()).Wait(); 1991 content::NotificationService::AllSources()).Wait();
1985 1992
1986 // Wait for the wallpaper to load. 1993 // Wait for the wallpaper to load.
1987 WaitForWallpaper(); 1994 WaitForWallpaper();
1988 EXPECT_TRUE(wallpaper_loaded()); 1995 EXPECT_TRUE(wallpaper_loaded());
1989 } 1996 }
1990 1997
1991 } // namespace chromeos 1998 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698