Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2632)

Unified Diff: chrome/browser/ui/find_bar/find_bar_host_browsertest.cc

Issue 10533132: Add a test for FindInPage after selecting text. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: nits + rebase Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/test/data/find_in_page/start_after_selection.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 9b5e8efb964ed65b2b6c302f699eb4b83f1c6db7..db27daeb5bbf367469894c792c668c80afa2fc9f 100644
--- a/chrome/browser/ui/find_bar/find_bar_host_browsertest.cc
+++ b/chrome/browser/ui/find_bar/find_bar_host_browsertest.cc
@@ -63,6 +63,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";
@@ -595,6 +596,40 @@ 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.
+ ui_test_utils::NavigateToURL(browser(), GetURL(kStartAfterSelection));
+
+ TabContents* tab = chrome::GetActiveTabContents(browser());
+ ASSERT_TRUE(tab != NULL);
+ int ordinal = 0;
+
+ // Move the selection to the text span.
+ std::string result;
+ ASSERT_TRUE(content::ExecuteJavaScriptAndExtractString(
+ tab->web_contents()->GetRenderViewHost(),
+ std::wstring(),
+ 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, L"fi", kFwd, kIgnoreCase, &ordinal));
+ EXPECT_EQ(2, ordinal);
+
+ // Refine the search, current active match should not change.
+ 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) {
« no previous file with comments | « no previous file | chrome/test/data/find_in_page/start_after_selection.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698