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

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

Issue 5769003: PrepopulateRespectBlank working, lets check the other test that was disabled... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years 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/ui/views/find_bar_host_interactive_uitest.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) 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/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
11 #include "base/string_number_conversions.h"
11 #include "base/string_util.h" 12 #include "base/string_util.h"
12 #include "base/utf_string_conversions.h" 13 #include "base/utf_string_conversions.h"
13 #include "chrome/browser/browser_window.h" 14 #include "chrome/browser/browser_window.h"
14 #include "chrome/browser/renderer_host/render_view_host.h" 15 #include "chrome/browser/renderer_host/render_view_host.h"
15 #include "chrome/browser/renderer_host/render_widget_host_view.h" 16 #include "chrome/browser/renderer_host/render_widget_host_view.h"
16 #include "chrome/browser/tab_contents/interstitial_page.h" 17 #include "chrome/browser/tab_contents/interstitial_page.h"
17 #include "chrome/browser/tab_contents/tab_contents.h" 18 #include "chrome/browser/tab_contents/tab_contents.h"
18 #include "chrome/browser/tab_contents/tab_contents_view.h" 19 #include "chrome/browser/tab_contents/tab_contents_view.h"
19 #include "chrome/browser/tabs/tab_strip_model.h" 20 #include "chrome/browser/tabs/tab_strip_model.h"
20 #include "chrome/browser/ui/browser.h" 21 #include "chrome/browser/ui/browser.h"
(...skipping 13 matching lines...) Expand all
34 #if defined(TOOLKIT_VIEWS) 35 #if defined(TOOLKIT_VIEWS)
35 #include "chrome/browser/views/frame/browser_view.h" 36 #include "chrome/browser/views/frame/browser_view.h"
36 #include "chrome/browser/views/location_bar/location_bar_view.h" 37 #include "chrome/browser/views/location_bar/location_bar_view.h"
37 #include "chrome/browser/views/tab_contents/tab_contents_container.h" 38 #include "chrome/browser/views/tab_contents/tab_contents_container.h"
38 #endif 39 #endif
39 40
40 #if defined(TOOLKIT_USES_GTK) 41 #if defined(TOOLKIT_USES_GTK)
41 #include "chrome/browser/gtk/view_id_util.h" 42 #include "chrome/browser/gtk/view_id_util.h"
42 #endif 43 #endif
43 44
45 #if defined(OS_WIN)
46 #include <windows.h>
47 #include <Psapi.h>
48 #endif
49
44 #if defined(OS_LINUX) 50 #if defined(OS_LINUX)
45 #define MAYBE_FocusTraversal FocusTraversal 51 #define MAYBE_FocusTraversal FocusTraversal
46 #define MAYBE_FocusTraversalOnInterstitial FocusTraversalOnInterstitial 52 #define MAYBE_FocusTraversalOnInterstitial FocusTraversalOnInterstitial
47 // TODO(jcampan): http://crbug.com/23683 53 // TODO(jcampan): http://crbug.com/23683
48 #define MAYBE_TabsRememberFocusFindInPage FAILS_TabsRememberFocusFindInPage 54 #define MAYBE_TabsRememberFocusFindInPage FAILS_TabsRememberFocusFindInPage
49 #elif defined(OS_MACOSX) 55 #elif defined(OS_MACOSX)
50 // TODO(suzhe): http://crbug.com/60973 (following two tests) 56 // TODO(suzhe): http://crbug.com/60973 (following two tests)
51 #define MAYBE_FocusTraversal DISABLED_FocusTraversal 57 #define MAYBE_FocusTraversal DISABLED_FocusTraversal
52 #define MAYBE_FocusTraversalOnInterstitial DISABLED_FocusTraversalOnInterstitial 58 #define MAYBE_FocusTraversalOnInterstitial DISABLED_FocusTraversalOnInterstitial
53 // TODO(suzhe): http://crbug.com/49737 59 // TODO(suzhe): http://crbug.com/49737
(...skipping 11 matching lines...) Expand all
65 71
66 // The delay waited in some cases where we don't have a notifications for an 72 // The delay waited in some cases where we don't have a notifications for an
67 // action we take. 73 // action we take.
68 const int kActionDelayMs = 500; 74 const int kActionDelayMs = 500;
69 75
70 const char kSimplePage[] = "files/focus/page_with_focus.html"; 76 const char kSimplePage[] = "files/focus/page_with_focus.html";
71 const char kStealFocusPage[] = "files/focus/page_steals_focus.html"; 77 const char kStealFocusPage[] = "files/focus/page_steals_focus.html";
72 const char kTypicalPage[] = "files/focus/typical_page.html"; 78 const char kTypicalPage[] = "files/focus/typical_page.html";
73 const char kTypicalPageName[] = "typical_page.html"; 79 const char kTypicalPageName[] = "typical_page.html";
74 80
81 // Test to make sure Chrome is in the foreground as we start testing. This is
82 // required for tests that synthesize input to the Chrome window.
83 bool ChromeInForeground() {
84 #if defined(OS_WIN)
85 HWND window = ::GetForegroundWindow();
86 std::wstring caption;
87 std::wstring filename;
88 int len = ::GetWindowTextLength(window) + 1;
89 ::GetWindowText(window, WriteInto(&caption, len), len);
90 bool chrome_window_in_foreground =
91 EndsWith(caption, L" - Google Chrome", true) ||
92 EndsWith(caption, L" - Chromium", true);
93 if (!chrome_window_in_foreground) {
94 DWORD process_id;
95 int thread_id = ::GetWindowThreadProcessId(window, &process_id);
96
97 base::ProcessHandle process;
98 if (base::OpenProcessHandleWithAccess(process_id,
99 PROCESS_QUERY_LIMITED_INFORMATION,
100 &process)) {
101 len = MAX_PATH;
102 if (!GetProcessImageFileName(process, WriteInto(&filename, len), len)) {
103 int error = GetLastError();
104 filename = std::wstring(L"Unable to read filename for process id '" +
105 base::IntToString16(process_id) +
106 L"' (error ") +
107 base::IntToString16(error) + L")";
108 }
109 base::CloseProcessHandle(process);
110 }
111 }
112 EXPECT_TRUE(chrome_window_in_foreground)
113 << "Chrome must be in the foreground when running interactive tests\n"
114 << "Process in foreground: " << filename.c_str() << "\n"
115 << "Window: " << window << "\n"
116 << "Caption: " << caption.c_str();
117 return chrome_window_in_foreground;
118 #else
119 // Windows only at the moment.
120 return true;
121 #endif
122 }
123
75 class BrowserFocusTest : public InProcessBrowserTest { 124 class BrowserFocusTest : public InProcessBrowserTest {
76 public: 125 public:
77 BrowserFocusTest() { 126 BrowserFocusTest() {
78 set_show_window(true); 127 set_show_window(true);
79 EnableDOMAutomation(); 128 EnableDOMAutomation();
80 } 129 }
81 130
82 bool IsViewFocused(ViewID vid) { 131 bool IsViewFocused(ViewID vid) {
83 return ui_test_utils::IsViewFocused(browser(), vid); 132 return ui_test_utils::IsViewFocused(browser(), vid);
84 } 133 }
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after
645 EXPECT_TRUE(interstitial_page->HasFocus()); 694 EXPECT_TRUE(interstitial_page->HasFocus());
646 695
647 // Hide the interstitial. 696 // Hide the interstitial.
648 interstitial_page->DontProceed(); 697 interstitial_page->DontProceed();
649 698
650 // Focus should be back on the original page. 699 // Focus should be back on the original page.
651 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); 700 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW));
652 } 701 }
653 702
654 // Make sure Find box can request focus, even when it is already open. 703 // Make sure Find box can request focus, even when it is already open.
655 // Disabled, http://crbug.com/62936. 704 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, FindFocusTest) {
656 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, DISABLED_FindFocusTest) {
657 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); 705 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
658 ASSERT_TRUE(test_server()->Start()); 706 ASSERT_TRUE(test_server()->Start());
659 707
660 // Open some page (any page that doesn't steal focus). 708 // Open some page (any page that doesn't steal focus).
661 GURL url = test_server()->GetURL(kTypicalPage); 709 GURL url = test_server()->GetURL(kTypicalPage);
662 ui_test_utils::NavigateToURL(browser(), url); 710 ui_test_utils::NavigateToURL(browser(), url);
663 711
712 EXPECT_TRUE(ChromeInForeground());
713
664 #if defined(OS_MACOSX) 714 #if defined(OS_MACOSX)
665 // Press Cmd+F, which will make the Find box open and request focus. 715 // Press Cmd+F, which will make the Find box open and request focus.
666 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( 716 ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
667 browser(), app::VKEY_F, false, false, false, true)); 717 browser(), app::VKEY_F, false, false, false, true));
668 #else 718 #else
669 // Press Ctrl+F, which will make the Find box open and request focus. 719 // Press Ctrl+F, which will make the Find box open and request focus.
670 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( 720 ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
671 browser(), app::VKEY_F, true, false, false, false)); 721 browser(), app::VKEY_F, true, false, false, false));
672 #endif 722 #endif
673 723
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
783 ui_test_utils::CrashTab(browser()->GetSelectedTabContents()); 833 ui_test_utils::CrashTab(browser()->GetSelectedTabContents());
784 browser()->Reload(CURRENT_TAB); 834 browser()->Reload(CURRENT_TAB);
785 ASSERT_TRUE(ui_test_utils::WaitForNavigationInCurrentTab(browser())); 835 ASSERT_TRUE(ui_test_utils::WaitForNavigationInCurrentTab(browser()));
786 836
787 // Focus should now be on the tab contents. 837 // Focus should now be on the tab contents.
788 browser()->ShowDownloadsTab(); 838 browser()->ShowDownloadsTab();
789 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW)); 839 ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW));
790 } 840 }
791 841
792 } // namespace 842 } // namespace
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/views/find_bar_host_interactive_uitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698