Index: chrome/browser/profiles/avatar_menu_model_unittest.cc |
diff --git a/chrome/browser/profiles/avatar_menu_model_unittest.cc b/chrome/browser/profiles/avatar_menu_model_unittest.cc |
index 2f74f07eebcba4d8da5b10cbbd6e1aaa2baad18f..8aec35af52bc21ac561dc7986f788238a988a8b0 100644 |
--- a/chrome/browser/profiles/avatar_menu_model_unittest.cc |
+++ b/chrome/browser/profiles/avatar_menu_model_unittest.cc |
@@ -4,10 +4,12 @@ |
#include "chrome/browser/profiles/avatar_menu_model.h" |
+#include "base/metrics/field_trial.h" |
#include "base/string16.h" |
#include "base/utf_string_conversions.h" |
#include "chrome/browser/profiles/avatar_menu_model_observer.h" |
#include "chrome/browser/profiles/profile_info_cache.h" |
+#include "chrome/browser/profiles/profile_manager.h" |
#include "chrome/test/base/testing_browser_process.h" |
#include "chrome/test/base/testing_profile_manager.h" |
#include "testing/gtest/include/gtest/gtest.h" |
@@ -44,6 +46,12 @@ class AvatarMenuModelTest : public testing::Test { |
#endif |
} |
+ virtual void TearDown() { |
+ // Some tests force IsMultipleProfilesEnabled to return a particular |
+ // value. We make sure it's always set back to a normal state. |
+ ProfileManager::UnforceMultipleProfilesForTests(); |
+ } |
+ |
Browser* browser() { return NULL; } |
TestingProfileManager* manager() { return &manager_; } |
@@ -164,4 +172,39 @@ TEST_F(AvatarMenuModelTest, ChangeOnNotify) { |
EXPECT_EQ(name3, item3.name); |
} |
+// Tests for ShouldShowAvatarMenu are only applicable when multiple profiles is |
+// enabled, so for these tests we force it to be enabled. |
+TEST_F(AvatarMenuModelTest, ShowAvatarMenuInTrial) { |
+ ProfileManager::ForceMultipleProfilesForTests(true); |
+ base::FieldTrialList field_trial_list_(NULL); |
+ base::FieldTrialList::CreateFieldTrial("ShowProfileSwitcher", "AlwaysShow"); |
+ |
+ EXPECT_TRUE(AvatarMenuModel::ShouldShowAvatarMenu()); |
+} |
+ |
+TEST_F(AvatarMenuModelTest, DontShowAvatarMenu) { |
+ ProfileManager::ForceMultipleProfilesForTests(true); |
+ string16 name1(ASCIIToUTF16("Test 1")); |
+ manager()->CreateTestingProfile("p1", name1, 0); |
+ |
+ EXPECT_FALSE(AvatarMenuModel::ShouldShowAvatarMenu()); |
+ |
+ ProfileManager::ForceMultipleProfilesForTests(false); |
+ string16 name2(ASCIIToUTF16("Test 2")); |
+ manager()->CreateTestingProfile("p2", name2, 0); |
+ |
+ EXPECT_FALSE(AvatarMenuModel::ShouldShowAvatarMenu()); |
+} |
+ |
+TEST_F(AvatarMenuModelTest, ShowAvatarMenu) { |
+ ProfileManager::ForceMultipleProfilesForTests(true); |
+ string16 name1(ASCIIToUTF16("Test 1")); |
+ string16 name2(ASCIIToUTF16("Test 2")); |
+ |
+ manager()->CreateTestingProfile("p1", name1, 0); |
+ manager()->CreateTestingProfile("p2", name2, 0); |
+ |
+ EXPECT_TRUE(AvatarMenuModel::ShouldShowAvatarMenu()); |
+} |
+ |
} // namespace |