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

Unified Diff: chrome/browser/profiles/avatar_menu_model_unittest.cc

Issue 12040085: Adding show profile switcher field trial. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698