Commit ebd9b95e authored by Sky Malice's avatar Sky Malice Committed by Commit Bot

[Feed] Add config values for placing synthetic token.

Bug: 910712
Change-Id: I70b768c1215ef0f540fbccbe98d0907881388782
Reviewed-on: https://chromium-review.googlesource.com/c/1357537
Commit-Queue: Sky Malice <skym@chromium.org>
Reviewed-by: default avatarFilip Gorski <fgorski@chromium.org>
Cr-Commit-Position: refs/heads/master@{#613349}
parent 80af4179
...@@ -34,11 +34,23 @@ public final class FeedConfiguration { ...@@ -34,11 +34,23 @@ public final class FeedConfiguration {
/** Default value for feed server response length prefixed. */ /** Default value for feed server response length prefixed. */
public static final boolean FEED_SERVER_RESPONSE_LENGTH_PREFIXED_DEFAULT = true; public static final boolean FEED_SERVER_RESPONSE_LENGTH_PREFIXED_DEFAULT = true;
private static final String INITIAL_NON_CACHED_PAGE_SIZE = "initial_non_cached_page_size";
/** Default value for initial non cached page size. */
public static final int INITIAL_NON_CACHED_PAGE_SIZE_DEFAULT = 10;
private static final String LOGGING_IMMEDIATE_CONTENT_THRESHOLD_MS = private static final String LOGGING_IMMEDIATE_CONTENT_THRESHOLD_MS =
"logging_immediate_content_threshold_ms"; "logging_immediate_content_threshold_ms";
/** Default value for logging immediate content threshold. */ /** Default value for logging immediate content threshold. */
public static final int LOGGING_IMMEDIATE_CONTENT_THRESHOLD_MS_DEFAULT = 1000; public static final int LOGGING_IMMEDIATE_CONTENT_THRESHOLD_MS_DEFAULT = 1000;
private static final String NON_CACHED_MIN_PAGE_SIZE = "non_cached_min_page_size";
/** Default value for non cached minimum page size. */
public static final int NON_CACHED_MIN_PAGE_SIZE_DEFAULT = 5;
private static final String NON_CACHED_PAGE_SIZE = "non_cached_page_size";
/** Default value for non cached page size. */
public static final int NON_CACHED_PAGE_SIZE_DEFAULT = 20;
private static final String SESSION_LIFETIME_MS = "session_lifetime_ms"; private static final String SESSION_LIFETIME_MS = "session_lifetime_ms";
/** Default value for session lifetime. */ /** Default value for session lifetime. */
public static final int SESSION_LIFETIME_MS_DEFAULT = 3600000; public static final int SESSION_LIFETIME_MS_DEFAULT = 3600000;
...@@ -69,12 +81,19 @@ public final class FeedConfiguration { ...@@ -69,12 +81,19 @@ public final class FeedConfiguration {
/** @return Whether server response should be length prefixed. */ /** @return Whether server response should be length prefixed. */
@VisibleForTesting @VisibleForTesting
static boolean getFeedServerReponseLengthPrefixed() { static boolean getFeedServerResponseLengthPrefixed() {
return ChromeFeatureList.getFieldTrialParamByFeatureAsBoolean( return ChromeFeatureList.getFieldTrialParamByFeatureAsBoolean(
ChromeFeatureList.INTEREST_FEED_CONTENT_SUGGESTIONS, ChromeFeatureList.INTEREST_FEED_CONTENT_SUGGESTIONS,
FEED_SERVER_RESPONSE_LENGTH_PREFIXED, FEED_SERVER_RESPONSE_LENGTH_PREFIXED_DEFAULT); FEED_SERVER_RESPONSE_LENGTH_PREFIXED, FEED_SERVER_RESPONSE_LENGTH_PREFIXED_DEFAULT);
} }
/** @return Used to decide where to place the more button initially. */
static int getInitialNonCachedPageSize() {
return ChromeFeatureList.getFieldTrialParamByFeatureAsInt(
ChromeFeatureList.INTEREST_FEED_CONTENT_SUGGESTIONS, INITIAL_NON_CACHED_PAGE_SIZE,
INITIAL_NON_CACHED_PAGE_SIZE_DEFAULT);
}
/** /**
* @return How long before showing content after opening NTP is no longer considered immediate * @return How long before showing content after opening NTP is no longer considered immediate
* in UMA. * in UMA.
...@@ -87,6 +106,20 @@ public final class FeedConfiguration { ...@@ -87,6 +106,20 @@ public final class FeedConfiguration {
LOGGING_IMMEDIATE_CONTENT_THRESHOLD_MS_DEFAULT); LOGGING_IMMEDIATE_CONTENT_THRESHOLD_MS_DEFAULT);
} }
/** @return Used to decide where to place the more button. */
static int getNonCachedMinPageSize() {
return ChromeFeatureList.getFieldTrialParamByFeatureAsInt(
ChromeFeatureList.INTEREST_FEED_CONTENT_SUGGESTIONS, NON_CACHED_MIN_PAGE_SIZE,
NON_CACHED_MIN_PAGE_SIZE_DEFAULT);
}
/** @return Used to decide where to place the more button. */
static int getNonCachedPageSize() {
return ChromeFeatureList.getFieldTrialParamByFeatureAsInt(
ChromeFeatureList.INTEREST_FEED_CONTENT_SUGGESTIONS, NON_CACHED_PAGE_SIZE,
NON_CACHED_PAGE_SIZE_DEFAULT);
}
/** @return Time until feed stops restoring the UI. */ /** @return Time until feed stops restoring the UI. */
@VisibleForTesting @VisibleForTesting
static long getSessionLifetimeMs() { static long getSessionLifetimeMs() {
...@@ -100,7 +133,7 @@ public final class FeedConfiguration { ...@@ -100,7 +133,7 @@ public final class FeedConfiguration {
* when server could potentially have more content. * when server could potentially have more content.
*/ */
@VisibleForTesting @VisibleForTesting
static boolean getTriggerImmedatePagination() { static boolean getTriggerImmediatePagination() {
return ChromeFeatureList.getFieldTrialParamByFeatureAsBoolean( return ChromeFeatureList.getFieldTrialParamByFeatureAsBoolean(
ChromeFeatureList.INTEREST_FEED_CONTENT_SUGGESTIONS, TRIGGER_IMMEDIATE_PAGINATION, ChromeFeatureList.INTEREST_FEED_CONTENT_SUGGESTIONS, TRIGGER_IMMEDIATE_PAGINATION,
TRIGGER_IMMEDIATE_PAGINATION_DEFAULT); TRIGGER_IMMEDIATE_PAGINATION_DEFAULT);
...@@ -122,12 +155,17 @@ public final class FeedConfiguration { ...@@ -122,12 +155,17 @@ public final class FeedConfiguration {
.put(ConfigKey.FEED_SERVER_ENDPOINT, FeedConfiguration.getFeedServerEndpoint()) .put(ConfigKey.FEED_SERVER_ENDPOINT, FeedConfiguration.getFeedServerEndpoint())
.put(ConfigKey.FEED_SERVER_METHOD, FeedConfiguration.getFeedServerMethod()) .put(ConfigKey.FEED_SERVER_METHOD, FeedConfiguration.getFeedServerMethod())
.put(ConfigKey.FEED_SERVER_RESPONSE_LENGTH_PREFIXED, .put(ConfigKey.FEED_SERVER_RESPONSE_LENGTH_PREFIXED,
FeedConfiguration.getFeedServerReponseLengthPrefixed()) FeedConfiguration.getFeedServerResponseLengthPrefixed())
.put(ConfigKey.INITIAL_NON_CACHED_PAGE_SIZE,
FeedConfiguration.getInitialNonCachedPageSize())
.put(ConfigKey.LOGGING_IMMEDIATE_CONTENT_THRESHOLD_MS, .put(ConfigKey.LOGGING_IMMEDIATE_CONTENT_THRESHOLD_MS,
FeedConfiguration.getLoggingImmediateContentThresholdMs()) FeedConfiguration.getLoggingImmediateContentThresholdMs())
.put(ConfigKey.NON_CACHED_MIN_PAGE_SIZE,
FeedConfiguration.getNonCachedMinPageSize())
.put(ConfigKey.NON_CACHED_PAGE_SIZE, FeedConfiguration.getNonCachedPageSize())
.put(ConfigKey.SESSION_LIFETIME_MS, FeedConfiguration.getSessionLifetimeMs()) .put(ConfigKey.SESSION_LIFETIME_MS, FeedConfiguration.getSessionLifetimeMs())
.put(ConfigKey.TRIGGER_IMMEDIATE_PAGINATION, .put(ConfigKey.TRIGGER_IMMEDIATE_PAGINATION,
FeedConfiguration.getTriggerImmedatePagination()) FeedConfiguration.getTriggerImmediatePagination())
.put(ConfigKey.VIEW_LOG_THRESHOLD, FeedConfiguration.getViewLogThreshold()) .put(ConfigKey.VIEW_LOG_THRESHOLD, FeedConfiguration.getViewLogThreshold())
.build(); .build();
} }
......
...@@ -39,12 +39,18 @@ public class FeedConfigurationTest { ...@@ -39,12 +39,18 @@ public class FeedConfigurationTest {
Assert.assertEquals(FeedConfiguration.FEED_SERVER_METHOD_DEFAULT, Assert.assertEquals(FeedConfiguration.FEED_SERVER_METHOD_DEFAULT,
FeedConfiguration.getFeedServerMethod()); FeedConfiguration.getFeedServerMethod());
Assert.assertEquals(FeedConfiguration.FEED_SERVER_RESPONSE_LENGTH_PREFIXED_DEFAULT, Assert.assertEquals(FeedConfiguration.FEED_SERVER_RESPONSE_LENGTH_PREFIXED_DEFAULT,
FeedConfiguration.getFeedServerReponseLengthPrefixed()); FeedConfiguration.getFeedServerResponseLengthPrefixed());
Assert.assertEquals(FeedConfiguration.INITIAL_NON_CACHED_PAGE_SIZE_DEFAULT,
FeedConfiguration.getInitialNonCachedPageSize());
Assert.assertEquals(FeedConfiguration.LOGGING_IMMEDIATE_CONTENT_THRESHOLD_MS_DEFAULT, Assert.assertEquals(FeedConfiguration.LOGGING_IMMEDIATE_CONTENT_THRESHOLD_MS_DEFAULT,
FeedConfiguration.getLoggingImmediateContentThresholdMs()); FeedConfiguration.getLoggingImmediateContentThresholdMs());
Assert.assertEquals(FeedConfiguration.NON_CACHED_MIN_PAGE_SIZE_DEFAULT,
FeedConfiguration.getNonCachedMinPageSize());
Assert.assertEquals(FeedConfiguration.NON_CACHED_PAGE_SIZE_DEFAULT,
FeedConfiguration.getNonCachedPageSize());
Assert.assertEquals(FeedConfiguration.SESSION_LIFETIME_MS_DEFAULT, Assert.assertEquals(FeedConfiguration.SESSION_LIFETIME_MS_DEFAULT,
FeedConfiguration.getSessionLifetimeMs()); FeedConfiguration.getSessionLifetimeMs());
Assert.assertFalse(FeedConfiguration.getTriggerImmedatePagination()); Assert.assertFalse(FeedConfiguration.getTriggerImmediatePagination());
Assert.assertEquals(FeedConfiguration.VIEW_LOG_THRESHOLD_DEFAULT, Assert.assertEquals(FeedConfiguration.VIEW_LOG_THRESHOLD_DEFAULT,
FeedConfiguration.getViewLogThreshold(), ASSERT_EQUALS_DOUBLE_DELTA); FeedConfiguration.getViewLogThreshold(), ASSERT_EQUALS_DOUBLE_DELTA);
} }
...@@ -75,7 +81,17 @@ public class FeedConfigurationTest { ...@@ -75,7 +81,17 @@ public class FeedConfigurationTest {
Add({"enable-features=InterestFeedContentSuggestions<Trial", "force-fieldtrials=Trial/Group", Add({"enable-features=InterestFeedContentSuggestions<Trial", "force-fieldtrials=Trial/Group",
"force-fieldtrial-params=Trial.Group:feed_server_response_length_prefixed/false"}) "force-fieldtrial-params=Trial.Group:feed_server_response_length_prefixed/false"})
public void testFeedServerResponseLengthPrefixedParameter() { public void testFeedServerResponseLengthPrefixedParameter() {
Assert.assertEquals(false, FeedConfiguration.getFeedServerReponseLengthPrefixed()); Assert.assertEquals(false, FeedConfiguration.getFeedServerResponseLengthPrefixed());
}
@Test
@Feature({"Feed"})
@CommandLineFlags.
Add({"enable-features=InterestFeedContentSuggestions<Trial", "force-fieldtrials=Trial/Group",
"force-fieldtrial-params=Trial.Group:initial_non_cached_page_size/100"})
public void
testInitialNonCachedPageSize() {
Assert.assertEquals(100, FeedConfiguration.getInitialNonCachedPageSize());
} }
@Test @Test
...@@ -83,10 +99,31 @@ public class FeedConfigurationTest { ...@@ -83,10 +99,31 @@ public class FeedConfigurationTest {
@CommandLineFlags. @CommandLineFlags.
Add({"enable-features=InterestFeedContentSuggestions<Trial", "force-fieldtrials=Trial/Group", Add({"enable-features=InterestFeedContentSuggestions<Trial", "force-fieldtrials=Trial/Group",
"force-fieldtrial-params=Trial.Group:logging_immediate_content_threshold_ms/5000"}) "force-fieldtrial-params=Trial.Group:logging_immediate_content_threshold_ms/5000"})
public void testLoggingImmediateContentThresholdMs() { public void
testLoggingImmediateContentThresholdMs() {
Assert.assertEquals(5000, FeedConfiguration.getLoggingImmediateContentThresholdMs()); Assert.assertEquals(5000, FeedConfiguration.getLoggingImmediateContentThresholdMs());
} }
@Test
@Feature({"Feed"})
@CommandLineFlags.
Add({"enable-features=InterestFeedContentSuggestions<Trial", "force-fieldtrials=Trial/Group",
"force-fieldtrial-params=Trial.Group:non_cached_min_page_size/100"})
public void
testNonCachedMinPageSize() {
Assert.assertEquals(100, FeedConfiguration.getNonCachedMinPageSize());
}
@Test
@Feature({"Feed"})
@CommandLineFlags.
Add({"enable-features=InterestFeedContentSuggestions<Trial", "force-fieldtrials=Trial/Group",
"force-fieldtrial-params=Trial.Group:non_cached_page_size/100"})
public void
testNonCachedPageSize() {
Assert.assertEquals(100, FeedConfiguration.getNonCachedPageSize());
}
@Test @Test
@Feature({"Feed"}) @Feature({"Feed"})
@CommandLineFlags. @CommandLineFlags.
...@@ -102,7 +139,7 @@ public class FeedConfigurationTest { ...@@ -102,7 +139,7 @@ public class FeedConfigurationTest {
Add({"enable-features=InterestFeedContentSuggestions<Trial", "force-fieldtrials=Trial/Group", Add({"enable-features=InterestFeedContentSuggestions<Trial", "force-fieldtrials=Trial/Group",
"force-fieldtrial-params=Trial.Group:trigger_immediate_pagination/true"}) "force-fieldtrial-params=Trial.Group:trigger_immediate_pagination/true"})
public void testTriggerImmedatePagination() { public void testTriggerImmedatePagination() {
Assert.assertTrue(FeedConfiguration.getTriggerImmedatePagination()); Assert.assertTrue(FeedConfiguration.getTriggerImmediatePagination());
} }
@Test @Test
...@@ -126,10 +163,16 @@ public class FeedConfigurationTest { ...@@ -126,10 +163,16 @@ public class FeedConfigurationTest {
configuration.getValueOrDefault(ConfigKey.FEED_SERVER_METHOD, "")); configuration.getValueOrDefault(ConfigKey.FEED_SERVER_METHOD, ""));
Assert.assertEquals(FeedConfiguration.FEED_SERVER_RESPONSE_LENGTH_PREFIXED_DEFAULT, Assert.assertEquals(FeedConfiguration.FEED_SERVER_RESPONSE_LENGTH_PREFIXED_DEFAULT,
configuration.getValueOrDefault(ConfigKey.FEED_SERVER_RESPONSE_LENGTH_PREFIXED, 0)); configuration.getValueOrDefault(ConfigKey.FEED_SERVER_RESPONSE_LENGTH_PREFIXED, 0));
Assert.assertEquals(Integer.valueOf(FeedConfiguration.INITIAL_NON_CACHED_PAGE_SIZE_DEFAULT),
configuration.getValueOrDefault(ConfigKey.INITIAL_NON_CACHED_PAGE_SIZE, 0));
Assert.assertEquals( Assert.assertEquals(
Long.valueOf(FeedConfiguration.LOGGING_IMMEDIATE_CONTENT_THRESHOLD_MS_DEFAULT), Long.valueOf(FeedConfiguration.LOGGING_IMMEDIATE_CONTENT_THRESHOLD_MS_DEFAULT),
configuration.getValueOrDefault( configuration.getValueOrDefault(
ConfigKey.LOGGING_IMMEDIATE_CONTENT_THRESHOLD_MS, 0l)); ConfigKey.LOGGING_IMMEDIATE_CONTENT_THRESHOLD_MS, 0l));
Assert.assertEquals(Integer.valueOf(FeedConfiguration.NON_CACHED_MIN_PAGE_SIZE_DEFAULT),
configuration.getValueOrDefault(ConfigKey.NON_CACHED_MIN_PAGE_SIZE, 0));
Assert.assertEquals(Integer.valueOf(FeedConfiguration.NON_CACHED_PAGE_SIZE_DEFAULT),
configuration.getValueOrDefault(ConfigKey.NON_CACHED_PAGE_SIZE, 0));
Assert.assertEquals(Long.valueOf(FeedConfiguration.SESSION_LIFETIME_MS_DEFAULT), Assert.assertEquals(Long.valueOf(FeedConfiguration.SESSION_LIFETIME_MS_DEFAULT),
configuration.getValueOrDefault(ConfigKey.SESSION_LIFETIME_MS, 0l)); configuration.getValueOrDefault(ConfigKey.SESSION_LIFETIME_MS, 0l));
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