| 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 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 SetExpectedCredentials(user_context); | 293 SetExpectedCredentials(user_context); |
| 294 content::WindowedNotificationObserver login_observer( | 294 content::WindowedNotificationObserver login_observer( |
| 295 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, | 295 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, |
| 296 content::NotificationService::AllSources()); | 296 content::NotificationService::AllSources()); |
| 297 | 297 |
| 298 // Log in as manager. | 298 // Log in as manager. |
| 299 JSEval("$('supervised-user-creation-next-button').click()"); | 299 JSEval("$('supervised-user-creation-next-button').click()"); |
| 300 login_observer.Wait(); | 300 login_observer.Wait(); |
| 301 | 301 |
| 302 // OAuth token is valid. | 302 // OAuth token is valid. |
| 303 UserManager::Get()->SaveUserOAuthStatus( | 303 user_manager::UserManager::Get()->SaveUserOAuthStatus( |
| 304 kTestManager, user_manager::User::OAUTH2_TOKEN_STATUS_VALID); | 304 kTestManager, user_manager::User::OAUTH2_TOKEN_STATUS_VALID); |
| 305 base::RunLoop().RunUntilIdle(); | 305 base::RunLoop().RunUntilIdle(); |
| 306 | 306 |
| 307 // Check the page have changed. | 307 // Check the page have changed. |
| 308 JSExpect(StringPrintf("%s == 'username'", kCurrentPage)); | 308 JSExpect(StringPrintf("%s == 'username'", kCurrentPage)); |
| 309 } | 309 } |
| 310 | 310 |
| 311 void SupervisedUserTestBase::FillNewUserData(const std::string& display_name) { | 311 void SupervisedUserTestBase::FillNewUserData(const std::string& display_name) { |
| 312 JSExpect("$('supervised-user-creation-next-button').disabled"); | 312 JSExpect("$('supervised-user-creation-next-button').disabled"); |
| 313 JSSetTextField("#supervised-user-creation-name", display_name); | 313 JSSetTextField("#supervised-user-creation-name", display_name); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 } | 350 } |
| 351 | 351 |
| 352 void SupervisedUserTestBase::SigninAsSupervisedUser( | 352 void SupervisedUserTestBase::SigninAsSupervisedUser( |
| 353 bool check_homedir_calls, | 353 bool check_homedir_calls, |
| 354 int user_index, | 354 int user_index, |
| 355 const std::string& expected_display_name) { | 355 const std::string& expected_display_name) { |
| 356 if (check_homedir_calls) | 356 if (check_homedir_calls) |
| 357 EXPECT_CALL(*mock_homedir_methods_, MountEx(_, _, _, _)).Times(1); | 357 EXPECT_CALL(*mock_homedir_methods_, MountEx(_, _, _, _)).Times(1); |
| 358 | 358 |
| 359 // Log in as supervised user, make sure that everything works. | 359 // Log in as supervised user, make sure that everything works. |
| 360 ASSERT_EQ(3UL, UserManager::Get()->GetUsers().size()); | 360 ASSERT_EQ(3UL, user_manager::UserManager::Get()->GetUsers().size()); |
| 361 | 361 |
| 362 // Created supervised user have to be first in a list. | 362 // Created supervised user have to be first in a list. |
| 363 const user_manager::User* user = | 363 const user_manager::User* user = |
| 364 UserManager::Get()->GetUsers().at(user_index); | 364 user_manager::UserManager::Get()->GetUsers().at(user_index); |
| 365 ASSERT_EQ(base::UTF8ToUTF16(expected_display_name), user->display_name()); | 365 ASSERT_EQ(base::UTF8ToUTF16(expected_display_name), user->display_name()); |
| 366 LoginUser(user->email()); | 366 LoginUser(user->email()); |
| 367 if (check_homedir_calls) | 367 if (check_homedir_calls) |
| 368 ::testing::Mock::VerifyAndClearExpectations(mock_homedir_methods_); | 368 ::testing::Mock::VerifyAndClearExpectations(mock_homedir_methods_); |
| 369 Profile* profile = ProfileHelper::Get()->GetProfileByUserUnsafe(user); | 369 Profile* profile = ProfileHelper::Get()->GetProfileByUserUnsafe(user); |
| 370 shared_settings_adapter_.reset( | 370 shared_settings_adapter_.reset( |
| 371 new SupervisedUsersSharedSettingsSyncTestAdapter(profile)); | 371 new SupervisedUsersSharedSettingsSyncTestAdapter(profile)); |
| 372 | 372 |
| 373 // Check ChromeOS preference is initialized. | 373 // Check ChromeOS preference is initialized. |
| 374 EXPECT_TRUE( | 374 EXPECT_TRUE( |
| 375 static_cast<ProfileImpl*>(profile)->chromeos_preferences_); | 375 static_cast<ProfileImpl*>(profile)->chromeos_preferences_); |
| 376 } | 376 } |
| 377 | 377 |
| 378 void SupervisedUserTestBase::SigninAsManager(int user_index) { | 378 void SupervisedUserTestBase::SigninAsManager(int user_index) { |
| 379 // Log in as supervised user, make sure that everything works. | 379 // Log in as supervised user, make sure that everything works. |
| 380 ASSERT_EQ(3UL, UserManager::Get()->GetUsers().size()); | 380 ASSERT_EQ(3UL, user_manager::UserManager::Get()->GetUsers().size()); |
| 381 | 381 |
| 382 // Created supervised user have to be first in a list. | 382 // Created supervised user have to be first in a list. |
| 383 const user_manager::User* user = | 383 const user_manager::User* user = |
| 384 UserManager::Get()->GetUsers().at(user_index); | 384 user_manager::UserManager::Get()->GetUsers().at(user_index); |
| 385 LoginUser(user->email()); | 385 LoginUser(user->email()); |
| 386 Profile* profile = ProfileHelper::Get()->GetProfileByUserUnsafe(user); | 386 Profile* profile = ProfileHelper::Get()->GetProfileByUserUnsafe(user); |
| 387 shared_settings_adapter_.reset( | 387 shared_settings_adapter_.reset( |
| 388 new SupervisedUsersSharedSettingsSyncTestAdapter(profile)); | 388 new SupervisedUsersSharedSettingsSyncTestAdapter(profile)); |
| 389 supervised_users_adapter_.reset(new SupervisedUsersSyncTestAdapter(profile)); | 389 supervised_users_adapter_.reset(new SupervisedUsersSyncTestAdapter(profile)); |
| 390 } | 390 } |
| 391 | 391 |
| 392 void SupervisedUserTestBase::RemoveSupervisedUser( | 392 void SupervisedUserTestBase::RemoveSupervisedUser( |
| 393 unsigned long original_user_count, | 393 unsigned long original_user_count, |
| 394 int user_index, | 394 int user_index, |
| 395 const std::string& expected_display_name) { | 395 const std::string& expected_display_name) { |
| 396 // Remove supervised user. | 396 // Remove supervised user. |
| 397 ASSERT_EQ(original_user_count, UserManager::Get()->GetUsers().size()); | 397 ASSERT_EQ(original_user_count, |
| 398 user_manager::UserManager::Get()->GetUsers().size()); |
| 398 | 399 |
| 399 // Created supervised user have to be first in a list. | 400 // Created supervised user have to be first in a list. |
| 400 const user_manager::User* user = | 401 const user_manager::User* user = |
| 401 UserManager::Get()->GetUsers().at(user_index); | 402 user_manager::UserManager::Get()->GetUsers().at(user_index); |
| 402 ASSERT_EQ(base::UTF8ToUTF16(expected_display_name), user->display_name()); | 403 ASSERT_EQ(base::UTF8ToUTF16(expected_display_name), user->display_name()); |
| 403 | 404 |
| 404 // Open pod menu. | 405 // Open pod menu. |
| 405 JSExpect( | 406 JSExpect( |
| 406 StringPrintf("!$('pod-row').pods[%d].isActionBoxMenuActive", user_index)); | 407 StringPrintf("!$('pod-row').pods[%d].isActionBoxMenuActive", user_index)); |
| 407 JSEval(StringPrintf( | 408 JSEval(StringPrintf( |
| 408 "$('pod-row').pods[%d].querySelector('.action-box-button').click()", | 409 "$('pod-row').pods[%d].querySelector('.action-box-button').click()", |
| 409 user_index)); | 410 user_index)); |
| 410 JSExpect( | 411 JSExpect( |
| 411 StringPrintf("$('pod-row').pods[%d].isActionBoxMenuActive", user_index)); | 412 StringPrintf("$('pod-row').pods[%d].isActionBoxMenuActive", user_index)); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 422 user_index)); | 423 user_index)); |
| 423 | 424 |
| 424 EXPECT_CALL(*mock_async_method_caller_, AsyncRemove(_, _)).Times(1); | 425 EXPECT_CALL(*mock_async_method_caller_, AsyncRemove(_, _)).Times(1); |
| 425 | 426 |
| 426 // Confirm deletion. | 427 // Confirm deletion. |
| 427 JSEval(StringPrintf( | 428 JSEval(StringPrintf( |
| 428 "$('pod-row').pods[%d].querySelector('.remove-warning-button').click()", | 429 "$('pod-row').pods[%d].querySelector('.remove-warning-button').click()", |
| 429 user_index)); | 430 user_index)); |
| 430 | 431 |
| 431 // Make sure there is no supervised user in list. | 432 // Make sure there is no supervised user in list. |
| 432 ASSERT_EQ(original_user_count - 1, UserManager::Get()->GetUsers().size()); | 433 ASSERT_EQ(original_user_count - 1, |
| 434 user_manager::UserManager::Get()->GetUsers().size()); |
| 433 } | 435 } |
| 434 | 436 |
| 435 } // namespace chromeos | 437 } // namespace chromeos |
| OLD | NEW |