Skip to content

Commit

Permalink
[M50 Merge] Disable Find-In-Page buttons when no text is entered
Browse files Browse the repository at this point in the history
This CL fixes a regression caused by https://crrev.com/1660273003 which
enables the buttons of the Find-In-Page bar even if no text is entered
or no search was issued yet.

[email protected]
BUG=594097
TEST=FindInPageTest.ButtonsDisabledWithoutText

Review URL: https://codereview.chromium.org/1785033004

Cr-Commit-Position: refs/heads/master@{#381074}
(cherry picked from commit afc0733)

Review URL: https://codereview.chromium.org/1801313003 .

Cr-Commit-Position: refs/branch-heads/2661@{crosswalk-project#248}
Cr-Branched-From: ef6f6ae-refs/heads/master@{#378081}
  • Loading branch information
Michael Wasserman committed Mar 15, 2016
1 parent d0808c6 commit 820c22f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
6 changes: 2 additions & 4 deletions chrome/browser/ui/views/find_bar_host.cc
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,10 @@ gfx::Range FindBarHost::GetSelectedRange() {

void FindBarHost::UpdateUIForFindResult(const FindNotificationDetails& result,
const base::string16& find_text) {
// Make sure match count is clear. It may get set again in UpdateForResult
// if enough data is available.
find_bar_view()->ClearMatchCount();

if (!find_text.empty())
find_bar_view()->UpdateForResult(result, find_text);
else
find_bar_view()->ClearMatchCount();

// We now need to check if the window is obscuring the search results.
MoveWindowIfNecessary(result.selection_rect());
Expand Down
4 changes: 1 addition & 3 deletions chrome/browser/ui/views/find_bar_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -605,9 +605,7 @@ void FindBarView::Find(const base::string16& search_text) {
}

void FindBarView::UpdateMatchCountAppearance(bool no_match) {
// Enable the buttons if there is a match or if there is a match count text
// set (from a prepopulated view).
bool enable_buttons = !match_count_text_->text().empty() || !no_match;
bool enable_buttons = !match_count_text_->text().empty() && !no_match;
find_previous_button_->SetEnabled(enable_buttons);
find_next_button_->SetEnabled(enable_buttons);

Expand Down
21 changes: 21 additions & 0 deletions chrome/browser/ui/views/find_bar_views_interactive_uitest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,27 @@ IN_PROC_BROWSER_TEST_F(FindInPageTest, DISABLED_NavigationByMouse) {
VIEW_ID_FIND_IN_PAGE_TEXT_FIELD));
}

IN_PROC_BROWSER_TEST_F(FindInPageTest, ButtonsDisabledWithoutText) {
ASSERT_TRUE(embedded_test_server()->Start());
// Make sure Chrome is in the foreground, otherwise sending input
// won't do anything and the test will hang.
ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
// First we navigate to any page.
ui_test_utils::NavigateToURL(browser(),
embedded_test_server()->GetURL(kSimplePage));
// Show the Find bar.
browser()->GetFindBarController()->Show();
EXPECT_TRUE(
ui_test_utils::IsViewFocused(browser(), VIEW_ID_FIND_IN_PAGE_TEXT_FIELD));

// The buttons should be disabled as there is no text entered in the find bar
// and no search has been issued yet.
ASSERT_TRUE(ui_test_utils::SendKeyPressSync(browser(), ui::VKEY_TAB, false,
false, false, false));
EXPECT_TRUE(ui_test_utils::IsViewFocused(browser(),
VIEW_ID_FIND_IN_PAGE_CLOSE_BUTTON));
}

#if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(USE_AURA)
// TODO(erg): linux_aura bringup: http://crbug.com/163931
#define MAYBE_FocusRestore DISABLED_FocusRestore
Expand Down

0 comments on commit 820c22f

Please sign in to comment.