diff options
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/tab_contents/tab_contents.cc | 6 | ||||
-rw-r--r-- | chrome/browser/views/find_bar_win_browsertest.cc | 40 | ||||
-rw-r--r-- | chrome/test/data/find_in_page/move_if_obscuring.html | 7 |
3 files changed, 52 insertions, 1 deletions
diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc index c136625..776a5b5 100644 --- a/chrome/browser/tab_contents/tab_contents.cc +++ b/chrome/browser/tab_contents/tab_contents.cc @@ -2309,10 +2309,14 @@ void TabContents::OnFindReply(int request_id, if (active_match_ordinal == -1) active_match_ordinal = find_result_.active_match_ordinal(); + gfx::Rect selection = selection_rect; + if (selection.IsEmpty()) + selection = find_result_.selection_rect(); + // Notify the UI, automation and any other observers that a find result was // found. find_result_ = FindNotificationDetails(request_id, number_of_matches, - selection_rect, active_match_ordinal, + selection, active_match_ordinal, final_update); NotificationService::current()->Notify( NotificationType::FIND_RESULT_AVAILABLE, diff --git a/chrome/browser/views/find_bar_win_browsertest.cc b/chrome/browser/views/find_bar_win_browsertest.cc index b24f229..2b173da 100644 --- a/chrome/browser/views/find_bar_win_browsertest.cc +++ b/chrome/browser/views/find_bar_win_browsertest.cc @@ -22,6 +22,7 @@ const std::wstring kCrashPage = L"files/find_in_page/crash_1341577.html"; const std::wstring kTooFewMatchesPage = L"files/find_in_page/bug_1155639.html"; const std::wstring kEndState = L"files/find_in_page/end_state.html"; const std::wstring kPrematureEnd = L"files/find_in_page/premature_end.html"; +const std::wstring kMoveIfOver = L"files/find_in_page/move_if_obscuring.html"; class FindInPageNotificationObserver : public NotificationObserver { public: @@ -487,3 +488,42 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, EXPECT_FALSE(fully_visible); } +// Make sure Find box moves out of the way if it is obscuring the active match. +IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindMovesWhenObscuring) { + HTTPTestServer* server = StartHTTPServer(); + + GURL url = server->TestServerPageW(kMoveIfOver); + ui_test_utils::NavigateToURL(browser(), url); + + // Open the Find window with animations disabled. + FindBarWin::disable_animations_during_testing_ = true; + browser()->ShowFindBar(); + + gfx::Point start_position; + gfx::Point position; + bool fully_visible = false; + + // Make sure it is open. + GetFindBarWindowInfo(&start_position, &fully_visible); + EXPECT_TRUE(fully_visible); + + // Search for 'dream' which the Find box is obscuring. + int ordinal = 0; + EXPECT_EQ(1, FindInPage(L"dream", FWD, IGNORE_CASE, false, &ordinal)); + EXPECT_EQ(1, ordinal); + + // Make sure Find box has moved. + GetFindBarWindowInfo(&position, &fully_visible); + EXPECT_EQ(start_position.y(), position.y()); + EXPECT_NE(start_position.x(), position.x()); + EXPECT_TRUE(fully_visible); + + // Search for 'Too much' which the Find box is not obscuring. + EXPECT_EQ(1, FindInPage(L"Too much", FWD, IGNORE_CASE, false, &ordinal)); + EXPECT_EQ(1, ordinal); + + // Make sure Find box has moved back to its original location. + GetFindBarWindowInfo(&position, &fully_visible); + EXPECT_EQ(start_position, position); + EXPECT_TRUE(fully_visible); +} diff --git a/chrome/test/data/find_in_page/move_if_obscuring.html b/chrome/test/data/find_in_page/move_if_obscuring.html new file mode 100644 index 0000000..8ca8080 --- /dev/null +++ b/chrome/test/data/find_in_page/move_if_obscuring.html @@ -0,0 +1,7 @@ +<html>
+<body>
+ <div align="right">"All day I dream about Essex."</div>
+<br><br><br>
+"Too much Essex makes your eyes go screwey"
+</body>
+</html>
|