Commit fea5471b authored by Hesen Zhang's avatar Hesen Zhang Committed by Commit Bot

[Query Tiles]: Cleanup tile configs.

Bug: 1086675
Change-Id: I80f71de863c3a6db40d9c7459356d5ef0184c4d9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2213899Reviewed-by: default avatarMin Qin <qinmin@chromium.org>
Commit-Queue: Hesen Zhang <hesen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#772113}
parent f52c0981
......@@ -58,7 +58,8 @@ constexpr int kDefaultScheduleInterval = 12 * 3600 * 1000; // 12 hours.
// Default length of random window added to the interval.
constexpr int kDefaultRandomWindow = 4 * 3600 * 1000; // 4 hours.
// Default length of random window added to the interval.
// Default delta value from start window time to end window time in one-off
// background task.
constexpr int kDefaultOneoffTaskWindow = 2 * 3600 * 1000; // 2 hours.
// Default initial delay in backoff policy.
......
......@@ -33,7 +33,7 @@ extern const char kIsUnmeteredNetworkRequiredKey[];
extern const char kImagePrefetchModeKey[];
// Finch parameter key for the minimum interval to next schedule.
extern const char kNextScheduleMinIntervalKey[];
extern const char kScheduleIntervalKey[];
// Finch parameter key for random window.
extern const char kMaxRandomWindowKey[];
......@@ -41,6 +41,12 @@ extern const char kMaxRandomWindowKey[];
// Finch parameter key for one off task window.
extern const char kOneoffTaskWindowKey[];
// Finch parameter key for Backoff policy initial delay in ms.
extern const char kBackoffInitDelayInMsKey[];
// Finch parameter key for Backoff policy maximum delay in ms.
extern const char kBackoffMaxDelayInMsKey[];
class TileConfig {
public:
// Gets the URL for the Query Tiles server.
......
......@@ -27,10 +27,11 @@ void TestImagePrefetchMode(std::map<std::string, std::string> params,
TEST(TileConfigTest, FinchConfigEnabled) {
base::test::ScopedFeatureList feature_list;
std::map<std::string, std::string> params = {
{kExperimentTagKey, "1234"},
{kBaseURLKey, "https://test.com"},
{kExpireDurationKey, "100"},
{kIsUnmeteredNetworkRequiredKey, "true"}};
{kExperimentTagKey, "1234"}, {kBaseURLKey, "https://test.com"},
{kExpireDurationKey, "100"}, {kIsUnmeteredNetworkRequiredKey, "true"},
{kScheduleIntervalKey, "123"}, {kMaxRandomWindowKey, "234"},
{kOneoffTaskWindowKey, "345"}, {kBackoffInitDelayInMsKey, "456"},
{kBackoffMaxDelayInMsKey, "567"}};
feature_list.InitAndEnableFeatureWithParameters(features::kQueryTiles,
params);
EXPECT_EQ(TileConfig::GetQueryTilesServerUrl(),
......@@ -38,6 +39,11 @@ TEST(TileConfigTest, FinchConfigEnabled) {
EXPECT_TRUE(TileConfig::GetIsUnMeteredNetworkRequired());
EXPECT_EQ(TileConfig::GetExperimentTag(), "1234");
EXPECT_EQ(TileConfig::GetExpireDuration(), base::TimeDelta::FromSeconds(100));
EXPECT_EQ(TileConfig::GetScheduleIntervalInMs(), 123);
EXPECT_EQ(TileConfig::GetMaxRandomWindowInMs(), 234);
EXPECT_EQ(TileConfig::GetOneoffTaskWindowInMs(), 345);
EXPECT_EQ(TileConfig::GetBackoffPolicyArgsInitDelayInMs(), 456);
EXPECT_EQ(TileConfig::GetBackoffPolicyArgsMaxDelayInMs(), 567);
}
// Test to verify that if not configured, default parameter values are used.
......@@ -49,8 +55,17 @@ TEST(TileConfigTest, FinchConfigDefaultParameter) {
"https://autopush-gsaprototype-pa.sandbox.googleapis.com/v1/querytiles");
EXPECT_FALSE(TileConfig::GetIsUnMeteredNetworkRequired());
EXPECT_TRUE(TileConfig::GetExperimentTag().empty());
EXPECT_EQ(TileConfig::GetExpireDuration(),
base::TimeDelta::FromSeconds(48 * 60 * 60));
EXPECT_EQ(TileConfig::GetExpireDuration(), base::TimeDelta::FromDays(2));
EXPECT_EQ(TileConfig::GetScheduleIntervalInMs(),
base::TimeDelta::FromHours(12).InMilliseconds());
EXPECT_EQ(TileConfig::GetMaxRandomWindowInMs(),
base::TimeDelta::FromHours(4).InMilliseconds());
EXPECT_EQ(TileConfig::GetOneoffTaskWindowInMs(),
base::TimeDelta::FromHours(2).InMilliseconds());
EXPECT_EQ(TileConfig::GetBackoffPolicyArgsInitDelayInMs(),
base::TimeDelta::FromSeconds(30).InMilliseconds());
EXPECT_EQ(TileConfig::GetBackoffPolicyArgsMaxDelayInMs(),
base::TimeDelta::FromDays(1).InMilliseconds());
}
// Test to verify ImagePrefetchMode can be parsed correctly from Finch
......
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