| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/message_loop.h" | 5 #include "base/message_loop.h" |
| 6 #include "chrome/browser/browser.h" | 6 #include "chrome/browser/browser.h" |
| 7 #include "chrome/browser/browser_window.h" | 7 #include "chrome/browser/browser_window.h" |
| 8 #include "chrome/browser/find_bar_controller.h" | 8 #include "chrome/browser/find_bar_controller.h" |
| 9 #include "chrome/browser/find_notification_details.h" | 9 #include "chrome/browser/find_notification_details.h" |
| 10 #include "chrome/browser/renderer_host/render_view_host.h" | 10 #include "chrome/browser/renderer_host/render_view_host.h" |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 EXPECT_EQ(1, ordinal); | 166 EXPECT_EQ(1, ordinal); |
| 167 EXPECT_EQ(1, FindInPage(L"Hreggvi\u00F0ur", FWD, CASE_SENSITIVE, &ordinal)); | 167 EXPECT_EQ(1, FindInPage(L"Hreggvi\u00F0ur", FWD, CASE_SENSITIVE, &ordinal)); |
| 168 EXPECT_EQ(1, ordinal); | 168 EXPECT_EQ(1, ordinal); |
| 169 EXPECT_EQ(0, FindInPage(L"hreggvi\u00F0ur", FWD, CASE_SENSITIVE, &ordinal)); | 169 EXPECT_EQ(0, FindInPage(L"hreggvi\u00F0ur", FWD, CASE_SENSITIVE, &ordinal)); |
| 170 EXPECT_EQ(0, ordinal); | 170 EXPECT_EQ(0, ordinal); |
| 171 } | 171 } |
| 172 | 172 |
| 173 std::string FocusedOnPage(TabContents* tab_contents) { | 173 std::string FocusedOnPage(TabContents* tab_contents) { |
| 174 std::string result; | 174 std::string result; |
| 175 ui_test_utils::ExecuteJavaScriptAndExtractString( | 175 ui_test_utils::ExecuteJavaScriptAndExtractString( |
| 176 tab_contents, | 176 tab_contents->render_view_host(), |
| 177 L"", | 177 L"", |
| 178 L"window.domAutomationController.send(getFocusedElement());", | 178 L"window.domAutomationController.send(getFocusedElement());", |
| 179 &result); | 179 &result); |
| 180 return result; | 180 return result; |
| 181 } | 181 } |
| 182 | 182 |
| 183 // This tests the FindInPage end-state, in other words: what is focused when you | 183 // This tests the FindInPage end-state, in other words: what is focused when you |
| 184 // close the Find box (ie. if you find within a link the link should be | 184 // close the Find box (ie. if you find within a link the link should be |
| 185 // focused). | 185 // focused). |
| 186 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindInPageEndState) { | 186 IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindInPageEndState) { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 207 // Verify that the link is focused. | 207 // Verify that the link is focused. |
| 208 EXPECT_STREQ("link1", FocusedOnPage(tab_contents).c_str()); | 208 EXPECT_STREQ("link1", FocusedOnPage(tab_contents).c_str()); |
| 209 | 209 |
| 210 // Search for a text that exists within a link on the page. | 210 // Search for a text that exists within a link on the page. |
| 211 EXPECT_EQ(1, FindInPage(L"Google", FWD, IGNORE_CASE, &ordinal)); | 211 EXPECT_EQ(1, FindInPage(L"Google", FWD, IGNORE_CASE, &ordinal)); |
| 212 EXPECT_EQ(1, ordinal); | 212 EXPECT_EQ(1, ordinal); |
| 213 | 213 |
| 214 // Move the selection to link 1, after searching. | 214 // Move the selection to link 1, after searching. |
| 215 std::string result; | 215 std::string result; |
| 216 ui_test_utils::ExecuteJavaScriptAndExtractString( | 216 ui_test_utils::ExecuteJavaScriptAndExtractString( |
| 217 tab_contents, | 217 tab_contents->render_view_host(), |
| 218 L"", | 218 L"", |
| 219 L"window.domAutomationController.send(selectLink1());", | 219 L"window.domAutomationController.send(selectLink1());", |
| 220 &result); | 220 &result); |
| 221 | 221 |
| 222 // End the find session. | 222 // End the find session. |
| 223 tab_contents->StopFinding(false); | 223 tab_contents->StopFinding(false); |
| 224 | 224 |
| 225 // Verify that link2 is not focused. | 225 // Verify that link2 is not focused. |
| 226 EXPECT_STREQ("", FocusedOnPage(tab_contents).c_str()); | 226 EXPECT_STREQ("", FocusedOnPage(tab_contents).c_str()); |
| 227 } | 227 } |
| (...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 618 // backspace, but that's been proven flaky in the past, so we go straight to | 618 // backspace, but that's been proven flaky in the past, so we go straight to |
| 619 // tab_contents. | 619 // tab_contents. |
| 620 TabContents* tab_contents = browser()->GetSelectedTabContents(); | 620 TabContents* tab_contents = browser()->GetSelectedTabContents(); |
| 621 // Stop the (non-existing) find operation, and clear the selection (which | 621 // Stop the (non-existing) find operation, and clear the selection (which |
| 622 // signals the UI is still active). | 622 // signals the UI is still active). |
| 623 tab_contents->StopFinding(true); | 623 tab_contents->StopFinding(true); |
| 624 // Make sure the Find UI flag hasn't been cleared, it must be so that the UI | 624 // Make sure the Find UI flag hasn't been cleared, it must be so that the UI |
| 625 // still responds to browser window resizing. | 625 // still responds to browser window resizing. |
| 626 ASSERT_TRUE(tab_contents->find_ui_active()); | 626 ASSERT_TRUE(tab_contents->find_ui_active()); |
| 627 } | 627 } |
| OLD | NEW |