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 {
/** Default value for feed server response length prefixed. */
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 =
"logging_immediate_content_threshold_ms";
/** Default value for logging immediate content threshold. */
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";
/** Default value for session lifetime. */
public static final int SESSION_LIFETIME_MS_DEFAULT = 3600000;
......@@ -69,12 +81,19 @@ public final class FeedConfiguration {
/** @return Whether server response should be length prefixed. */
@VisibleForTesting
static boolean getFeedServerReponseLengthPrefixed() {
static boolean getFeedServerResponseLengthPrefixed() {
return ChromeFeatureList.getFieldTrialParamByFeatureAsBoolean(
ChromeFeatureList.INTEREST_FEED_CONTENT_SUGGESTIONS,
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
* in UMA.
......@@ -87,6 +106,20 @@ public final class FeedConfiguration {
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. */
@VisibleForTesting
static long getSessionLifetimeMs() {
......@@ -100,7 +133,7 @@ public final class FeedConfiguration {
* when server could potentially have more content.
*/
@VisibleForTesting
static boolean getTriggerImmedatePagination() {
static boolean getTriggerImmediatePagination() {
return ChromeFeatureList.getFieldTrialParamByFeatureAsBoolean(
ChromeFeatureList.INTEREST_FEED_CONTENT_SUGGESTIONS, TRIGGER_IMMEDIATE_PAGINATION,
TRIGGER_IMMEDIATE_PAGINATION_DEFAULT);
......@@ -122,12 +155,17 @@ public final class FeedConfiguration {
.put(ConfigKey.FEED_SERVER_ENDPOINT, FeedConfiguration.getFeedServerEndpoint())
.put(ConfigKey.FEED_SERVER_METHOD, FeedConfiguration.getFeedServerMethod())
.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,
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.TRIGGER_IMMEDIATE_PAGINATION,
FeedConfiguration.getTriggerImmedatePagination())
FeedConfiguration.getTriggerImmediatePagination())
.put(ConfigKey.VIEW_LOG_THRESHOLD, FeedConfiguration.getViewLogThreshold())
.build();
}
......
......@@ -39,12 +39,18 @@ public class FeedConfigurationTest {
Assert.assertEquals(FeedConfiguration.FEED_SERVER_METHOD_DEFAULT,
FeedConfiguration.getFeedServerMethod());
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,
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,
FeedConfiguration.getSessionLifetimeMs());
Assert.assertFalse(FeedConfiguration.getTriggerImmedatePagination());
Assert.assertFalse(FeedConfiguration.getTriggerImmediatePagination());
Assert.assertEquals(FeedConfiguration.VIEW_LOG_THRESHOLD_DEFAULT,
FeedConfiguration.getViewLogThreshold(), ASSERT_EQUALS_DOUBLE_DELTA);
}
......@@ -75,7 +81,17 @@ public class FeedConfigurationTest {
Add({"enable-features=InterestFeedContentSuggestions<Trial", "force-fieldtrials=Trial/Group",
"force-fieldtrial-params=Trial.Group:feed_server_response_length_prefixed/false"})
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
......@@ -83,10 +99,31 @@ public class FeedConfigurationTest {
@CommandLineFlags.
Add({"enable-features=InterestFeedContentSuggestions<Trial", "force-fieldtrials=Trial/Group",
"force-fieldtrial-params=Trial.Group:logging_immediate_content_threshold_ms/5000"})
public void testLoggingImmediateContentThresholdMs() {
public void
testLoggingImmediateContentThresholdMs() {
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
@Feature({"Feed"})
@CommandLineFlags.
......@@ -102,7 +139,7 @@ public class FeedConfigurationTest {
Add({"enable-features=InterestFeedContentSuggestions<Trial", "force-fieldtrials=Trial/Group",
"force-fieldtrial-params=Trial.Group:trigger_immediate_pagination/true"})
public void testTriggerImmedatePagination() {
Assert.assertTrue(FeedConfiguration.getTriggerImmedatePagination());
Assert.assertTrue(FeedConfiguration.getTriggerImmediatePagination());
}
@Test
......@@ -126,10 +163,16 @@ public class FeedConfigurationTest {
configuration.getValueOrDefault(ConfigKey.FEED_SERVER_METHOD, ""));
Assert.assertEquals(FeedConfiguration.FEED_SERVER_RESPONSE_LENGTH_PREFIXED_DEFAULT,
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(
Long.valueOf(FeedConfiguration.LOGGING_IMMEDIATE_CONTENT_THRESHOLD_MS_DEFAULT),
configuration.getValueOrDefault(
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),
configuration.getValueOrDefault(ConfigKey.SESSION_LIFETIME_MS, 0l));
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