Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / chromeos / login / supervised / supervised_user_test_base.cc
index 300de81..fb9ede2 100644 (file)
@@ -18,7 +18,9 @@
 #include "chrome/browser/chromeos/login/supervised/supervised_user_authentication.h"
 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h"
 #include "chrome/browser/chromeos/login/ui/webui_login_view.h"
+#include "chrome/browser/chromeos/login/users/chrome_user_manager.h"
 #include "chrome/browser/chromeos/login/users/supervised_user_manager.h"
+#include "chrome/browser/chromeos/login/users/supervised_user_manager_impl.h"
 #include "chrome/browser/chromeos/net/network_portal_detector_test_impl.h"
 #include "chrome/browser/chromeos/profiles/profile_helper.h"
 #include "chrome/browser/chromeos/settings/stub_cros_settings_provider.h"
@@ -219,6 +221,10 @@ void SupervisedUserTestBase::JSEval(const std::string& script) {
   EXPECT_TRUE(content::ExecuteScript(web_contents(), script)) << script;
 }
 
+void SupervisedUserTestBase::JSEvalOrExitBrowser(const std::string& script) {
+  ignore_result(content::ExecuteScript(web_contents(), script));
+}
+
 void SupervisedUserTestBase::JSExpectAsync(const std::string& function) {
   bool result;
   EXPECT_TRUE(content::ExecuteScriptAndExtractBool(
@@ -344,7 +350,7 @@ void SupervisedUserTestBase::StartUserCreation(
   content::RunAllBlockingPoolTasksUntilIdle();
 
   JSExpect(StringPrintf("%s == 'created'", kCurrentPage));
-  JSEval("$('supervised-user-creation-gotit-button').click()");
+  JSEvalOrExitBrowser("$('supervised-user-creation-gotit-button').click()");
 }
 
 void SupervisedUserTestBase::SigninAsSupervisedUser(
@@ -361,6 +367,13 @@ void SupervisedUserTestBase::SigninAsSupervisedUser(
   const user_manager::User* user =
       user_manager::UserManager::Get()->GetUsers().at(user_index);
   ASSERT_EQ(base::UTF8ToUTF16(expected_display_name), user->display_name());
+
+  // Currently FakeLoginUtils do not support first-run use cases.
+  // Clean first run flag before logging in.
+  static_cast<SupervisedUserManagerImpl*>(
+      ChromeUserManager::Get()->GetSupervisedUserManager())
+      ->CheckForFirstRun(user->email());
+
   LoginUser(user->email());
   if (check_homedir_calls)
     ::testing::Mock::VerifyAndClearExpectations(mock_homedir_methods_);