Upstream version 7.35.139.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / chromeos / login / wizard_controller_browsertest.cc
index 49ffcfd..3a86b02 100644 (file)
@@ -51,6 +51,8 @@
 #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"
@@ -62,6 +64,7 @@
 #include "ui/base/l10n/l10n_util.h"
 
 using ::testing::Exactly;
+using ::testing::Invoke;
 using ::testing::Return;
 
 namespace chromeos {
@@ -514,15 +517,58 @@ IN_PROC_BROWSER_TEST_F(WizardControllerFlowTest,
   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);