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

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

Issue 212653004: Update server-backed state key generation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix re-enrollment test. Created 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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 "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/command_line.h" 6 #include "base/command_line.h"
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/path_service.h" 8 #include "base/path_service.h"
9 #include "base/prefs/pref_registry_simple.h" 9 #include "base/prefs/pref_registry_simple.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 #include "chrome/common/chrome_switches.h" 44 #include "chrome/common/chrome_switches.h"
45 #include "chrome/common/pref_names.h" 45 #include "chrome/common/pref_names.h"
46 #include "chrome/test/base/ui_test_utils.h" 46 #include "chrome/test/base/ui_test_utils.h"
47 #include "chromeos/audio/cras_audio_handler.h" 47 #include "chromeos/audio/cras_audio_handler.h"
48 #include "chromeos/chromeos_switches.h" 48 #include "chromeos/chromeos_switches.h"
49 #include "chromeos/chromeos_test_utils.h" 49 #include "chromeos/chromeos_test_utils.h"
50 #include "chromeos/dbus/dbus_thread_manager.h" 50 #include "chromeos/dbus/dbus_thread_manager.h"
51 #include "chromeos/dbus/fake_dbus_thread_manager.h" 51 #include "chromeos/dbus/fake_dbus_thread_manager.h"
52 #include "chromeos/dbus/fake_session_manager_client.h" 52 #include "chromeos/dbus/fake_session_manager_client.h"
53 #include "chromeos/network/network_state_handler.h" 53 #include "chromeos/network/network_state_handler.h"
54 #include "chromeos/system/mock_statistics_provider.h"
55 #include "chromeos/system/statistics_provider.h"
54 #include "content/public/test/browser_test_utils.h" 56 #include "content/public/test/browser_test_utils.h"
55 #include "content/public/test/test_utils.h" 57 #include "content/public/test/test_utils.h"
56 #include "grit/generated_resources.h" 58 #include "grit/generated_resources.h"
57 #include "net/test/spawned_test_server/spawned_test_server.h" 59 #include "net/test/spawned_test_server/spawned_test_server.h"
58 #include "testing/gmock/include/gmock/gmock.h" 60 #include "testing/gmock/include/gmock/gmock.h"
59 #include "testing/gtest/include/gtest/gtest.h" 61 #include "testing/gtest/include/gtest/gtest.h"
60 #include "third_party/icu/source/common/unicode/locid.h" 62 #include "third_party/icu/source/common/unicode/locid.h"
61 #include "ui/base/accelerators/accelerator.h" 63 #include "ui/base/accelerators/accelerator.h"
62 #include "ui/base/l10n/l10n_util.h" 64 #include "ui/base/l10n/l10n_util.h"
63 65
64 using ::testing::Exactly; 66 using ::testing::Exactly;
67 using ::testing::Invoke;
65 using ::testing::Return; 68 using ::testing::Return;
66 69
67 namespace chromeos { 70 namespace chromeos {
68 71
69 namespace { 72 namespace {
70 const char kUsername[] = "test_user@managedchrome.com"; 73 const char kUsername[] = "test_user@managedchrome.com";
71 const char kPassword[] = "test_password"; 74 const char kPassword[] = "test_password";
72 75
73 class PrefStoreStub : public TestingPrefStore { 76 class PrefStoreStub : public TestingPrefStore {
74 public: 77 public:
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 WrongHWIDScreen* screen = 510 WrongHWIDScreen* screen =
508 WizardController::default_controller()->GetWrongHWIDScreen(); 511 WizardController::default_controller()->GetWrongHWIDScreen();
509 EXPECT_EQ(screen, WizardController::default_controller()->current_screen()); 512 EXPECT_EQ(screen, WizardController::default_controller()->current_screen());
510 513
511 // After warning is skipped, user returns to sign-in screen. 514 // After warning is skipped, user returns to sign-in screen.
512 // And this destroys WizardController. 515 // And this destroys WizardController.
513 OnExit(ScreenObserver::WRONG_HWID_WARNING_SKIPPED); 516 OnExit(ScreenObserver::WRONG_HWID_WARNING_SKIPPED);
514 EXPECT_FALSE(ExistingUserController::current_controller() == NULL); 517 EXPECT_FALSE(ExistingUserController::current_controller() == NULL);
515 } 518 }
516 519
517 IN_PROC_BROWSER_TEST_F(WizardControllerFlowTest, 520 class WizardControllerEnrollmentFlowTest : public WizardControllerFlowTest {
521 protected:
522 WizardControllerEnrollmentFlowTest() {}
523
524 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
525 WizardControllerFlowTest::SetUpCommandLine(command_line);
526
527 command_line->AppendSwitch(
528 switches::kEnterpriseEnableForcedReEnrollment);
529 command_line->AppendSwitchASCII(
530 switches::kEnterpriseEnrollmentInitialModulus, "1");
531 command_line->AppendSwitchASCII(
532 switches::kEnterpriseEnrollmentModulusLimit, "2");
533 }
534
535 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE {
536 WizardControllerFlowTest::SetUpInProcessBrowserTestFixture();
537 system::StatisticsProvider::SetTestProvider(&statistics_provider_);
538 EXPECT_CALL(statistics_provider_, StartLoadingMachineStatistics(_, _));
539 EXPECT_CALL(statistics_provider_, GetMachineStatistic(_, _)).WillRepeatedly(
540 Invoke(this, &WizardControllerEnrollmentFlowTest::GetMachineStatistic));
541 EXPECT_CALL(statistics_provider_, GetMachineFlag(_, _)).WillRepeatedly(
542 Return(false));
543 EXPECT_CALL(statistics_provider_, Shutdown());
544 }
545
546 virtual void TearDownInProcessBrowserTestFixture() OVERRIDE {
547 system::StatisticsProvider::SetTestProvider(NULL);
548 WizardControllerFlowTest::TearDownInProcessBrowserTestFixture();
549 }
550
551 bool GetMachineStatistic(const std::string& name, std::string* result) {
552 if (name == system::kDiskSerialNumber) {
553 *result = "fake-disk-serial-number";
554 return true;
555 } else if (name == "serial_number") {
556 *result = "fake-machine-serial-number";
557 return true;
558 }
559
560 return false;
561 }
562
563 private:
564 system::MockStatisticsProvider statistics_provider_;
565
566 DISALLOW_COPY_AND_ASSIGN(WizardControllerEnrollmentFlowTest);
567 };
568
569 IN_PROC_BROWSER_TEST_F(WizardControllerEnrollmentFlowTest,
518 ControlFlowForcedReEnrollment) { 570 ControlFlowForcedReEnrollment) {
519 CommandLine::ForCurrentProcess()->AppendSwitch(
520 switches::kEnterpriseEnableForcedReEnrollment);
521 CommandLine::ForCurrentProcess()->AppendSwitchASCII(
522 switches::kEnterpriseEnrollmentInitialModulus, "1");
523 CommandLine::ForCurrentProcess()->AppendSwitchASCII(
524 switches::kEnterpriseEnrollmentModulusLimit, "2");
525
526 EXPECT_EQ(WizardController::default_controller()->GetNetworkScreen(), 571 EXPECT_EQ(WizardController::default_controller()->GetNetworkScreen(),
527 WizardController::default_controller()->current_screen()); 572 WizardController::default_controller()->current_screen());
528 EXPECT_CALL(*mock_network_screen_, Hide()).Times(1); 573 EXPECT_CALL(*mock_network_screen_, Hide()).Times(1);
529 EXPECT_CALL(*mock_eula_screen_, Show()).Times(1); 574 EXPECT_CALL(*mock_eula_screen_, Show()).Times(1);
530 OnExit(ScreenObserver::NETWORK_CONNECTED); 575 OnExit(ScreenObserver::NETWORK_CONNECTED);
531 576
532 EXPECT_EQ(WizardController::default_controller()->GetEulaScreen(), 577 EXPECT_EQ(WizardController::default_controller()->GetEulaScreen(),
533 WizardController::default_controller()->current_screen()); 578 WizardController::default_controller()->current_screen());
534 EXPECT_CALL(*mock_eula_screen_, Hide()).Times(1); 579 EXPECT_CALL(*mock_eula_screen_, Hide()).Times(1);
535 EXPECT_CALL(*mock_update_screen_, StartNetworkCheck()).Times(1); 580 EXPECT_CALL(*mock_update_screen_, StartNetworkCheck()).Times(1);
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
831 } 876 }
832 877
833 // TODO(dzhioev): Add test emaulating device with wrong HWID. 878 // TODO(dzhioev): Add test emaulating device with wrong HWID.
834 879
835 // TODO(nkostylev): Add test for WebUI accelerators http://crosbug.com/22571 880 // TODO(nkostylev): Add test for WebUI accelerators http://crosbug.com/22571
836 881
837 COMPILE_ASSERT(ScreenObserver::EXIT_CODES_COUNT == 20, 882 COMPILE_ASSERT(ScreenObserver::EXIT_CODES_COUNT == 20,
838 add_tests_for_new_control_flow_you_just_introduced); 883 add_tests_for_new_control_flow_you_just_introduced);
839 884
840 } // namespace chromeos 885 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698