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

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: Extract managed user specific stuff into another changelist. 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::Builder profile_builder;
191 profile_builder.SetOffTheRecord();
192 scoped_ptr<TestingProfile> profile2 = profile_builder.Build();
193 TestingProfile* profile1 =
194 testing_profile_manager.CreateTestingProfile("p1");
195 profile2->SetOriginalProfile(profile1);
196 EXPECT_EQ(profile2->GetOriginalProfile(), profile1);
197 // Create a new browser based on the off the record profile.
198 scoped_ptr<Browser> browser2(
199 chrome::CreateBrowserWithTestWindowForProfile(profile2.get()));
200 profile1->SetOffTheRecordProfile(profile2.release());
201
202 ProfileManager* profile_manager = testing_profile_manager.profile_manager();
203 chrome::BrowserCommandController* command_controller =
204 new chrome::BrowserCommandController(browser2.get(), profile_manager);
205 const CommandUpdater* command_updater = command_controller->command_updater();
206
207 // Check that the SYNC_SETUP command is updated on preference change.
208 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP));
209 profile1->GetPrefs()->SetBoolean(prefs::kSigninAllowed, false);
210 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP));
211 delete command_controller;
212 browser2.reset();
213 testing_profile_manager.DeleteTestingProfile("p1");
214 }
215
216 TEST_F(BrowserCommandControllerTest,
217 OnSigninAllowedPrefChange) {
218 TestingProfileManager testing_profile_manager(
219 TestingBrowserProcess::GetGlobal());
220 ASSERT_TRUE(testing_profile_manager.SetUp());
221 ProfileManager* profile_manager = testing_profile_manager.profile_manager();
222 chrome::BrowserCommandController command_controller(browser(),
223 profile_manager);
224 const CommandUpdater* command_updater = command_controller.command_updater();
225
226 // Check that the SYNC_SETUP command is updated on preference change.
227 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP));
228 profile()->GetPrefs()->SetBoolean(prefs::kSigninAllowed, false);
229 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP));
230 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698