Index: components/previews/core/previews_black_list_unittest.cc |
diff --git a/components/previews/core/previews_black_list_unittest.cc b/components/previews/core/previews_black_list_unittest.cc |
index 489986058d6521904c59339e67ea6acf78c2c1a2..d6ce5a4f75b8cf69063df1458099c69fd93ccd0d 100644 |
--- a/components/previews/core/previews_black_list_unittest.cc |
+++ b/components/previews/core/previews_black_list_unittest.cc |
@@ -27,130 +27,162 @@ |
namespace { |
using PreviewsBlackListTest = testing::Test; |
} // namespace |
namespace previews { |
namespace { |
-void RunLoadCallback(LoadBlackListCallback callback, |
- std::unique_ptr<BlackListItemMap> black_list_item_map) { |
- callback.Run(std::move(black_list_item_map)); |
+void RunLoadCallback( |
+ LoadBlackListCallback callback, |
+ std::unique_ptr<BlackListItemMap> black_list_item_map, |
+ std::unique_ptr<PreviewsBlackListItem> host_indifferent_black_list_item) { |
+ callback.Run(std::move(black_list_item_map), |
+ std::move(host_indifferent_black_list_item)); |
} |
class TestPreviewsOptOutStore : public PreviewsOptOutStore { |
public: |
TestPreviewsOptOutStore() : clear_blacklist_count_(0) {} |
~TestPreviewsOptOutStore() override {} |
int clear_blacklist_count() { return clear_blacklist_count_; } |
private: |
// PreviewsOptOutStore implementation: |
void AddPreviewNavigation(bool opt_out, |
const std::string& host_name, |
PreviewsType type, |
base::Time now) override {} |
void LoadBlackList(LoadBlackListCallback callback) override { |
std::unique_ptr<BlackListItemMap> black_list_item_map( |
new BlackListItemMap()); |
+ std::unique_ptr<PreviewsBlackListItem> host_indifferent_black_list_item = |
+ PreviewsBlackList::CreateHostIndifferentBlackListItem(); |
base::ThreadTaskRunnerHandle::Get()->PostTask( |
FROM_HERE, base::Bind(&RunLoadCallback, callback, |
- base::Passed(&black_list_item_map))); |
+ base::Passed(&black_list_item_map), |
+ base::Passed(&host_indifferent_black_list_item))); |
} |
void ClearBlackList(base::Time begin_time, base::Time end_time) override { |
++clear_blacklist_count_; |
} |
int clear_blacklist_count_; |
}; |
} // namespace |
-TEST_F(PreviewsBlackListTest, BlackListNoStore) { |
+TEST_F(PreviewsBlackListTest, PerHostBlackListNoStore) { |
// Tests the black list behavior when a null OptOutSture is passed in. |
const GURL url_a("http://www.url_a.com"); |
const GURL url_b("http://www.url_b.com"); |
- const size_t history = 4; |
- const int threshold = 2; |
+ const size_t per_host_history = 4; |
+ const int per_host_threshold = 2; |
+ // Host indifferent blacklisting should have no effect with the following |
+ // params. |
+ const size_t host_indifferent_history = 1; |
+ const int host_indifferent_threshold = 2; |
tbansal1
2016/10/28 21:59:33
s/2/host_indifferent_history + 1/
Also, why are so
RyanSturm
2016/11/02 19:52:30
Done.
size_t is used here for the actual size of
|
const int duration_in_days = 365; |
// Disable single opt out by setting duration to 0. |
const int single_opt_out_duration = 0; |
base::FieldTrialList field_trial_list(nullptr); |
std::map<std::string, std::string> params; |
- params["stored_history_length"] = base::SizeTToString(history); |
- params["opt_out_threshold"] = base::IntToString(threshold); |
- params["black_list_duration_in_days"] = base::IntToString(duration_in_days); |
+ params["per_host_max_stored_history_length"] = |
+ base::SizeTToString(per_host_history); |
+ params["host_indifferent_max_stored_history_length"] = |
+ base::SizeTToString(host_indifferent_history); |
+ params["per_host_opt_out_threshold"] = base::IntToString(per_host_threshold); |
+ params["host_indifferent_opt_out_threshold"] = |
+ base::IntToString(host_indifferent_threshold); |
+ params["per_host_black_list_duration_in_days"] = |
+ base::IntToString(duration_in_days); |
params["single_opt_out_duration_in_seconds"] = |
base::IntToString(single_opt_out_duration); |
ASSERT_TRUE( |
variations::AssociateVariationParams("ClientSidePreviews", "Enabled", |
params) && |
base::FieldTrialList::CreateFieldTrial("ClientSidePreviews", "Enabled")); |
base::SimpleTestClock* test_clock = new base::SimpleTestClock(); |
base::Time start = test_clock->Now(); |
test_clock->Advance(base::TimeDelta::FromSeconds(1)); |
std::unique_ptr<PreviewsBlackList> black_list( |
new PreviewsBlackList(nullptr, base::WrapUnique(test_clock))); |
EXPECT_TRUE(black_list->IsLoadedAndAllowed(url_a, PreviewsType::OFFLINE)); |
EXPECT_TRUE(black_list->IsLoadedAndAllowed(url_b, PreviewsType::OFFLINE)); |
black_list->AddPreviewNavigation(url_a, true, PreviewsType::OFFLINE); |
+ test_clock->Advance(base::TimeDelta::FromSeconds(1)); |
black_list->AddPreviewNavigation(url_a, true, PreviewsType::OFFLINE); |
+ test_clock->Advance(base::TimeDelta::FromSeconds(1)); |
EXPECT_FALSE(black_list->IsLoadedAndAllowed(url_a, PreviewsType::OFFLINE)); |
EXPECT_TRUE(black_list->IsLoadedAndAllowed(url_b, PreviewsType::OFFLINE)); |
black_list->AddPreviewNavigation(url_b, true, PreviewsType::OFFLINE); |
+ test_clock->Advance(base::TimeDelta::FromSeconds(1)); |
black_list->AddPreviewNavigation(url_b, true, PreviewsType::OFFLINE); |
+ test_clock->Advance(base::TimeDelta::FromSeconds(1)); |
EXPECT_FALSE(black_list->IsLoadedAndAllowed(url_a, PreviewsType::OFFLINE)); |
EXPECT_FALSE(black_list->IsLoadedAndAllowed(url_b, PreviewsType::OFFLINE)); |
black_list->AddPreviewNavigation(url_b, false, PreviewsType::OFFLINE); |
+ test_clock->Advance(base::TimeDelta::FromSeconds(1)); |
black_list->AddPreviewNavigation(url_b, false, PreviewsType::OFFLINE); |
+ test_clock->Advance(base::TimeDelta::FromSeconds(1)); |
black_list->AddPreviewNavigation(url_b, false, PreviewsType::OFFLINE); |
+ test_clock->Advance(base::TimeDelta::FromSeconds(1)); |
EXPECT_FALSE(black_list->IsLoadedAndAllowed(url_a, PreviewsType::OFFLINE)); |
EXPECT_TRUE(black_list->IsLoadedAndAllowed(url_b, PreviewsType::OFFLINE)); |
- test_clock->Advance(base::TimeDelta::FromSeconds(1)); |
black_list->ClearBlackList(start, test_clock->Now()); |
EXPECT_TRUE(black_list->IsLoadedAndAllowed(url_a, PreviewsType::OFFLINE)); |
EXPECT_TRUE(black_list->IsLoadedAndAllowed(url_b, PreviewsType::OFFLINE)); |
variations::testing::ClearAllVariationParams(); |
} |
-TEST_F(PreviewsBlackListTest, BlackListWithStore) { |
+TEST_F(PreviewsBlackListTest, PerHostBlackListWithStore) { |
// Tests the black list behavior when a non-null OptOutSture is passed in. |
const GURL url_a1("http://www.url_a.com/a1"); |
const GURL url_a2("http://www.url_a.com/a2"); |
const GURL url_b("http://www.url_b.com"); |
- const size_t history = 4; |
- const int threshold = 2; |
+ const size_t per_host_history = 4; |
+ const int per_host_threshold = 2; |
+ // Host indifferent blacklisting should have no effect with the following |
+ // params. |
+ const size_t host_indifferent_history = 1; |
+ const int host_indifferent_threshold = 2; |
const int duration_in_days = 365; |
// Disable single opt out by setting duration to 0. |
const int single_opt_out_duration = 0; |
base::FieldTrialList field_trial_list(nullptr); |
std::map<std::string, std::string> params; |
- params["stored_history_length"] = base::SizeTToString(history); |
- params["opt_out_threshold"] = base::IntToString(threshold); |
- params["black_list_duration_in_days"] = base::IntToString(duration_in_days); |
+ params["per_host_max_stored_history_length"] = |
+ base::SizeTToString(per_host_history); |
+ params["host_indifferent_max_stored_history_length"] = |
+ base::SizeTToString(host_indifferent_history); |
+ params["per_host_opt_out_threshold"] = base::IntToString(per_host_threshold); |
+ params["host_indifferent_opt_out_threshold"] = |
+ base::IntToString(host_indifferent_threshold); |
+ params["per_host_black_list_duration_in_days"] = |
+ base::IntToString(duration_in_days); |
params["single_opt_out_duration_in_seconds"] = |
base::IntToString(single_opt_out_duration); |
ASSERT_TRUE( |
variations::AssociateVariationParams("ClientSidePreviews", "Enabled", |
params) && |
base::FieldTrialList::CreateFieldTrial("ClientSidePreviews", "Enabled")); |
base::MessageLoop loop; |
base::SimpleTestClock* test_clock = new base::SimpleTestClock(); |
@@ -166,109 +198,201 @@ TEST_F(PreviewsBlackListTest, BlackListWithStore) { |
EXPECT_FALSE(black_list->IsLoadedAndAllowed(url_a2, PreviewsType::OFFLINE)); |
EXPECT_FALSE(black_list->IsLoadedAndAllowed(url_b, PreviewsType::OFFLINE)); |
base::RunLoop().RunUntilIdle(); |
EXPECT_TRUE(black_list->IsLoadedAndAllowed(url_a1, PreviewsType::OFFLINE)); |
EXPECT_TRUE(black_list->IsLoadedAndAllowed(url_a2, PreviewsType::OFFLINE)); |
EXPECT_TRUE(black_list->IsLoadedAndAllowed(url_b, PreviewsType::OFFLINE)); |
black_list->AddPreviewNavigation(url_a1, true, PreviewsType::OFFLINE); |
+ test_clock->Advance(base::TimeDelta::FromSeconds(1)); |
black_list->AddPreviewNavigation(url_a1, true, PreviewsType::OFFLINE); |
+ test_clock->Advance(base::TimeDelta::FromSeconds(1)); |
EXPECT_FALSE(black_list->IsLoadedAndAllowed(url_a1, PreviewsType::OFFLINE)); |
EXPECT_FALSE(black_list->IsLoadedAndAllowed(url_a2, PreviewsType::OFFLINE)); |
EXPECT_TRUE(black_list->IsLoadedAndAllowed(url_b, PreviewsType::OFFLINE)); |
black_list->AddPreviewNavigation(url_b, true, PreviewsType::OFFLINE); |
+ test_clock->Advance(base::TimeDelta::FromSeconds(1)); |
black_list->AddPreviewNavigation(url_b, true, PreviewsType::OFFLINE); |
+ test_clock->Advance(base::TimeDelta::FromSeconds(1)); |
EXPECT_FALSE(black_list->IsLoadedAndAllowed(url_a1, PreviewsType::OFFLINE)); |
EXPECT_FALSE(black_list->IsLoadedAndAllowed(url_a2, PreviewsType::OFFLINE)); |
EXPECT_FALSE(black_list->IsLoadedAndAllowed(url_b, PreviewsType::OFFLINE)); |
black_list->AddPreviewNavigation(url_b, false, PreviewsType::OFFLINE); |
+ test_clock->Advance(base::TimeDelta::FromSeconds(1)); |
black_list->AddPreviewNavigation(url_b, false, PreviewsType::OFFLINE); |
+ test_clock->Advance(base::TimeDelta::FromSeconds(1)); |
black_list->AddPreviewNavigation(url_b, false, PreviewsType::OFFLINE); |
+ test_clock->Advance(base::TimeDelta::FromSeconds(1)); |
EXPECT_FALSE(black_list->IsLoadedAndAllowed(url_a1, PreviewsType::OFFLINE)); |
EXPECT_FALSE(black_list->IsLoadedAndAllowed(url_a2, PreviewsType::OFFLINE)); |
EXPECT_TRUE(black_list->IsLoadedAndAllowed(url_b, PreviewsType::OFFLINE)); |
- test_clock->Advance(base::TimeDelta::FromSeconds(1)); |
EXPECT_EQ(0, opt_out_store->clear_blacklist_count()); |
black_list->ClearBlackList(start, base::Time::Now()); |
EXPECT_EQ(1, opt_out_store->clear_blacklist_count()); |
EXPECT_FALSE(black_list->IsLoadedAndAllowed(url_a1, PreviewsType::OFFLINE)); |
EXPECT_FALSE(black_list->IsLoadedAndAllowed(url_a2, PreviewsType::OFFLINE)); |
EXPECT_FALSE(black_list->IsLoadedAndAllowed(url_b, PreviewsType::OFFLINE)); |
base::RunLoop().RunUntilIdle(); |
EXPECT_EQ(1, opt_out_store->clear_blacklist_count()); |
EXPECT_TRUE(black_list->IsLoadedAndAllowed(url_a1, PreviewsType::OFFLINE)); |
EXPECT_TRUE(black_list->IsLoadedAndAllowed(url_a1, PreviewsType::OFFLINE)); |
EXPECT_TRUE(black_list->IsLoadedAndAllowed(url_b, PreviewsType::OFFLINE)); |
variations::testing::ClearAllVariationParams(); |
} |
+TEST_F(PreviewsBlackListTest, HostIndifferentBlackList) { |
+ // Tests the black list behavior when a null OptOutSture is passed in. |
+ const GURL url_a("http://www.url_a.com"); |
+ const GURL url_b("http://www.url_b.com"); |
+ const GURL url_c("http://www.url_c.com"); |
+ const GURL url_d("http://www.url_d.com"); |
+ // Per host blacklisting should have no effect with the following params. |
+ const size_t per_host_history = 1; |
+ const int per_host_threshold = 2; |
tbansal1
2016/10/28 21:59:34
s/2/per_host_history + 1/
RyanSturm
2016/11/02 19:52:30
Done.
|
+ const size_t host_indifferent_history = 4; |
+ const int host_indifferent_threshold = 4; |
+ const int duration_in_days = 365; |
+ // Disable single opt out by setting duration to 0. |
+ const int single_opt_out_duration = 0; |
+ base::FieldTrialList field_trial_list(nullptr); |
+ std::map<std::string, std::string> params; |
+ params["per_host_max_stored_history_length"] = |
+ base::SizeTToString(per_host_history); |
+ params["host_indifferent_max_stored_history_length"] = |
+ base::SizeTToString(host_indifferent_history); |
+ params["per_host_opt_out_threshold"] = base::IntToString(per_host_threshold); |
+ params["host_indifferent_opt_out_threshold"] = |
+ base::IntToString(host_indifferent_threshold); |
+ params["per_host_black_list_duration_in_days"] = |
+ base::IntToString(duration_in_days); |
+ params["single_opt_out_duration_in_seconds"] = |
+ base::IntToString(single_opt_out_duration); |
+ ASSERT_TRUE( |
+ variations::AssociateVariationParams("ClientSidePreviews", "Enabled", |
+ params) && |
+ base::FieldTrialList::CreateFieldTrial("ClientSidePreviews", "Enabled")); |
+ |
+ base::SimpleTestClock* test_clock = new base::SimpleTestClock(); |
+ test_clock->Advance(base::TimeDelta::FromSeconds(1)); |
+ |
+ std::unique_ptr<PreviewsBlackList> black_list( |
+ new PreviewsBlackList(nullptr, base::WrapUnique(test_clock))); |
+ |
+ EXPECT_TRUE(black_list->IsLoadedAndAllowed(url_a, PreviewsType::OFFLINE)); |
+ EXPECT_TRUE(black_list->IsLoadedAndAllowed(url_b, PreviewsType::OFFLINE)); |
+ EXPECT_TRUE(black_list->IsLoadedAndAllowed(url_c, PreviewsType::OFFLINE)); |
+ EXPECT_TRUE(black_list->IsLoadedAndAllowed(url_d, PreviewsType::OFFLINE)); |
+ |
+ black_list->AddPreviewNavigation(url_a, true, PreviewsType::OFFLINE); |
+ test_clock->Advance(base::TimeDelta::FromSeconds(1)); |
+ EXPECT_TRUE(black_list->IsLoadedAndAllowed(url_a, PreviewsType::OFFLINE)); |
+ |
+ black_list->AddPreviewNavigation(url_b, true, PreviewsType::OFFLINE); |
+ test_clock->Advance(base::TimeDelta::FromSeconds(1)); |
+ EXPECT_TRUE(black_list->IsLoadedAndAllowed(url_a, PreviewsType::OFFLINE)); |
+ |
+ black_list->AddPreviewNavigation(url_c, true, PreviewsType::OFFLINE); |
+ test_clock->Advance(base::TimeDelta::FromSeconds(1)); |
+ EXPECT_TRUE(black_list->IsLoadedAndAllowed(url_a, PreviewsType::OFFLINE)); |
+ |
+ black_list->AddPreviewNavigation(url_d, true, PreviewsType::OFFLINE); |
tbansal1
2016/10/28 21:59:33
can you put this in a loop:
for(size_t i=0; i< hos
RyanSturm
2016/11/02 19:52:30
Done.
|
+ test_clock->Advance(base::TimeDelta::FromSeconds(1)); |
+ EXPECT_FALSE(black_list->IsLoadedAndAllowed(url_a, PreviewsType::OFFLINE)); |
+ EXPECT_FALSE(black_list->IsLoadedAndAllowed(url_b, PreviewsType::OFFLINE)); |
+ EXPECT_FALSE(black_list->IsLoadedAndAllowed(url_c, PreviewsType::OFFLINE)); |
+ EXPECT_FALSE(black_list->IsLoadedAndAllowed(url_d, PreviewsType::OFFLINE)); |
+ |
+ black_list->AddPreviewNavigation(url_d, false, PreviewsType::OFFLINE); |
+ test_clock->Advance(base::TimeDelta::FromSeconds(1)); |
+ |
+ // New non-opt-out entry will cause these to be allowed now. |
+ EXPECT_TRUE(black_list->IsLoadedAndAllowed(url_a, PreviewsType::OFFLINE)); |
+ EXPECT_TRUE(black_list->IsLoadedAndAllowed(url_b, PreviewsType::OFFLINE)); |
+ EXPECT_TRUE(black_list->IsLoadedAndAllowed(url_c, PreviewsType::OFFLINE)); |
+ EXPECT_TRUE(black_list->IsLoadedAndAllowed(url_d, PreviewsType::OFFLINE)); |
+ |
+ variations::testing::ClearAllVariationParams(); |
+} |
+ |
TEST_F(PreviewsBlackListTest, QueueBehavior) { |
// Tests the black list asynchronous queue behavior. Methods called while |
// loading are queued and should run in the order they were queued. |
tbansal1
2016/10/28 21:59:34
s/loading/loading opt-out store/
It is not clear
RyanSturm
2016/11/02 19:52:30
Done.
|
const GURL url("http://www.url.com"); |
const GURL url2("http://www.url2.com"); |
+ // Host indifferent blacklisting should have no effect with the following |
+ // params. |
+ const size_t host_indifferent_history = 1; |
+ const int host_indifferent_threshold = 2; |
const int duration_in_days = 365; |
// Disable single opt out by setting duration to 0. |
const int single_opt_out_duration = 0; |
base::FieldTrialList field_trial_list(nullptr); |
std::map<std::string, std::string> params; |
- params["black_list_duration_in_days"] = base::IntToString(duration_in_days); |
+ params["per_host_black_list_duration_in_days"] = |
+ base::IntToString(duration_in_days); |
+ params["host_indifferent_max_stored_history_length"] = |
+ base::SizeTToString(host_indifferent_history); |
+ params["host_indifferent_opt_out_threshold"] = |
+ base::IntToString(host_indifferent_threshold); |
params["single_opt_out_duration_in_seconds"] = |
base::IntToString(single_opt_out_duration); |
ASSERT_TRUE( |
variations::AssociateVariationParams("ClientSidePreviews", "Enabled", |
params) && |
base::FieldTrialList::CreateFieldTrial("ClientSidePreviews", "Enabled")); |
base::MessageLoop loop; |
std::vector<bool> test_opt_out{true, false}; |
for (auto opt_out : test_opt_out) { |
base::SimpleTestClock* test_clock = new base::SimpleTestClock(); |
+ base::Time start = test_clock->Now(); |
TestPreviewsOptOutStore* opt_out_store = new TestPreviewsOptOutStore(); |
std::unique_ptr<PreviewsBlackList> black_list(new PreviewsBlackList( |
base::WrapUnique(opt_out_store), base::WrapUnique(test_clock))); |
EXPECT_FALSE(black_list->IsLoadedAndAllowed(url, PreviewsType::OFFLINE)); |
black_list->AddPreviewNavigation(url, opt_out, PreviewsType::OFFLINE); |
+ test_clock->Advance(base::TimeDelta::FromSeconds(1)); |
black_list->AddPreviewNavigation(url, opt_out, PreviewsType::OFFLINE); |
+ test_clock->Advance(base::TimeDelta::FromSeconds(1)); |
EXPECT_FALSE(black_list->IsLoadedAndAllowed(url, PreviewsType::OFFLINE)); |
base::RunLoop().RunUntilIdle(); |
EXPECT_EQ(!opt_out, |
black_list->IsLoadedAndAllowed(url, PreviewsType::OFFLINE)); |
- |
- base::Time start = test_clock->Now(); |
- test_clock->Advance(base::TimeDelta::FromSeconds(1)); |
black_list->AddPreviewNavigation(url, opt_out, PreviewsType::OFFLINE); |
+ test_clock->Advance(base::TimeDelta::FromSeconds(1)); |
black_list->AddPreviewNavigation(url, opt_out, PreviewsType::OFFLINE); |
test_clock->Advance(base::TimeDelta::FromSeconds(1)); |
EXPECT_EQ(0, opt_out_store->clear_blacklist_count()); |
black_list->ClearBlackList( |
start, test_clock->Now() + base::TimeDelta::FromSeconds(1)); |
EXPECT_EQ(1, opt_out_store->clear_blacklist_count()); |
black_list->AddPreviewNavigation(url2, opt_out, PreviewsType::OFFLINE); |
+ test_clock->Advance(base::TimeDelta::FromSeconds(1)); |
black_list->AddPreviewNavigation(url2, opt_out, PreviewsType::OFFLINE); |
+ test_clock->Advance(base::TimeDelta::FromSeconds(1)); |
base::RunLoop().RunUntilIdle(); |
EXPECT_EQ(1, opt_out_store->clear_blacklist_count()); |
EXPECT_TRUE(black_list->IsLoadedAndAllowed(url, PreviewsType::OFFLINE)); |
EXPECT_EQ(!opt_out, |
black_list->IsLoadedAndAllowed(url2, PreviewsType::OFFLINE)); |
} |
variations::testing::ClearAllVariationParams(); |
} |
@@ -280,28 +404,37 @@ TEST_F(PreviewsBlackListTest, MaxHosts) { |
const GURL url_b("http://www.url_b.com"); |
const GURL url_c("http://www.url_c.com"); |
const GURL url_d("http://www.url_d.com"); |
const GURL url_e("http://www.url_e.com"); |
const size_t stored_history_length = 1; |
const int opt_out_threshold = 1; |
const int black_list_duration_in_days = 365; |
// Disable single opt out by setting duration to 0. |
const int single_opt_out_duration = 0; |
const size_t max_hosts_in_blacklist = 2; |
+ // Host indifferent blacklisting should have no effect with the following |
+ // params. |
+ const size_t host_indifferent_history = 1; |
+ const int host_indifferent_threshold = 2; |
base::FieldTrialList field_trial_list(nullptr); |
std::map<std::string, std::string> params; |
- params["stored_history_length"] = base::SizeTToString(stored_history_length); |
- params["opt_out_threshold"] = base::IntToString(opt_out_threshold); |
- params["black_list_duration_in_days"] = |
+ params["per_host_stored_history_length"] = |
+ base::SizeTToString(stored_history_length); |
+ params["per_host_opt_out_threshold"] = base::IntToString(opt_out_threshold); |
+ params["per_host_black_list_duration_in_days"] = |
base::IntToString(black_list_duration_in_days); |
params["max_hosts_in_blacklist"] = |
base::SizeTToString(max_hosts_in_blacklist); |
+ params["host_indifferent_max_stored_history_length"] = |
+ base::SizeTToString(host_indifferent_history); |
+ params["host_indifferent_opt_out_threshold"] = |
+ base::IntToString(host_indifferent_threshold); |
params["single_opt_out_duration_in_seconds"] = |
base::IntToString(single_opt_out_duration); |
ASSERT_TRUE( |
variations::AssociateVariationParams("ClientSidePreviews", "Enabled", |
params) && |
base::FieldTrialList::CreateFieldTrial("ClientSidePreviews", "Enabled")); |
base::MessageLoop loop; |
base::SimpleTestClock* test_clock = new base::SimpleTestClock(); |
@@ -335,28 +468,37 @@ TEST_F(PreviewsBlackListTest, SingleOptOut) { |
// Test that when a user opts out of a preview, previews won't be shown until |
// |single_opt_out_duration| has elapsed. |
const GURL url_a("http://www.url_a.com"); |
const GURL url_b("http://www.url_b.com"); |
const GURL url_c("http://www.url_c.com"); |
const size_t stored_history_length = 1; |
const int opt_out_threshold = 2; |
const int black_list_duration_in_days = 365; |
const int single_opt_out_duration = 5; |
const size_t max_hosts_in_blacklist = 10; |
+ // Host indifferent blacklisting should have no effect with the following |
+ // params. |
+ const size_t host_indifferent_history = 1; |
+ const int host_indifferent_threshold = 2; |
tbansal1
2016/10/28 21:59:33
same comment here and elsewhere:
s/2/host_indiffer
RyanSturm
2016/11/02 19:52:30
Done.
|
base::FieldTrialList field_trial_list(nullptr); |
std::map<std::string, std::string> params; |
- params["stored_history_length"] = base::SizeTToString(stored_history_length); |
- params["opt_out_threshold"] = base::IntToString(opt_out_threshold); |
- params["black_list_duration_in_days"] = |
+ params["per_host_stored_history_length"] = |
+ base::SizeTToString(stored_history_length); |
+ params["per_host_opt_out_threshold"] = base::IntToString(opt_out_threshold); |
+ params["per_host_black_list_duration_in_days"] = |
base::IntToString(black_list_duration_in_days); |
params["max_hosts_in_blacklist"] = |
base::SizeTToString(max_hosts_in_blacklist); |
+ params["host_indifferent_max_stored_history_length"] = |
+ base::SizeTToString(host_indifferent_history); |
+ params["host_indifferent_opt_out_threshold"] = |
+ base::IntToString(host_indifferent_threshold); |
params["single_opt_out_duration_in_seconds"] = |
base::IntToString(single_opt_out_duration); |
ASSERT_TRUE( |
variations::AssociateVariationParams("ClientSidePreviews", "Enabled", |
params) && |
base::FieldTrialList::CreateFieldTrial("ClientSidePreviews", "Enabled")); |
base::SimpleTestClock* test_clock = new base::SimpleTestClock(); |
std::unique_ptr<PreviewsBlackList> black_list( |