Commit 230b6965 authored by Donn Denman's avatar Donn Denman Committed by Commit Bot

[TTS] Fix Tap behavior w/ longpress-resolve active

Fixes some recently introduced resolve behavior problems with
the Tap gesture when the CSLongpressResolve feature is enabled:
1) Tap should not be recognized (unless we're in the preserve-tap
   variation of the longpress experiment).
2) Tap should not resolve even when we're in the longpress
   variation when privacy-aggressive behavior is enabled.

Adds automated tests.

BUG=999448, 999663

Change-Id: I29d14c7666fdcd8ea286ae5d55c46e250e23c350
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1779301
Auto-Submit: Donn Denman <donnd@chromium.org>
Reviewed-by: default avatarMatthew Jones <mdjones@chromium.org>
Commit-Queue: Matthew Jones <mdjones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#692268}
parent edc5b05c
......@@ -116,11 +116,13 @@ class ContextualSearchPolicy {
* @return Whether a Tap gesture is currently supported as a trigger for the feature.
*/
boolean isTapSupported() {
if (isTapDisabledDueToLongpress()) return false;
return (!isUserUndecided()
|| ContextualSearchFieldTrial.getSwitch(
ContextualSearchSwitch
.IS_CONTEXTUAL_SEARCH_TAP_DISABLE_OVERRIDE_ENABLED))
? !isTapDisabledDueToLongpress()
? true
: (getPromoTapsRemaining() != 0);
}
......@@ -150,7 +152,9 @@ class ContextualSearchPolicy {
return false;
}
if (isPrivacyAggressiveResolveEnabled()) return true;
if (isPrivacyAggressiveResolveEnabled()
&& mSelectionController.getSelectionType() == SelectionType.RESOLVING_LONG_PRESS)
return true;
return (isPromoAvailable()
|| (mContextualSearchPreferenceHelper != null
......
......@@ -719,22 +719,6 @@ public class ContextualSearchManagerTest {
assertLoadedNoUrl();
}
/**
* Asserts that the tap triggered promo counter is enabled and at the specified count.
*/
private void assertTapPromoCounterEnabledAt(int expectedCount) {
Assert.assertTrue(mPolicy.getPromoTapCounter().isEnabled());
Assert.assertEquals(expectedCount, mPolicy.getPromoTapCounter().getCount());
}
/**
* Asserts that the tap triggered promo counter is disabled and at the specified count.
*/
private void assertTapPromoCounterDisabledAt(int expectedCount) {
Assert.assertFalse(mPolicy.getPromoTapCounter().isEnabled());
Assert.assertEquals(expectedCount, mPolicy.getPromoTapCounter().getCount());
}
/**
* Waits for the Search Panel (the Search Bar) to peek up from the bottom, and asserts that it
* did peek.
......@@ -3268,4 +3252,56 @@ public class ContextualSearchManagerTest {
RecordHistogram.getHistogramValueCountForTesting(
"Search.ContextualSearch.OutcomesDuration", 0));
}
// --------------------------------------------------------------------------------------------
// Longpress-resolve Feature tests.
// --------------------------------------------------------------------------------------------
@Test
@SmallTest
@Feature({"ContextualSearch"})
@Features.EnableFeatures("ContextualSearchLongpressResolve")
public void testTapIsIgnoredWithLongpressResolveEnabled()
throws InterruptedException, TimeoutException {
clickNode("states");
Assert.assertNull(getSelectedText());
assertPanelClosedOrUndefined();
assertLoadedNoUrl();
}
@Test
@SmallTest
@Feature({"ContextualSearch"})
@CommandLineFlags.Add({"enable-features=ContextualSearchLongpressResolve<FakeStudyName",
"force-fieldtrials=FakeStudyName/FakeGroup",
"force-fieldtrial-params=FakeStudyName.FakeGroup:longpress_resolve_variation/"
+ ContextualSearchFieldTrial.LONGPRESS_RESOLVE_PRESERVE_TAP})
public void
testTapNotIgnoredWithLongpressResolveEnabledAndVariationPreserveTap()
throws InterruptedException, TimeoutException {
clickWordNode("states");
Assert.assertEquals("States", getSelectedText());
waitForPanelToPeek();
}
@Test
@SmallTest
@Feature({"ContextualSearch"})
@CommandLineFlags.Add({"enable-features=ContextualSearchLongpressResolve<FakeStudyName",
"force-fieldtrials=FakeStudyName/FakeGroup",
"force-fieldtrial-params=FakeStudyName.FakeGroup:longpress_resolve_variation/"
+ ContextualSearchFieldTrial.LONGPRESS_RESOLVE_PRIVACY_AGGRESSIVE})
public void
testLongpressResolvesWithLongpressResolveEnabledAndVariationPrivacyAggressive()
throws InterruptedException, TimeoutException {
mPolicy.overrideDecidedStateForTesting(false);
mFakeServer.setShouldUseHttps(true);
longPressNode("states");
assertLoadedNoUrl();
assertSearchTermRequested();
fakeResponse(false, 200, "states", "United States Intelligence", "alternate-term", false);
waitForPanelToPeek();
assertLoadedLowPriorityUrl();
assertContainsParameters("states", "alternate-term");
}
}
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