| 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 3938 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3990 AutocompleteInput::OTHER, &profile_)); | 3991 AutocompleteInput::OTHER, &profile_)); |
| 3991 profile_.GetPrefs()->SetBoolean(prefs::kSearchSuggestEnabled, true); | 3992 profile_.GetPrefs()->SetBoolean(prefs::kSearchSuggestEnabled, true); |
| 3992 | 3993 |
| 3993 // Incognito. | 3994 // Incognito. |
| 3994 EXPECT_FALSE(SearchProvider::CanSendURL( | 3995 EXPECT_FALSE(SearchProvider::CanSendURL( |
| 3995 GURL("http://www.google.com/search"), | 3996 GURL("http://www.google.com/search"), |
| 3996 GURL("https://www.google.com/complete/search"), &google_template_url, | 3997 GURL("https://www.google.com/complete/search"), &google_template_url, |
| 3997 AutocompleteInput::OTHER, profile_.GetOffTheRecordProfile())); | 3998 AutocompleteInput::OTHER, profile_.GetOffTheRecordProfile())); |
| 3998 | 3999 |
| 3999 // Tab sync not enabled. | 4000 // Tab sync not enabled. |
| 4000 profile_.GetPrefs()->SetBoolean(prefs::kSyncKeepEverythingSynced, false); | 4001 profile_.GetPrefs()->SetBoolean(sync_driver::prefs::kSyncKeepEverythingSynced, |
| 4001 profile_.GetPrefs()->SetBoolean(prefs::kSyncTabs, false); | 4002 false); |
| 4003 profile_.GetPrefs()->SetBoolean(sync_driver::prefs::kSyncTabs, false); |
| 4002 EXPECT_FALSE(SearchProvider::CanSendURL( | 4004 EXPECT_FALSE(SearchProvider::CanSendURL( |
| 4003 GURL("http://www.google.com/search"), | 4005 GURL("http://www.google.com/search"), |
| 4004 GURL("https://www.google.com/complete/search"), &google_template_url, | 4006 GURL("https://www.google.com/complete/search"), &google_template_url, |
| 4005 AutocompleteInput::OTHER, &profile_)); | 4007 AutocompleteInput::OTHER, &profile_)); |
| 4006 profile_.GetPrefs()->SetBoolean(prefs::kSyncTabs, true); | 4008 profile_.GetPrefs()->SetBoolean(sync_driver::prefs::kSyncTabs, true); |
| 4007 | 4009 |
| 4008 // Tab sync is encrypted. | 4010 // Tab sync is encrypted. |
| 4009 ProfileSyncService* service = | 4011 ProfileSyncService* service = |
| 4010 ProfileSyncServiceFactory::GetInstance()->GetForProfile(&profile_); | 4012 ProfileSyncServiceFactory::GetInstance()->GetForProfile(&profile_); |
| 4011 syncer::ModelTypeSet encrypted_types = service->GetEncryptedDataTypes(); | 4013 syncer::ModelTypeSet encrypted_types = service->GetEncryptedDataTypes(); |
| 4012 encrypted_types.Put(syncer::SESSIONS); | 4014 encrypted_types.Put(syncer::SESSIONS); |
| 4013 service->OnEncryptedTypesChanged(encrypted_types, false); | 4015 service->OnEncryptedTypesChanged(encrypted_types, false); |
| 4014 EXPECT_FALSE(SearchProvider::CanSendURL( | 4016 EXPECT_FALSE(SearchProvider::CanSendURL( |
| 4015 GURL("http://www.google.com/search"), | 4017 GURL("http://www.google.com/search"), |
| 4016 GURL("https://www.google.com/complete/search"), &google_template_url, | 4018 GURL("https://www.google.com/complete/search"), &google_template_url, |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4095 // Verbatim match duplicates are added such that each one has a higher | 4097 // Verbatim match duplicates are added such that each one has a higher |
| 4096 // relevance than the previous one. | 4098 // relevance than the previous one. |
| 4097 EXPECT_EQ(2U, verbatim.duplicate_matches.size()); | 4099 EXPECT_EQ(2U, verbatim.duplicate_matches.size()); |
| 4098 | 4100 |
| 4099 // Other match duplicates are added in descending relevance order. | 4101 // Other match duplicates are added in descending relevance order. |
| 4100 EXPECT_EQ(1U, match_alpha.duplicate_matches.size()); | 4102 EXPECT_EQ(1U, match_alpha.duplicate_matches.size()); |
| 4101 EXPECT_EQ(1U, match_avid.duplicate_matches.size()); | 4103 EXPECT_EQ(1U, match_avid.duplicate_matches.size()); |
| 4102 | 4104 |
| 4103 EXPECT_EQ(0U, match_apricot.duplicate_matches.size()); | 4105 EXPECT_EQ(0U, match_apricot.duplicate_matches.size()); |
| 4104 } | 4106 } |
| OLD | NEW |