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

Side by Side Diff: chrome/browser/ui/browser_command_controller_unittest.cc

Issue 12088040: Add a SigninAllowed policy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address review comments and rebase to ToT. 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/ui/browser_command_controller.h" 5 #include "chrome/browser/ui/browser_command_controller.h"
6 6
7 #include "chrome/app/chrome_command_ids.h" 7 #include "chrome/app/chrome_command_ids.h"
8 #include "chrome/browser/browser_process.h" 8 #include "chrome/browser/browser_process.h"
9 #include "chrome/browser/command_updater.h"
9 #include "chrome/browser/profiles/profile_manager.h" 10 #include "chrome/browser/profiles/profile_manager.h"
10 #include "chrome/browser/ui/browser.h" 11 #include "chrome/browser/ui/browser.h"
11 #include "chrome/browser/ui/browser_commands.h" 12 #include "chrome/browser/ui/browser_commands.h"
12 #include "chrome/browser/ui/browser_window_state.h" 13 #include "chrome/browser/ui/browser_window_state.h"
14 #include "chrome/common/pref_names.h"
13 #include "chrome/test/base/browser_with_test_window_test.h" 15 #include "chrome/test/base/browser_with_test_window_test.h"
14 #include "chrome/test/base/testing_browser_process.h" 16 #include "chrome/test/base/testing_browser_process.h"
15 #include "chrome/test/base/testing_profile_manager.h" 17 #include "chrome/test/base/testing_profile_manager.h"
16 #include "content/public/browser/native_web_keyboard_event.h" 18 #include "content/public/browser/native_web_keyboard_event.h"
17 #include "ui/base/keycodes/keyboard_codes.h" 19 #include "ui/base/keycodes/keyboard_codes.h"
18 20
19 typedef BrowserWithTestWindowTest BrowserCommandControllerTest; 21 typedef BrowserWithTestWindowTest BrowserCommandControllerTest;
20 22
21 TEST_F(BrowserCommandControllerTest, IsReservedCommandOrKey) { 23 TEST_F(BrowserCommandControllerTest, IsReservedCommandOrKey) {
22 #if defined(OS_CHROMEOS) 24 #if defined(OS_CHROMEOS)
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 testing_profile_manager.CreateTestingProfile("p2"); 172 testing_profile_manager.CreateTestingProfile("p2");
171 ASSERT_EQ(2U, profile_manager->GetNumberOfProfiles()); 173 ASSERT_EQ(2U, profile_manager->GetNumberOfProfiles());
172 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SHOW_AVATAR_MENU)); 174 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SHOW_AVATAR_MENU));
173 175
174 testing_profile_manager.DeleteTestingProfile("p1"); 176 testing_profile_manager.DeleteTestingProfile("p1");
175 ASSERT_EQ(1U, profile_manager->GetNumberOfProfiles()); 177 ASSERT_EQ(1U, profile_manager->GetNumberOfProfiles());
176 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_AVATAR_MENU)); 178 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_AVATAR_MENU));
177 179
178 testing_profile_manager.DeleteTestingProfile("p2"); 180 testing_profile_manager.DeleteTestingProfile("p2");
179 } 181 }
182
183 TEST_F(BrowserCommandControllerTest,
184 IncognitoModeOnSigninAllowedPrefChange) {
185 TestingProfileManager testing_profile_manager(
186 TestingBrowserProcess::GetGlobal());
187 ASSERT_TRUE(testing_profile_manager.SetUp());
188
189 // Set up a profile with an off the record profile.
190 TestingProfile* profile2 = new TestingProfile();
191 profile2->set_incognito(true);
192 TestingProfile* profile1 =
193 testing_profile_manager.CreateTestingProfile("p1");
194 profile2->SetOriginalProfile(profile1);
195 EXPECT_EQ(profile2->GetOriginalProfile(), profile1);
196 profile1->SetOffTheRecordProfile(profile2);
197 // Create a new browser based on the off the record profile.
198 Browser::CreateParams profile_params(profile2,
199 chrome::HOST_DESKTOP_TYPE_NATIVE);
200 scoped_ptr<Browser> browser2(
201 chrome::CreateBrowserWithTestWindowForParams(&profile_params));
202
203 ProfileManager* profile_manager = testing_profile_manager.profile_manager();
204 chrome::BrowserCommandController* command_controller =
205 new chrome::BrowserCommandController(browser2.get(), profile_manager);
206 const CommandUpdater* command_updater = command_controller->command_updater();
207
208 // Check that the SYNC_SETUP command is updated on preference change.
209 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP));
210 profile1->GetPrefs()->SetBoolean(prefs::kSigninAllowed, false);
211 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP));
212 delete command_controller;
213 browser2.reset();
214 testing_profile_manager.DeleteTestingProfile("p1");
215 }
216
217 TEST_F(BrowserCommandControllerTest,
218 OnSigninAllowedPrefChange) {
219 TestingProfileManager testing_profile_manager(
220 TestingBrowserProcess::GetGlobal());
221 ASSERT_TRUE(testing_profile_manager.SetUp());
222 ProfileManager* profile_manager = testing_profile_manager.profile_manager();
223 chrome::BrowserCommandController command_controller(browser(),
224 profile_manager);
225 const CommandUpdater* command_updater = command_controller.command_updater();
226
227 // Check that the SYNC_SETUP command is updated on preference change.
228 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP));
229 profile()->GetPrefs()->SetBoolean(prefs::kSigninAllowed, false);
230 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP));
231 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698