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

Side by Side Diff: chrome/browser/chromeos/policy/device_local_account_browsertest.cc

Issue 123833004: Tentatively re-enable previously flaky tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 months 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 <map> 5 #include <map>
6 #include <string> 6 #include <string>
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 scoped_ptr<base::ScopedPathOverride> extension_cache_root_dir_override_; 424 scoped_ptr<base::ScopedPathOverride> extension_cache_root_dir_override_;
425 scoped_ptr<base::ScopedPathOverride> external_data_cache_dir_override_; 425 scoped_ptr<base::ScopedPathOverride> external_data_cache_dir_override_;
426 426
427 DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountTest); 427 DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountTest);
428 }; 428 };
429 429
430 static bool IsKnownUser(const std::string& account_id) { 430 static bool IsKnownUser(const std::string& account_id) {
431 return chromeos::UserManager::Get()->IsKnownUser(account_id); 431 return chromeos::UserManager::Get()->IsKnownUser(account_id);
432 } 432 }
433 433
434 // http://crbug.com/330454 434 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, LoginScreen) {
435 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, DISABLED_LoginScreen) {
436 AddPublicSessionToDevicePolicy(kAccountId1); 435 AddPublicSessionToDevicePolicy(kAccountId1);
437 AddPublicSessionToDevicePolicy(kAccountId2); 436 AddPublicSessionToDevicePolicy(kAccountId2);
438 437
439 content::WindowedNotificationObserver(chrome::NOTIFICATION_USER_LIST_CHANGED, 438 content::WindowedNotificationObserver(chrome::NOTIFICATION_USER_LIST_CHANGED,
440 base::Bind(&IsKnownUser, user_id_1_)) 439 base::Bind(&IsKnownUser, user_id_1_))
441 .Wait(); 440 .Wait();
442 content::WindowedNotificationObserver(chrome::NOTIFICATION_USER_LIST_CHANGED, 441 content::WindowedNotificationObserver(chrome::NOTIFICATION_USER_LIST_CHANGED,
443 base::Bind(&IsKnownUser, user_id_2_)) 442 base::Bind(&IsKnownUser, user_id_2_))
444 .Wait(); 443 .Wait();
445 444
446 CheckPublicSessionPresent(user_id_1_); 445 CheckPublicSessionPresent(user_id_1_);
447 CheckPublicSessionPresent(user_id_2_); 446 CheckPublicSessionPresent(user_id_2_);
448 } 447 }
449 448
450 static bool DisplayNameMatches(const std::string& account_id, 449 static bool DisplayNameMatches(const std::string& account_id,
451 const std::string& display_name) { 450 const std::string& display_name) {
452 const chromeos::User* user = 451 const chromeos::User* user =
453 chromeos::UserManager::Get()->FindUser(account_id); 452 chromeos::UserManager::Get()->FindUser(account_id);
454 if (!user || user->display_name().empty()) 453 if (!user || user->display_name().empty())
455 return false; 454 return false;
456 EXPECT_EQ(base::UTF8ToUTF16(display_name), user->display_name()); 455 EXPECT_EQ(base::UTF8ToUTF16(display_name), user->display_name());
457 return true; 456 return true;
458 } 457 }
459 458
460 // http://crbug.com/330454 459 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, DisplayName) {
461 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, DISABLED_DisplayName) {
462 UploadAndInstallDeviceLocalAccountPolicy(); 460 UploadAndInstallDeviceLocalAccountPolicy();
463 AddPublicSessionToDevicePolicy(kAccountId1); 461 AddPublicSessionToDevicePolicy(kAccountId1);
464 462
465 content::WindowedNotificationObserver( 463 content::WindowedNotificationObserver(
466 chrome::NOTIFICATION_USER_LIST_CHANGED, 464 chrome::NOTIFICATION_USER_LIST_CHANGED,
467 base::Bind(&DisplayNameMatches, user_id_1_, kDisplayName)).Wait(); 465 base::Bind(&DisplayNameMatches, user_id_1_, kDisplayName)).Wait();
468 } 466 }
469 467
470 // http://crbug.com/330454 468 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, PolicyDownload) {
471 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, DISABLED_PolicyDownload) {
472 UploadDeviceLocalAccountPolicy(); 469 UploadDeviceLocalAccountPolicy();
473 AddPublicSessionToDevicePolicy(kAccountId1); 470 AddPublicSessionToDevicePolicy(kAccountId1);
474 471
475 // Policy for the account is not installed in session_manager_client. Because 472 // Policy for the account is not installed in session_manager_client. Because
476 // of this, the presence of the display name (which comes from policy) can be 473 // of this, the presence of the display name (which comes from policy) can be
477 // used as a signal that indicates successful policy download. 474 // used as a signal that indicates successful policy download.
478 content::WindowedNotificationObserver( 475 content::WindowedNotificationObserver(
479 chrome::NOTIFICATION_USER_LIST_CHANGED, 476 chrome::NOTIFICATION_USER_LIST_CHANGED,
480 base::Bind(&DisplayNameMatches, user_id_1_, kDisplayName)).Wait(); 477 base::Bind(&DisplayNameMatches, user_id_1_, kDisplayName)).Wait();
481 478
482 // Sanity check: The policy should be present now. 479 // Sanity check: The policy should be present now.
483 ASSERT_FALSE(session_manager_client()->device_local_account_policy( 480 ASSERT_FALSE(session_manager_client()->device_local_account_policy(
484 kAccountId1).empty()); 481 kAccountId1).empty());
485 } 482 }
486 483
487 static bool IsNotKnownUser(const std::string& account_id) { 484 static bool IsNotKnownUser(const std::string& account_id) {
488 return !IsKnownUser(account_id); 485 return !IsKnownUser(account_id);
489 } 486 }
490 487
491 // http://crbug.com/330454 488 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, DevicePolicyChange) {
492 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, DISABLED_DevicePolicyChange) {
493 AddPublicSessionToDevicePolicy(kAccountId1); 489 AddPublicSessionToDevicePolicy(kAccountId1);
494 AddPublicSessionToDevicePolicy(kAccountId2); 490 AddPublicSessionToDevicePolicy(kAccountId2);
495 491
496 // Wait until the login screen is up. 492 // Wait until the login screen is up.
497 content::WindowedNotificationObserver(chrome::NOTIFICATION_USER_LIST_CHANGED, 493 content::WindowedNotificationObserver(chrome::NOTIFICATION_USER_LIST_CHANGED,
498 base::Bind(&IsKnownUser, user_id_1_)) 494 base::Bind(&IsKnownUser, user_id_1_))
499 .Wait(); 495 .Wait();
500 content::WindowedNotificationObserver(chrome::NOTIFICATION_USER_LIST_CHANGED, 496 content::WindowedNotificationObserver(chrome::NOTIFICATION_USER_LIST_CHANGED,
501 base::Bind(&IsKnownUser, user_id_2_)) 497 base::Bind(&IsKnownUser, user_id_2_))
502 .Wait(); 498 .Wait();
(...skipping 18 matching lines...) Expand all
521 // Make sure the second device-local account disappears. 517 // Make sure the second device-local account disappears.
522 content::WindowedNotificationObserver( 518 content::WindowedNotificationObserver(
523 chrome::NOTIFICATION_USER_LIST_CHANGED, 519 chrome::NOTIFICATION_USER_LIST_CHANGED,
524 base::Bind(&IsNotKnownUser, user_id_2_)).Wait(); 520 base::Bind(&IsNotKnownUser, user_id_2_)).Wait();
525 } 521 }
526 522
527 static bool IsSessionStarted() { 523 static bool IsSessionStarted() {
528 return chromeos::UserManager::Get()->IsSessionStarted(); 524 return chromeos::UserManager::Get()->IsSessionStarted();
529 } 525 }
530 526
531 // http://crbug.com/330454 527 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, StartSession) {
532 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, DISABLED_StartSession) {
533 // Specify startup pages. 528 // Specify startup pages.
534 device_local_account_policy_.payload().mutable_restoreonstartup()->set_value( 529 device_local_account_policy_.payload().mutable_restoreonstartup()->set_value(
535 SessionStartupPref::kPrefValueURLs); 530 SessionStartupPref::kPrefValueURLs);
536 em::StringListPolicyProto* startup_urls_proto = 531 em::StringListPolicyProto* startup_urls_proto =
537 device_local_account_policy_.payload().mutable_restoreonstartupurls(); 532 device_local_account_policy_.payload().mutable_restoreonstartupurls();
538 for (size_t i = 0; i < arraysize(kStartupURLs); ++i) 533 for (size_t i = 0; i < arraysize(kStartupURLs); ++i)
539 startup_urls_proto->mutable_value()->add_entries(kStartupURLs[i]); 534 startup_urls_proto->mutable_value()->add_entries(kStartupURLs[i]);
540 UploadAndInstallDeviceLocalAccountPolicy(); 535 UploadAndInstallDeviceLocalAccountPolicy();
541 AddPublicSessionToDevicePolicy(kAccountId1); 536 AddPublicSessionToDevicePolicy(kAccountId1);
542 537
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 TabStripModel* tabs = browser->tab_strip_model(); 575 TabStripModel* tabs = browser->tab_strip_model();
581 ASSERT_TRUE(tabs); 576 ASSERT_TRUE(tabs);
582 int expected_tab_count = static_cast<int>(arraysize(kStartupURLs)); 577 int expected_tab_count = static_cast<int>(arraysize(kStartupURLs));
583 EXPECT_EQ(expected_tab_count, tabs->count()); 578 EXPECT_EQ(expected_tab_count, tabs->count());
584 for (int i = 0; i < expected_tab_count && i < tabs->count(); ++i) { 579 for (int i = 0; i < expected_tab_count && i < tabs->count(); ++i) {
585 EXPECT_EQ(GURL(kStartupURLs[i]), 580 EXPECT_EQ(GURL(kStartupURLs[i]),
586 tabs->GetWebContentsAt(i)->GetVisibleURL()); 581 tabs->GetWebContentsAt(i)->GetVisibleURL());
587 } 582 }
588 } 583 }
589 584
590 // http://crbug.com/330454 585 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, FullscreenDisallowed) {
591 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, DISABLED_FullscreenDisallowed) {
592 UploadAndInstallDeviceLocalAccountPolicy(); 586 UploadAndInstallDeviceLocalAccountPolicy();
593 AddPublicSessionToDevicePolicy(kAccountId1); 587 AddPublicSessionToDevicePolicy(kAccountId1);
594 588
595 // This observes the display name becoming available as this indicates 589 // This observes the display name becoming available as this indicates
596 // device-local account policy is fully loaded, which is a prerequisite for 590 // device-local account policy is fully loaded, which is a prerequisite for
597 // successful login. 591 // successful login.
598 content::WindowedNotificationObserver( 592 content::WindowedNotificationObserver(
599 chrome::NOTIFICATION_USER_LIST_CHANGED, 593 chrome::NOTIFICATION_USER_LIST_CHANGED,
600 base::Bind(&DisplayNameMatches, user_id_1_, kDisplayName)).Wait(); 594 base::Bind(&DisplayNameMatches, user_id_1_, kDisplayName)).Wait();
601 595
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 BrowserWindow* browser_window = browser->window(); 630 BrowserWindow* browser_window = browser->window();
637 ASSERT_TRUE(browser_window); 631 ASSERT_TRUE(browser_window);
638 chrome::EndKeepAlive(); 632 chrome::EndKeepAlive();
639 633
640 // Verify that an attempt to enter fullscreen mode is denied. 634 // Verify that an attempt to enter fullscreen mode is denied.
641 EXPECT_FALSE(browser_window->IsFullscreen()); 635 EXPECT_FALSE(browser_window->IsFullscreen());
642 chrome::ToggleFullscreenMode(browser); 636 chrome::ToggleFullscreenMode(browser);
643 EXPECT_FALSE(browser_window->IsFullscreen()); 637 EXPECT_FALSE(browser_window->IsFullscreen());
644 } 638 }
645 639
646 // http://crbug.com/330454 640 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, ExtensionsUncached) {
647 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, DISABLED_ExtensionsUncached) {
648 // Make it possible to force-install a hosted app and an extension. 641 // Make it possible to force-install a hosted app and an extension.
649 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); 642 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
650 TestingUpdateManifestProvider testing_update_manifest_provider( 643 TestingUpdateManifestProvider testing_update_manifest_provider(
651 kRelativeUpdateURL); 644 kRelativeUpdateURL);
652 testing_update_manifest_provider.AddUpdate( 645 testing_update_manifest_provider.AddUpdate(
653 kHostedAppID, 646 kHostedAppID,
654 kHostedAppVersion, 647 kHostedAppVersion,
655 embedded_test_server()->GetURL(std::string("/") + kHostedAppCRXPath)); 648 embedded_test_server()->GetURL(std::string("/") + kHostedAppCRXPath));
656 testing_update_manifest_provider.AddUpdate( 649 testing_update_manifest_provider.AddUpdate(
657 kGoodExtensionID, 650 kGoodExtensionID,
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
735 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_dir)); 728 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_dir));
736 EXPECT_TRUE(ContentsEqual( 729 EXPECT_TRUE(ContentsEqual(
737 GetCacheCRXFile(kAccountId1, kHostedAppID, kHostedAppVersion), 730 GetCacheCRXFile(kAccountId1, kHostedAppID, kHostedAppVersion),
738 test_dir.Append(kHostedAppCRXPath))); 731 test_dir.Append(kHostedAppCRXPath)));
739 732
740 // Verify that the extension was not copied to the account's extension cache. 733 // Verify that the extension was not copied to the account's extension cache.
741 EXPECT_FALSE(PathExists(GetCacheCRXFile( 734 EXPECT_FALSE(PathExists(GetCacheCRXFile(
742 kAccountId1, kGoodExtensionID, kGoodExtensionVersion))); 735 kAccountId1, kGoodExtensionID, kGoodExtensionVersion)));
743 } 736 }
744 737
745 // http://crbug.com/330454 738 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, ExtensionsCached) {
746 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, DISABLED_ExtensionsCached) {
747 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); 739 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
748 740
749 // Pre-populate the device local account's extension cache with a hosted app 741 // Pre-populate the device local account's extension cache with a hosted app
750 // and an extension. 742 // and an extension.
751 EXPECT_TRUE(base::CreateDirectory( 743 EXPECT_TRUE(base::CreateDirectory(
752 GetCacheDirectoryForAccountID(kAccountId1))); 744 GetCacheDirectoryForAccountID(kAccountId1)));
753 base::FilePath test_dir; 745 base::FilePath test_dir;
754 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_dir)); 746 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_dir));
755 const base::FilePath cached_hosted_app = 747 const base::FilePath cached_hosted_app =
756 GetCacheCRXFile(kAccountId1, kHostedAppID, kHostedAppVersion); 748 GetCacheCRXFile(kAccountId1, kHostedAppID, kHostedAppVersion);
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
953 policy_entry->external_data_fetcher->Fetch(base::Bind( 945 policy_entry->external_data_fetcher->Fetch(base::Bind(
954 &test::ExternalDataFetchCallback, 946 &test::ExternalDataFetchCallback,
955 &fetched_external_data, 947 &fetched_external_data,
956 run_loop->QuitClosure())); 948 run_loop->QuitClosure()));
957 run_loop->Run(); 949 run_loop->Run();
958 950
959 ASSERT_TRUE(fetched_external_data); 951 ASSERT_TRUE(fetched_external_data);
960 EXPECT_EQ(kExternalData, *fetched_external_data); 952 EXPECT_EQ(kExternalData, *fetched_external_data);
961 } 953 }
962 954
963 // http://crbug.com/330454 955 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, UserAvatarImage) {
964 IN_PROC_BROWSER_TEST_F(DeviceLocalAccountTest, DISABLED_UserAvatarImage) {
965 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); 956 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
966 957
967 UploadDeviceLocalAccountPolicy(); 958 UploadDeviceLocalAccountPolicy();
968 AddPublicSessionToDevicePolicy(kAccountId1); 959 AddPublicSessionToDevicePolicy(kAccountId1);
969 960
970 // This observes the display name becoming available as this indicates 961 // This observes the display name becoming available as this indicates
971 // device-local account policy is fully loaded. 962 // device-local account policy is fully loaded.
972 content::WindowedNotificationObserver( 963 content::WindowedNotificationObserver(
973 chrome::NOTIFICATION_USER_LIST_CHANGED, 964 chrome::NOTIFICATION_USER_LIST_CHANGED,
974 base::Bind(&DisplayNameMatches, user_id_1_, kDisplayName)).Wait(); 965 base::Bind(&DisplayNameMatches, user_id_1_, kDisplayName)).Wait();
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
1036 1027
1037 // Check image dimensions. Images can't be compared since JPEG is lossy. 1028 // Check image dimensions. Images can't be compared since JPEG is lossy.
1038 EXPECT_EQ(policy_image->width(), saved_image->width()); 1029 EXPECT_EQ(policy_image->width(), saved_image->width());
1039 EXPECT_EQ(policy_image->height(), saved_image->height()); 1030 EXPECT_EQ(policy_image->height(), saved_image->height());
1040 } 1031 }
1041 1032
1042 class TermsOfServiceTest : public DeviceLocalAccountTest, 1033 class TermsOfServiceTest : public DeviceLocalAccountTest,
1043 public testing::WithParamInterface<bool> { 1034 public testing::WithParamInterface<bool> {
1044 }; 1035 };
1045 1036
1046 // http://crbug.com/330454 1037 IN_PROC_BROWSER_TEST_P(TermsOfServiceTest, TermsOfServiceScreen) {
1047 IN_PROC_BROWSER_TEST_P(TermsOfServiceTest, DISABLED_TermsOfServiceScreen) {
1048 // Specify Terms of Service URL. 1038 // Specify Terms of Service URL.
1049 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); 1039 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
1050 device_local_account_policy_.payload().mutable_termsofserviceurl()->set_value( 1040 device_local_account_policy_.payload().mutable_termsofserviceurl()->set_value(
1051 embedded_test_server()->GetURL( 1041 embedded_test_server()->GetURL(
1052 std::string("/") + 1042 std::string("/") +
1053 (GetParam() ? kExistentTermsOfServicePath 1043 (GetParam() ? kExistentTermsOfServicePath
1054 : kNonexistentTermsOfServicePath)).spec()); 1044 : kNonexistentTermsOfServicePath)).spec());
1055 UploadAndInstallDeviceLocalAccountPolicy(); 1045 UploadAndInstallDeviceLocalAccountPolicy();
1056 AddPublicSessionToDevicePolicy(kAccountId1); 1046 AddPublicSessionToDevicePolicy(kAccountId1);
1057 1047
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
1194 if (!IsSessionStarted()) { 1184 if (!IsSessionStarted()) {
1195 content::WindowedNotificationObserver(chrome::NOTIFICATION_SESSION_STARTED, 1185 content::WindowedNotificationObserver(chrome::NOTIFICATION_SESSION_STARTED,
1196 base::Bind(IsSessionStarted)).Wait(); 1186 base::Bind(IsSessionStarted)).Wait();
1197 } 1187 }
1198 } 1188 }
1199 1189
1200 INSTANTIATE_TEST_CASE_P(TermsOfServiceTestInstance, 1190 INSTANTIATE_TEST_CASE_P(TermsOfServiceTestInstance,
1201 TermsOfServiceTest, testing::Bool()); 1191 TermsOfServiceTest, testing::Bool());
1202 1192
1203 } // namespace policy 1193 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698