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