OLD | NEW |
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/command_updater.h" |
10 #include "chrome/browser/profiles/profile_manager.h" | 10 #include "chrome/browser/profiles/profile_manager.h" |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_EDIT_SEARCH_ENGINES)); | 248 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_EDIT_SEARCH_ENGINES)); |
249 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_VIEW_PASSWORDS)); | 249 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_VIEW_PASSWORDS)); |
250 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_ABOUT)); | 250 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_ABOUT)); |
251 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_SHOW_APP_MENU)); | 251 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_SHOW_APP_MENU)); |
252 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FULLSCREEN)); | 252 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FULLSCREEN)); |
253 | 253 |
254 // Simulate going fullscreen. | 254 // Simulate going fullscreen. |
255 chrome::ToggleFullscreenMode(browser()); | 255 chrome::ToggleFullscreenMode(browser()); |
256 ASSERT_TRUE(browser()->window()->IsFullscreen()); | 256 ASSERT_TRUE(browser()->window()->IsFullscreen()); |
257 browser()->command_controller()->FullscreenStateChanged(); | 257 browser()->command_controller()->FullscreenStateChanged(); |
258 #if defined(OS_MACOS) | 258 |
259 // Mac leaves things enabled in fullscreen. | 259 // Most commands are disabled in fullscreen. |
260 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_OPEN_CURRENT_URL)); | |
261 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_SHOW_AS_TAB)); | |
262 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_TOOLBAR)); | |
263 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_LOCATION)); | |
264 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_SEARCH)); | |
265 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_MENU_BAR)); | |
266 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_NEXT_PANE)); | |
267 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_PREVIOUS_PANE)); | |
268 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_BOOKMARKS)); | |
269 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEVELOPER_MENU)); | |
270 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FEEDBACK)); | |
271 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_OPTIONS)); | |
272 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_IMPORT_SETTINGS)); | |
273 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_EDIT_SEARCH_ENGINES)); | |
274 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_VIEW_PASSWORDS)); | |
275 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_ABOUT)); | |
276 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_SHOW_APP_MENU)); | |
277 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FULLSCREEN)); | |
278 #else | |
279 // Windows and GTK disable most commands in fullscreen. | |
280 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_OPEN_CURRENT_URL)); | 260 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_OPEN_CURRENT_URL)); |
281 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_SHOW_AS_TAB)); | 261 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_SHOW_AS_TAB)); |
282 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_TOOLBAR)); | 262 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_TOOLBAR)); |
283 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_LOCATION)); | 263 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_LOCATION)); |
284 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_SEARCH)); | 264 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_SEARCH)); |
285 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_MENU_BAR)); | 265 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_MENU_BAR)); |
286 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_NEXT_PANE)); | 266 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_NEXT_PANE)); |
287 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_PREVIOUS_PANE)); | 267 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_PREVIOUS_PANE)); |
288 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_BOOKMARKS)); | 268 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_BOOKMARKS)); |
289 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_DEVELOPER_MENU)); | 269 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_DEVELOPER_MENU)); |
290 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_FEEDBACK)); | 270 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_FEEDBACK)); |
291 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_OPTIONS)); | 271 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_OPTIONS)); |
292 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_IMPORT_SETTINGS)); | 272 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_IMPORT_SETTINGS)); |
293 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_EDIT_SEARCH_ENGINES)); | 273 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_EDIT_SEARCH_ENGINES)); |
294 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_VIEW_PASSWORDS)); | 274 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_VIEW_PASSWORDS)); |
295 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_ABOUT)); | 275 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_ABOUT)); |
296 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_SHOW_APP_MENU)); | 276 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_SHOW_APP_MENU)); |
297 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FULLSCREEN)); | 277 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FULLSCREEN)); |
298 #endif // defined(OS_MACOS) | |
299 | 278 |
300 // Exit fullscreen. | 279 // Exit fullscreen. |
301 chrome::ToggleFullscreenMode(browser()); | 280 chrome::ToggleFullscreenMode(browser()); |
302 ASSERT_FALSE(browser()->window()->IsFullscreen()); | 281 ASSERT_FALSE(browser()->window()->IsFullscreen()); |
303 browser()->command_controller()->FullscreenStateChanged(); | 282 browser()->command_controller()->FullscreenStateChanged(); |
304 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_OPEN_CURRENT_URL)); | 283 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_OPEN_CURRENT_URL)); |
305 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_SHOW_AS_TAB)); | 284 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_SHOW_AS_TAB)); |
306 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_TOOLBAR)); | 285 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_TOOLBAR)); |
307 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_LOCATION)); | 286 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_LOCATION)); |
308 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_SEARCH)); | 287 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_SEARCH)); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 ProfileManager* profile_manager = testing_profile_manager.profile_manager(); | 343 ProfileManager* profile_manager = testing_profile_manager.profile_manager(); |
365 chrome::BrowserCommandController command_controller(browser(), | 344 chrome::BrowserCommandController command_controller(browser(), |
366 profile_manager); | 345 profile_manager); |
367 const CommandUpdater* command_updater = command_controller.command_updater(); | 346 const CommandUpdater* command_updater = command_controller.command_updater(); |
368 | 347 |
369 // Check that the SYNC_SETUP command is updated on preference change. | 348 // Check that the SYNC_SETUP command is updated on preference change. |
370 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP)); | 349 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP)); |
371 profile()->GetPrefs()->SetBoolean(prefs::kSigninAllowed, false); | 350 profile()->GetPrefs()->SetBoolean(prefs::kSigninAllowed, false); |
372 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP)); | 351 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP)); |
373 } | 352 } |
OLD | NEW |