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 "app/keyboard_codes.h" | |
6 #include "base/process_util.h" | 5 #include "base/process_util.h" |
7 #include "base/string_util.h" | 6 #include "base/string_util.h" |
8 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
9 #include "chrome/browser/tab_contents/tab_contents.h" | 8 #include "chrome/browser/tab_contents/tab_contents.h" |
10 #include "chrome/browser/tabs/tab_strip_model.h" | 9 #include "chrome/browser/tabs/tab_strip_model.h" |
11 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
12 #include "chrome/browser/ui/find_bar/find_bar_controller.h" | 11 #include "chrome/browser/ui/find_bar/find_bar_controller.h" |
13 #include "chrome/browser/ui/view_ids.h" | 12 #include "chrome/browser/ui/view_ids.h" |
14 #include "chrome/browser/ui/views/find_bar_host.h" | 13 #include "chrome/browser/ui/views/find_bar_host.h" |
15 #include "chrome/browser/ui/views/frame/browser_view.h" | 14 #include "chrome/browser/ui/views/frame/browser_view.h" |
16 #include "chrome/test/in_process_browser_test.h" | 15 #include "chrome/test/in_process_browser_test.h" |
17 #include "chrome/test/ui_test_utils.h" | 16 #include "chrome/test/ui_test_utils.h" |
18 #include "net/test/test_server.h" | 17 #include "net/test/test_server.h" |
| 18 #include "ui/base/keycodes/keyboard_codes.h" |
19 #include "views/focus/focus_manager.h" | 19 #include "views/focus/focus_manager.h" |
20 #include "views/view.h" | 20 #include "views/view.h" |
21 | 21 |
22 namespace { | 22 namespace { |
23 | 23 |
24 // The delay waited after sending an OS simulated event. | 24 // The delay waited after sending an OS simulated event. |
25 static const int kActionDelayMs = 500; | 25 static const int kActionDelayMs = 500; |
26 static const char kSimplePage[] = "files/find_in_page/simple.html"; | 26 static const char kSimplePage[] = "files/find_in_page/simple.html"; |
27 | 27 |
28 class FindInPageTest : public InProcessBrowserTest { | 28 class FindInPageTest : public InProcessBrowserTest { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 // Click on the location bar so that Find box loses focus. | 66 // Click on the location bar so that Find box loses focus. |
67 ASSERT_NO_FATAL_FAILURE(ui_test_utils::ClickOnView(browser(), | 67 ASSERT_NO_FATAL_FAILURE(ui_test_utils::ClickOnView(browser(), |
68 VIEW_ID_LOCATION_BAR)); | 68 VIEW_ID_LOCATION_BAR)); |
69 #if defined(TOOLKIT_VIEWS) || defined(OS_WIN) | 69 #if defined(TOOLKIT_VIEWS) || defined(OS_WIN) |
70 // Check the location bar is focused. | 70 // Check the location bar is focused. |
71 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_LOCATION_BAR)); | 71 EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_LOCATION_BAR)); |
72 #endif | 72 #endif |
73 | 73 |
74 // This used to crash until bug 1303709 was fixed. | 74 // This used to crash until bug 1303709 was fixed. |
75 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( | 75 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( |
76 browser(), app::VKEY_ESCAPE, false, false, false, false)); | 76 browser(), ui::VKEY_ESCAPE, false, false, false, false)); |
77 } | 77 } |
78 | 78 |
79 IN_PROC_BROWSER_TEST_F(FindInPageTest, FocusRestore) { | 79 IN_PROC_BROWSER_TEST_F(FindInPageTest, FocusRestore) { |
80 ASSERT_TRUE(test_server()->Start()); | 80 ASSERT_TRUE(test_server()->Start()); |
81 | 81 |
82 GURL url = test_server()->GetURL("title1.html"); | 82 GURL url = test_server()->GetURL("title1.html"); |
83 ui_test_utils::NavigateToURL(browser(), url); | 83 ui_test_utils::NavigateToURL(browser(), url); |
84 | 84 |
85 // Focus the location bar, open and close the find-in-page, focus should | 85 // Focus the location bar, open and close the find-in-page, focus should |
86 // return to the location bar. | 86 // return to the location bar. |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 | 185 |
186 // First we navigate to any page. | 186 // First we navigate to any page. |
187 GURL url = test_server()->GetURL(kSimplePage); | 187 GURL url = test_server()->GetURL(kSimplePage); |
188 ui_test_utils::NavigateToURL(browser(), url); | 188 ui_test_utils::NavigateToURL(browser(), url); |
189 | 189 |
190 // Show the Find bar. | 190 // Show the Find bar. |
191 browser()->GetFindBarController()->Show(); | 191 browser()->GetFindBarController()->Show(); |
192 | 192 |
193 // Search for "a". | 193 // Search for "a". |
194 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( | 194 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( |
195 browser(), app::VKEY_A, false, false, false, false)); | 195 browser(), ui::VKEY_A, false, false, false, false)); |
196 | 196 |
197 // We should find "a" here. | 197 // We should find "a" here. |
198 EXPECT_EQ(ASCIIToUTF16("a"), GetFindBarText()); | 198 EXPECT_EQ(ASCIIToUTF16("a"), GetFindBarText()); |
199 | 199 |
200 // Delete "a". | 200 // Delete "a". |
201 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( | 201 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( |
202 browser(), app::VKEY_BACK, false, false, false, false)); | 202 browser(), ui::VKEY_BACK, false, false, false, false)); |
203 | 203 |
204 // Validate we have cleared the text. | 204 // Validate we have cleared the text. |
205 EXPECT_EQ(string16(), GetFindBarText()); | 205 EXPECT_EQ(string16(), GetFindBarText()); |
206 | 206 |
207 // Close the Find box. | 207 // Close the Find box. |
208 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( | 208 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( |
209 browser(), app::VKEY_ESCAPE, false, false, false, false)); | 209 browser(), ui::VKEY_ESCAPE, false, false, false, false)); |
210 | 210 |
211 // Show the Find bar. | 211 // Show the Find bar. |
212 browser()->GetFindBarController()->Show(); | 212 browser()->GetFindBarController()->Show(); |
213 | 213 |
214 // After the Find box has been reopened, it should not have been prepopulated | 214 // After the Find box has been reopened, it should not have been prepopulated |
215 // with "a" again. | 215 // with "a" again. |
216 EXPECT_EQ(string16(), GetFindBarText()); | 216 EXPECT_EQ(string16(), GetFindBarText()); |
217 | 217 |
218 // Close the Find box. | 218 // Close the Find box. |
219 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( | 219 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( |
220 browser(), app::VKEY_ESCAPE, false, false, false, false)); | 220 browser(), ui::VKEY_ESCAPE, false, false, false, false)); |
221 | 221 |
222 // Press F3 to trigger FindNext. | 222 // Press F3 to trigger FindNext. |
223 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( | 223 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( |
224 browser(), app::VKEY_F3, false, false, false, false)); | 224 browser(), ui::VKEY_F3, false, false, false, false)); |
225 | 225 |
226 // After the Find box has been reopened, it should still have no prepopulate | 226 // After the Find box has been reopened, it should still have no prepopulate |
227 // value. | 227 // value. |
228 EXPECT_EQ(string16(), GetFindBarText()); | 228 EXPECT_EQ(string16(), GetFindBarText()); |
229 } | 229 } |
OLD | NEW |