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