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

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

Issue 7489019: Fix up various browser tests not to use WaitForNavigation. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 9 years, 5 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
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"
(...skipping 828 matching lines...) Expand 10 before | Expand all | Expand 10 after
839 browser()->GetSelectedTabContents())); 839 browser()->GetSelectedTabContents()));
840 EXPECT_TRUE(IsViewFocused(VIEW_ID_LOCATION_BAR)); 840 EXPECT_TRUE(IsViewFocused(VIEW_ID_LOCATION_BAR));
841 } 841 }
842 842
843 // Tests that focus goes where expected when using reload. 843 // Tests that focus goes where expected when using reload.
844 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, FocusOnReload) { 844 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, FocusOnReload) {
845 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); 845 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
846 ASSERT_TRUE(test_server()->Start()); 846 ASSERT_TRUE(test_server()->Start());
847 847
848 // Open the new tab, reload. 848 // Open the new tab, reload.
849 browser()->NewTab(); 849 {
850 ui_test_utils::WindowedNotificationObserver observer(
851 content::NOTIFICATION_LOAD_STOP,
852 NotificationService::AllSources());
853 browser()->NewTab();
854 observer.Wait();
855 }
850 ui_test_utils::RunAllPendingInMessageLoop(); 856 ui_test_utils::RunAllPendingInMessageLoop();
851 857
852 browser()->Reload(CURRENT_TAB); 858 {
853 ASSERT_TRUE(ui_test_utils::WaitForNavigationInCurrentTab(browser())); 859 ui_test_utils::WindowedNotificationObserver observer(*browser());
860 browser()->Reload(CURRENT_TAB);
861 observer.Wait();
862 }
854 // Focus should stay on the location bar. 863 // Focus should stay on the location bar.
855 ASSERT_TRUE(IsViewFocused(VIEW_ID_LOCATION_BAR)); 864 ASSERT_TRUE(IsViewFocused(VIEW_ID_LOCATION_BAR));
856 865
857 // Open a regular page, focus the location bar, reload. 866 // Open a regular page, focus the location bar, reload.
858 ui_test_utils::NavigateToURL(browser(), test_server()->GetURL(kSimplePage)); 867 ui_test_utils::NavigateToURL(browser(), test_server()->GetURL(kSimplePage));
859 browser()->FocusLocationBar(); 868 browser()->FocusLocationBar();
860 ASSERT_TRUE(IsViewFocused(VIEW_ID_LOCATION_BAR)); 869 ASSERT_TRUE(IsViewFocused(VIEW_ID_LOCATION_BAR));
861 browser()->Reload(CURRENT_TAB); 870 {
862 ASSERT_TRUE(ui_test_utils::WaitForNavigationInCurrentTab(browser())); 871 ui_test_utils::WindowedNotificationObserver observer(*browser());
872 browser()->Reload(CURRENT_TAB);
873 observer.Wait();
874 }
863 875
864 // Focus should now be on the tab contents. 876 // Focus should now be on the tab contents.
865 browser()->ShowDownloadsTab(); 877 browser()->ShowDownloadsTab();
866 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); 878 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW));
867 } 879 }
868 880
869 // Tests that focus goes where expected when using reload on a crashed tab. 881 // Tests that focus goes where expected when using reload on a crashed tab.
870 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, DISABLED_FocusOnReloadCrashedTab) { 882 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, DISABLED_FocusOnReloadCrashedTab) {
871 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); 883 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
872 ASSERT_TRUE(test_server()->Start()); 884 ASSERT_TRUE(test_server()->Start());
873 885
874 // Open a regular page, crash, reload. 886 // Open a regular page, crash, reload.
875 ui_test_utils::NavigateToURL(browser(), test_server()->GetURL(kSimplePage)); 887 ui_test_utils::NavigateToURL(browser(), test_server()->GetURL(kSimplePage));
876 ui_test_utils::CrashTab(browser()->GetSelectedTabContents()); 888 ui_test_utils::CrashTab(browser()->GetSelectedTabContents());
877 browser()->Reload(CURRENT_TAB); 889 {
878 ASSERT_TRUE(ui_test_utils::WaitForNavigationInCurrentTab(browser())); 890 ui_test_utils::WindowedNotificationObserver observer(*browser());
891 browser()->Reload(CURRENT_TAB);
892 observer.Wait();
893 }
879 894
880 // Focus should now be on the tab contents. 895 // Focus should now be on the tab contents.
881 browser()->ShowDownloadsTab(); 896 browser()->ShowDownloadsTab();
882 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); 897 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW));
883 } 898 }
884 899
885 } // namespace 900 } // namespace
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/crash_recovery_browsertest.cc » ('j') | chrome/browser/ssl/ssl_browser_tests.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698