| 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/omnibox/browser/omnibox_field_trial.h" | 5 #include "components/omnibox/browser/omnibox_field_trial.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/memory/ptr_util.h" |
| 11 #include "base/metrics/field_trial.h" | 12 #include "base/metrics/field_trial.h" |
| 12 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
| 13 #include "build/build_config.h" | 14 #include "build/build_config.h" |
| 14 #include "components/metrics/proto/omnibox_event.pb.h" | 15 #include "components/metrics/proto/omnibox_event.pb.h" |
| 15 #include "components/search/search.h" | 16 #include "components/search/search.h" |
| 16 #include "components/variations/entropy_provider.h" | 17 #include "components/variations/entropy_provider.h" |
| 17 #include "components/variations/variations_associated_data.h" | 18 #include "components/variations/variations_associated_data.h" |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
| 19 | 20 |
| 20 using metrics::OmniboxEventProto; | 21 using metrics::OmniboxEventProto; |
| 21 | 22 |
| 22 class OmniboxFieldTrialTest : public testing::Test { | 23 class OmniboxFieldTrialTest : public testing::Test { |
| 23 public: | 24 public: |
| 24 OmniboxFieldTrialTest() { | 25 OmniboxFieldTrialTest() { |
| 25 ResetFieldTrialList(); | 26 ResetFieldTrialList(); |
| 26 } | 27 } |
| 27 | 28 |
| 28 void ResetFieldTrialList() { | 29 void ResetFieldTrialList() { |
| 29 // Destroy the existing FieldTrialList before creating a new one to avoid | 30 // Destroy the existing FieldTrialList before creating a new one to avoid |
| 30 // a DCHECK. | 31 // a DCHECK. |
| 31 field_trial_list_.reset(); | 32 field_trial_list_.reset(); |
| 32 field_trial_list_.reset(new base::FieldTrialList( | 33 field_trial_list_.reset(new base::FieldTrialList( |
| 33 new metrics::SHA1EntropyProvider("foo"))); | 34 base::MakeUnique<metrics::SHA1EntropyProvider>("foo"))); |
| 34 variations::testing::ClearAllVariationParams(); | 35 variations::testing::ClearAllVariationParams(); |
| 35 } | 36 } |
| 36 | 37 |
| 37 // Creates and activates a field trial. | 38 // Creates and activates a field trial. |
| 38 static base::FieldTrial* CreateTestTrial(const std::string& name, | 39 static base::FieldTrial* CreateTestTrial(const std::string& name, |
| 39 const std::string& group_name) { | 40 const std::string& group_name) { |
| 40 base::FieldTrial* trial = base::FieldTrialList::CreateFieldTrial( | 41 base::FieldTrial* trial = base::FieldTrialList::CreateFieldTrial( |
| 41 name, group_name); | 42 name, group_name); |
| 42 trial->group(); | 43 trial->group(); |
| 43 return trial; | 44 return trial; |
| (...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 NULL, NULL, false, | 506 NULL, NULL, false, |
| 506 OmniboxFieldTrial::kDefaultMinimumTimeBetweenSuggestQueriesMs); | 507 OmniboxFieldTrial::kDefaultMinimumTimeBetweenSuggestQueriesMs); |
| 507 | 508 |
| 508 // Valid params. | 509 // Valid params. |
| 509 VerifySuggestPollingStrategy("true", "50", true, 50); | 510 VerifySuggestPollingStrategy("true", "50", true, 50); |
| 510 VerifySuggestPollingStrategy(NULL, "35", false, 35); | 511 VerifySuggestPollingStrategy(NULL, "35", false, 35); |
| 511 VerifySuggestPollingStrategy( | 512 VerifySuggestPollingStrategy( |
| 512 "true", NULL, true, | 513 "true", NULL, true, |
| 513 OmniboxFieldTrial::kDefaultMinimumTimeBetweenSuggestQueriesMs); | 514 OmniboxFieldTrial::kDefaultMinimumTimeBetweenSuggestQueriesMs); |
| 514 } | 515 } |
| OLD | NEW |