| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/search/instant_unittest_base.h" | 5 #include "chrome/browser/search/instant_unittest_base.h" |
| 6 #include <string> | 6 #include <string> |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "chrome/browser/chrome_notification_types.h" | 9 #include "chrome/browser/chrome_notification_types.h" |
| 10 #include "chrome/browser/google/google_url_tracker.h" | 10 #include "chrome/browser/google/google_url_tracker.h" |
| 11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
| 12 #include "chrome/browser/search/instant_service.h" | 12 #include "chrome/browser/search/instant_service.h" |
| 13 #include "chrome/browser/search/instant_service_factory.h" | 13 #include "chrome/browser/search/instant_service_factory.h" |
| 14 #include "chrome/browser/search/search.h" | 14 #include "chrome/browser/search/search.h" |
| 15 #include "chrome/browser/search_engines/search_terms_data.h" | 15 #include "chrome/browser/search_engines/search_terms_data.h" |
| 16 #include "chrome/browser/search_engines/template_url.h" | 16 #include "chrome/browser/search_engines/template_url.h" |
| 17 #include "chrome/browser/search_engines/template_url_service.h" | 17 #include "chrome/browser/search_engines/template_url_service.h" |
| 18 #include "chrome/browser/search_engines/template_url_service_factory.h" | 18 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 19 #include "chrome/common/pref_names.h" | 19 #include "chrome/common/pref_names.h" |
| 20 #include "chrome/test/base/browser_with_test_window_test.h" | 20 #include "chrome/test/base/browser_with_test_window_test.h" |
| 21 #include "chrome/test/base/testing_pref_service_syncable.h" | 21 #include "chrome/test/base/testing_pref_service_syncable.h" |
| 22 #include "chrome/test/base/ui_test_utils.h" | 22 #include "chrome/test/base/ui_test_utils.h" |
| 23 #include "components/variations/entropy_provider.h" |
| 23 #include "content/public/browser/notification_details.h" | 24 #include "content/public/browser/notification_details.h" |
| 24 #include "content/public/browser/notification_service.h" | 25 #include "content/public/browser/notification_service.h" |
| 25 #include "content/public/browser/notification_source.h" | 26 #include "content/public/browser/notification_source.h" |
| 26 | 27 |
| 28 InstantUnitTestBase::InstantUnitTestBase() { |
| 29 field_trial_list_.reset(new base::FieldTrialList( |
| 30 new metrics::SHA1EntropyProvider("42"))); |
| 31 } |
| 32 |
| 33 InstantUnitTestBase::~InstantUnitTestBase() { |
| 34 } |
| 35 |
| 27 void InstantUnitTestBase::SetUp() { | 36 void InstantUnitTestBase::SetUp() { |
| 28 chrome::EnableInstantExtendedAPIForTesting(); | 37 SetUpHelper(); |
| 38 } |
| 39 |
| 40 void InstantUnitTestBase::SetUpWithoutCacheableNTP() { |
| 41 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( |
| 42 "InstantExtended", "Group1 use_cacheable_ntp:0")); |
| 43 SetUpHelper(); |
| 44 } |
| 45 |
| 46 void InstantUnitTestBase::SetUpHelper() { |
| 47 chrome::EnableQueryExtractionForTesting(); |
| 29 BrowserWithTestWindowTest::SetUp(); | 48 BrowserWithTestWindowTest::SetUp(); |
| 30 | 49 |
| 31 TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse( | 50 TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse( |
| 32 profile(), &TemplateURLServiceFactory::BuildInstanceFor); | 51 profile(), &TemplateURLServiceFactory::BuildInstanceFor); |
| 33 template_url_service_ = TemplateURLServiceFactory::GetForProfile(profile()); | 52 template_url_service_ = TemplateURLServiceFactory::GetForProfile(profile()); |
| 34 ui_test_utils::WaitForTemplateURLServiceToLoad(template_url_service_); | 53 ui_test_utils::WaitForTemplateURLServiceToLoad(template_url_service_); |
| 35 | 54 |
| 36 UIThreadSearchTermsData::SetGoogleBaseURL("https://www.google.com/"); | 55 UIThreadSearchTermsData::SetGoogleBaseURL("https://www.google.com/"); |
| 37 TestingPrefServiceSyncable* pref_service = profile()->GetTestingPrefService(); | 56 TestingPrefServiceSyncable* pref_service = profile()->GetTestingPrefService(); |
| 38 pref_service->SetUserPref(prefs::kLastPromptedGoogleURL, | 57 pref_service->SetUserPref(prefs::kLastPromptedGoogleURL, |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 content::Source<Profile>(profile()->GetOriginalProfile()), | 96 content::Source<Profile>(profile()->GetOriginalProfile()), |
| 78 content::Details<GoogleURLTracker::UpdatedDetails>(&details)); | 97 content::Details<GoogleURLTracker::UpdatedDetails>(&details)); |
| 79 } | 98 } |
| 80 | 99 |
| 81 | 100 |
| 82 bool InstantUnitTestBase::IsInstantServiceObserver( | 101 bool InstantUnitTestBase::IsInstantServiceObserver( |
| 83 InstantServiceObserver* observer) { | 102 InstantServiceObserver* observer) { |
| 84 return instant_service_->observers_.HasObserver(observer); | 103 return instant_service_->observers_.HasObserver(observer); |
| 85 } | 104 } |
| 86 | 105 |
| OLD | NEW |