Commit afcb4dd2 authored by Emily Stark's avatar Emily Stark Committed by Commit Bot

Factor out simplified domain unit tests helper methods

This CL factors out some common code from OmniboxViewViews unit tests
that test simplified domain field trials:
* Stepping through an animation
* Setup code that sets the display URL
* Simulating a navigation and checking that the URL is elided or
  unelided afterwards

Bug: 1102572
Change-Id: If388d8174cdbaa822478ed93b7ec7782bfec2c18
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2363368
Commit-Queue: Emily Stark <estark@chromium.org>
Reviewed-by: default avatarJustin Donnelly <jdonnelly@chromium.org>
Cr-Commit-Position: refs/heads/master@{#799821}
parent ae010439
...@@ -170,93 +170,6 @@ class OmniboxViewViews : public OmniboxView, ...@@ -170,93 +170,6 @@ class OmniboxViewViews : public OmniboxView,
} }
protected: protected:
// views::Textfield:
void OnThemeChanged() override;
bool IsDropCursorForInsertion() const override;
// Applies the given |color| to |range|. This is a wrapper method around
// Textfield::ApplyColor that tests can override.
virtual void ApplyColor(SkColor color, const gfx::Range& range);
private:
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);
FRIEND_TEST_ALL_PREFIXES(
OmniboxViewViewsHideOnInteractionAndRevealOnHoverTest,
MouseClick);
FRIEND_TEST_ALL_PREFIXES(
OmniboxViewViewsHideOnInteractionAndRevealOnHoverTest,
FocusingEditableNode);
FRIEND_TEST_ALL_PREFIXES(
OmniboxViewViewsHideOnInteractionAndRevealOnHoverTest,
BoundsChanged);
FRIEND_TEST_ALL_PREFIXES(OmniboxViewViewsRevealOnHoverTest, BoundsChanged);
FRIEND_TEST_ALL_PREFIXES(OmniboxViewViewsRevealOnHoverTest,
CancellingAnimationDoesNotCrash);
FRIEND_TEST_ALL_PREFIXES(
OmniboxViewViewsHideOnInteractionAndRevealOnHoverTest,
SchemeAndTrivialSubdomainElision);
FRIEND_TEST_ALL_PREFIXES(OmniboxViewViewsRevealOnHoverTest,
SimplifiedDomainElisionWithNarrowOmnibox);
FRIEND_TEST_ALL_PREFIXES(
OmniboxViewViewsHideOnInteractionAndRevealOnHoverTest,
SimplifiedDomainElisionWithNarrowOmnibox);
FRIEND_TEST_ALL_PREFIXES(
OmniboxViewViewsHideOnInteractionAndRevealOnHoverTest,
HideOnInteractionAfterFocusAndBlur);
FRIEND_TEST_ALL_PREFIXES(
OmniboxViewViewsHideOnInteractionAndRevealOnHoverTest,
URLPositionWithHideOnInteraction);
FRIEND_TEST_ALL_PREFIXES(OmniboxViewViewsRevealOnHoverTest, AfterBlur);
FRIEND_TEST_ALL_PREFIXES(
OmniboxViewViewsHideOnInteractionAndRevealOnHoverTest,
PathChangeDuringAnimation);
FRIEND_TEST_ALL_PREFIXES(
OmniboxViewViewsHideOnInteractionAndRevealOnHoverTest,
VerticalAndHorizontalPosition);
FRIEND_TEST_ALL_PREFIXES(
OmniboxViewViewsHideOnInteractionAndRevealOnHoverTest,
NoStaleGradientMask);
FRIEND_TEST_ALL_PREFIXES(OmniboxViewViewsHideOnInteractionTest, ModifierKeys);
FRIEND_TEST_ALL_PREFIXES(OmniboxViewViewsHideOnInteractionTest,
SameDocNavigations);
FRIEND_TEST_ALL_PREFIXES(OmniboxViewViewsHideOnInteractionTest,
SameDocNavigationDuringAnimation);
FRIEND_TEST_ALL_PREFIXES(OmniboxViewViewsHideOnInteractionTest, GradientMask);
FRIEND_TEST_ALL_PREFIXES(OmniboxViewViewsHideOnInteractionTest,
GradientMaskResetAfterStop);
FRIEND_TEST_ALL_PREFIXES(OmniboxViewViewsHideOnInteractionTest,
UserInteractionDuringAnimation);
FRIEND_TEST_ALL_PREFIXES(OmniboxViewViewsHideOnInteractionTest,
SubframeNavigations);
FRIEND_TEST_ALL_PREFIXES(OmniboxViewViewsRevealOnHoverTest,
AlwaysShowFullURLs);
FRIEND_TEST_ALL_PREFIXES(OmniboxViewViewsHideOnInteractionTest,
AlwaysShowFullURLs);
FRIEND_TEST_ALL_PREFIXES(
OmniboxViewViewsRevealOnHoverAndMaybeHideOnInteractionTest,
UnsetAlwaysShowFullURLs);
FRIEND_TEST_ALL_PREFIXES(OmniboxViewViewsRevealOnHoverTest,
RegistrableDomainRepeated);
FRIEND_TEST_ALL_PREFIXES(
OmniboxViewViewsHideOnInteractionAndRevealOnHoverTest,
TabChangeWhenNotEligibleForEliding);
FRIEND_TEST_ALL_PREFIXES(OmniboxPopupContentsViewTest,
EmitAccessibilityEvents);
// TODO(tommycli): Remove the rest of these friends after porting these
// browser tests to unit tests.
FRIEND_TEST_ALL_PREFIXES(OmniboxViewViewsTest, CloseOmniboxPopupOnTextDrag);
FRIEND_TEST_ALL_PREFIXES(OmniboxViewViewsTest, FriendlyAccessibleLabel);
FRIEND_TEST_ALL_PREFIXES(OmniboxViewViewsTest, DoNotNavigateOnDrop);
FRIEND_TEST_ALL_PREFIXES(OmniboxViewViewsTest,
ElideAnimationDoesntStartIfNoVisibleChange);
// Animates the URL to a given range of text, which could be a substring or // Animates the URL to a given range of text, which could be a substring or
// superstring of what's currently displayed. An elision animation hides the // superstring of what's currently displayed. An elision animation hides the
// path (and optionally subdomains) by narrowing the bounds of each side of // path (and optionally subdomains) by narrowing the bounds of each side of
...@@ -354,6 +267,94 @@ class OmniboxViewViews : public OmniboxView, ...@@ -354,6 +267,94 @@ class OmniboxViewViews : public OmniboxView,
std::unique_ptr<gfx::MultiAnimation> animation_; std::unique_ptr<gfx::MultiAnimation> animation_;
}; };
ElideAnimation* GetHoverElideOrUnelideAnimationForTesting();
ElideAnimation* GetElideAfterInteractionAnimationForTesting();
// views::Textfield:
void OnThemeChanged() override;
bool IsDropCursorForInsertion() const override;
// Applies the given |color| to |range|. This is a wrapper method around
// Textfield::ApplyColor that tests can override.
virtual void ApplyColor(SkColor color, const gfx::Range& range);
private:
FRIEND_TEST_ALL_PREFIXES(OmniboxViewViewsRevealOnHoverTest, HoverAndExit);
FRIEND_TEST_ALL_PREFIXES(OmniboxViewViewsRevealOnHoverTest, HoverAndExitIDN);
FRIEND_TEST_ALL_PREFIXES(OmniboxViewViewsRevealOnHoverTest, PrivateRegistry);
FRIEND_TEST_ALL_PREFIXES(
OmniboxViewViewsHideOnInteractionAndRevealOnHoverTest,
UserInteractionAndHover);
FRIEND_TEST_ALL_PREFIXES(
OmniboxViewViewsHideOnInteractionAndRevealOnHoverTest,
MouseClick);
FRIEND_TEST_ALL_PREFIXES(
OmniboxViewViewsHideOnInteractionAndRevealOnHoverTest,
FocusingEditableNode);
FRIEND_TEST_ALL_PREFIXES(
OmniboxViewViewsHideOnInteractionAndRevealOnHoverTest,
BoundsChanged);
FRIEND_TEST_ALL_PREFIXES(OmniboxViewViewsRevealOnHoverTest, BoundsChanged);
FRIEND_TEST_ALL_PREFIXES(OmniboxViewViewsRevealOnHoverTest,
CancellingAnimationDoesNotCrash);
FRIEND_TEST_ALL_PREFIXES(
OmniboxViewViewsHideOnInteractionAndRevealOnHoverTest,
SchemeAndTrivialSubdomainElision);
FRIEND_TEST_ALL_PREFIXES(OmniboxViewViewsRevealOnHoverTest,
SimplifiedDomainElisionWithNarrowOmnibox);
FRIEND_TEST_ALL_PREFIXES(
OmniboxViewViewsHideOnInteractionAndRevealOnHoverTest,
SimplifiedDomainElisionWithNarrowOmnibox);
FRIEND_TEST_ALL_PREFIXES(
OmniboxViewViewsHideOnInteractionAndRevealOnHoverTest,
HideOnInteractionAfterFocusAndBlur);
FRIEND_TEST_ALL_PREFIXES(
OmniboxViewViewsHideOnInteractionAndRevealOnHoverTest,
URLPositionWithHideOnInteraction);
FRIEND_TEST_ALL_PREFIXES(OmniboxViewViewsRevealOnHoverTest, AfterBlur);
FRIEND_TEST_ALL_PREFIXES(
OmniboxViewViewsHideOnInteractionAndRevealOnHoverTest,
PathChangeDuringAnimation);
FRIEND_TEST_ALL_PREFIXES(
OmniboxViewViewsHideOnInteractionAndRevealOnHoverTest,
VerticalAndHorizontalPosition);
FRIEND_TEST_ALL_PREFIXES(
OmniboxViewViewsHideOnInteractionAndRevealOnHoverTest,
NoStaleGradientMask);
FRIEND_TEST_ALL_PREFIXES(OmniboxViewViewsHideOnInteractionTest, ModifierKeys);
FRIEND_TEST_ALL_PREFIXES(OmniboxViewViewsHideOnInteractionTest,
SameDocNavigations);
FRIEND_TEST_ALL_PREFIXES(OmniboxViewViewsHideOnInteractionTest,
SameDocNavigationDuringAnimation);
FRIEND_TEST_ALL_PREFIXES(OmniboxViewViewsHideOnInteractionTest, GradientMask);
FRIEND_TEST_ALL_PREFIXES(OmniboxViewViewsHideOnInteractionTest,
GradientMaskResetAfterStop);
FRIEND_TEST_ALL_PREFIXES(OmniboxViewViewsHideOnInteractionTest,
UserInteractionDuringAnimation);
FRIEND_TEST_ALL_PREFIXES(OmniboxViewViewsHideOnInteractionTest,
SubframeNavigations);
FRIEND_TEST_ALL_PREFIXES(OmniboxViewViewsRevealOnHoverTest,
AlwaysShowFullURLs);
FRIEND_TEST_ALL_PREFIXES(OmniboxViewViewsHideOnInteractionTest,
AlwaysShowFullURLs);
FRIEND_TEST_ALL_PREFIXES(
OmniboxViewViewsRevealOnHoverAndMaybeHideOnInteractionTest,
UnsetAlwaysShowFullURLs);
FRIEND_TEST_ALL_PREFIXES(OmniboxViewViewsRevealOnHoverTest,
RegistrableDomainRepeated);
FRIEND_TEST_ALL_PREFIXES(
OmniboxViewViewsHideOnInteractionAndRevealOnHoverTest,
TabChangeWhenNotEligibleForEliding);
FRIEND_TEST_ALL_PREFIXES(OmniboxPopupContentsViewTest,
EmitAccessibilityEvents);
// TODO(tommycli): Remove the rest of these friends after porting these
// browser tests to unit tests.
FRIEND_TEST_ALL_PREFIXES(OmniboxViewViewsTest, CloseOmniboxPopupOnTextDrag);
FRIEND_TEST_ALL_PREFIXES(OmniboxViewViewsTest, FriendlyAccessibleLabel);
FRIEND_TEST_ALL_PREFIXES(OmniboxViewViewsTest, DoNotNavigateOnDrop);
FRIEND_TEST_ALL_PREFIXES(OmniboxViewViewsTest,
ElideAnimationDoesntStartIfNoVisibleChange);
enum class UnelisionGesture { enum class UnelisionGesture {
HOME_KEY_PRESSED, HOME_KEY_PRESSED,
MOUSE_RELEASE, MOUSE_RELEASE,
...@@ -546,9 +547,6 @@ class OmniboxViewViews : public OmniboxView, ...@@ -546,9 +547,6 @@ class OmniboxViewViews : public OmniboxView,
// applicable), and returns the result. // applicable), and returns the result.
url::Component GetHostComponentAfterTrivialSubdomain(); url::Component GetHostComponentAfterTrivialSubdomain();
ElideAnimation* GetHoverElideOrUnelideAnimationForTesting();
ElideAnimation* GetElideAfterInteractionAnimationForTesting();
// When true, the location bar view is read only and also is has a slightly // When true, the location bar view is read only and also is has a slightly
// different presentation (smaller font size). This is used for popups. // different presentation (smaller font size). This is used for popups.
bool popup_window_mode_; bool popup_window_mode_;
......
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