| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 "chrome/browser/autocomplete/search_provider.h" | 5 #include "chrome/browser/autocomplete/search_provider.h" |
| 6 | 6 |
| 7 #include "base/metrics/field_trial.h" | 7 #include "base/metrics/field_trial.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/time.h" | 10 #include "base/time.h" |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 // Profile we use. | 125 // Profile we use. |
| 126 TestingProfile profile_; | 126 TestingProfile profile_; |
| 127 | 127 |
| 128 // The provider. | 128 // The provider. |
| 129 scoped_refptr<SearchProvider> provider_; | 129 scoped_refptr<SearchProvider> provider_; |
| 130 | 130 |
| 131 // If true, OnProviderUpdate exits out of the current message loop. | 131 // If true, OnProviderUpdate exits out of the current message loop. |
| 132 bool quit_when_done_; | 132 bool quit_when_done_; |
| 133 | 133 |
| 134 // Needed for AutucompleteFieldTrial::Activate(); | 134 // Needed for AutucompleteFieldTrial::Activate(); |
| 135 static scoped_ptr<base::FieldTrialList> field_trial_list_; | 135 static base::FieldTrialList* field_trial_list_; |
| 136 | 136 |
| 137 DISALLOW_COPY_AND_ASSIGN(SearchProviderTest); | 137 DISALLOW_COPY_AND_ASSIGN(SearchProviderTest); |
| 138 }; | 138 }; |
| 139 | 139 |
| 140 // static | 140 // static |
| 141 scoped_ptr<base::FieldTrialList> SearchProviderTest::field_trial_list_; | 141 base::FieldTrialList* SearchProviderTest::field_trial_list_ = NULL; |
| 142 | 142 |
| 143 // static | 143 // static |
| 144 void SearchProviderTest::SetUpTestCase() { | 144 void SearchProviderTest::SetUpTestCase() { |
| 145 // Set up Suggest experiments. | 145 // Set up Suggest experiments. |
| 146 field_trial_list_.reset(new base::FieldTrialList( | 146 field_trial_list_ = new base::FieldTrialList( |
| 147 new metrics::SHA1EntropyProvider("foo"))); | 147 new metrics::SHA1EntropyProvider("foo")); |
| 148 AutocompleteFieldTrial::Activate(); | 148 AutocompleteFieldTrial::Activate(); |
| 149 } | 149 } |
| 150 | 150 |
| 151 // static | 151 // static |
| 152 void SearchProviderTest::TearDownTestCase() { | 152 void SearchProviderTest::TearDownTestCase() { |
| 153 // Make sure the global instance of FieldTrialList is gone. | 153 // Make sure the global instance of FieldTrialList is gone. |
| 154 field_trial_list_.reset(); | 154 delete field_trial_list_; |
| 155 } | 155 } |
| 156 | 156 |
| 157 void SearchProviderTest::SetUp() { | 157 void SearchProviderTest::SetUp() { |
| 158 // Make sure that fetchers are automatically ungregistered upon destruction. | 158 // Make sure that fetchers are automatically ungregistered upon destruction. |
| 159 test_factory_.set_remove_fetcher_on_delete(true); | 159 test_factory_.set_remove_fetcher_on_delete(true); |
| 160 | 160 |
| 161 // We need both the history service and template url model loaded. | 161 // We need both the history service and template url model loaded. |
| 162 profile_.CreateHistoryService(true, false); | 162 profile_.CreateHistoryService(true, false); |
| 163 TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse( | 163 TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse( |
| 164 &profile_, &TemplateURLServiceFactory::BuildInstanceFor); | 164 &profile_, &TemplateURLServiceFactory::BuildInstanceFor); |
| (...skipping 1174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1339 EXPECT_EQ(AutocompleteMatch::ACMatchClassification::URL, | 1339 EXPECT_EQ(AutocompleteMatch::ACMatchClassification::URL, |
| 1340 match.contents_class[0].style); | 1340 match.contents_class[0].style); |
| 1341 EXPECT_EQ(4U, match.contents_class[1].offset); | 1341 EXPECT_EQ(4U, match.contents_class[1].offset); |
| 1342 EXPECT_EQ(AutocompleteMatch::ACMatchClassification::URL | | 1342 EXPECT_EQ(AutocompleteMatch::ACMatchClassification::URL | |
| 1343 AutocompleteMatch::ACMatchClassification::MATCH, | 1343 AutocompleteMatch::ACMatchClassification::MATCH, |
| 1344 match.contents_class[1].style); | 1344 match.contents_class[1].style); |
| 1345 EXPECT_EQ(5U, match.contents_class[2].offset); | 1345 EXPECT_EQ(5U, match.contents_class[2].offset); |
| 1346 EXPECT_EQ(AutocompleteMatch::ACMatchClassification::URL, | 1346 EXPECT_EQ(AutocompleteMatch::ACMatchClassification::URL, |
| 1347 match.contents_class[2].style); | 1347 match.contents_class[2].style); |
| 1348 } | 1348 } |
| OLD | NEW |