Commit 7b85b8c0 authored by Sky Malice's avatar Sky Malice Committed by Commit Bot

[Feed] Pass finch params through for spinner delay and minn.

Bug: 968611
Change-Id: I5710626293133e424a80a231f672802fa6c92c8b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1636826Reviewed-by: default avatarDan H <harringtond@chromium.org>
Commit-Queue: Sky Malice <skym@chromium.org>
Cr-Commit-Position: refs/heads/master@{#664897}
parent f7840ccd
...@@ -71,6 +71,14 @@ public final class FeedConfiguration { ...@@ -71,6 +71,14 @@ public final class FeedConfiguration {
/** Default value for whether to show article snippets. */ /** Default value for whether to show article snippets. */
public static final boolean SNIPPETS_ENABLED_DEFAULT = false; public static final boolean SNIPPETS_ENABLED_DEFAULT = false;
private static final String SPINNER_DELAY_MS = "spinner_delay";
/** Default value for delay before showing a spinner. */
public static final long SPINNER_DELAY_MS_DEFAULT = 500;
private static final String SPINNER_MINIMUM_SHOW_TIME_MS = "spinner_minimum_show_time";
/** Default value for how long spinners must be shown for. */
public static final long SPINNER_MINIMUM_SHOW_TIME_MS_DEFAULT = 500;
private static final String TRIGGER_IMMEDIATE_PAGINATION = "trigger_immediate_pagination"; private static final String TRIGGER_IMMEDIATE_PAGINATION = "trigger_immediate_pagination";
/** Default value for triggering immediate pagination. */ /** Default value for triggering immediate pagination. */
public static final boolean TRIGGER_IMMEDIATE_PAGINATION_DEFAULT = false; public static final boolean TRIGGER_IMMEDIATE_PAGINATION_DEFAULT = false;
...@@ -183,6 +191,30 @@ public final class FeedConfiguration { ...@@ -183,6 +191,30 @@ public final class FeedConfiguration {
(int) SESSION_LIFETIME_MS_DEFAULT); (int) SESSION_LIFETIME_MS_DEFAULT);
} }
/** @return Whether the article snippets feature is enabled. */
@VisibleForTesting
static boolean getSnippetsEnabled() {
return ChromeFeatureList.getFieldTrialParamByFeatureAsBoolean(
ChromeFeatureList.INTEREST_FEED_CONTENT_SUGGESTIONS, SNIPPETS_ENABLED,
SNIPPETS_ENABLED_DEFAULT);
}
/** @return Delay before a spinner should be shown after content is requested. */
@VisibleForTesting
static long getSpinnerDelayMs() {
return (long) ChromeFeatureList.getFieldTrialParamByFeatureAsInt(
ChromeFeatureList.INTEREST_FEED_CONTENT_SUGGESTIONS, SPINNER_DELAY_MS,
(int) SPINNER_DELAY_MS_DEFAULT);
}
/** @return Minimum time before a spinner should show before disappearing. */
@VisibleForTesting
static long getSpinnerMinimumShowTimeMs() {
return (long) ChromeFeatureList.getFieldTrialParamByFeatureAsInt(
ChromeFeatureList.INTEREST_FEED_CONTENT_SUGGESTIONS, SPINNER_MINIMUM_SHOW_TIME_MS,
(int) SPINNER_MINIMUM_SHOW_TIME_MS_DEFAULT);
}
/** /**
* @return Whether UI initially shows "More" button upon reaching the end of known content, * @return Whether UI initially shows "More" button upon reaching the end of known content,
* when server could potentially have more content. * when server could potentially have more content.
...@@ -232,14 +264,6 @@ public final class FeedConfiguration { ...@@ -232,14 +264,6 @@ public final class FeedConfiguration {
VIEW_LOG_THRESHOLD_DEFAULT); VIEW_LOG_THRESHOLD_DEFAULT);
} }
/** @return Whether the article snippets feature is enabled. */
@VisibleForTesting
static boolean getSnippetsEnabled() {
return ChromeFeatureList.getFieldTrialParamByFeatureAsBoolean(
ChromeFeatureList.INTEREST_FEED_CONTENT_SUGGESTIONS, SNIPPETS_ENABLED,
SNIPPETS_ENABLED_DEFAULT);
}
/** /**
* @return A fully built {@link Configuration}, ready to be given to the Feed. * @return A fully built {@link Configuration}, ready to be given to the Feed.
*/ */
...@@ -263,6 +287,9 @@ public final class FeedConfiguration { ...@@ -263,6 +287,9 @@ public final class FeedConfiguration {
.put(ConfigKey.NON_CACHED_PAGE_SIZE, FeedConfiguration.getNonCachedPageSize()) .put(ConfigKey.NON_CACHED_PAGE_SIZE, FeedConfiguration.getNonCachedPageSize())
.put(ConfigKey.SESSION_LIFETIME_MS, FeedConfiguration.getSessionLifetimeMs()) .put(ConfigKey.SESSION_LIFETIME_MS, FeedConfiguration.getSessionLifetimeMs())
.put(ConfigKey.SNIPPETS_ENABLED, FeedConfiguration.getSnippetsEnabled()) .put(ConfigKey.SNIPPETS_ENABLED, FeedConfiguration.getSnippetsEnabled())
.put(ConfigKey.SPINNER_DELAY_MS, FeedConfiguration.getSpinnerDelayMs())
.put(ConfigKey.SPINNER_MINIMUM_SHOW_TIME_MS,
FeedConfiguration.getSpinnerMinimumShowTimeMs())
.put(ConfigKey.TRIGGER_IMMEDIATE_PAGINATION, .put(ConfigKey.TRIGGER_IMMEDIATE_PAGINATION,
FeedConfiguration.getTriggerImmediatePagination()) FeedConfiguration.getTriggerImmediatePagination())
.put(ConfigKey.UNDOABLE_ACTIONS_ENABLED, .put(ConfigKey.UNDOABLE_ACTIONS_ENABLED,
......
...@@ -58,6 +58,10 @@ public class FeedConfigurationTest { ...@@ -58,6 +58,10 @@ public class FeedConfigurationTest {
FeedConfiguration.getSessionLifetimeMs()); FeedConfiguration.getSessionLifetimeMs());
Assert.assertEquals( Assert.assertEquals(
FeedConfiguration.SNIPPETS_ENABLED_DEFAULT, FeedConfiguration.getSnippetsEnabled()); FeedConfiguration.SNIPPETS_ENABLED_DEFAULT, FeedConfiguration.getSnippetsEnabled());
Assert.assertEquals(
FeedConfiguration.SPINNER_DELAY_MS_DEFAULT, FeedConfiguration.getSpinnerDelayMs());
Assert.assertEquals(FeedConfiguration.SPINNER_MINIMUM_SHOW_TIME_MS_DEFAULT,
FeedConfiguration.getSpinnerMinimumShowTimeMs());
Assert.assertEquals(FeedConfiguration.TRIGGER_IMMEDIATE_PAGINATION_DEFAULT, Assert.assertEquals(FeedConfiguration.TRIGGER_IMMEDIATE_PAGINATION_DEFAULT,
FeedConfiguration.getTriggerImmediatePagination()); FeedConfiguration.getTriggerImmediatePagination());
Assert.assertEquals(FeedConfiguration.UNDOABLE_ACTIONS_ENABLED_DEFAULT, Assert.assertEquals(FeedConfiguration.UNDOABLE_ACTIONS_ENABLED_DEFAULT,
...@@ -191,6 +195,26 @@ public class FeedConfigurationTest { ...@@ -191,6 +195,26 @@ public class FeedConfigurationTest {
Assert.assertTrue(FeedConfiguration.getSnippetsEnabled()); Assert.assertTrue(FeedConfiguration.getSnippetsEnabled());
} }
@Test
@Feature({"Feed"})
@CommandLineFlags.
Add({"enable-features=InterestFeedContentSuggestions<Trial", "force-fieldtrials=Trial/Group",
"force-fieldtrial-params=Trial.Group:spinner_delay/333"})
public void
testSpinnerDelayMs() {
Assert.assertEquals(333, FeedConfiguration.getSpinnerDelayMs());
}
@Test
@Feature({"Feed"})
@CommandLineFlags.
Add({"enable-features=InterestFeedContentSuggestions<Trial", "force-fieldtrials=Trial/Group",
"force-fieldtrial-params=Trial.Group:spinner_minimum_show_time/444"})
public void
testSpinnerMinimumShowTimeMs() {
Assert.assertEquals(444, FeedConfiguration.getSpinnerMinimumShowTimeMs());
}
@Test @Test
@Feature({"Feed"}) @Feature({"Feed"})
@CommandLineFlags. @CommandLineFlags.
...@@ -270,6 +294,10 @@ public class FeedConfigurationTest { ...@@ -270,6 +294,10 @@ public class FeedConfigurationTest {
Assert.assertEquals((long) FeedConfiguration.SESSION_LIFETIME_MS_DEFAULT, Assert.assertEquals((long) FeedConfiguration.SESSION_LIFETIME_MS_DEFAULT,
configuration.getValueOrDefault(ConfigKey.SESSION_LIFETIME_MS, 0l)); configuration.getValueOrDefault(ConfigKey.SESSION_LIFETIME_MS, 0l));
Assert.assertFalse(configuration.getValueOrDefault(ConfigKey.SNIPPETS_ENABLED, true)); Assert.assertFalse(configuration.getValueOrDefault(ConfigKey.SNIPPETS_ENABLED, true));
Assert.assertEquals((long) FeedConfiguration.SPINNER_DELAY_MS_DEFAULT,
configuration.getValueOrDefault(ConfigKey.SPINNER_DELAY_MS, 0l));
Assert.assertEquals((long) FeedConfiguration.SPINNER_MINIMUM_SHOW_TIME_MS_DEFAULT,
configuration.getValueOrDefault(ConfigKey.SPINNER_MINIMUM_SHOW_TIME_MS, 0l));
Assert.assertFalse( Assert.assertFalse(
configuration.getValueOrDefault(ConfigKey.TRIGGER_IMMEDIATE_PAGINATION, true)); configuration.getValueOrDefault(ConfigKey.TRIGGER_IMMEDIATE_PAGINATION, true));
Assert.assertFalse( Assert.assertFalse(
......
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