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

Side by Side Diff: chrome/browser/chromeos/login/supervised/supervised_user_test_base.cc

Issue 2540683002: Don't defer quitting in ExecuteScript and other helpers that use DOMMessageQueue. (Closed)
Patch Set: Spin the loop in PRE_CreateAndCancelSupervisedUser. Created 4 years 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
OLDNEW
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
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;
339 base::RunLoop add_key_wait_loop;
340 mock_homedir_methods_->set_mount_callback(mount_wait_loop.QuitClosure());
341 mock_homedir_methods_->set_add_key_callback(add_key_wait_loop.QuitClosure());
338 EXPECT_CALL(*mock_homedir_methods_, MountEx(_, _, _, _)).Times(1); 342 EXPECT_CALL(*mock_homedir_methods_, MountEx(_, _, _, _)).Times(1);
339 EXPECT_CALL(*mock_homedir_methods_, AddKeyEx(_, _, _, _, _)).Times(1); 343 EXPECT_CALL(*mock_homedir_methods_, AddKeyEx(_, _, _, _, _)).Times(1);
340 344
341 JSEval(std::string("$('").append(button_id).append("').click()")); 345 JSEval(std::string("$('").append(button_id).append("').click()"));
342 346
347 mount_wait_loop.Run();
348 add_key_wait_loop.Run();
343 ::testing::Mock::VerifyAndClearExpectations(mock_homedir_methods_); 349 ::testing::Mock::VerifyAndClearExpectations(mock_homedir_methods_);
350 mock_homedir_methods_->set_mount_callback(base::Closure());
351 mock_homedir_methods_->set_add_key_callback(base::Closure());
344 352
345 EXPECT_TRUE(registration_utility_stub_->register_was_called()); 353 EXPECT_TRUE(registration_utility_stub_->register_was_called());
346 EXPECT_EQ(registration_utility_stub_->display_name(), 354 EXPECT_EQ(base::UTF8ToUTF16(expected_display_name),
347 base::UTF8ToUTF16(expected_display_name)); 355 registration_utility_stub_->display_name());
348 356
349 registration_utility_stub_->RunSuccessCallback("token"); 357 registration_utility_stub_->RunSuccessCallback("token");
350 358
351 // Token writing moves control to BlockingPool and back. 359 // Token writing moves control to BlockingPool and back.
352 content::RunAllBlockingPoolTasksUntilIdle(); 360 content::RunAllBlockingPoolTasksUntilIdle();
353 361
354 JSExpect(StringPrintf("%s == 'created'", kCurrentPage)); 362 JSExpect(StringPrintf("%s == 'created'", kCurrentPage));
355 JSEvalOrExitBrowser("$('supervised-user-creation-gotit-button').click()"); 363 JSEvalOrExitBrowser("$('supervised-user-creation-gotit-button').click()");
364
365 // FIXME: There should probably be a wait for a specific event.
nasko 2016/11/30 17:38:56 FIXME is not used in Chromium, please use // TODO(
Alexander Semashko 2016/11/30 22:23:08 Ok. I just did not know who to assign on these TOD
366 content::RunAllPendingInMessageLoop();
356 } 367 }
357 368
358 void SupervisedUserTestBase::SigninAsSupervisedUser( 369 void SupervisedUserTestBase::SigninAsSupervisedUser(
359 bool check_homedir_calls, 370 bool check_homedir_calls,
360 int user_index, 371 int user_index,
361 const std::string& expected_display_name) { 372 const std::string& expected_display_name) {
362 if (check_homedir_calls) 373 if (check_homedir_calls)
363 EXPECT_CALL(*mock_homedir_methods_, MountEx(_, _, _, _)).Times(1); 374 EXPECT_CALL(*mock_homedir_methods_, MountEx(_, _, _, _)).Times(1);
364 375
365 // Log in as supervised user, make sure that everything works. 376 // Log in as supervised user, make sure that everything works.
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 JSEval(StringPrintf( 451 JSEval(StringPrintf(
441 "$('pod-row').pods[%d].querySelector('.remove-warning-button').click()", 452 "$('pod-row').pods[%d].querySelector('.remove-warning-button').click()",
442 user_index)); 453 user_index));
443 454
444 // Make sure there is no supervised user in list. 455 // Make sure there is no supervised user in list.
445 ASSERT_EQ(original_user_count - 1, 456 ASSERT_EQ(original_user_count - 1,
446 user_manager::UserManager::Get()->GetUsers().size()); 457 user_manager::UserManager::Get()->GetUsers().size());
447 } 458 }
448 459
449 } // namespace chromeos 460 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698