| 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" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 #if defined(TOOLKIT_USES_GTK) | 43 #if defined(TOOLKIT_USES_GTK) |
| 44 #include "chrome/browser/ui/gtk/view_id_util.h" | 44 #include "chrome/browser/ui/gtk/view_id_util.h" |
| 45 #endif | 45 #endif |
| 46 | 46 |
| 47 #if defined(OS_WIN) | 47 #if defined(OS_WIN) |
| 48 #include <Psapi.h> | 48 #include <Psapi.h> |
| 49 #include <windows.h> | 49 #include <windows.h> |
| 50 #include "base/string_util.h" | 50 #include "base/string_util.h" |
| 51 #endif | 51 #endif |
| 52 | 52 |
| 53 using content::NavigationController; |
| 53 using content::WebContents; | 54 using content::WebContents; |
| 54 | 55 |
| 55 #if defined(OS_MACOSX) | 56 #if defined(OS_MACOSX) |
| 56 // TODO(suzhe): http://crbug.com/60973 | 57 // TODO(suzhe): http://crbug.com/60973 |
| 57 #define MAYBE_FocusTraversal DISABLED_FocusTraversal | 58 #define MAYBE_FocusTraversal DISABLED_FocusTraversal |
| 58 #define MAYBE_FocusTraversalOnInterstitial DISABLED_FocusTraversalOnInterstitial | 59 #define MAYBE_FocusTraversalOnInterstitial DISABLED_FocusTraversalOnInterstitial |
| 59 #else | 60 #else |
| 60 #define MAYBE_FocusTraversal FocusTraversal | 61 #define MAYBE_FocusTraversal FocusTraversal |
| 61 #define MAYBE_FocusTraversalOnInterstitial FocusTraversalOnInterstitial | 62 #define MAYBE_FocusTraversalOnInterstitial FocusTraversalOnInterstitial |
| 62 #endif | 63 #endif |
| (...skipping 783 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 846 content::NOTIFICATION_LOAD_STOP, | 847 content::NOTIFICATION_LOAD_STOP, |
| 847 content::NotificationService::AllSources()); | 848 content::NotificationService::AllSources()); |
| 848 browser()->NewTab(); | 849 browser()->NewTab(); |
| 849 observer.Wait(); | 850 observer.Wait(); |
| 850 } | 851 } |
| 851 ui_test_utils::RunAllPendingInMessageLoop(); | 852 ui_test_utils::RunAllPendingInMessageLoop(); |
| 852 | 853 |
| 853 { | 854 { |
| 854 ui_test_utils::WindowedNotificationObserver observer( | 855 ui_test_utils::WindowedNotificationObserver observer( |
| 855 content::NOTIFICATION_LOAD_STOP, | 856 content::NOTIFICATION_LOAD_STOP, |
| 856 content::Source<content::NavigationController>( | 857 content::Source<NavigationController>( |
| 857 &browser()->GetSelectedTabContentsWrapper()->web_contents()-> | 858 &browser()->GetSelectedTabContentsWrapper()->web_contents()-> |
| 858 GetController())); | 859 GetController())); |
| 859 browser()->Reload(CURRENT_TAB); | 860 browser()->Reload(CURRENT_TAB); |
| 860 observer.Wait(); | 861 observer.Wait(); |
| 861 } | 862 } |
| 862 // Focus should stay on the location bar. | 863 // Focus should stay on the location bar. |
| 863 ASSERT_TRUE(IsViewFocused(location_bar_focus_view_id_)); | 864 ASSERT_TRUE(IsViewFocused(location_bar_focus_view_id_)); |
| 864 | 865 |
| 865 // Open a regular page, focus the location bar, reload. | 866 // Open a regular page, focus the location bar, reload. |
| 866 ui_test_utils::NavigateToURL(browser(), test_server()->GetURL(kSimplePage)); | 867 ui_test_utils::NavigateToURL(browser(), test_server()->GetURL(kSimplePage)); |
| 867 browser()->FocusLocationBar(); | 868 browser()->FocusLocationBar(); |
| 868 ASSERT_TRUE(IsViewFocused(location_bar_focus_view_id_)); | 869 ASSERT_TRUE(IsViewFocused(location_bar_focus_view_id_)); |
| 869 { | 870 { |
| 870 ui_test_utils::WindowedNotificationObserver observer( | 871 ui_test_utils::WindowedNotificationObserver observer( |
| 871 content::NOTIFICATION_LOAD_STOP, | 872 content::NOTIFICATION_LOAD_STOP, |
| 872 content::Source<content::NavigationController>( | 873 content::Source<NavigationController>( |
| 873 &browser()->GetSelectedTabContentsWrapper()->web_contents()-> | 874 &browser()->GetSelectedTabContentsWrapper()->web_contents()-> |
| 874 GetController())); | 875 GetController())); |
| 875 browser()->Reload(CURRENT_TAB); | 876 browser()->Reload(CURRENT_TAB); |
| 876 observer.Wait(); | 877 observer.Wait(); |
| 877 } | 878 } |
| 878 | 879 |
| 879 // Focus should now be on the tab contents. | 880 // Focus should now be on the tab contents. |
| 880 browser()->ShowDownloadsTab(); | 881 browser()->ShowDownloadsTab(); |
| 881 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); | 882 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); |
| 882 } | 883 } |
| 883 | 884 |
| 884 // Tests that focus goes where expected when using reload on a crashed tab. | 885 // Tests that focus goes where expected when using reload on a crashed tab. |
| 885 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, DISABLED_FocusOnReloadCrashedTab) { | 886 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, DISABLED_FocusOnReloadCrashedTab) { |
| 886 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); | 887 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); |
| 887 ASSERT_TRUE(test_server()->Start()); | 888 ASSERT_TRUE(test_server()->Start()); |
| 888 | 889 |
| 889 // Open a regular page, crash, reload. | 890 // Open a regular page, crash, reload. |
| 890 ui_test_utils::NavigateToURL(browser(), test_server()->GetURL(kSimplePage)); | 891 ui_test_utils::NavigateToURL(browser(), test_server()->GetURL(kSimplePage)); |
| 891 ui_test_utils::CrashTab(browser()->GetSelectedWebContents()); | 892 ui_test_utils::CrashTab(browser()->GetSelectedWebContents()); |
| 892 { | 893 { |
| 893 ui_test_utils::WindowedNotificationObserver observer( | 894 ui_test_utils::WindowedNotificationObserver observer( |
| 894 content::NOTIFICATION_LOAD_STOP, | 895 content::NOTIFICATION_LOAD_STOP, |
| 895 content::Source<content::NavigationController>( | 896 content::Source<NavigationController>( |
| 896 &browser()->GetSelectedTabContentsWrapper()->web_contents()-> | 897 &browser()->GetSelectedTabContentsWrapper()->web_contents()-> |
| 897 GetController())); | 898 GetController())); |
| 898 browser()->Reload(CURRENT_TAB); | 899 browser()->Reload(CURRENT_TAB); |
| 899 observer.Wait(); | 900 observer.Wait(); |
| 900 } | 901 } |
| 901 | 902 |
| 902 // Focus should now be on the tab contents. | 903 // Focus should now be on the tab contents. |
| 903 browser()->ShowDownloadsTab(); | 904 browser()->ShowDownloadsTab(); |
| 904 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); | 905 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); |
| 905 } | 906 } |
| 906 | 907 |
| 907 } // namespace | 908 } // namespace |
| OLD | NEW |