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

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

Issue 7633032: Revert 96593 - Fix up various browser tests not to use WaitForNavigation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/crash_recovery_browsertest.cc » ('j') | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
11 #include "base/stringprintf.h" 11 #include "base/stringprintf.h"
12 #include "base/string_number_conversions.h" 12 #include "base/string_number_conversions.h"
13 #include "base/utf_string_conversions.h" 13 #include "base/utf_string_conversions.h"
14 #include "chrome/browser/tabs/tab_strip_model.h" 14 #include "chrome/browser/tabs/tab_strip_model.h"
15 #include "chrome/browser/ui/browser.h" 15 #include "chrome/browser/ui/browser.h"
16 #include "chrome/browser/ui/browser_window.h" 16 #include "chrome/browser/ui/browser_window.h"
17 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
18 #include "chrome/browser/ui/view_ids.h" 17 #include "chrome/browser/ui/view_ids.h"
19 #include "chrome/common/chrome_notification_types.h" 18 #include "chrome/common/chrome_notification_types.h"
20 #include "chrome/common/chrome_paths.h" 19 #include "chrome/common/chrome_paths.h"
21 #include "chrome/common/url_constants.h" 20 #include "chrome/common/url_constants.h"
22 #include "chrome/test/base/ui_test_utils.h" 21 #include "chrome/test/base/ui_test_utils.h"
23 #include "chrome/test/base/in_process_browser_test.h" 22 #include "chrome/test/base/in_process_browser_test.h"
24 #include "content/browser/renderer_host/render_view_host.h" 23 #include "content/browser/renderer_host/render_view_host.h"
25 #include "content/browser/renderer_host/render_widget_host_view.h" 24 #include "content/browser/renderer_host/render_widget_host_view.h"
26 #include "content/browser/tab_contents/interstitial_page.h" 25 #include "content/browser/tab_contents/interstitial_page.h"
27 #include "content/browser/tab_contents/tab_contents.h" 26 #include "content/browser/tab_contents/tab_contents.h"
(...skipping 813 matching lines...) Expand 10 before | Expand all | Expand 10 after
841 browser()->GetSelectedTabContents())); 840 browser()->GetSelectedTabContents()));
842 EXPECT_TRUE(IsViewFocused(VIEW_ID_LOCATION_BAR)); 841 EXPECT_TRUE(IsViewFocused(VIEW_ID_LOCATION_BAR));
843 } 842 }
844 843
845 // Tests that focus goes where expected when using reload. 844 // Tests that focus goes where expected when using reload.
846 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, FocusOnReload) { 845 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, FocusOnReload) {
847 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); 846 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
848 ASSERT_TRUE(test_server()->Start()); 847 ASSERT_TRUE(test_server()->Start());
849 848
850 // Open the new tab, reload. 849 // Open the new tab, reload.
851 { 850 browser()->NewTab();
852 ui_test_utils::WindowedNotificationObserver observer(
853 content::NOTIFICATION_LOAD_STOP,
854 NotificationService::AllSources());
855 browser()->NewTab();
856 observer.Wait();
857 }
858 ui_test_utils::RunAllPendingInMessageLoop(); 851 ui_test_utils::RunAllPendingInMessageLoop();
859 852
860 { 853 browser()->Reload(CURRENT_TAB);
861 ui_test_utils::WindowedNotificationObserver observer( 854 ASSERT_TRUE(ui_test_utils::WaitForNavigationInCurrentTab(browser()));
862 content::NOTIFICATION_LOAD_STOP,
863 Source<NavigationController>(
864 &browser()->GetSelectedTabContentsWrapper()->controller()));
865 browser()->Reload(CURRENT_TAB);
866 observer.Wait();
867 }
868 // Focus should stay on the location bar. 855 // Focus should stay on the location bar.
869 ASSERT_TRUE(IsViewFocused(VIEW_ID_LOCATION_BAR)); 856 ASSERT_TRUE(IsViewFocused(VIEW_ID_LOCATION_BAR));
870 857
871 // Open a regular page, focus the location bar, reload. 858 // Open a regular page, focus the location bar, reload.
872 ui_test_utils::NavigateToURL(browser(), test_server()->GetURL(kSimplePage)); 859 ui_test_utils::NavigateToURL(browser(), test_server()->GetURL(kSimplePage));
873 browser()->FocusLocationBar(); 860 browser()->FocusLocationBar();
874 ASSERT_TRUE(IsViewFocused(VIEW_ID_LOCATION_BAR)); 861 ASSERT_TRUE(IsViewFocused(VIEW_ID_LOCATION_BAR));
875 { 862 browser()->Reload(CURRENT_TAB);
876 ui_test_utils::WindowedNotificationObserver observer( 863 ASSERT_TRUE(ui_test_utils::WaitForNavigationInCurrentTab(browser()));
877 content::NOTIFICATION_LOAD_STOP,
878 Source<NavigationController>(
879 &browser()->GetSelectedTabContentsWrapper()->controller()));
880 browser()->Reload(CURRENT_TAB);
881 observer.Wait();
882 }
883 864
884 // Focus should now be on the tab contents. 865 // Focus should now be on the tab contents.
885 browser()->ShowDownloadsTab(); 866 browser()->ShowDownloadsTab();
886 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); 867 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW));
887 } 868 }
888 869
889 // Tests that focus goes where expected when using reload on a crashed tab. 870 // Tests that focus goes where expected when using reload on a crashed tab.
890 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, DISABLED_FocusOnReloadCrashedTab) { 871 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, DISABLED_FocusOnReloadCrashedTab) {
891 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); 872 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
892 ASSERT_TRUE(test_server()->Start()); 873 ASSERT_TRUE(test_server()->Start());
893 874
894 // Open a regular page, crash, reload. 875 // Open a regular page, crash, reload.
895 ui_test_utils::NavigateToURL(browser(), test_server()->GetURL(kSimplePage)); 876 ui_test_utils::NavigateToURL(browser(), test_server()->GetURL(kSimplePage));
896 ui_test_utils::CrashTab(browser()->GetSelectedTabContents()); 877 ui_test_utils::CrashTab(browser()->GetSelectedTabContents());
897 { 878 browser()->Reload(CURRENT_TAB);
898 ui_test_utils::WindowedNotificationObserver observer( 879 ASSERT_TRUE(ui_test_utils::WaitForNavigationInCurrentTab(browser()));
899 content::NOTIFICATION_LOAD_STOP,
900 Source<NavigationController>(
901 &browser()->GetSelectedTabContentsWrapper()->controller()));
902 browser()->Reload(CURRENT_TAB);
903 observer.Wait();
904 }
905 880
906 // Focus should now be on the tab contents. 881 // Focus should now be on the tab contents.
907 browser()->ShowDownloadsTab(); 882 browser()->ShowDownloadsTab();
908 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); 883 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW));
909 } 884 }
910 885
911 } // namespace 886 } // namespace
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/crash_recovery_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698