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

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

Issue 2488383003: Reenable several BrowserFocusTests under crbug/163931 (Closed)
Patch Set: Created 4 years, 1 month 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/files/file_util.h" 8 #include "base/files/file_util.h"
9 #include "base/format_macros.h" 9 #include "base/format_macros.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 focused_browser->window()->Activate(); 410 focused_browser->window()->Activate();
411 411
412 ASSERT_TRUE(content::ExecuteScript( 412 ASSERT_TRUE(content::ExecuteScript(
413 unfocused_browser->tab_strip_model()->GetActiveWebContents(), 413 unfocused_browser->tab_strip_model()->GetActiveWebContents(),
414 "stealFocus();")); 414 "stealFocus();"));
415 415
416 // Make sure the first browser is still active. 416 // Make sure the first browser is still active.
417 EXPECT_TRUE(focused_browser->window()->IsActive()); 417 EXPECT_TRUE(focused_browser->window()->IsActive());
418 } 418 }
419 419
420 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(USE_AURA)
421 // TODO(erg): http://crbug.com/163931
422 #define MAYBE_LocationBarLockFocus DISABLED_LocationBarLockFocus
423 #else
424 #define MAYBE_LocationBarLockFocus LocationBarLockFocus
425 #endif
426
427 // Page cannot steal focus when focus is on location bar. 420 // Page cannot steal focus when focus is on location bar.
428 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, MAYBE_LocationBarLockFocus) { 421 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, LocationBarLockFocus) {
429 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); 422 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
423 ui_test_utils::BrowserActivationWaiter waiter(browser());
424 waiter.WaitForActivation();
430 425
431 // Open the page that steals focus. 426 // Open the page that steals focus.
432 const GURL url = embedded_test_server()->GetURL(kStealFocusPage); 427 const GURL url = embedded_test_server()->GetURL(kStealFocusPage);
433 ui_test_utils::NavigateToURL(browser(), url); 428 ui_test_utils::NavigateToURL(browser(), url);
434 429
435 chrome::FocusLocationBar(browser()); 430 chrome::FocusLocationBar(browser());
436 431
437 ASSERT_TRUE(content::ExecuteScript( 432 ASSERT_TRUE(content::ExecuteScript(
438 browser()->tab_strip_model()->GetActiveWebContents(), 433 browser()->tab_strip_model()->GetActiveWebContents(),
439 "stealFocus();")); 434 "stealFocus();"));
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 EXPECT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER)); 553 EXPECT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER));
559 554
560 // Open about:blank, focus should be on the location bar. 555 // Open about:blank, focus should be on the location bar.
561 chrome::AddSelectedTabWithURL( 556 chrome::AddSelectedTabWithURL(
562 browser(), GURL(url::kAboutBlankURL), ui::PAGE_TRANSITION_LINK); 557 browser(), GURL(url::kAboutBlankURL), ui::PAGE_TRANSITION_LINK);
563 ASSERT_NO_FATAL_FAILURE(content::WaitForLoadStop( 558 ASSERT_NO_FATAL_FAILURE(content::WaitForLoadStop(
564 browser()->tab_strip_model()->GetActiveWebContents())); 559 browser()->tab_strip_model()->GetActiveWebContents()));
565 EXPECT_TRUE(IsViewFocused(VIEW_ID_OMNIBOX)); 560 EXPECT_TRUE(IsViewFocused(VIEW_ID_OMNIBOX));
566 } 561 }
567 562
568 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(USE_AURA)
569 // TODO(erg): http://crbug.com/163931
570 #define MAYBE_FocusOnReload DISABLED_FocusOnReload
571 #else
572 #define MAYBE_FocusOnReload FocusOnReload
573 #endif
574
575 // Tests that focus goes where expected when using reload. 563 // Tests that focus goes where expected when using reload.
576 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, MAYBE_FocusOnReload) { 564 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, FocusOnReload) {
577 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); 565 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
566 ui_test_utils::BrowserActivationWaiter waiter(browser());
567 waiter.WaitForActivation();
578 568
579 // Open the new tab, reload. 569 // Open the new tab, reload.
580 { 570 {
581 content::WindowedNotificationObserver observer( 571 content::WindowedNotificationObserver observer(
582 content::NOTIFICATION_LOAD_STOP, 572 content::NOTIFICATION_LOAD_STOP,
583 content::NotificationService::AllSources()); 573 content::NotificationService::AllSources());
584 chrome::NewTab(browser()); 574 chrome::NewTab(browser());
585 observer.Wait(); 575 observer.Wait();
586 } 576 }
587 content::RunAllPendingInMessageLoop(); 577 content::RunAllPendingInMessageLoop();
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
681 671
682 // The tab contents should have the focus in the second tab. 672 // The tab contents should have the focus in the second tab.
683 EXPECT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER)); 673 EXPECT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER));
684 674
685 // Go back to the first tab. The focus should not be in the omnibox. 675 // Go back to the first tab. The focus should not be in the omnibox.
686 chrome::SelectPreviousTab(browser()); 676 chrome::SelectPreviousTab(browser());
687 EXPECT_EQ(0, browser()->tab_strip_model()->active_index()); 677 EXPECT_EQ(0, browser()->tab_strip_model()->active_index());
688 EXPECT_FALSE(IsViewFocused(VIEW_ID_OMNIBOX)); 678 EXPECT_FALSE(IsViewFocused(VIEW_ID_OMNIBOX));
689 } 679 }
690 680
691 // This functionality is currently broken. http://crbug.com/304865. 681 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, FocusOnNavigate) {
692 // 682 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
693 // #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(USE_AURA) 683 ui_test_utils::BrowserActivationWaiter waiter(browser());
694 // // TODO(erg): http://crbug.com/163931 684 waiter.WaitForActivation();
695 // #define MAYBE_FocusOnNavigate DISABLED_FocusOnNavigate
696 // #else
697 // #define MAYBE_FocusOnNavigate FocusOnNavigate
698 // #endif
699 685
700 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, DISABLED_FocusOnNavigate) {
701 // Needed on Mac.
702 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
703 // Load the NTP. 686 // Load the NTP.
704 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL)); 687 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL));
705 EXPECT_TRUE(IsViewFocused(VIEW_ID_OMNIBOX)); 688 EXPECT_TRUE(IsViewFocused(VIEW_ID_OMNIBOX));
706 689
707 // Navigate to another page. 690 // Navigate to another page.
708 const base::FilePath::CharType* kEmptyFile = FILE_PATH_LITERAL("empty.html"); 691 const base::FilePath::CharType* kEmptyFile = FILE_PATH_LITERAL("empty.html");
709 GURL file_url(ui_test_utils::GetTestUrl(base::FilePath( 692 GURL file_url(ui_test_utils::GetTestUrl(base::FilePath(
710 base::FilePath::kCurrentDirectory), base::FilePath(kEmptyFile))); 693 base::FilePath::kCurrentDirectory), base::FilePath(kEmptyFile)));
711 ui_test_utils::NavigateToURL(browser(), file_url); 694 ui_test_utils::NavigateToURL(browser(), file_url);
712 695
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
755 ASSERT_TRUE(content::ExecuteScript(web_contents, spoof)); 738 ASSERT_TRUE(content::ExecuteScript(web_contents, spoof));
756 EXPECT_EQ(url1, web_contents->GetVisibleURL()); 739 EXPECT_EQ(url1, web_contents->GetVisibleURL());
757 // After running the spoof code, |GetActiveWebContents| returns the new tab, 740 // After running the spoof code, |GetActiveWebContents| returns the new tab,
758 // not the same as |web_contents|. 741 // not the same as |web_contents|.
759 ASSERT_NO_FATAL_FAILURE(content::WaitForLoadStop( 742 ASSERT_NO_FATAL_FAILURE(content::WaitForLoadStop(
760 browser()->tab_strip_model()->GetActiveWebContents())); 743 browser()->tab_strip_model()->GetActiveWebContents()));
761 EXPECT_FALSE(IsViewFocused(VIEW_ID_OMNIBOX)); 744 EXPECT_FALSE(IsViewFocused(VIEW_ID_OMNIBOX));
762 } 745 }
763 746
764 } // namespace 747 } // namespace
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698