Chromium Code Reviews| Index: chrome/browser/safe_browsing/settings_reset_prompt/settings_reset_prompt_config_unittest.cc |
| diff --git a/chrome/browser/safe_browsing/settings_reset_prompt/settings_reset_prompt_config_unittest.cc b/chrome/browser/safe_browsing/settings_reset_prompt/settings_reset_prompt_config_unittest.cc |
| index 15a57249f9107f5dd3d210f3c817cb19cce7c113..6e25b28468a542b74816542c7f001718764a30db 100644 |
| --- a/chrome/browser/safe_browsing/settings_reset_prompt/settings_reset_prompt_config_unittest.cc |
| +++ b/chrome/browser/safe_browsing/settings_reset_prompt/settings_reset_prompt_config_unittest.cc |
| @@ -45,7 +45,9 @@ class SettingsResetPromptConfigTest : public ::testing::Test { |
| Parameters GetDefaultFeatureParams() { |
| return { |
| {"domain_hashes", base::StringPrintf("{\"%s\": \"1\"}", kDomainHash)}, |
| - {"delay_before_prompt_seconds", "42"}}; |
| + {"delay_before_prompt_seconds", "42"}, |
| + {"prompt_wave", "20170101"}, |
| + {"time_between_prompts_seconds", "3600"}}; |
| } |
| variations::testing::VariationParamsManager params_manager_; |
| @@ -205,7 +207,7 @@ TEST_F(SettingsResetPromptConfigTest, UrlToResetDomainIdTLDs) { |
| } |
| TEST_F(SettingsResetPromptConfigTest, DelayBeforePromptSecondsParam) { |
| - constexpr char kDelayParam[] = "delay_before_prompt_seconds"; |
| + constexpr const char kDelayParam[] = "delay_before_prompt_seconds"; |
|
csharp
2017/03/03 00:50:46
I don't think you need the const, constexpr should
alito
2017/03/03 01:35:01
Actually, I learned that it isn't enough. Without
|
| Parameters params = GetDefaultFeatureParams(); |
| @@ -248,4 +250,75 @@ TEST_F(SettingsResetPromptConfigTest, DelayBeforePromptSecondsParam) { |
| } |
| } |
| +TEST_F(SettingsResetPromptConfigTest, PromptWaveParam) { |
| + constexpr const char kPromptWaveParam[] = "prompt_wave"; |
| + |
| + Parameters params = GetDefaultFeatureParams(); |
| + |
| + // Missing parameter. |
| + ASSERT_EQ(params.erase(kPromptWaveParam), 1U); |
| + SetFeatureParams(params); |
| + EXPECT_FALSE(SettingsResetPromptConfig::Create()); |
| + |
| + // Empty parameter. |
| + params[kPromptWaveParam] = ""; |
| + SetFeatureParams(params); |
| + EXPECT_FALSE(SettingsResetPromptConfig::Create()); |
| + |
| + // Bad parameter value. |
| + params[kPromptWaveParam] = "not-a-number"; |
| + SetFeatureParams(params); |
| + EXPECT_FALSE(SettingsResetPromptConfig::Create()); |
| + |
| + // Negative parameter value. |
| + params[kPromptWaveParam] = "-3"; |
| + SetFeatureParams(params); |
| + EXPECT_FALSE(SettingsResetPromptConfig::Create()); |
| + |
| + // Correct parameter value. |
| + params[kPromptWaveParam] = "20170202"; |
| + SetFeatureParams(params); |
| + { |
| + auto config = SettingsResetPromptConfig::Create(); |
| + ASSERT_TRUE(config); |
| + EXPECT_EQ(config->prompt_wave(), 20170202); |
| + } |
| +} |
| + |
| +TEST_F(SettingsResetPromptConfigTest, TimeBetweenPromptsParam) { |
| + constexpr const char kParamName[] = "time_between_prompts_seconds"; |
| + |
| + Parameters params = GetDefaultFeatureParams(); |
| + |
| + // Missing parameter. |
| + ASSERT_EQ(params.erase(kParamName), 1U); |
| + SetFeatureParams(params); |
| + EXPECT_FALSE(SettingsResetPromptConfig::Create()); |
| + |
| + // Empty parameter. |
| + params[kParamName] = ""; |
| + SetFeatureParams(params); |
| + EXPECT_FALSE(SettingsResetPromptConfig::Create()); |
| + |
| + // Bad parameter value. |
| + params[kParamName] = "not-a-number"; |
| + SetFeatureParams(params); |
| + EXPECT_FALSE(SettingsResetPromptConfig::Create()); |
| + |
| + // Negative parameter value. |
| + params[kParamName] = "-3"; |
| + SetFeatureParams(params); |
| + EXPECT_FALSE(SettingsResetPromptConfig::Create()); |
| + |
| + // Correct parameter value. |
| + params[kParamName] = "3600"; |
| + SetFeatureParams(params); |
| + { |
| + auto config = SettingsResetPromptConfig::Create(); |
| + ASSERT_TRUE(config); |
| + EXPECT_EQ(config->time_between_prompts(), |
| + base::TimeDelta::FromSeconds(3600)); |
| + } |
| +} |
| + |
| } // namespace safe_browsing |