Chromium Code Reviews| Index: chrome/browser/ui/find_bar/find_bar_host_browsertest.cc |
| diff --git a/chrome/browser/ui/find_bar/find_bar_host_browsertest.cc b/chrome/browser/ui/find_bar/find_bar_host_browsertest.cc |
| index eb378be44f607d4e568ff57e3fb30b5d75e5f88e..c24e9e3cbec21f99037dd2fe031bb395100cb717 100644 |
| --- a/chrome/browser/ui/find_bar/find_bar_host_browsertest.cc |
| +++ b/chrome/browser/ui/find_bar/find_bar_host_browsertest.cc |
| @@ -53,6 +53,7 @@ const std::string kPrematureEnd = "premature_end.html"; |
| const std::string kMoveIfOver = "move_if_obscuring.html"; |
| const std::string kBitstackCrash = "crash_14491.html"; |
| const std::string kSelectChangesOrdinal = "select_changes_ordinal.html"; |
| +const std::string kStartAfterSelection = "start_after_selection.html"; |
| const std::string kSimple = "simple.html"; |
| const std::string kLinkPage = "link.html"; |
| @@ -387,6 +388,47 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, |
| tab->find_tab_helper()->StopFinding(FindBarController::kKeepSelectionOnPage); |
| } |
| +// This tests that we start searching after selected text. |
| +IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, |
| + StartSearchAfterSelection) { |
| + // First we navigate to our test content. |
| + GURL url = GetURL(kStartAfterSelection); |
|
Peter Kasting
2012/09/05 21:22:59
Nit: Can inline into next statement
mkosiba (inactive)
2012/09/10 18:45:23
Done.
|
| + ui_test_utils::NavigateToURL(browser(), url); |
| + |
| + TabContents* tab = browser()->GetActiveTabContents(); |
| + ASSERT_TRUE(NULL != tab); |
|
Peter Kasting
2012/09/05 21:22:59
Nit: "tab != NULL" (or ASSERT_FALSE(tab == NULL))
mkosiba (inactive)
2012/09/10 18:45:23
Done.
|
| + int ordinal = 0; |
| + |
| + // Move the selection to the text span. |
| + std::string result; |
| + ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractString( |
| + tab->web_contents()->GetRenderViewHost(), |
| + L"", |
|
Peter Kasting
2012/09/05 21:22:59
Nit: Use std::wstring()
mkosiba (inactive)
2012/09/10 18:45:23
Done.
|
| + L"window.domAutomationController.send(selectSpan());", |
| + &result)); |
| + |
| + // Do a find-next after the selection. This should select the 2nd occurrence |
| + // of the word 'find'. |
| + EXPECT_EQ(4, FindInPageWchar(tab, |
|
Peter Kasting
2012/09/05 21:22:59
Nit: Feel free to collapse args onto one line (3 p
mkosiba (inactive)
2012/09/10 18:45:23
Done.
|
| + L"fi", |
| + kFwd, kIgnoreCase, &ordinal)); |
| + EXPECT_EQ(2, ordinal); |
| + |
| + // Refine the search, current active match should not change (bug 129552). |
|
Peter Kasting
2012/09/05 21:22:59
Nit: Don't bother with the bug number.
mkosiba (inactive)
2012/09/10 18:45:23
Done.
|
| + EXPECT_EQ(4, FindInPageWchar(tab, |
| + L"find", |
| + kFwd, kIgnoreCase, &ordinal)); |
| + EXPECT_EQ(2, ordinal); |
| + |
| + // Refine the search to 'findMe'. The first new match is before the current |
| + // active match, the second one is after it. This verifies that refining a |
| + // search doesn't reset it. |
| + EXPECT_EQ(2, FindInPageWchar(tab, |
| + L"findMe", |
| + kFwd, kIgnoreCase, &ordinal)); |
| + EXPECT_EQ(2, ordinal); |
| +} |
| + |
| // This test loads a page with frames and makes sure the ordinal returned makes |
| // sense. |
| IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindInPageMultiFramesOrdinal) { |