diff options
author | bauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-31 15:08:54 +0000 |
---|---|---|
committer | bauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-31 15:08:54 +0000 |
commit | 0aa018aaf1c38cbe08477a4f3fc9ebcd202924c5 (patch) | |
tree | dee6e164bd71ecd8251501b28f25b6bb415848bf /chrome/browser/profiles/profile_info_cache_unittest.cc | |
parent | 163713eb87570157b91a3259f8846b74ee1d18cb (diff) | |
download | chromium_src-0aa018aaf1c38cbe08477a4f3fc9ebcd202924c5.zip chromium_src-0aa018aaf1c38cbe08477a4f3fc9ebcd202924c5.tar.gz chromium_src-0aa018aaf1c38cbe08477a4f3fc9ebcd202924c5.tar.bz2 |
[Mac] Disable the "Add new user" menu item for managed users.
Also disable the menu items for switching to a different user. Switching via the avatar menu is still possible.
TBR=bartfab@chromium.org
BUG=248948
TEST=Verify that the menu item for a managed user is disabled.
Review URL: https://chromiumcodereview.appspot.com/17074006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@214743 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/profiles/profile_info_cache_unittest.cc')
-rw-r--r-- | chrome/browser/profiles/profile_info_cache_unittest.cc | 43 |
1 files changed, 35 insertions, 8 deletions
diff --git a/chrome/browser/profiles/profile_info_cache_unittest.cc b/chrome/browser/profiles/profile_info_cache_unittest.cc index 2dc49ea..ee0c592 100644 --- a/chrome/browser/profiles/profile_info_cache_unittest.cc +++ b/chrome/browser/profiles/profile_info_cache_unittest.cc @@ -9,6 +9,7 @@ #include "base/strings/utf_string_conversions.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/chrome_notification_types.h" +#include "chrome/browser/prefs/pref_service_syncable.h" #include "chrome/browser/profiles/profile_info_cache.h" #include "chrome/browser/profiles/profile_manager.h" #include "chrome/test/base/testing_browser_process.h" @@ -77,10 +78,7 @@ ProfileInfoCache* ProfileNameVerifierObserver::GetCache() { } ProfileInfoCacheTest::ProfileInfoCacheTest() - : testing_profile_manager_( - TestingBrowserProcess::GetGlobal()), - ui_thread_(BrowserThread::UI, &ui_loop_), - file_thread_(BrowserThread::FILE, &ui_loop_), + : testing_profile_manager_(TestingBrowserProcess::GetGlobal()), name_observer_(&testing_profile_manager_) { } @@ -95,7 +93,7 @@ void ProfileInfoCacheTest::SetUp() { void ProfileInfoCacheTest::TearDown() { // Drain the UI thread to make sure all tasks are completed. This prevents // memory leaks. - ui_loop_.RunUntilIdle(); + base::RunLoop().RunUntilIdle(); } ProfileInfoCache* ProfileInfoCacheTest::GetCache() { @@ -125,9 +123,10 @@ TEST_F(ProfileInfoCacheTest, AddProfiles) { const SkBitmap* icon = rb.GetImageNamed( ProfileInfoCache::GetDefaultAvatarIconResourceIDAtIndex( i)).ToSkBitmap(); + bool is_managed = i == 3; GetCache()->AddProfileToCache(profile_path, profile_name, string16(), i, - false); + is_managed); GetCache()->SetBackgroundStatusOfProfileAtIndex(i, true); string16 gaia_name = ASCIIToUTF16(base::StringPrintf("gaia_%ud", i)); GetCache()->SetGAIANameOfProfileAtIndex(i, gaia_name); @@ -135,10 +134,11 @@ TEST_F(ProfileInfoCacheTest, AddProfiles) { EXPECT_EQ(i + 1, GetCache()->GetNumberOfProfiles()); EXPECT_EQ(profile_name, GetCache()->GetNameOfProfileAtIndex(i)); EXPECT_EQ(profile_path, GetCache()->GetPathOfProfileAtIndex(i)); - const SkBitmap* actual_icon = GetCache()->GetAvatarIconOfProfileAtIndex( - i).ToSkBitmap(); + const SkBitmap* actual_icon = + GetCache()->GetAvatarIconOfProfileAtIndex(i).ToSkBitmap(); EXPECT_EQ(icon->width(), actual_icon->width()); EXPECT_EQ(icon->height(), actual_icon->height()); + EXPECT_EQ(is_managed, GetCache()->ProfileIsManagedAtIndex(i)); } // Reset the cache and test the it reloads correctly. @@ -394,6 +394,21 @@ TEST_F(ProfileInfoCacheTest, PersistGAIAPicture) { gaia_image, *GetCache()->GetGAIAPictureOfProfileAtIndex(0))); } +TEST_F(ProfileInfoCacheTest, SetProfileIsManaged) { + GetCache()->AddProfileToCache( + GetProfilePath("test"), ASCIIToUTF16("Test"), string16(), 0, false); + EXPECT_FALSE(GetCache()->ProfileIsManagedAtIndex(0)); + + GetCache()->SetProfileIsManagedAtIndex(0, true); + EXPECT_TRUE(GetCache()->ProfileIsManagedAtIndex(0)); + + ResetCache(); + EXPECT_TRUE(GetCache()->ProfileIsManagedAtIndex(0)); + + GetCache()->SetProfileIsManagedAtIndex(0, false); + EXPECT_FALSE(GetCache()->ProfileIsManagedAtIndex(0)); +} + TEST_F(ProfileInfoCacheTest, EmptyGAIAInfo) { string16 profile_name = ASCIIToUTF16("name_1"); int id = ProfileInfoCache::GetDefaultAvatarIconResourceIDAtIndex(0); @@ -415,4 +430,16 @@ TEST_F(ProfileInfoCacheTest, EmptyGAIAInfo) { profile_image, GetCache()->GetAvatarIconOfProfileAtIndex(0))); } +TEST_F(ProfileInfoCacheTest, CreateManagedTestingProfile) { + testing_profile_manager_.CreateTestingProfile("default"); + string16 managed_user_name = ASCIIToUTF16("Supervised User"); + testing_profile_manager_.CreateTestingProfile( + "test1", scoped_ptr<PrefServiceSyncable>(), managed_user_name, 0, true); + for (size_t i = 0; i < GetCache()->GetNumberOfProfiles(); i++) { + bool is_managed = + GetCache()->GetNameOfProfileAtIndex(i) == managed_user_name; + EXPECT_EQ(is_managed, GetCache()->ProfileIsManagedAtIndex(i)); + } +} + } // namespace |