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

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

Issue 3005038: Uncrash BrowserFocusTest.* (Closed)
Patch Set: Created 10 years, 4 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
« 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "build/build_config.h" 5 #include "build/build_config.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/format_macros.h" 8 #include "base/format_macros.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 727 matching lines...) Expand 10 before | Expand all | Expand 10 after
738 MessageLoop::current()->PostDelayedTask( 738 MessageLoop::current()->PostDelayedTask(
739 FROM_HERE, new MessageLoop::QuitTask(), kActionDelayMs); 739 FROM_HERE, new MessageLoop::QuitTask(), kActionDelayMs);
740 ui_test_utils::RunMessageLoop(); 740 ui_test_utils::RunMessageLoop();
741 ASSERT_TRUE(IsViewFocused(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); 741 ASSERT_TRUE(IsViewFocused(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD));
742 } 742 }
743 743
744 // Makes sure the focus is in the right location when opening the different 744 // Makes sure the focus is in the right location when opening the different
745 // types of tabs. 745 // types of tabs.
746 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, TabInitialFocus) { 746 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, TabInitialFocus) {
747 BringBrowserWindowToFront(); 747 BringBrowserWindowToFront();
748
748 // Open the history tab, focus should be on the tab contents. 749 // Open the history tab, focus should be on the tab contents.
749 browser()->ShowHistoryTab(); 750 browser()->ShowHistoryTab();
750
751 ui_test_utils::RunAllPendingInMessageLoop(); 751 ui_test_utils::RunAllPendingInMessageLoop();
752
753 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); 752 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW));
754 753
755 // Open the new tab, focus should be on the location bar. 754 // Open the new tab, focus should be on the location bar.
756 browser()->NewTab(); 755 browser()->NewTab();
756 ui_test_utils::RunAllPendingInMessageLoop();
757 ASSERT_TRUE(IsViewFocused(VIEW_ID_LOCATION_BAR)); 757 ASSERT_TRUE(IsViewFocused(VIEW_ID_LOCATION_BAR));
758 758
759 // Open the download tab, focus should be on the tab contents. 759 // Open the download tab, focus should be on the tab contents.
760 browser()->ShowDownloadsTab(); 760 browser()->ShowDownloadsTab();
761 ui_test_utils::RunAllPendingInMessageLoop();
761 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); 762 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW));
762 763
763 // Open about:blank, focus should be on the location bar. 764 // Open about:blank, focus should be on the location bar.
764 browser()->AddTabWithURL(GURL("about:blank"), GURL(), PageTransition::LINK, 765 browser()->AddTabWithURL(GURL("about:blank"), GURL(), PageTransition::LINK,
765 -1, TabStripModel::ADD_SELECTED, NULL, 766 -1, TabStripModel::ADD_SELECTED, NULL,
766 std::string()); 767 std::string());
767 ASSERT_TRUE(IsViewFocused(VIEW_ID_LOCATION_BAR)); 768 ASSERT_TRUE(IsViewFocused(VIEW_ID_LOCATION_BAR));
768 } 769 }
769 770
770 // Tests that focus goes where expected when using reload. 771 // Tests that focus goes where expected when using reload.
771 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, FocusOnReload) { 772 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, FocusOnReload) {
772 BringBrowserWindowToFront(); 773 BringBrowserWindowToFront();
773 net::HTTPTestServer* server = StartHTTPServer(); 774 net::HTTPTestServer* server = StartHTTPServer();
774 ASSERT_TRUE(server); 775 ASSERT_TRUE(server);
775 776
776 // Open the new tab, reload. 777 // Open the new tab, reload.
777 browser()->NewTab(); 778 browser()->NewTab();
778
779 ui_test_utils::RunAllPendingInMessageLoop(); 779 ui_test_utils::RunAllPendingInMessageLoop();
780 780
781 browser()->Reload(CURRENT_TAB); 781 browser()->Reload(CURRENT_TAB);
782 ASSERT_TRUE(ui_test_utils::WaitForNavigationInCurrentTab(browser())); 782 ASSERT_TRUE(ui_test_utils::WaitForNavigationInCurrentTab(browser()));
783 // Focus should stay on the location bar. 783 // Focus should stay on the location bar.
784 ASSERT_TRUE(IsViewFocused(VIEW_ID_LOCATION_BAR)); 784 ASSERT_TRUE(IsViewFocused(VIEW_ID_LOCATION_BAR));
785 785
786 // Open a regular page, focus the location bar, reload. 786 // Open a regular page, focus the location bar, reload.
787 ui_test_utils::NavigateToURL(browser(), server->TestServerPage(kSimplePage)); 787 ui_test_utils::NavigateToURL(browser(), server->TestServerPage(kSimplePage));
788 browser()->FocusLocationBar(); 788 browser()->FocusLocationBar();
789 ASSERT_TRUE(IsViewFocused(VIEW_ID_LOCATION_BAR)); 789 ASSERT_TRUE(IsViewFocused(VIEW_ID_LOCATION_BAR));
790 browser()->Reload(CURRENT_TAB); 790 browser()->Reload(CURRENT_TAB);
791 ASSERT_TRUE(ui_test_utils::WaitForNavigationInCurrentTab(browser())); 791 ASSERT_TRUE(ui_test_utils::WaitForNavigationInCurrentTab(browser()));
792
792 // Focus should now be on the tab contents. 793 // Focus should now be on the tab contents.
793 browser()->ShowDownloadsTab(); 794 browser()->ShowDownloadsTab();
795 ui_test_utils::RunAllPendingInMessageLoop();
794 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); 796 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW));
795 } 797 }
796 798
797 // FocusOnReloadCrashedTab times out often on chromium os debug build. 799 // FocusOnReloadCrashedTab times out often on chromium os debug build.
798 // http://crbug.com/50025 800 // http://crbug.com/50025
799 #if defined(OS_CHROMEOS) && !defined(NDEBUG) 801 #if defined(OS_CHROMEOS) && !defined(NDEBUG)
800 #define MAYBE_FocusOnReloadCrashedTab DISABLED_FocusOnReloadCrashedTab 802 #define MAYBE_FocusOnReloadCrashedTab DISABLED_FocusOnReloadCrashedTab
801 #else 803 #else
802 #define MAYBE_FocusOnReloadCrashedTab FocusOnReloadCrashedTab 804 #define MAYBE_FocusOnReloadCrashedTab FocusOnReloadCrashedTab
803 #endif 805 #endif
804 806
805 // Tests that focus goes where expected when using reload on a crashed tab. 807 // Tests that focus goes where expected when using reload on a crashed tab.
806 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, MAYBE_FocusOnReloadCrashedTab) { 808 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, MAYBE_FocusOnReloadCrashedTab) {
807 BringBrowserWindowToFront(); 809 BringBrowserWindowToFront();
808 net::HTTPTestServer* server = StartHTTPServer(); 810 net::HTTPTestServer* server = StartHTTPServer();
809 ASSERT_TRUE(server); 811 ASSERT_TRUE(server);
810 812
811 // Open a regular page, crash, reload. 813 // Open a regular page, crash, reload.
812 ui_test_utils::NavigateToURL(browser(), server->TestServerPage(kSimplePage)); 814 ui_test_utils::NavigateToURL(browser(), server->TestServerPage(kSimplePage));
813 ui_test_utils::CrashTab(browser()->GetSelectedTabContents()); 815 ui_test_utils::CrashTab(browser()->GetSelectedTabContents());
814 browser()->Reload(CURRENT_TAB); 816 browser()->Reload(CURRENT_TAB);
815 ASSERT_TRUE(ui_test_utils::WaitForNavigationInCurrentTab(browser())); 817 ASSERT_TRUE(ui_test_utils::WaitForNavigationInCurrentTab(browser()));
818
816 // Focus should now be on the tab contents. 819 // Focus should now be on the tab contents.
817 browser()->ShowDownloadsTab(); 820 browser()->ShowDownloadsTab();
821 ui_test_utils::RunAllPendingInMessageLoop();
818 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); 822 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW));
819 } 823 }
820 824
821 } // namespace 825 } // 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