| 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" | 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" |
| 11 #include "chrome/browser/browser_window.h" | 11 #include "chrome/browser/browser_window.h" |
| 12 #include "chrome/browser/find_bar_controller.h" | 12 #include "chrome/browser/find_bar_controller.h" |
| 13 #include "chrome/browser/tab_contents/tab_contents.h" | 13 #include "chrome/browser/tab_contents/tab_contents.h" |
| 14 #include "chrome/browser/views/find_bar_host.h" | 14 #include "chrome/browser/views/find_bar_host.h" |
| 15 #include "chrome/browser/views/frame/browser_view.h" | 15 #include "chrome/browser/views/frame/browser_view.h" |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 | 114 |
| 115 // Click on the location bar so that Find box loses focus. | 115 // Click on the location bar so that Find box loses focus. |
| 116 ASSERT_NO_FATAL_FAILURE(ClickOnView(VIEW_ID_LOCATION_BAR)); | 116 ASSERT_NO_FATAL_FAILURE(ClickOnView(VIEW_ID_LOCATION_BAR)); |
| 117 #if defined(TOOLKIT_VIEWS) || defined(OS_WIN) | 117 #if defined(TOOLKIT_VIEWS) || defined(OS_WIN) |
| 118 // Check the location bar is focused. | 118 // Check the location bar is focused. |
| 119 EXPECT_EQ(VIEW_ID_LOCATION_BAR, GetFocusedViewID()); | 119 EXPECT_EQ(VIEW_ID_LOCATION_BAR, GetFocusedViewID()); |
| 120 #endif | 120 #endif |
| 121 | 121 |
| 122 // This used to crash until bug 1303709 was fixed. | 122 // This used to crash until bug 1303709 was fixed. |
| 123 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( | 123 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( |
| 124 browser()->window()->GetNativeHandle(), app::VKEY_ESCAPE, | 124 browser()->window()->GetNativeHandle(), base::VKEY_ESCAPE, |
| 125 false, false, false, false)); | 125 false, false, false, false)); |
| 126 } | 126 } |
| 127 | 127 |
| 128 IN_PROC_BROWSER_TEST_F(FindInPageTest, FocusRestore) { | 128 IN_PROC_BROWSER_TEST_F(FindInPageTest, FocusRestore) { |
| 129 ASSERT_TRUE(test_server()->Start()); | 129 ASSERT_TRUE(test_server()->Start()); |
| 130 | 130 |
| 131 GURL url = test_server()->GetURL("title1.html"); | 131 GURL url = test_server()->GetURL("title1.html"); |
| 132 ui_test_utils::NavigateToURL(browser(), url); | 132 ui_test_utils::NavigateToURL(browser(), url); |
| 133 | 133 |
| 134 // Focus the location bar, open and close the find-in-page, focus should | 134 // Focus the location bar, open and close the find-in-page, focus should |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 GURL url = test_server()->GetURL(kSimplePage); | 180 GURL url = test_server()->GetURL(kSimplePage); |
| 181 ui_test_utils::NavigateToURL(browser(), url); | 181 ui_test_utils::NavigateToURL(browser(), url); |
| 182 | 182 |
| 183 gfx::NativeWindow window = browser()->window()->GetNativeHandle(); | 183 gfx::NativeWindow window = browser()->window()->GetNativeHandle(); |
| 184 | 184 |
| 185 // Show the Find bar. | 185 // Show the Find bar. |
| 186 browser()->GetFindBarController()->Show(); | 186 browser()->GetFindBarController()->Show(); |
| 187 | 187 |
| 188 // Search for "a". | 188 // Search for "a". |
| 189 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( | 189 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( |
| 190 window, app::VKEY_A, false, false, false, false)); // No modifiers | 190 window, base::VKEY_A, false, false, false, false)); // No modifiers |
| 191 | 191 |
| 192 // We should find "a" here. | 192 // We should find "a" here. |
| 193 EXPECT_EQ(ASCIIToUTF16("a"), GetFindBarText()); | 193 EXPECT_EQ(ASCIIToUTF16("a"), GetFindBarText()); |
| 194 | 194 |
| 195 // Delete "a". | 195 // Delete "a". |
| 196 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( | 196 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( |
| 197 window, app::VKEY_BACK, false, false, false, false)); // No modifiers. | 197 window, base::VKEY_BACK, false, false, false, false)); // No modifiers. |
| 198 | 198 |
| 199 // Validate we have cleared the text. | 199 // Validate we have cleared the text. |
| 200 EXPECT_EQ(string16(), GetFindBarText()); | 200 EXPECT_EQ(string16(), GetFindBarText()); |
| 201 | 201 |
| 202 // Close the Find box. | 202 // Close the Find box. |
| 203 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( | 203 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( |
| 204 window, app::VKEY_ESCAPE, false, false, false, false)); // No modifiers. | 204 window, base::VKEY_ESCAPE, false, false, false, false)); // No modifiers. |
| 205 | 205 |
| 206 // Show the Find bar. | 206 // Show the Find bar. |
| 207 browser()->GetFindBarController()->Show(); | 207 browser()->GetFindBarController()->Show(); |
| 208 | 208 |
| 209 // After the Find box has been reopened, it should not have been prepopulated | 209 // After the Find box has been reopened, it should not have been prepopulated |
| 210 // with "a" again. | 210 // with "a" again. |
| 211 EXPECT_EQ(string16(), GetFindBarText()); | 211 EXPECT_EQ(string16(), GetFindBarText()); |
| 212 | 212 |
| 213 // Close the Find box. | 213 // Close the Find box. |
| 214 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( | 214 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( |
| 215 window, app::VKEY_ESCAPE, false, false, false, false)); // No modifiers. | 215 window, base::VKEY_ESCAPE, false, false, false, false)); // No modifiers. |
| 216 | 216 |
| 217 // Press F3 to trigger FindNext. | 217 // Press F3 to trigger FindNext. |
| 218 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( | 218 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( |
| 219 window, app::VKEY_F3, false, false, false, false)); // No modifiers. | 219 window, base::VKEY_F3, false, false, false, false)); // No modifiers. |
| 220 | 220 |
| 221 // After the Find box has been reopened, it should still have no prepopulate | 221 // After the Find box has been reopened, it should still have no prepopulate |
| 222 // value. | 222 // value. |
| 223 EXPECT_EQ(string16(), GetFindBarText()); | 223 EXPECT_EQ(string16(), GetFindBarText()); |
| 224 } | 224 } |
| OLD | NEW |