OLD | NEW |
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" |
17 #include "chrome/browser/ui/view_ids.h" | 18 #include "chrome/browser/ui/view_ids.h" |
18 #include "chrome/common/chrome_notification_types.h" | 19 #include "chrome/common/chrome_notification_types.h" |
19 #include "chrome/common/chrome_paths.h" | 20 #include "chrome/common/chrome_paths.h" |
20 #include "chrome/common/url_constants.h" | 21 #include "chrome/common/url_constants.h" |
21 #include "chrome/test/base/ui_test_utils.h" | 22 #include "chrome/test/base/ui_test_utils.h" |
22 #include "chrome/test/base/in_process_browser_test.h" | 23 #include "chrome/test/base/in_process_browser_test.h" |
23 #include "content/browser/renderer_host/render_view_host.h" | 24 #include "content/browser/renderer_host/render_view_host.h" |
24 #include "content/browser/renderer_host/render_widget_host_view.h" | 25 #include "content/browser/renderer_host/render_widget_host_view.h" |
25 #include "content/browser/tab_contents/interstitial_page.h" | 26 #include "content/browser/tab_contents/interstitial_page.h" |
26 #include "content/browser/tab_contents/tab_contents.h" | 27 #include "content/browser/tab_contents/tab_contents.h" |
(...skipping 813 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
840 browser()->GetSelectedTabContents())); | 841 browser()->GetSelectedTabContents())); |
841 EXPECT_TRUE(IsViewFocused(VIEW_ID_LOCATION_BAR)); | 842 EXPECT_TRUE(IsViewFocused(VIEW_ID_LOCATION_BAR)); |
842 } | 843 } |
843 | 844 |
844 // Tests that focus goes where expected when using reload. | 845 // Tests that focus goes where expected when using reload. |
845 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, FocusOnReload) { | 846 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, FocusOnReload) { |
846 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); | 847 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); |
847 ASSERT_TRUE(test_server()->Start()); | 848 ASSERT_TRUE(test_server()->Start()); |
848 | 849 |
849 // Open the new tab, reload. | 850 // Open the new tab, reload. |
850 browser()->NewTab(); | 851 { |
| 852 ui_test_utils::WindowedNotificationObserver observer( |
| 853 content::NOTIFICATION_LOAD_STOP, |
| 854 NotificationService::AllSources()); |
| 855 browser()->NewTab(); |
| 856 observer.Wait(); |
| 857 } |
851 ui_test_utils::RunAllPendingInMessageLoop(); | 858 ui_test_utils::RunAllPendingInMessageLoop(); |
852 | 859 |
853 browser()->Reload(CURRENT_TAB); | 860 { |
854 ASSERT_TRUE(ui_test_utils::WaitForNavigationInCurrentTab(browser())); | 861 ui_test_utils::WindowedNotificationObserver observer( |
| 862 content::NOTIFICATION_LOAD_STOP, |
| 863 Source<NavigationController>( |
| 864 &browser()->GetSelectedTabContentsWrapper()->controller())); |
| 865 browser()->Reload(CURRENT_TAB); |
| 866 observer.Wait(); |
| 867 } |
855 // Focus should stay on the location bar. | 868 // Focus should stay on the location bar. |
856 ASSERT_TRUE(IsViewFocused(VIEW_ID_LOCATION_BAR)); | 869 ASSERT_TRUE(IsViewFocused(VIEW_ID_LOCATION_BAR)); |
857 | 870 |
858 // Open a regular page, focus the location bar, reload. | 871 // Open a regular page, focus the location bar, reload. |
859 ui_test_utils::NavigateToURL(browser(), test_server()->GetURL(kSimplePage)); | 872 ui_test_utils::NavigateToURL(browser(), test_server()->GetURL(kSimplePage)); |
860 browser()->FocusLocationBar(); | 873 browser()->FocusLocationBar(); |
861 ASSERT_TRUE(IsViewFocused(VIEW_ID_LOCATION_BAR)); | 874 ASSERT_TRUE(IsViewFocused(VIEW_ID_LOCATION_BAR)); |
862 browser()->Reload(CURRENT_TAB); | 875 { |
863 ASSERT_TRUE(ui_test_utils::WaitForNavigationInCurrentTab(browser())); | 876 ui_test_utils::WindowedNotificationObserver observer( |
| 877 content::NOTIFICATION_LOAD_STOP, |
| 878 Source<NavigationController>( |
| 879 &browser()->GetSelectedTabContentsWrapper()->controller())); |
| 880 browser()->Reload(CURRENT_TAB); |
| 881 observer.Wait(); |
| 882 } |
864 | 883 |
865 // Focus should now be on the tab contents. | 884 // Focus should now be on the tab contents. |
866 browser()->ShowDownloadsTab(); | 885 browser()->ShowDownloadsTab(); |
867 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); | 886 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); |
868 } | 887 } |
869 | 888 |
870 // Tests that focus goes where expected when using reload on a crashed tab. | 889 // Tests that focus goes where expected when using reload on a crashed tab. |
871 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, DISABLED_FocusOnReloadCrashedTab) { | 890 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, DISABLED_FocusOnReloadCrashedTab) { |
872 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); | 891 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); |
873 ASSERT_TRUE(test_server()->Start()); | 892 ASSERT_TRUE(test_server()->Start()); |
874 | 893 |
875 // Open a regular page, crash, reload. | 894 // Open a regular page, crash, reload. |
876 ui_test_utils::NavigateToURL(browser(), test_server()->GetURL(kSimplePage)); | 895 ui_test_utils::NavigateToURL(browser(), test_server()->GetURL(kSimplePage)); |
877 ui_test_utils::CrashTab(browser()->GetSelectedTabContents()); | 896 ui_test_utils::CrashTab(browser()->GetSelectedTabContents()); |
878 browser()->Reload(CURRENT_TAB); | 897 { |
879 ASSERT_TRUE(ui_test_utils::WaitForNavigationInCurrentTab(browser())); | 898 ui_test_utils::WindowedNotificationObserver observer( |
| 899 content::NOTIFICATION_LOAD_STOP, |
| 900 Source<NavigationController>( |
| 901 &browser()->GetSelectedTabContentsWrapper()->controller())); |
| 902 browser()->Reload(CURRENT_TAB); |
| 903 observer.Wait(); |
| 904 } |
880 | 905 |
881 // Focus should now be on the tab contents. | 906 // Focus should now be on the tab contents. |
882 browser()->ShowDownloadsTab(); | 907 browser()->ShowDownloadsTab(); |
883 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); | 908 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); |
884 } | 909 } |
885 | 910 |
886 } // namespace | 911 } // namespace |
OLD | NEW |