Chromium Code Reviews| 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 "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
| 10 #include "chrome/app/chrome_command_ids.h" | 10 #include "chrome/app/chrome_command_ids.h" |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 245 | 245 |
| 246 ////////////////////////////////////////////////////////////////////////////// | 246 ////////////////////////////////////////////////////////////////////////////// |
| 247 class BrowserCommandControllerFullscreenTest; | 247 class BrowserCommandControllerFullscreenTest; |
| 248 | 248 |
| 249 // A test browser window that can toggle fullscreen state. | 249 // A test browser window that can toggle fullscreen state. |
| 250 class FullscreenTestBrowserWindow : public TestBrowserWindow, | 250 class FullscreenTestBrowserWindow : public TestBrowserWindow, |
| 251 ExclusiveAccessContext { | 251 ExclusiveAccessContext { |
| 252 public: | 252 public: |
| 253 FullscreenTestBrowserWindow( | 253 FullscreenTestBrowserWindow( |
| 254 BrowserCommandControllerFullscreenTest* test_browser) | 254 BrowserCommandControllerFullscreenTest* test_browser) |
| 255 : fullscreen_(false), test_browser_(test_browser) {} | 255 : fullscreen_(false), |
| 256 toolbar_showing_(false), | |
| 257 test_browser_(test_browser) {} | |
| 256 | 258 |
| 257 ~FullscreenTestBrowserWindow() override {} | 259 ~FullscreenTestBrowserWindow() override {} |
| 258 | 260 |
| 259 // TestBrowserWindow overrides: | 261 // TestBrowserWindow overrides: |
| 260 bool ShouldHideUIForFullscreen() const override { return fullscreen_; } | 262 bool ShouldHideUIForFullscreen() const override { return fullscreen_; } |
| 261 bool IsFullscreen() const override { return fullscreen_; } | 263 bool IsFullscreen() const override { return fullscreen_; } |
| 262 void EnterFullscreen(const GURL& url, | 264 void EnterFullscreen(const GURL& url, |
| 263 ExclusiveAccessBubbleType type) override { | 265 ExclusiveAccessBubbleType type) override { |
| 264 fullscreen_ = true; | 266 fullscreen_ = true; |
| 265 } | 267 } |
| 266 void ExitFullscreen() override { fullscreen_ = false; } | 268 void ExitFullscreen() override { fullscreen_ = false; } |
| 269 bool IsToolbarShowing() const override { return toolbar_showing_; } | |
| 267 | 270 |
| 268 ExclusiveAccessContext* GetExclusiveAccessContext() override { return this; } | 271 ExclusiveAccessContext* GetExclusiveAccessContext() override { return this; } |
| 269 | 272 |
| 270 // Exclusive access interface: | 273 // Exclusive access interface: |
| 271 Profile* GetProfile() override; | 274 Profile* GetProfile() override; |
| 272 content::WebContents* GetActiveWebContents() override; | 275 content::WebContents* GetActiveWebContents() override; |
| 273 void HideDownloadShelf() override {} | 276 void HideDownloadShelf() override {} |
| 274 void UnhideDownloadShelf() override {} | 277 void UnhideDownloadShelf() override {} |
| 275 void UpdateExclusiveAccessExitBubbleContent( | 278 void UpdateExclusiveAccessExitBubbleContent( |
| 276 const GURL& url, | 279 const GURL& url, |
| 277 ExclusiveAccessBubbleType bubble_type) override {} | 280 ExclusiveAccessBubbleType bubble_type) override {} |
| 278 void OnExclusiveAccessUserInput() override {} | 281 void OnExclusiveAccessUserInput() override {} |
| 279 | 282 |
| 283 void set_toolbar_showing(bool showing) { toolbar_showing_ = showing; } | |
| 284 | |
| 280 private: | 285 private: |
| 281 bool fullscreen_; | 286 bool fullscreen_; |
| 287 bool toolbar_showing_; | |
| 282 BrowserCommandControllerFullscreenTest* test_browser_; | 288 BrowserCommandControllerFullscreenTest* test_browser_; |
| 283 | 289 |
| 284 DISALLOW_COPY_AND_ASSIGN(FullscreenTestBrowserWindow); | 290 DISALLOW_COPY_AND_ASSIGN(FullscreenTestBrowserWindow); |
| 285 }; | 291 }; |
| 286 | 292 |
| 287 // Test that uses FullscreenTestBrowserWindow for its window. | 293 // Test that uses FullscreenTestBrowserWindow for its window. |
| 288 class BrowserCommandControllerFullscreenTest | 294 class BrowserCommandControllerFullscreenTest |
| 289 : public BrowserWithTestWindowTest { | 295 : public BrowserWithTestWindowTest { |
| 290 public: | 296 public: |
| 291 BrowserCommandControllerFullscreenTest() {} | 297 BrowserCommandControllerFullscreenTest() {} |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 305 Profile* FullscreenTestBrowserWindow::GetProfile() { | 311 Profile* FullscreenTestBrowserWindow::GetProfile() { |
| 306 return test_browser_->GetBrowser()->profile(); | 312 return test_browser_->GetBrowser()->profile(); |
| 307 } | 313 } |
| 308 | 314 |
| 309 content::WebContents* FullscreenTestBrowserWindow::GetActiveWebContents() { | 315 content::WebContents* FullscreenTestBrowserWindow::GetActiveWebContents() { |
| 310 return test_browser_->GetBrowser()->tab_strip_model()->GetActiveWebContents(); | 316 return test_browser_->GetBrowser()->tab_strip_model()->GetActiveWebContents(); |
| 311 } | 317 } |
| 312 | 318 |
| 313 TEST_F(BrowserCommandControllerFullscreenTest, | 319 TEST_F(BrowserCommandControllerFullscreenTest, |
| 314 UpdateCommandsForFullscreenMode) { | 320 UpdateCommandsForFullscreenMode) { |
| 321 const int commands_enabled_in_tab[] = { | |
|
msw
2017/04/05 23:55:11
I have a slight preference for a struct with bool
Hzj_jie
2017/04/06 02:37:59
Done.
| |
| 322 IDC_OPEN_CURRENT_URL, | |
|
msw
2017/04/05 23:55:11
nit: use a consistent indentation level for these
Hzj_jie
2017/04/06 02:37:58
Weird, git cl format does not format all the lines
| |
| 323 IDC_FOCUS_TOOLBAR, | |
| 324 IDC_FOCUS_LOCATION, | |
| 325 IDC_FOCUS_SEARCH, | |
| 326 IDC_FOCUS_MENU_BAR, | |
| 327 IDC_FOCUS_NEXT_PANE, | |
| 328 IDC_FOCUS_PREVIOUS_PANE, | |
| 329 IDC_FOCUS_BOOKMARKS, | |
| 330 IDC_DEVELOPER_MENU, | |
| 331 #if defined(GOOGLE_CHROME_BUILD) | |
| 332 IDC_FEEDBACK, | |
| 333 #endif | |
| 334 IDC_OPTIONS, | |
| 335 IDC_IMPORT_SETTINGS, | |
| 336 IDC_EDIT_SEARCH_ENGINES, | |
| 337 IDC_VIEW_PASSWORDS, | |
| 338 IDC_ABOUT, | |
| 339 IDC_SHOW_APP_MENU, | |
| 340 IDC_FULLSCREEN, | |
| 341 IDC_CLOSE_TAB, | |
| 342 IDC_CLOSE_WINDOW, | |
| 343 IDC_NEW_INCOGNITO_WINDOW, | |
| 344 IDC_NEW_TAB, | |
| 345 IDC_NEW_WINDOW, | |
| 346 IDC_SELECT_NEXT_TAB, | |
| 347 IDC_SELECT_PREVIOUS_TAB, | |
| 348 IDC_EXIT, | |
| 349 }; | |
| 350 const int commands_disabled_in_tab[] = { | |
| 351 IDC_SHOW_AS_TAB, | |
| 352 }; | |
| 353 const int commands_enabled_in_fullscreen[] = { | |
| 354 IDC_FULLSCREEN, | |
| 355 IDC_CLOSE_TAB, | |
| 356 IDC_CLOSE_WINDOW, | |
| 357 IDC_NEW_INCOGNITO_WINDOW, | |
| 358 IDC_NEW_TAB, | |
| 359 IDC_NEW_WINDOW, | |
| 360 IDC_SELECT_NEXT_TAB, | |
| 361 IDC_SELECT_PREVIOUS_TAB, | |
| 362 IDC_EXIT, | |
| 363 }; | |
| 364 // Most commands are disabled in fullscreen. | |
| 365 const int commands_disabled_in_fullscreen[] = { | |
| 366 IDC_OPEN_CURRENT_URL, | |
| 367 IDC_SHOW_AS_TAB, | |
| 368 IDC_FOCUS_TOOLBAR, | |
| 369 IDC_FOCUS_LOCATION, | |
| 370 IDC_FOCUS_SEARCH, | |
| 371 IDC_FOCUS_MENU_BAR, | |
| 372 IDC_FOCUS_NEXT_PANE, | |
| 373 IDC_FOCUS_PREVIOUS_PANE, | |
| 374 IDC_FOCUS_BOOKMARKS, | |
| 375 IDC_DEVELOPER_MENU, | |
| 376 #if defined(GOOGLE_CHROME_BUILD) | |
| 377 IDC_FEEDBACK, | |
| 378 #endif | |
| 379 IDC_OPTIONS, | |
| 380 IDC_IMPORT_SETTINGS, | |
| 381 IDC_EDIT_SEARCH_ENGINES, | |
| 382 IDC_VIEW_PASSWORDS, | |
| 383 IDC_ABOUT, | |
| 384 IDC_SHOW_APP_MENU, | |
| 385 }; | |
| 386 | |
| 387 // The command shortcuts which are reserved by browser. | |
| 388 const int commands_reserved_in_tab[] = { | |
| 389 IDC_CLOSE_TAB, | |
| 390 IDC_CLOSE_WINDOW, | |
| 391 IDC_NEW_INCOGNITO_WINDOW, | |
| 392 IDC_NEW_TAB, | |
| 393 IDC_NEW_WINDOW, | |
| 394 IDC_SELECT_NEXT_TAB, | |
| 395 IDC_SELECT_PREVIOUS_TAB, | |
| 396 IDC_EXIT, | |
| 397 }; | |
| 398 const int commands_unreserved_in_tab[] = { | |
| 399 IDC_FULLSCREEN, | |
| 400 }; | |
| 401 // In fullscreen, only the exit fullscreen commands are reserved. All other | |
| 402 // shortcuts should be delivered to the web page. See http://crbug.com/680809. | |
| 403 const int commands_reserved_in_fullscreen[] = { | |
| 404 IDC_EXIT, IDC_FULLSCREEN, | |
| 405 }; | |
| 406 const int commands_unreserved_in_fullscreen[] = { | |
| 407 IDC_CLOSE_TAB, | |
| 408 IDC_CLOSE_WINDOW, | |
| 409 IDC_NEW_INCOGNITO_WINDOW, | |
| 410 IDC_NEW_TAB, | |
| 411 IDC_NEW_WINDOW, | |
| 412 IDC_SELECT_NEXT_TAB, | |
| 413 IDC_SELECT_PREVIOUS_TAB, | |
| 414 }; | |
| 415 const content::NativeWebKeyboardEvent key_event( | |
| 416 blink::WebInputEvent::TypeFirst, 0, 0); | |
| 315 // Defaults for a tabbed browser. | 417 // Defaults for a tabbed browser. |
| 316 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_OPEN_CURRENT_URL)); | 418 for (size_t i = 0; i < arraysize(commands_enabled_in_tab); i++) { |
| 317 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_SHOW_AS_TAB)); | 419 EXPECT_TRUE( |
|
msw
2017/04/05 23:55:11
Have you checked the output for a failure in this
Hzj_jie
2017/04/06 02:37:59
Done.
| |
| 318 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_TOOLBAR)); | 420 chrome::IsCommandEnabled(browser(), commands_enabled_in_tab[i])); |
| 319 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_LOCATION)); | 421 } |
| 320 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_SEARCH)); | 422 for (size_t i = 0; i < arraysize(commands_disabled_in_tab); i++) { |
| 321 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_MENU_BAR)); | 423 EXPECT_FALSE( |
| 322 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_NEXT_PANE)); | 424 chrome::IsCommandEnabled(browser(), commands_disabled_in_tab[i])); |
| 323 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_PREVIOUS_PANE)); | 425 } |
| 324 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_BOOKMARKS)); | 426 for (size_t i = 0; i < arraysize(commands_reserved_in_tab); i++) { |
| 325 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEVELOPER_MENU)); | 427 EXPECT_TRUE(browser()->command_controller()->IsReservedCommandOrKey( |
| 326 #if defined(GOOGLE_CHROME_BUILD) | 428 commands_reserved_in_tab[i], key_event)); |
| 327 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FEEDBACK)); | 429 } |
| 328 #endif | 430 for (size_t i = 0; i < arraysize(commands_unreserved_in_tab); i++) { |
| 329 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_OPTIONS)); | 431 EXPECT_FALSE(browser()->command_controller()->IsReservedCommandOrKey( |
| 330 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_IMPORT_SETTINGS)); | 432 commands_unreserved_in_tab[i], key_event)); |
| 331 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_EDIT_SEARCH_ENGINES)); | 433 } |
| 332 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_VIEW_PASSWORDS)); | |
| 333 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_ABOUT)); | |
| 334 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_SHOW_APP_MENU)); | |
| 335 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FULLSCREEN)); | |
| 336 | 434 |
| 337 // Simulate going fullscreen. | 435 // Simulate going fullscreen. |
| 338 chrome::ToggleFullscreenMode(browser()); | 436 chrome::ToggleFullscreenMode(browser()); |
| 339 ASSERT_TRUE(browser()->window()->IsFullscreen()); | 437 ASSERT_TRUE(browser()->window()->IsFullscreen()); |
| 340 browser()->command_controller()->FullscreenStateChanged(); | 438 browser()->command_controller()->FullscreenStateChanged(); |
| 341 | 439 |
| 342 // Most commands are disabled in fullscreen. | 440 #if defined(OS_MACOSX) |
| 343 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_OPEN_CURRENT_URL)); | 441 // Once the toolbar is not showing, the behavior on Mac OS should be |
|
msw
2017/04/05 23:55:10
nit: 'When the'
Hzj_jie
2017/04/06 02:37:58
Done.
| |
| 344 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_SHOW_AS_TAB)); | 442 // consistent as other platforms. |
|
msw
2017/04/05 23:55:10
nit: 'consistent with'
Hzj_jie
2017/04/06 02:37:58
Done.
| |
| 345 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_TOOLBAR)); | 443 static_cast<FullscreenTestBrowserWindow*>(window())->set_toolbar_showing( |
| 346 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_LOCATION)); | 444 false); |
| 347 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_SEARCH)); | |
| 348 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_MENU_BAR)); | |
| 349 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_NEXT_PANE)); | |
| 350 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_PREVIOUS_PANE)); | |
| 351 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_BOOKMARKS)); | |
| 352 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_DEVELOPER_MENU)); | |
| 353 #if defined(GOOGLE_CHROME_BUILD) | |
| 354 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_FEEDBACK)); | |
| 355 #endif | 445 #endif |
| 356 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_OPTIONS)); | 446 for (size_t i = 0; i < arraysize(commands_enabled_in_fullscreen); i++) { |
| 357 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_IMPORT_SETTINGS)); | 447 EXPECT_TRUE( |
| 358 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_EDIT_SEARCH_ENGINES)); | 448 chrome::IsCommandEnabled(browser(), commands_enabled_in_fullscreen[i])); |
| 359 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_VIEW_PASSWORDS)); | 449 } |
| 360 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_ABOUT)); | 450 for (size_t i = 0; i < arraysize(commands_disabled_in_fullscreen); i++) { |
| 361 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_SHOW_APP_MENU)); | 451 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), |
| 362 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FULLSCREEN)); | 452 commands_disabled_in_fullscreen[i])); |
| 453 } | |
| 454 for (size_t i = 0; i < arraysize(commands_reserved_in_fullscreen); i++) { | |
| 455 EXPECT_TRUE(browser()->command_controller()->IsReservedCommandOrKey( | |
| 456 commands_reserved_in_fullscreen[i], key_event)); | |
| 457 } | |
| 458 for (size_t i = 0; i < arraysize(commands_unreserved_in_fullscreen); i++) { | |
| 459 EXPECT_FALSE(browser()->command_controller()->IsReservedCommandOrKey( | |
| 460 commands_unreserved_in_fullscreen[i], key_event)); | |
| 461 } | |
| 363 | 462 |
| 463 #if defined(OS_MACOSX) | |
| 464 // If the toolbar is visible, all the keyboard shortcuts should be preserved | |
|
msw
2017/04/05 23:55:11
nit: "When the toolbar is showing, commands should
Hzj_jie
2017/04/06 02:37:59
Done.
| |
| 465 // by browser, include IDC_FULLSCREEN. | |
| 466 static_cast<FullscreenTestBrowserWindow*>(window())->set_toolbar_showing( | |
| 467 true); | |
| 468 for (size_t i = 0; i < arraysize(commands_reserved_in_tab); i++) { | |
| 469 EXPECT_TRUE(browser()->command_controller()->IsReservedCommandOrKey( | |
| 470 commands_reserved_in_tab[i], key_event)); | |
| 471 } | |
| 364 EXPECT_TRUE(browser()->command_controller()->IsReservedCommandOrKey( | 472 EXPECT_TRUE(browser()->command_controller()->IsReservedCommandOrKey( |
| 365 IDC_CLOSE_TAB, | 473 IDC_FULLSCREEN, key_event)); |
| 366 content::NativeWebKeyboardEvent(blink::WebInputEvent::TypeFirst, 0, 0))); | 474 for (size_t i = 0; i < arraysize(commands_unreserved_in_tab); i++) { |
| 367 EXPECT_TRUE(browser()->command_controller()->IsReservedCommandOrKey( | 475 if (commands_unreserved_in_tab[i] != IDC_FULLSCREEN) { |
|
msw
2017/04/05 23:55:11
aside: This is a bit odd, since the only value in
Hzj_jie
2017/04/06 02:37:59
Now all commands are in one structure, we do not h
| |
| 368 IDC_CLOSE_WINDOW, | 476 EXPECT_FALSE(browser()->command_controller()->IsReservedCommandOrKey( |
| 369 content::NativeWebKeyboardEvent(blink::WebInputEvent::TypeFirst, 0, 0))); | 477 commands_unreserved_in_tab[i], key_event)); |
| 370 EXPECT_TRUE(browser()->command_controller()->IsReservedCommandOrKey( | 478 } |
| 371 IDC_NEW_INCOGNITO_WINDOW, | 479 } |
| 372 content::NativeWebKeyboardEvent(blink::WebInputEvent::TypeFirst, 0, 0))); | 480 // Return to default state. |
| 373 EXPECT_TRUE(browser()->command_controller()->IsReservedCommandOrKey( | 481 static_cast<FullscreenTestBrowserWindow*>(window())->set_toolbar_showing( |
| 374 IDC_NEW_TAB, | 482 false); |
| 375 content::NativeWebKeyboardEvent(blink::WebInputEvent::TypeFirst, 0, 0))); | 483 #endif |
| 376 EXPECT_TRUE(browser()->command_controller()->IsReservedCommandOrKey( | |
| 377 IDC_NEW_WINDOW, | |
| 378 content::NativeWebKeyboardEvent(blink::WebInputEvent::TypeFirst, 0, 0))); | |
| 379 EXPECT_TRUE(browser()->command_controller()->IsReservedCommandOrKey( | |
| 380 IDC_SELECT_NEXT_TAB, | |
| 381 content::NativeWebKeyboardEvent(blink::WebInputEvent::TypeFirst, 0, 0))); | |
| 382 EXPECT_TRUE(browser()->command_controller()->IsReservedCommandOrKey( | |
| 383 IDC_SELECT_PREVIOUS_TAB, | |
| 384 content::NativeWebKeyboardEvent(blink::WebInputEvent::TypeFirst, 0, 0))); | |
| 385 EXPECT_TRUE(browser()->command_controller()->IsReservedCommandOrKey( | |
| 386 IDC_EXIT, | |
| 387 content::NativeWebKeyboardEvent(blink::WebInputEvent::TypeFirst, 0, 0))); | |
| 388 | 484 |
| 389 // Exit fullscreen. | 485 // Exit fullscreen. |
| 390 chrome::ToggleFullscreenMode(browser()); | 486 chrome::ToggleFullscreenMode(browser()); |
| 391 ASSERT_FALSE(browser()->window()->IsFullscreen()); | 487 ASSERT_FALSE(browser()->window()->IsFullscreen()); |
| 392 browser()->command_controller()->FullscreenStateChanged(); | 488 browser()->command_controller()->FullscreenStateChanged(); |
| 393 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_OPEN_CURRENT_URL)); | |
| 394 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_SHOW_AS_TAB)); | |
| 395 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_TOOLBAR)); | |
| 396 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_LOCATION)); | |
| 397 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_SEARCH)); | |
| 398 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_MENU_BAR)); | |
| 399 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_NEXT_PANE)); | |
| 400 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_PREVIOUS_PANE)); | |
| 401 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FOCUS_BOOKMARKS)); | |
| 402 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEVELOPER_MENU)); | |
| 403 #if defined(GOOGLE_CHROME_BUILD) | |
| 404 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FEEDBACK)); | |
| 405 #endif | |
| 406 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_OPTIONS)); | |
| 407 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_IMPORT_SETTINGS)); | |
| 408 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_EDIT_SEARCH_ENGINES)); | |
| 409 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_VIEW_PASSWORDS)); | |
| 410 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_ABOUT)); | |
| 411 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_SHOW_APP_MENU)); | |
| 412 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FULLSCREEN)); | |
| 413 | 489 |
| 414 EXPECT_TRUE(browser()->command_controller()->IsReservedCommandOrKey( | 490 for (size_t i = 0; i < arraysize(commands_enabled_in_tab); i++) { |
| 415 IDC_CLOSE_TAB, | 491 EXPECT_TRUE( |
| 416 content::NativeWebKeyboardEvent(blink::WebInputEvent::TypeFirst, 0, 0))); | 492 chrome::IsCommandEnabled(browser(), commands_enabled_in_tab[i])); |
| 417 EXPECT_TRUE(browser()->command_controller()->IsReservedCommandOrKey( | 493 } |
| 418 IDC_CLOSE_WINDOW, | 494 for (size_t i = 0; i < arraysize(commands_disabled_in_tab); i++) { |
| 419 content::NativeWebKeyboardEvent(blink::WebInputEvent::TypeFirst, 0, 0))); | 495 EXPECT_FALSE( |
| 420 EXPECT_TRUE(browser()->command_controller()->IsReservedCommandOrKey( | 496 chrome::IsCommandEnabled(browser(), commands_disabled_in_tab[i])); |
| 421 IDC_NEW_INCOGNITO_WINDOW, | 497 } |
| 422 content::NativeWebKeyboardEvent(blink::WebInputEvent::TypeFirst, 0, 0))); | 498 for (size_t i = 0; i < arraysize(commands_reserved_in_tab); i++) { |
| 423 EXPECT_TRUE(browser()->command_controller()->IsReservedCommandOrKey( | 499 EXPECT_TRUE(browser()->command_controller()->IsReservedCommandOrKey( |
| 424 IDC_NEW_TAB, | 500 commands_reserved_in_tab[i], key_event)); |
| 425 content::NativeWebKeyboardEvent(blink::WebInputEvent::TypeFirst, 0, 0))); | 501 } |
| 426 EXPECT_TRUE(browser()->command_controller()->IsReservedCommandOrKey( | 502 for (size_t i = 0; i < arraysize(commands_unreserved_in_tab); i++) { |
| 427 IDC_NEW_WINDOW, | 503 EXPECT_FALSE(browser()->command_controller()->IsReservedCommandOrKey( |
| 428 content::NativeWebKeyboardEvent(blink::WebInputEvent::TypeFirst, 0, 0))); | 504 commands_unreserved_in_tab[i], key_event)); |
| 429 EXPECT_TRUE(browser()->command_controller()->IsReservedCommandOrKey( | 505 } |
| 430 IDC_SELECT_NEXT_TAB, | |
| 431 content::NativeWebKeyboardEvent(blink::WebInputEvent::TypeFirst, 0, 0))); | |
| 432 EXPECT_TRUE(browser()->command_controller()->IsReservedCommandOrKey( | |
| 433 IDC_SELECT_PREVIOUS_TAB, | |
| 434 content::NativeWebKeyboardEvent(blink::WebInputEvent::TypeFirst, 0, 0))); | |
| 435 EXPECT_TRUE(browser()->command_controller()->IsReservedCommandOrKey( | |
| 436 IDC_EXIT, | |
| 437 content::NativeWebKeyboardEvent(blink::WebInputEvent::TypeFirst, 0, 0))); | |
| 438 | 506 |
| 439 // Guest Profiles disallow some options. | 507 // Guest Profiles disallow some options. |
| 440 TestingProfile* testprofile = browser()->profile()->AsTestingProfile(); | 508 TestingProfile* testprofile = browser()->profile()->AsTestingProfile(); |
| 441 EXPECT_TRUE(testprofile); | 509 EXPECT_TRUE(testprofile); |
| 442 testprofile->SetGuestSession(true); | 510 testprofile->SetGuestSession(true); |
| 443 | 511 |
| 444 browser()->command_controller()->FullscreenStateChanged(); | 512 browser()->command_controller()->FullscreenStateChanged(); |
| 445 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_OPTIONS)); | 513 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_OPTIONS)); |
| 446 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_IMPORT_SETTINGS)); | 514 EXPECT_FALSE(chrome::IsCommandEnabled(browser(), IDC_IMPORT_SETTINGS)); |
| 447 } | 515 } |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 496 | 564 |
| 497 TEST_F(BrowserCommandControllerTest, OnSigninAllowedPrefChange) { | 565 TEST_F(BrowserCommandControllerTest, OnSigninAllowedPrefChange) { |
| 498 chrome::BrowserCommandController command_controller(browser()); | 566 chrome::BrowserCommandController command_controller(browser()); |
| 499 const CommandUpdater* command_updater = command_controller.command_updater(); | 567 const CommandUpdater* command_updater = command_controller.command_updater(); |
| 500 | 568 |
| 501 // Check that the SYNC_SETUP command is updated on preference change. | 569 // Check that the SYNC_SETUP command is updated on preference change. |
| 502 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP)); | 570 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP)); |
| 503 profile()->GetPrefs()->SetBoolean(prefs::kSigninAllowed, false); | 571 profile()->GetPrefs()->SetBoolean(prefs::kSigninAllowed, false); |
| 504 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP)); | 572 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_SYNC_SETUP)); |
| 505 } | 573 } |
| OLD | NEW |