diff options
-rw-r--r-- | chrome/browser/browser_focus_uitest.cc | 2 | ||||
-rw-r--r-- | chrome/browser/history/history_browsertest.cc | 2 | ||||
-rw-r--r-- | chrome/browser/tab_restore_browsertest.cc | 6 | ||||
-rw-r--r-- | chrome/browser/ui/find_bar/find_bar_host_browsertest.cc | 11 | ||||
-rw-r--r-- | chrome/browser/ui/pdf/pdf_browsertest.cc | 5 | ||||
-rw-r--r-- | chrome/browser/ui/views/find_bar_host_interactive_uitest.cc | 6 | ||||
-rw-r--r-- | chrome/test/base/ui_test_utils.cc | 12 | ||||
-rw-r--r-- | chrome/test/base/ui_test_utils.h | 6 |
8 files changed, 31 insertions, 19 deletions
diff --git a/chrome/browser/browser_focus_uitest.cc b/chrome/browser/browser_focus_uitest.cc index 29afc94..ffc0988 100644 --- a/chrome/browser/browser_focus_uitest.cc +++ b/chrome/browser/browser_focus_uitest.cc @@ -395,7 +395,7 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, MAYBE_TabsRememberFocusFindInPage) { chrome::Find(browser()); ui_test_utils::FindInPage(chrome::GetActiveTabContents(browser()), - ASCIIToUTF16("a"), true, false, NULL); + ASCIIToUTF16("a"), true, false, NULL, NULL); ASSERT_TRUE(IsViewFocused(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); // Focus the location bar. diff --git a/chrome/browser/history/history_browsertest.cc b/chrome/browser/history/history_browsertest.cc index 0118d6e..0d8027d 100644 --- a/chrome/browser/history/history_browsertest.cc +++ b/chrome/browser/history/history_browsertest.cc @@ -309,7 +309,7 @@ IN_PROC_BROWSER_TEST_F(HistoryBrowserTest, HistorySearchXSS) { // Should a race condition ever trigger, it won't result in flakiness. int num = ui_test_utils::FindInPage( chrome::GetActiveTabContents(browser()), ASCIIToUTF16("<img"), true, - true, NULL); + true, NULL, NULL); EXPECT_GT(num, 0); EXPECT_EQ(ASCIIToUTF16("History"), chrome::GetActiveWebContents(browser())->GetTitle()); diff --git a/chrome/browser/tab_restore_browsertest.cc b/chrome/browser/tab_restore_browsertest.cc index b46342a..f3e5cc3 100644 --- a/chrome/browser/tab_restore_browsertest.cc +++ b/chrome/browser/tab_restore_browsertest.cc @@ -509,7 +509,8 @@ IN_PROC_BROWSER_TEST_F(TabRestoreTest, RestoreTabWithSpecialURL) { // See if content is as expected. EXPECT_GT( - ui_test_utils::FindInPage(tab, ASCIIToUTF16("webkit"), true, false, NULL), + ui_test_utils::FindInPage(tab, ASCIIToUTF16("webkit"), true, false, NULL, + NULL), 0); } @@ -540,6 +541,7 @@ IN_PROC_BROWSER_TEST_F(TabRestoreTest, RestoreTabWithSpecialURLOnBack) { // Go back, and see if content is as expected. GoBack(browser()); EXPECT_GT( - ui_test_utils::FindInPage(tab, ASCIIToUTF16("webkit"), true, false, NULL), + ui_test_utils::FindInPage(tab, ASCIIToUTF16("webkit"), true, false, NULL, + NULL), 0); } 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 23a0559..cdfaebf 100644 --- a/chrome/browser/ui/find_bar/find_bar_host_browsertest.cc +++ b/chrome/browser/ui/find_bar/find_bar_host_browsertest.cc @@ -140,7 +140,7 @@ class FindInPageControllerTest : public InProcessBrowserTest { int* ordinal) { return ui_test_utils::FindInPage( tab, WideToUTF16(std::wstring(search_str)), - forward, case_sensitive, ordinal); + forward, case_sensitive, ordinal, NULL); } // Calls FindInPageWchar till the find box's x position != |start_x_position|. @@ -811,7 +811,7 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, // Simulate what happens when you press F3 for FindNext. We should get a // response here (a hang means search was aborted). EXPECT_EQ(0, ui_test_utils::FindInPage(tab, string16(), - kFwd, kIgnoreCase, &ordinal)); + kFwd, kIgnoreCase, &ordinal, NULL)); EXPECT_EQ(0, ordinal); // Open another tab (tab C). @@ -821,7 +821,7 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, // Simulate what happens when you press F3 for FindNext. We should get a // response here (a hang means search was aborted). EXPECT_EQ(0, ui_test_utils::FindInPage(tab, string16(), - kFwd, kIgnoreCase, &ordinal)); + kFwd, kIgnoreCase, &ordinal, NULL)); EXPECT_EQ(0, ordinal); } @@ -908,7 +908,7 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, RestartSearchFromF3) { // Simulate what happens when you press F3 for FindNext. Still should show // one match. This cleared the pre-populate string at one point (see bug). EXPECT_EQ(1, ui_test_utils::FindInPage(tab, string16(), - kFwd, kIgnoreCase, &ordinal)); + kFwd, kIgnoreCase, &ordinal, NULL)); EXPECT_EQ(1, ordinal); // End the Find session, thereby making the next F3 start afresh. @@ -952,7 +952,8 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, PreferPreviousSearch) { FindBarController::kKeepSelectionOnPage, FindBarController::kKeepResultsInFindBox); // Simulate F3. - ui_test_utils::FindInPage(tab1, string16(), kFwd, kIgnoreCase, &ordinal); + ui_test_utils::FindInPage(tab1, string16(), kFwd, kIgnoreCase, &ordinal, + NULL); EXPECT_EQ(tab1->find_tab_helper()->find_text(), WideToUTF16(L"text")); } diff --git a/chrome/browser/ui/pdf/pdf_browsertest.cc b/chrome/browser/ui/pdf/pdf_browsertest.cc index 74f7176..5872d96 100644 --- a/chrome/browser/ui/pdf/pdf_browsertest.cc +++ b/chrome/browser/ui/pdf/pdf_browsertest.cc @@ -110,7 +110,8 @@ class PDFBrowserTest : public InProcessBrowserTest, string16 query = UTF8ToUTF16( std::string("xyzxyz" + base::IntToString(next_dummy_search_value_++))); ASSERT_EQ(0, ui_test_utils::FindInPage( - chrome::GetActiveTabContents(browser()), query, true, false, NULL)); + chrome::GetActiveTabContents(browser()), query, true, false, NULL, + NULL)); } private: @@ -265,7 +266,7 @@ IN_PROC_BROWSER_TEST_F(PDFBrowserTest, MAYBE_FindAndCopy) { // Verifies that find in page works. ASSERT_EQ(3, ui_test_utils::FindInPage( chrome::GetActiveTabContents(browser()), UTF8ToUTF16("adipiscing"), - true, false, NULL)); + true, false, NULL, NULL)); // Verify that copying selected text works. ui::Clipboard clipboard; diff --git a/chrome/browser/ui/views/find_bar_host_interactive_uitest.cc b/chrome/browser/ui/views/find_bar_host_interactive_uitest.cc index 37692da..ded923b 100644 --- a/chrome/browser/ui/views/find_bar_host_interactive_uitest.cc +++ b/chrome/browser/ui/views/find_bar_host_interactive_uitest.cc @@ -139,7 +139,7 @@ IN_PROC_BROWSER_TEST_F(FindInPageTest, FocusRestore) { EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); ui_test_utils::FindInPage(chrome::GetActiveTabContents(browser()), - ASCIIToUTF16("a"), true, false, NULL); + ASCIIToUTF16("a"), true, false, NULL, NULL); browser()->GetFindBarController()->EndFindSession( FindBarController::kKeepSelectionOnPage, FindBarController::kKeepResultsInFindBox); @@ -182,7 +182,7 @@ IN_PROC_BROWSER_TEST_F(FindInPageTest, MAYBE_FocusRestoreOnTabSwitch) { // Search for 'a'. ui_test_utils::FindInPage(chrome::GetActiveTabContents(browser()), - ASCIIToUTF16("a"), true, false, NULL); + ASCIIToUTF16("a"), true, false, NULL, NULL); EXPECT_TRUE(ASCIIToUTF16("a") == find_bar->GetFindSelectedText()); // Open another tab (tab B). @@ -199,7 +199,7 @@ IN_PROC_BROWSER_TEST_F(FindInPageTest, MAYBE_FocusRestoreOnTabSwitch) { // Search for 'b'. ui_test_utils::FindInPage(chrome::GetActiveTabContents(browser()), - ASCIIToUTF16("b"), true, false, NULL); + ASCIIToUTF16("b"), true, false, NULL, NULL); EXPECT_TRUE(ASCIIToUTF16("b") == find_bar->GetFindSelectedText()); // Set focus away from the Find bar (to the Location bar). diff --git a/chrome/test/base/ui_test_utils.cc b/chrome/test/base/ui_test_utils.cc index c5821bb..93f2650 100644 --- a/chrome/test/base/ui_test_utils.cc +++ b/chrome/test/base/ui_test_utils.cc @@ -106,8 +106,8 @@ class FindInPageNotificationObserver : public content::NotificationObserver { } int active_match_ordinal() const { return active_match_ordinal_; } - int number_of_matches() const { return number_of_matches_; } + gfx::Rect selection_rect() const { return selection_rect_; } virtual void Observe(int type, const content::NotificationSource& source, const content::NotificationDetails& details) { @@ -116,8 +116,10 @@ class FindInPageNotificationObserver : public content::NotificationObserver { if (find_details->request_id() == current_find_request_id_) { // We get multiple responses and one of those will contain the ordinal. // This message comes to us before the final update is sent. - if (find_details->active_match_ordinal() > -1) + if (find_details->active_match_ordinal() > -1) { active_match_ordinal_ = find_details->active_match_ordinal(); + selection_rect_ = find_details->selection_rect(); + } if (find_details->final_update()) { number_of_matches_ = find_details->number_of_matches(); message_loop_runner_->Quit(); @@ -137,6 +139,7 @@ class FindInPageNotificationObserver : public content::NotificationObserver { // we need to preserve it so we can send it later. int active_match_ordinal_; int number_of_matches_; + gfx::Rect selection_rect_; // The id of the current find request, obtained from WebContents. Allows us // to monitor when the search completes. int current_find_request_id_; @@ -367,12 +370,15 @@ AppModalDialog* WaitForAppModalDialog() { } int FindInPage(TabContents* tab_contents, const string16& search_string, - bool forward, bool match_case, int* ordinal) { + bool forward, bool match_case, int* ordinal, + gfx::Rect* selection_rect) { tab_contents-> find_tab_helper()->StartFinding(search_string, forward, match_case); FindInPageNotificationObserver observer(tab_contents); if (ordinal) *ordinal = observer.active_match_ordinal(); + if (selection_rect) + *selection_rect = observer.selection_rect(); return observer.number_of_matches(); } diff --git a/chrome/test/base/ui_test_utils.h b/chrome/test/base/ui_test_utils.h index d1f3cab..712da87 100644 --- a/chrome/test/base/ui_test_utils.h +++ b/chrome/test/base/ui_test_utils.h @@ -138,12 +138,14 @@ AppModalDialog* WaitForAppModalDialog(); // Performs a find in the page of the specified tab. Returns the number of // matches found. |ordinal| is an optional parameter which is set to the index -// of the current match. +// of the current match. |selection_rect| is an optional parameter which is set +// to the location of the current match. int FindInPage(TabContents* tab, const string16& search_string, bool forward, bool case_sensitive, - int* ordinal); + int* ordinal, + gfx::Rect* selection_rect); // Closes all infobars |tab| has open, if any. Tests that depend on there being // no InfoBar open when the test starts may need to use this. |