| 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 "components/omnibox/browser/search_provider.h" | 5 #include "components/omnibox/browser/search_provider.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 542 } | 542 } |
| 543 } | 543 } |
| 544 | 544 |
| 545 void SearchProviderTest::ResetFieldTrialList() { | 545 void SearchProviderTest::ResetFieldTrialList() { |
| 546 // Destroy the existing FieldTrialList before creating a new one to avoid | 546 // Destroy the existing FieldTrialList before creating a new one to avoid |
| 547 // a DCHECK. | 547 // a DCHECK. |
| 548 field_trial_list_.reset(); | 548 field_trial_list_.reset(); |
| 549 field_trial_list_.reset(new base::FieldTrialList( | 549 field_trial_list_.reset(new base::FieldTrialList( |
| 550 new metrics::SHA1EntropyProvider("foo"))); | 550 new metrics::SHA1EntropyProvider("foo"))); |
| 551 variations::testing::ClearAllVariationParams(); | 551 variations::testing::ClearAllVariationParams(); |
| 552 base::FieldTrial* trial = base::FieldTrialList::CreateFieldTrial( | |
| 553 "AutocompleteDynamicTrial_0", "DefaultGroup"); | |
| 554 trial->group(); | |
| 555 } | 552 } |
| 553 |
| 556 base::FieldTrial* SearchProviderTest::CreateFieldTrial( | 554 base::FieldTrial* SearchProviderTest::CreateFieldTrial( |
| 557 const char* field_trial_rule, | 555 const char* field_trial_rule, |
| 558 bool enabled) { | 556 bool enabled) { |
| 559 std::map<std::string, std::string> params; | 557 std::map<std::string, std::string> params; |
| 560 params[std::string(field_trial_rule)] = enabled ? | 558 params[std::string(field_trial_rule)] = enabled ? |
| 561 "true" : "false"; | 559 "true" : "false"; |
| 562 variations::AssociateVariationParams( | 560 variations::AssociateVariationParams( |
| 563 OmniboxFieldTrial::kBundledExperimentFieldTrialName, "A", params); | 561 OmniboxFieldTrial::kBundledExperimentFieldTrialName, "A", params); |
| 564 return base::FieldTrialList::CreateFieldTrial( | 562 return base::FieldTrialList::CreateFieldTrial( |
| 565 OmniboxFieldTrial::kBundledExperimentFieldTrialName, "A"); | 563 OmniboxFieldTrial::kBundledExperimentFieldTrialName, "A"); |
| (...skipping 1977 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2543 EXPECT_EQ(kNotApplicable, cases[i].output[j].match_contents); | 2541 EXPECT_EQ(kNotApplicable, cases[i].output[j].match_contents); |
| 2544 EXPECT_EQ(AutocompleteMatchType::NUM_TYPES, | 2542 EXPECT_EQ(AutocompleteMatchType::NUM_TYPES, |
| 2545 cases[i].output[j].match_type); | 2543 cases[i].output[j].match_type); |
| 2546 EXPECT_FALSE(cases[i].output[j].allowed_to_be_default_match); | 2544 EXPECT_FALSE(cases[i].output[j].allowed_to_be_default_match); |
| 2547 } | 2545 } |
| 2548 } | 2546 } |
| 2549 } | 2547 } |
| 2550 | 2548 |
| 2551 // A basic test that verifies the field trial triggered parsing logic. | 2549 // A basic test that verifies the field trial triggered parsing logic. |
| 2552 TEST_F(SearchProviderTest, FieldTrialTriggeredParsing) { | 2550 TEST_F(SearchProviderTest, FieldTrialTriggeredParsing) { |
| 2551 base::FieldTrial* trial = base::FieldTrialList::CreateFieldTrial( |
| 2552 OmniboxFieldTrial::kBundledExperimentFieldTrialName, "DefaultGroup"); |
| 2553 trial->group(); |
| 2554 |
| 2553 QueryForInputAndWaitForFetcherResponses( | 2555 QueryForInputAndWaitForFetcherResponses( |
| 2554 ASCIIToUTF16("foo"), false, | 2556 ASCIIToUTF16("foo"), false, |
| 2555 "[\"foo\",[\"foo bar\"],[\"\"],[]," | 2557 "[\"foo\",[\"foo bar\"],[\"\"],[]," |
| 2556 "{\"google:suggesttype\":[\"QUERY\"]," | 2558 "{\"google:suggesttype\":[\"QUERY\"]," |
| 2557 "\"google:fieldtrialtriggered\":true}]", | 2559 "\"google:fieldtrialtriggered\":true}]", |
| 2558 std::string()); | 2560 std::string()); |
| 2559 | 2561 |
| 2560 { | 2562 { |
| 2561 // Check for the match and field trial triggered bits. | 2563 // Check for the match and field trial triggered bits. |
| 2562 AutocompleteMatch match; | 2564 AutocompleteMatch match; |
| (...skipping 1033 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3596 } | 3598 } |
| 3597 | 3599 |
| 3598 TEST_F(SearchProviderTest, DoesNotProvideOnFocus) { | 3600 TEST_F(SearchProviderTest, DoesNotProvideOnFocus) { |
| 3599 AutocompleteInput input( | 3601 AutocompleteInput input( |
| 3600 base::ASCIIToUTF16("f"), base::string16::npos, std::string(), GURL(), | 3602 base::ASCIIToUTF16("f"), base::string16::npos, std::string(), GURL(), |
| 3601 metrics::OmniboxEventProto::INVALID_SPEC, false, true, true, true, true, | 3603 metrics::OmniboxEventProto::INVALID_SPEC, false, true, true, true, true, |
| 3602 ChromeAutocompleteSchemeClassifier(&profile_)); | 3604 ChromeAutocompleteSchemeClassifier(&profile_)); |
| 3603 provider_->Start(input, false); | 3605 provider_->Start(input, false); |
| 3604 EXPECT_TRUE(provider_->matches().empty()); | 3606 EXPECT_TRUE(provider_->matches().empty()); |
| 3605 } | 3607 } |
| OLD | NEW |