Commit 63ecd996 authored by Carlos IL's avatar Carlos IL Committed by Commit Bot

Re-add removed parameter to find in GetSimplifiedDomainBounds

The parameter was accidentally removed when solving merge conflicts in
crrev.com/c/2350022

Also adds a test to prevent a similar regression in the future.

Change-Id: Ib0646c69fc1881f8a82fc122fc4d2fce23f41a65
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2356935
Commit-Queue: Carlos IL <carlosil@chromium.org>
Auto-Submit: Carlos IL <carlosil@chromium.org>
Reviewed-by: default avatarEmily Stark <estark@chromium.org>
Reviewed-by: default avatarTommy Li <tommycli@chromium.org>
Cr-Commit-Position: refs/heads/master@{#798933}
parent 2b79cc9c
......@@ -2439,7 +2439,7 @@ gfx::Range OmniboxViewViews::GetSimplifiedDomainBounds(
return gfx::Range(host.begin, host.end());
}
size_t simplified_domain_pos = text.rfind(simplified_domain);
size_t simplified_domain_pos = text.rfind(simplified_domain, host.end());
DCHECK_NE(simplified_domain_pos, std::string::npos);
ranges_surrounding_simplified_domain->emplace_back(0, simplified_domain_pos);
ranges_surrounding_simplified_domain->emplace_back(host.end(), text.size());
......
......@@ -182,6 +182,8 @@ class OmniboxViewViews : public OmniboxView,
FRIEND_TEST_ALL_PREFIXES(OmniboxViewViewsRevealOnHoverTest, HoverAndExit);
FRIEND_TEST_ALL_PREFIXES(OmniboxViewViewsRevealOnHoverTest, HoverAndExitIDN);
FRIEND_TEST_ALL_PREFIXES(OmniboxViewViewsRevealOnHoverTest, PrivateRegistry);
FRIEND_TEST_ALL_PREFIXES(OmniboxViewViewsRevealOnHoverTest,
HoverAndExitDomainInPath);
FRIEND_TEST_ALL_PREFIXES(
OmniboxViewViewsHideOnInteractionAndRevealOnHoverTest,
UserInteractionAndHover);
......
......@@ -1845,6 +1845,39 @@ TEST_P(OmniboxViewViewsRevealOnHoverTest, PrivateRegistry) {
ShouldElideToRegistrableDomain()));
}
// Tests the field trial variation that shows a simplified domain by default and
// reveals the unsimplified URL on hover, using a URL where the path contains
// the domain name.
TEST_P(OmniboxViewViewsRevealOnHoverTest, HoverAndExitDomainInPath) {
// The display URL used in simplified domain display tests.
const base::string16 kSimplifiedDomainDisplayRepeatedUrl =
base::UTF8ToUTF16("https://ex.example.test/example.test");
const base::string16 kSimplifiedDomainDisplayRepeatedUrlHostnameAndScheme =
base::UTF8ToUTF16("https://ex.example.test");
const base::string16 kSimplifiedDomainDisplayRepeatedUrlSubdomainAndScheme =
base::UTF8ToUTF16("https://ex.");
const base::string16 kSimplifiedDomainDisplayRepeatedUrlSubdomain =
base::UTF8ToUTF16("ex.");
const base::string16 kSimplifiedDomainDisplayRepeatedUrlPath =
base::UTF8ToUTF16("/example.test");
const base::string16 kSimplifiedDomainDisplayRepeatedUrlScheme =
base::UTF8ToUTF16("https://");
location_bar_model()->set_url(GURL(kSimplifiedDomainDisplayRepeatedUrl));
location_bar_model()->set_url_for_display(
kSimplifiedDomainDisplayRepeatedUrl);
omnibox_view()->model()->ResetDisplayTexts();
omnibox_view()->RevertAll();
// Call OnThemeChanged() to create the animations.
omnibox_view()->OnThemeChanged();
ASSERT_NO_FATAL_FAILURE(ExpectElidedToSimplifiedDomain(
omnibox_view(), kSimplifiedDomainDisplayRepeatedUrlScheme,
kSimplifiedDomainDisplayRepeatedUrlSubdomain,
kSimplifiedDomainDisplayRepeatedUrlHostnameAndScheme,
kSimplifiedDomainDisplayRepeatedUrlPath,
ShouldElideToRegistrableDomain()));
}
class OmniboxViewViewsHideOnInteractionAndRevealOnHoverTest
: public OmniboxViewViewsTest,
public ::testing::WithParamInterface<std::pair<bool, bool>> {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment