#include "chromeos/dbus/fake_dbus_thread_manager.h"
#include "chromeos/dbus/fake_session_manager_client.h"
#include "chromeos/network/network_state_handler.h"
+#include "chromeos/system/mock_statistics_provider.h"
+#include "chromeos/system/statistics_provider.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/test_utils.h"
#include "grit/generated_resources.h"
#include "ui/base/l10n/l10n_util.h"
using ::testing::Exactly;
+using ::testing::Invoke;
using ::testing::Return;
namespace chromeos {
EXPECT_FALSE(ExistingUserController::current_controller() == NULL);
}
-IN_PROC_BROWSER_TEST_F(WizardControllerFlowTest,
- ControlFlowForcedReEnrollment) {
- CommandLine::ForCurrentProcess()->AppendSwitch(
- switches::kEnterpriseEnableForcedReEnrollment);
- CommandLine::ForCurrentProcess()->AppendSwitchASCII(
- switches::kEnterpriseEnrollmentInitialModulus, "1");
- CommandLine::ForCurrentProcess()->AppendSwitchASCII(
- switches::kEnterpriseEnrollmentModulusLimit, "2");
+class WizardControllerEnrollmentFlowTest : public WizardControllerFlowTest {
+ protected:
+ WizardControllerEnrollmentFlowTest() {}
+
+ virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
+ WizardControllerFlowTest::SetUpCommandLine(command_line);
+
+ command_line->AppendSwitchASCII(
+ switches::kEnterpriseEnableForcedReEnrollment,
+ chromeos::AutoEnrollmentController::kForcedReEnrollmentAlways);
+ command_line->AppendSwitchASCII(
+ switches::kEnterpriseEnrollmentInitialModulus, "1");
+ command_line->AppendSwitchASCII(
+ switches::kEnterpriseEnrollmentModulusLimit, "2");
+ }
+
+ virtual void SetUpInProcessBrowserTestFixture() OVERRIDE {
+ WizardControllerFlowTest::SetUpInProcessBrowserTestFixture();
+ system::StatisticsProvider::SetTestProvider(&statistics_provider_);
+ EXPECT_CALL(statistics_provider_, StartLoadingMachineStatistics(_, _));
+ EXPECT_CALL(statistics_provider_, GetMachineStatistic(_, _)).WillRepeatedly(
+ Invoke(this, &WizardControllerEnrollmentFlowTest::GetMachineStatistic));
+ EXPECT_CALL(statistics_provider_, GetMachineFlag(_, _)).WillRepeatedly(
+ Return(false));
+ EXPECT_CALL(statistics_provider_, Shutdown());
+ }
+
+ virtual void TearDownInProcessBrowserTestFixture() OVERRIDE {
+ system::StatisticsProvider::SetTestProvider(NULL);
+ WizardControllerFlowTest::TearDownInProcessBrowserTestFixture();
+ }
+
+ bool GetMachineStatistic(const std::string& name, std::string* result) {
+ if (name == system::kDiskSerialNumber) {
+ *result = "fake-disk-serial-number";
+ return true;
+ } else if (name == "serial_number") {
+ *result = "fake-machine-serial-number";
+ return true;
+ }
+
+ return false;
+ }
+ private:
+ system::MockStatisticsProvider statistics_provider_;
+
+ DISALLOW_COPY_AND_ASSIGN(WizardControllerEnrollmentFlowTest);
+};
+
+IN_PROC_BROWSER_TEST_F(WizardControllerEnrollmentFlowTest,
+ ControlFlowForcedReEnrollment) {
EXPECT_EQ(WizardController::default_controller()->GetNetworkScreen(),
WizardController::default_controller()->current_screen());
EXPECT_CALL(*mock_network_screen_, Hide()).Times(1);