OLD | NEW |
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 "base/keyboard_codes.h" | 5 #include "base/keyboard_codes.h" |
6 #include "base/message_loop.h" | 6 #include "base/message_loop.h" |
7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "chrome/browser/automation/ui_controls.h" | 9 #include "chrome/browser/automation/ui_controls.h" |
10 #include "chrome/browser/browser.h" | 10 #include "chrome/browser/browser.h" |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 string16 GetFindBarText() { | 82 string16 GetFindBarText() { |
83 FindBarTesting* find_bar = | 83 FindBarTesting* find_bar = |
84 browser()->GetFindBarController()->find_bar()->GetFindBarTesting(); | 84 browser()->GetFindBarController()->find_bar()->GetFindBarTesting(); |
85 return find_bar->GetFindText(); | 85 return find_bar->GetFindText(); |
86 } | 86 } |
87 }; | 87 }; |
88 | 88 |
89 } // namespace | 89 } // namespace |
90 | 90 |
91 IN_PROC_BROWSER_TEST_F(FindInPageTest, CrashEscHandlers) { | 91 IN_PROC_BROWSER_TEST_F(FindInPageTest, CrashEscHandlers) { |
92 scoped_refptr<net::HTTPTestServer> server(net::HTTPTestServer::CreateServer(kD
ocRoot)); | 92 scoped_refptr<net::HTTPTestServer> server( |
| 93 net::HTTPTestServer::CreateServer(kDocRoot)); |
93 ASSERT_TRUE(NULL != server.get()); | 94 ASSERT_TRUE(NULL != server.get()); |
94 | 95 |
95 // First we navigate to our test page (tab A). | 96 // First we navigate to our test page (tab A). |
96 GURL url = server->TestServerPage(kSimplePage); | 97 GURL url = server->TestServerPage(kSimplePage); |
97 ui_test_utils::NavigateToURL(browser(), url); | 98 ui_test_utils::NavigateToURL(browser(), url); |
98 | 99 |
99 browser()->Find(); | 100 browser()->Find(); |
100 | 101 |
101 // Open another tab (tab B). | 102 // Open another tab (tab B). |
| 103 Browser* browser_used = NULL; |
102 browser()->AddTabWithURL(url, GURL(), PageTransition::TYPED, -1, | 104 browser()->AddTabWithURL(url, GURL(), PageTransition::TYPED, -1, |
103 TabStripModel::ADD_SELECTED, NULL, std::string()); | 105 TabStripModel::ADD_SELECTED, NULL, std::string(), |
| 106 &browser_used); |
| 107 EXPECT_EQ(browser(), browser_used); |
104 | 108 |
105 browser()->Find(); | 109 browser()->Find(); |
106 EXPECT_EQ(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD, GetFocusedViewID()); | 110 EXPECT_EQ(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD, GetFocusedViewID()); |
107 | 111 |
108 // Select tab A. | 112 // Select tab A. |
109 browser()->SelectTabContentsAt(0, true); | 113 browser()->SelectTabContentsAt(0, true); |
110 | 114 |
111 // Close tab B. | 115 // Close tab B. |
112 browser()->CloseTabContents(browser()->GetTabContentsAt(1)); | 116 browser()->CloseTabContents(browser()->GetTabContentsAt(1)); |
113 | 117 |
114 // Click on the location bar so that Find box loses focus. | 118 // Click on the location bar so that Find box loses focus. |
115 ClickOnView(VIEW_ID_LOCATION_BAR); | 119 ClickOnView(VIEW_ID_LOCATION_BAR); |
116 #if defined(TOOLKIT_VIEWS) || defined(OS_WIN) | 120 #if defined(TOOLKIT_VIEWS) || defined(OS_WIN) |
117 // Check the location bar is focused. | 121 // Check the location bar is focused. |
118 EXPECT_EQ(VIEW_ID_LOCATION_BAR, GetFocusedViewID()); | 122 EXPECT_EQ(VIEW_ID_LOCATION_BAR, GetFocusedViewID()); |
119 #endif | 123 #endif |
120 | 124 |
121 // This used to crash until bug 1303709 was fixed. | 125 // This used to crash until bug 1303709 was fixed. |
122 ui_controls::SendKeyPressNotifyWhenDone( | 126 ui_controls::SendKeyPressNotifyWhenDone( |
123 browser()->window()->GetNativeHandle(), base::VKEY_ESCAPE, | 127 browser()->window()->GetNativeHandle(), base::VKEY_ESCAPE, |
124 false, false, false, false, new MessageLoop::QuitTask()); | 128 false, false, false, false, new MessageLoop::QuitTask()); |
125 ui_test_utils::RunMessageLoop(); | 129 ui_test_utils::RunMessageLoop(); |
126 } | 130 } |
127 | 131 |
128 IN_PROC_BROWSER_TEST_F(FindInPageTest, FocusRestore) { | 132 IN_PROC_BROWSER_TEST_F(FindInPageTest, FocusRestore) { |
129 scoped_refptr<net::HTTPTestServer> server(net::HTTPTestServer::CreateServer(kD
ocRoot)); | 133 scoped_refptr<net::HTTPTestServer> server( |
| 134 net::HTTPTestServer::CreateServer(kDocRoot)); |
130 ASSERT_TRUE(NULL != server.get()); | 135 ASSERT_TRUE(NULL != server.get()); |
131 | 136 |
132 GURL url = server->TestServerPage("title1.html"); | 137 GURL url = server->TestServerPage("title1.html"); |
133 ui_test_utils::NavigateToURL(browser(), url); | 138 ui_test_utils::NavigateToURL(browser(), url); |
134 | 139 |
135 // Focus the location bar, open and close the find-in-page, focus should | 140 // Focus the location bar, open and close the find-in-page, focus should |
136 // return to the location bar. | 141 // return to the location bar. |
137 browser()->FocusLocationBar(); | 142 browser()->FocusLocationBar(); |
138 EXPECT_EQ(VIEW_ID_LOCATION_BAR, GetFocusedViewID()); | 143 EXPECT_EQ(VIEW_ID_LOCATION_BAR, GetFocusedViewID()); |
139 // Ensure the creation of the find bar controller. | 144 // Ensure the creation of the find bar controller. |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 // Press F3 to trigger FindNext. | 232 // Press F3 to trigger FindNext. |
228 ui_controls::SendKeyPressNotifyWhenDone(window, base::VKEY_F3, | 233 ui_controls::SendKeyPressNotifyWhenDone(window, base::VKEY_F3, |
229 false, false, false, false, // No modifiers. | 234 false, false, false, false, // No modifiers. |
230 new MessageLoop::QuitTask()); | 235 new MessageLoop::QuitTask()); |
231 ui_test_utils::RunMessageLoop(); | 236 ui_test_utils::RunMessageLoop(); |
232 | 237 |
233 // After the Find box has been reopened, it should still have no prepopulate | 238 // After the Find box has been reopened, it should still have no prepopulate |
234 // value. | 239 // value. |
235 EXPECT_EQ(string16(), GetFindBarText()); | 240 EXPECT_EQ(string16(), GetFindBarText()); |
236 } | 241 } |
OLD | NEW |