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

Side by Side Diff: chrome/browser/notifications/message_center_settings_controller_unittest.cc

Issue 1657913003: Refactor of ProfileInfoCache in c/b/notifications (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix errors Created 4 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 <string> 5 #include <string>
6 #include <utility> 6 #include <utility>
7 7
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 } 44 }
45 45
46 void SetUp() override { ASSERT_TRUE(testing_profile_manager_.SetUp()); } 46 void SetUp() override { ASSERT_TRUE(testing_profile_manager_.SetUp()); }
47 47
48 virtual TestingProfile* CreateProfile(const std::string& name) { 48 virtual TestingProfile* CreateProfile(const std::string& name) {
49 return testing_profile_manager_.CreateTestingProfile(name); 49 return testing_profile_manager_.CreateTestingProfile(name);
50 } 50 }
51 51
52 void CreateController() { 52 void CreateController() {
53 controller_.reset(new MessageCenterSettingsController( 53 controller_.reset(new MessageCenterSettingsController(
54 testing_profile_manager_.profile_info_cache())); 54 *testing_profile_manager_.profile_attributes_storage()));
55 } 55 }
56 56
57 void ResetController() { 57 void ResetController() {
58 controller_.reset(); 58 controller_.reset();
59 } 59 }
60 60
61 MessageCenterSettingsController* controller() { return controller_.get(); } 61 MessageCenterSettingsController* controller() { return controller_.get(); }
62 62
63 private: 63 private:
64 content::TestBrowserThreadBundle thread_bundle_; 64 content::TestBrowserThreadBundle thread_bundle_;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 #if !defined(OS_CHROMEOS) 124 #if !defined(OS_CHROMEOS)
125 TEST_F(MessageCenterSettingsControllerTest, NotifierGroups) { 125 TEST_F(MessageCenterSettingsControllerTest, NotifierGroups) {
126 CreateProfile("Profile-1"); 126 CreateProfile("Profile-1");
127 CreateProfile("Profile-2"); 127 CreateProfile("Profile-2");
128 CreateController(); 128 CreateController();
129 129
130 EXPECT_EQ(controller()->GetNotifierGroupCount(), 2u); 130 EXPECT_EQ(controller()->GetNotifierGroupCount(), 2u);
131 131
132 EXPECT_EQ(controller()->GetNotifierGroupAt(0).name, 132 EXPECT_EQ(controller()->GetNotifierGroupAt(0).name,
133 base::UTF8ToUTF16("Profile-1")); 133 base::UTF8ToUTF16("Profile-1"));
134 EXPECT_EQ(controller()->GetNotifierGroupAt(0).index, 0u);
135
136 EXPECT_EQ(controller()->GetNotifierGroupAt(1).name, 134 EXPECT_EQ(controller()->GetNotifierGroupAt(1).name,
137 base::UTF8ToUTF16("Profile-2")); 135 base::UTF8ToUTF16("Profile-2"));
138 EXPECT_EQ(controller()->GetNotifierGroupAt(1).index, 1u);
139 136
140 EXPECT_EQ(controller()->GetActiveNotifierGroup().name, 137 EXPECT_EQ(controller()->GetActiveNotifierGroup().name,
141 base::UTF8ToUTF16("Profile-1")); 138 base::UTF8ToUTF16("Profile-1"));
142 EXPECT_EQ(controller()->GetActiveNotifierGroup().index, 0u);
143 139
144 controller()->SwitchToNotifierGroup(1); 140 controller()->SwitchToNotifierGroup(1);
145 EXPECT_EQ(controller()->GetActiveNotifierGroup().name, 141 EXPECT_EQ(controller()->GetActiveNotifierGroup().name,
146 base::UTF8ToUTF16("Profile-2")); 142 base::UTF8ToUTF16("Profile-2"));
147 EXPECT_EQ(controller()->GetActiveNotifierGroup().index, 1u);
148 143
149 controller()->SwitchToNotifierGroup(0); 144 controller()->SwitchToNotifierGroup(0);
150 EXPECT_EQ(controller()->GetActiveNotifierGroup().name, 145 EXPECT_EQ(controller()->GetActiveNotifierGroup().name,
151 base::UTF8ToUTF16("Profile-1")); 146 base::UTF8ToUTF16("Profile-1"));
152 } 147 }
153 #else // !defined(OS_CHROMEOS) 148 #else // !defined(OS_CHROMEOS)
154 TEST_F(MessageCenterSettingsControllerChromeOSTest, NotifierGroups) { 149 TEST_F(MessageCenterSettingsControllerChromeOSTest, NotifierGroups) {
155 CreateProfile("Profile-1"); 150 CreateProfile("Profile-1");
156 CreateProfile("Profile-2"); 151 CreateProfile("Profile-2");
157 CreateController(); 152 CreateController();
158 153
159 EXPECT_EQ(controller()->GetNotifierGroupCount(), 1u); 154 EXPECT_EQ(controller()->GetNotifierGroupCount(), 1u);
160 155
161 EXPECT_EQ(controller()->GetNotifierGroupAt(0).name, 156 EXPECT_EQ(controller()->GetNotifierGroupAt(0).name,
162 base::UTF8ToUTF16("Profile-1")); 157 base::UTF8ToUTF16("Profile-1"));
163 EXPECT_EQ(controller()->GetNotifierGroupAt(0).index, 0u);
164 158
165 SwitchActiveUser("Profile-2"); 159 SwitchActiveUser("Profile-2");
166 EXPECT_EQ(controller()->GetNotifierGroupCount(), 1u); 160 EXPECT_EQ(controller()->GetNotifierGroupCount(), 1u);
167 EXPECT_EQ(controller()->GetNotifierGroupAt(0).name, 161 EXPECT_EQ(controller()->GetNotifierGroupAt(0).name,
168 base::UTF8ToUTF16("Profile-2")); 162 base::UTF8ToUTF16("Profile-2"));
169 EXPECT_EQ(controller()->GetNotifierGroupAt(0).index, 1u);
170 163
171 SwitchActiveUser("Profile-1"); 164 SwitchActiveUser("Profile-1");
172 EXPECT_EQ(controller()->GetNotifierGroupCount(), 1u); 165 EXPECT_EQ(controller()->GetNotifierGroupCount(), 1u);
173 EXPECT_EQ(controller()->GetNotifierGroupAt(0).name, 166 EXPECT_EQ(controller()->GetNotifierGroupAt(0).name,
174 base::UTF8ToUTF16("Profile-1")); 167 base::UTF8ToUTF16("Profile-1"));
175 EXPECT_EQ(controller()->GetNotifierGroupAt(0).index, 0u);
176 } 168 }
177 // TODO(mukai): write a test case to reproduce the actual guest session scenario 169 // TODO(mukai): write a test case to reproduce the actual guest session scenario
178 // in ChromeOS -- no profiles in the profile_info_cache. 170 // in ChromeOS -- no profiles in the profile_info_cache.
179 #endif // !defined(OS_CHROMEOS) 171 #endif // !defined(OS_CHROMEOS)
180 172
181 TEST_F(MessageCenterSettingsControllerTest, NotifierSortOrder) { 173 TEST_F(MessageCenterSettingsControllerTest, NotifierSortOrder) {
182 TestingProfile* profile = CreateProfile("Profile-1"); 174 TestingProfile* profile = CreateProfile("Profile-1");
183 extensions::TestExtensionSystem* test_extension_system = 175 extensions::TestExtensionSystem* test_extension_system =
184 static_cast<extensions::TestExtensionSystem*>( 176 static_cast<extensions::TestExtensionSystem*>(
185 extensions::ExtensionSystem::Get(profile)); 177 extensions::ExtensionSystem::Get(profile));
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 // (5) Enable the permission when the default is blocked (expected to set). 333 // (5) Enable the permission when the default is blocked (expected to set).
342 controller()->SetNotifierEnabled(disabled_notifier, true); 334 controller()->SetNotifierEnabled(disabled_notifier, true);
343 EXPECT_EQ(CONTENT_SETTING_ALLOW, 335 EXPECT_EQ(CONTENT_SETTING_ALLOW,
344 DesktopNotificationProfileUtil::GetContentSetting(profile, origin)); 336 DesktopNotificationProfileUtil::GetContentSetting(profile, origin));
345 337
346 // (6) Disable the permission when the default is blocked (expected to clear). 338 // (6) Disable the permission when the default is blocked (expected to clear).
347 controller()->SetNotifierEnabled(enabled_notifier, false); 339 controller()->SetNotifierEnabled(enabled_notifier, false);
348 EXPECT_EQ(CONTENT_SETTING_BLOCK, 340 EXPECT_EQ(CONTENT_SETTING_BLOCK,
349 DesktopNotificationProfileUtil::GetContentSetting(profile, origin)); 341 DesktopNotificationProfileUtil::GetContentSetting(profile, origin));
350 } 342 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698