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

Side by Side 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, 10 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/profiles/avatar_menu_model.h" 5 #include "chrome/browser/profiles/avatar_menu_model.h"
6 6
7 #include "base/metrics/field_trial.h"
7 #include "base/string16.h" 8 #include "base/string16.h"
8 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/profiles/avatar_menu_model_observer.h" 10 #include "chrome/browser/profiles/avatar_menu_model_observer.h"
10 #include "chrome/browser/profiles/profile_info_cache.h" 11 #include "chrome/browser/profiles/profile_info_cache.h"
12 #include "chrome/browser/profiles/profile_manager.h"
11 #include "chrome/test/base/testing_browser_process.h" 13 #include "chrome/test/base/testing_browser_process.h"
12 #include "chrome/test/base/testing_profile_manager.h" 14 #include "chrome/test/base/testing_profile_manager.h"
13 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
14 16
15 namespace { 17 namespace {
16 18
17 class MockObserver : public AvatarMenuModelObserver { 19 class MockObserver : public AvatarMenuModelObserver {
18 public: 20 public:
19 MockObserver() : count_(0) {} 21 MockObserver() : count_(0) {}
20 virtual ~MockObserver() {} 22 virtual ~MockObserver() {}
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 159
158 const AvatarMenuModel::Item& item2 = model.GetItemAt(1); 160 const AvatarMenuModel::Item& item2 = model.GetItemAt(1);
159 EXPECT_EQ(1U, item2.model_index); 161 EXPECT_EQ(1U, item2.model_index);
160 EXPECT_EQ(name2, item2.name); 162 EXPECT_EQ(name2, item2.name);
161 163
162 const AvatarMenuModel::Item& item3 = model.GetItemAt(2); 164 const AvatarMenuModel::Item& item3 = model.GetItemAt(2);
163 EXPECT_EQ(2U, item3.model_index); 165 EXPECT_EQ(2U, item3.model_index);
164 EXPECT_EQ(name3, item3.name); 166 EXPECT_EQ(name3, item3.name);
165 } 167 }
166 168
169 TEST_F(AvatarMenuModelTest, ShowAvatarMenuInTrial) {
170 // If multiple profiles is not enabled, the trial will not be enabled, so it
171 // isn't tested.
172 if (!ProfileManager::IsMultipleProfilesEnabled())
173 return;
174
175 base::FieldTrialList field_trial_list_(NULL);
176 base::FieldTrialList::CreateFieldTrial("ShowProfileSwitcher", "AlwaysShow");
177
178 EXPECT_TRUE(AvatarMenuModel::ShouldShowAvatarMenu());
179 }
180
181 TEST_F(AvatarMenuModelTest, DontShowAvatarMenu) {
182 string16 name1(ASCIIToUTF16("Test 1"));
183 manager()->CreateTestingProfile("p1", name1, 0);
184
185 EXPECT_FALSE(AvatarMenuModel::ShouldShowAvatarMenu());
186
187 // If multiple profiles is enabled, there are no other cases when we wouldn't
188 // show the menu.
189 if (ProfileManager::IsMultipleProfilesEnabled())
190 return;
191
192 string16 name2(ASCIIToUTF16("Test 2"));
193 manager()->CreateTestingProfile("p2", name2, 0);
194
195 EXPECT_FALSE(AvatarMenuModel::ShouldShowAvatarMenu());
196 }
197
198 TEST_F(AvatarMenuModelTest, ShowAvatarMenu) {
199 // If multiple profiles is enabled then the menu is never show.
200 if (!ProfileManager::IsMultipleProfilesEnabled())
201 return;
202
203 string16 name1(ASCIIToUTF16("Test 1"));
204 string16 name2(ASCIIToUTF16("Test 2"));
205
206 manager()->CreateTestingProfile("p1", name1, 0);
207 manager()->CreateTestingProfile("p2", name2, 0);
208
209 EXPECT_TRUE(AvatarMenuModel::ShouldShowAvatarMenu());
210 }
211
167 } // namespace 212 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/profiles/avatar_menu_model.cc ('k') | chrome/browser/ui/browser_command_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698