| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/suggestions/suggestions_service.h" | 5 #include "components/suggestions/suggestions_service.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <sstream> | 8 #include <sstream> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 void EnableFieldTrial(const std::string& url, | 155 void EnableFieldTrial(const std::string& url, |
| 156 const std::string& common_params, | 156 const std::string& common_params, |
| 157 const std::string& blacklist_path, | 157 const std::string& blacklist_path, |
| 158 const std::string& blacklist_url_param, | 158 const std::string& blacklist_url_param, |
| 159 bool control_group) { | 159 bool control_group) { |
| 160 // Clear the existing |field_trial_list_| to avoid firing a DCHECK. | 160 // Clear the existing |field_trial_list_| to avoid firing a DCHECK. |
| 161 field_trial_list_.reset(NULL); | 161 field_trial_list_.reset(NULL); |
| 162 field_trial_list_.reset( | 162 field_trial_list_.reset( |
| 163 new base::FieldTrialList(new metrics::SHA1EntropyProvider("foo"))); | 163 new base::FieldTrialList(new metrics::SHA1EntropyProvider("foo"))); |
| 164 | 164 |
| 165 chrome_variations::testing::ClearAllVariationParams(); | 165 variations::testing::ClearAllVariationParams(); |
| 166 std::map<std::string, std::string> params; | 166 std::map<std::string, std::string> params; |
| 167 params[kSuggestionsFieldTrialStateParam] = | 167 params[kSuggestionsFieldTrialStateParam] = |
| 168 kSuggestionsFieldTrialStateEnabled; | 168 kSuggestionsFieldTrialStateEnabled; |
| 169 if (control_group) { | 169 if (control_group) { |
| 170 params[kSuggestionsFieldTrialControlParam] = | 170 params[kSuggestionsFieldTrialControlParam] = |
| 171 kSuggestionsFieldTrialStateEnabled; | 171 kSuggestionsFieldTrialStateEnabled; |
| 172 } | 172 } |
| 173 params[kSuggestionsFieldTrialURLParam] = url; | 173 params[kSuggestionsFieldTrialURLParam] = url; |
| 174 params[kSuggestionsFieldTrialCommonParamsParam] = common_params; | 174 params[kSuggestionsFieldTrialCommonParamsParam] = common_params; |
| 175 params[kSuggestionsFieldTrialBlacklistPathParam] = blacklist_path; | 175 params[kSuggestionsFieldTrialBlacklistPathParam] = blacklist_path; |
| 176 params[kSuggestionsFieldTrialBlacklistUrlParam] = blacklist_url_param; | 176 params[kSuggestionsFieldTrialBlacklistUrlParam] = blacklist_url_param; |
| 177 chrome_variations::AssociateVariationParams(kSuggestionsFieldTrialName, | 177 variations::AssociateVariationParams(kSuggestionsFieldTrialName, "Group1", |
| 178 "Group1", params); | 178 params); |
| 179 field_trial_ = base::FieldTrialList::CreateFieldTrial( | 179 field_trial_ = base::FieldTrialList::CreateFieldTrial( |
| 180 kSuggestionsFieldTrialName, "Group1"); | 180 kSuggestionsFieldTrialName, "Group1"); |
| 181 field_trial_->group(); | 181 field_trial_->group(); |
| 182 } | 182 } |
| 183 | 183 |
| 184 // Should not be called more than once per test since it stashes the | 184 // Should not be called more than once per test since it stashes the |
| 185 // SuggestionsStore in |mock_suggestions_store_|. | 185 // SuggestionsStore in |mock_suggestions_store_|. |
| 186 SuggestionsService* CreateSuggestionsServiceWithMocks() { | 186 SuggestionsService* CreateSuggestionsServiceWithMocks() { |
| 187 mock_suggestions_store_ = new StrictMock<MockSuggestionsStore>(); | 187 mock_suggestions_store_ = new StrictMock<MockSuggestionsStore>(); |
| 188 mock_thumbnail_manager_ = new NiceMock<MockImageManager>(); | 188 mock_thumbnail_manager_ = new NiceMock<MockImageManager>(); |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 // Delay increases on failure. | 491 // Delay increases on failure. |
| 492 suggestions_service->UpdateBlacklistDelay(false); | 492 suggestions_service->UpdateBlacklistDelay(false); |
| 493 EXPECT_GT(suggestions_service->blacklist_delay(), initial_delay); | 493 EXPECT_GT(suggestions_service->blacklist_delay(), initial_delay); |
| 494 | 494 |
| 495 // Delay resets on success. | 495 // Delay resets on success. |
| 496 suggestions_service->UpdateBlacklistDelay(true); | 496 suggestions_service->UpdateBlacklistDelay(true); |
| 497 EXPECT_EQ(initial_delay, suggestions_service->blacklist_delay()); | 497 EXPECT_EQ(initial_delay, suggestions_service->blacklist_delay()); |
| 498 } | 498 } |
| 499 | 499 |
| 500 } // namespace suggestions | 500 } // namespace suggestions |
| OLD | NEW |