| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/chromeos/login/supervised/supervised_user_test_base.h" | 5 #include "chrome/browser/chromeos/login/supervised/supervised_user_test_base.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 JSSetTextField("#supervised-user-creation-password-confirm", | 328 JSSetTextField("#supervised-user-creation-password-confirm", |
| 329 kTestSupervisedUserPassword); | 329 kTestSupervisedUserPassword); |
| 330 | 330 |
| 331 JSEval("$('supervised-user-creation').updateNextButtonForUser_()"); | 331 JSEval("$('supervised-user-creation').updateNextButtonForUser_()"); |
| 332 JSExpect("!$('supervised-user-creation-next-button').disabled"); | 332 JSExpect("!$('supervised-user-creation-next-button').disabled"); |
| 333 } | 333 } |
| 334 | 334 |
| 335 void SupervisedUserTestBase::StartUserCreation( | 335 void SupervisedUserTestBase::StartUserCreation( |
| 336 const std::string& button_id, | 336 const std::string& button_id, |
| 337 const std::string& expected_display_name) { | 337 const std::string& expected_display_name) { |
| 338 base::RunLoop mount_wait_loop, add_key_wait_loop; |
| 339 mock_homedir_methods_->set_mount_callback(mount_wait_loop.QuitClosure()); |
| 340 mock_homedir_methods_->set_add_key_callback(add_key_wait_loop.QuitClosure()); |
| 338 EXPECT_CALL(*mock_homedir_methods_, MountEx(_, _, _, _)).Times(1); | 341 EXPECT_CALL(*mock_homedir_methods_, MountEx(_, _, _, _)).Times(1); |
| 339 EXPECT_CALL(*mock_homedir_methods_, AddKeyEx(_, _, _, _, _)).Times(1); | 342 EXPECT_CALL(*mock_homedir_methods_, AddKeyEx(_, _, _, _, _)).Times(1); |
| 340 | 343 |
| 341 JSEval(std::string("$('").append(button_id).append("').click()")); | 344 JSEval(std::string("$('").append(button_id).append("').click()")); |
| 342 | 345 |
| 346 mount_wait_loop.Run(); |
| 347 add_key_wait_loop.Run(); |
| 343 ::testing::Mock::VerifyAndClearExpectations(mock_homedir_methods_); | 348 ::testing::Mock::VerifyAndClearExpectations(mock_homedir_methods_); |
| 349 mock_homedir_methods_->set_mount_callback(base::Closure()); |
| 350 mock_homedir_methods_->set_add_key_callback(base::Closure()); |
| 344 | 351 |
| 345 EXPECT_TRUE(registration_utility_stub_->register_was_called()); | 352 EXPECT_TRUE(registration_utility_stub_->register_was_called()); |
| 346 EXPECT_EQ(registration_utility_stub_->display_name(), | 353 EXPECT_EQ(base::UTF8ToUTF16(expected_display_name), |
| 347 base::UTF8ToUTF16(expected_display_name)); | 354 registration_utility_stub_->display_name()); |
| 348 | 355 |
| 349 registration_utility_stub_->RunSuccessCallback("token"); | 356 registration_utility_stub_->RunSuccessCallback("token"); |
| 350 | 357 |
| 351 // Token writing moves control to BlockingPool and back. | 358 // Token writing moves control to BlockingPool and back. |
| 352 content::RunAllBlockingPoolTasksUntilIdle(); | 359 content::RunAllBlockingPoolTasksUntilIdle(); |
| 353 | 360 |
| 354 JSExpect(StringPrintf("%s == 'created'", kCurrentPage)); | 361 JSExpect(StringPrintf("%s == 'created'", kCurrentPage)); |
| 355 JSEvalOrExitBrowser("$('supervised-user-creation-gotit-button').click()"); | 362 JSEvalOrExitBrowser("$('supervised-user-creation-gotit-button').click()"); |
| 363 |
| 364 // TODO(achuith): There should probably be a wait for a specific event. |
| 365 content::RunAllPendingInMessageLoop(); |
| 356 } | 366 } |
| 357 | 367 |
| 358 void SupervisedUserTestBase::SigninAsSupervisedUser( | 368 void SupervisedUserTestBase::SigninAsSupervisedUser( |
| 359 bool check_homedir_calls, | 369 bool check_homedir_calls, |
| 360 int user_index, | 370 int user_index, |
| 361 const std::string& expected_display_name) { | 371 const std::string& expected_display_name) { |
| 362 if (check_homedir_calls) | 372 if (check_homedir_calls) |
| 363 EXPECT_CALL(*mock_homedir_methods_, MountEx(_, _, _, _)).Times(1); | 373 EXPECT_CALL(*mock_homedir_methods_, MountEx(_, _, _, _)).Times(1); |
| 364 | 374 |
| 365 // Log in as supervised user, make sure that everything works. | 375 // Log in as supervised user, make sure that everything works. |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 JSEval(StringPrintf( | 450 JSEval(StringPrintf( |
| 441 "$('pod-row').pods[%d].querySelector('.remove-warning-button').click()", | 451 "$('pod-row').pods[%d].querySelector('.remove-warning-button').click()", |
| 442 user_index)); | 452 user_index)); |
| 443 | 453 |
| 444 // Make sure there is no supervised user in list. | 454 // Make sure there is no supervised user in list. |
| 445 ASSERT_EQ(original_user_count - 1, | 455 ASSERT_EQ(original_user_count - 1, |
| 446 user_manager::UserManager::Get()->GetUsers().size()); | 456 user_manager::UserManager::Get()->GetUsers().size()); |
| 447 } | 457 } |
| 448 | 458 |
| 449 } // namespace chromeos | 459 } // namespace chromeos |
| OLD | NEW |