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 <string> | 7 #include <string> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 #include "chrome/browser/search_engines/template_url_service_factory.h" | 32 #include "chrome/browser/search_engines/template_url_service_factory.h" |
33 #include "chrome/browser/signin/signin_manager.h" | 33 #include "chrome/browser/signin/signin_manager.h" |
34 #include "chrome/browser/signin/signin_manager_factory.h" | 34 #include "chrome/browser/signin/signin_manager_factory.h" |
35 #include "chrome/browser/sync/profile_sync_service.h" | 35 #include "chrome/browser/sync/profile_sync_service.h" |
36 #include "chrome/browser/sync/profile_sync_service_factory.h" | 36 #include "chrome/browser/sync/profile_sync_service_factory.h" |
37 #include "chrome/common/chrome_switches.h" | 37 #include "chrome/common/chrome_switches.h" |
38 #include "chrome/common/metrics/variations/variations_util.h" | 38 #include "chrome/common/metrics/variations/variations_util.h" |
39 #include "chrome/common/pref_names.h" | 39 #include "chrome/common/pref_names.h" |
40 #include "chrome/test/base/testing_browser_process.h" | 40 #include "chrome/test/base/testing_browser_process.h" |
41 #include "chrome/test/base/testing_profile.h" | 41 #include "chrome/test/base/testing_profile.h" |
| 42 #include "components/sync_driver/pref_names.h" |
42 #include "components/variations/entropy_provider.h" | 43 #include "components/variations/entropy_provider.h" |
43 #include "content/public/test/test_browser_thread_bundle.h" | 44 #include "content/public/test/test_browser_thread_bundle.h" |
44 #include "net/url_request/test_url_fetcher_factory.h" | 45 #include "net/url_request/test_url_fetcher_factory.h" |
45 #include "net/url_request/url_request_status.h" | 46 #include "net/url_request/url_request_status.h" |
46 #include "testing/gtest/include/gtest/gtest.h" | 47 #include "testing/gtest/include/gtest/gtest.h" |
47 | 48 |
48 using base::ASCIIToUTF16; | 49 using base::ASCIIToUTF16; |
49 | 50 |
50 namespace { | 51 namespace { |
51 | 52 |
(...skipping 3946 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3998 AutocompleteInput::OTHER, &profile_)); | 3999 AutocompleteInput::OTHER, &profile_)); |
3999 profile_.GetPrefs()->SetBoolean(prefs::kSearchSuggestEnabled, true); | 4000 profile_.GetPrefs()->SetBoolean(prefs::kSearchSuggestEnabled, true); |
4000 | 4001 |
4001 // Incognito. | 4002 // Incognito. |
4002 EXPECT_FALSE(SearchProvider::CanSendURL( | 4003 EXPECT_FALSE(SearchProvider::CanSendURL( |
4003 GURL("http://www.google.com/search"), | 4004 GURL("http://www.google.com/search"), |
4004 GURL("https://www.google.com/complete/search"), &google_template_url, | 4005 GURL("https://www.google.com/complete/search"), &google_template_url, |
4005 AutocompleteInput::OTHER, profile_.GetOffTheRecordProfile())); | 4006 AutocompleteInput::OTHER, profile_.GetOffTheRecordProfile())); |
4006 | 4007 |
4007 // Tab sync not enabled. | 4008 // Tab sync not enabled. |
4008 profile_.GetPrefs()->SetBoolean(prefs::kSyncKeepEverythingSynced, false); | 4009 profile_.GetPrefs()->SetBoolean(sync_driver::prefs::kSyncKeepEverythingSynced, |
4009 profile_.GetPrefs()->SetBoolean(prefs::kSyncTabs, false); | 4010 false); |
| 4011 profile_.GetPrefs()->SetBoolean(sync_driver::prefs::kSyncTabs, false); |
4010 EXPECT_FALSE(SearchProvider::CanSendURL( | 4012 EXPECT_FALSE(SearchProvider::CanSendURL( |
4011 GURL("http://www.google.com/search"), | 4013 GURL("http://www.google.com/search"), |
4012 GURL("https://www.google.com/complete/search"), &google_template_url, | 4014 GURL("https://www.google.com/complete/search"), &google_template_url, |
4013 AutocompleteInput::OTHER, &profile_)); | 4015 AutocompleteInput::OTHER, &profile_)); |
4014 profile_.GetPrefs()->SetBoolean(prefs::kSyncTabs, true); | 4016 profile_.GetPrefs()->SetBoolean(sync_driver::prefs::kSyncTabs, true); |
4015 | 4017 |
4016 // Tab sync is encrypted. | 4018 // Tab sync is encrypted. |
4017 ProfileSyncService* service = | 4019 ProfileSyncService* service = |
4018 ProfileSyncServiceFactory::GetInstance()->GetForProfile(&profile_); | 4020 ProfileSyncServiceFactory::GetInstance()->GetForProfile(&profile_); |
4019 syncer::ModelTypeSet encrypted_types = service->GetEncryptedDataTypes(); | 4021 syncer::ModelTypeSet encrypted_types = service->GetEncryptedDataTypes(); |
4020 encrypted_types.Put(syncer::SESSIONS); | 4022 encrypted_types.Put(syncer::SESSIONS); |
4021 service->OnEncryptedTypesChanged(encrypted_types, false); | 4023 service->OnEncryptedTypesChanged(encrypted_types, false); |
4022 EXPECT_FALSE(SearchProvider::CanSendURL( | 4024 EXPECT_FALSE(SearchProvider::CanSendURL( |
4023 GURL("http://www.google.com/search"), | 4025 GURL("http://www.google.com/search"), |
4024 GURL("https://www.google.com/complete/search"), &google_template_url, | 4026 GURL("https://www.google.com/complete/search"), &google_template_url, |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4128 // Verbatim match duplicates are added such that each one has a higher | 4130 // Verbatim match duplicates are added such that each one has a higher |
4129 // relevance than the previous one. | 4131 // relevance than the previous one. |
4130 EXPECT_EQ(2U, verbatim.duplicate_matches.size()); | 4132 EXPECT_EQ(2U, verbatim.duplicate_matches.size()); |
4131 | 4133 |
4132 // Other match duplicates are added in descending relevance order. | 4134 // Other match duplicates are added in descending relevance order. |
4133 EXPECT_EQ(1U, match_alpha.duplicate_matches.size()); | 4135 EXPECT_EQ(1U, match_alpha.duplicate_matches.size()); |
4134 EXPECT_EQ(1U, match_avid.duplicate_matches.size()); | 4136 EXPECT_EQ(1U, match_avid.duplicate_matches.size()); |
4135 | 4137 |
4136 EXPECT_EQ(0U, match_apricot.duplicate_matches.size()); | 4138 EXPECT_EQ(0U, match_apricot.duplicate_matches.size()); |
4137 } | 4139 } |
OLD | NEW |