| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
| 12 #include "base/run_loop.h" | 12 #include "base/run_loop.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 14 #include "chrome/browser/search_engines/search_provider_install_data.h" | 14 #include "chrome/browser/search_engines/search_provider_install_data.h" |
| 15 #include "chrome/browser/search_engines/template_url_service_test_util.h" | 15 #include "chrome/browser/search_engines/template_url_service_test_util.h" |
| 16 #include "chrome/test/base/testing_pref_service_syncable.h" | 16 #include "chrome/test/base/testing_pref_service_syncable.h" |
| 17 #include "chrome/test/base/testing_profile.h" | 17 #include "chrome/test/base/testing_profile.h" |
| 18 #include "components/search_engines/search_terms_data.h" |
| 18 #include "components/search_engines/template_url.h" | 19 #include "components/search_engines/template_url.h" |
| 19 #include "components/search_engines/template_url_prepopulate_data.h" | 20 #include "components/search_engines/template_url_prepopulate_data.h" |
| 20 #include "components/search_engines/template_url_service.h" | 21 #include "components/search_engines/template_url_service.h" |
| 21 #include "content/public/test/mock_render_process_host.h" | 22 #include "content/public/test/mock_render_process_host.h" |
| 22 #include "content/public/test/test_browser_thread.h" | 23 #include "content/public/test/test_browser_thread.h" |
| 23 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
| 24 | 25 |
| 25 using content::BrowserThread; | 26 using content::BrowserThread; |
| 26 | 27 |
| 27 namespace { | 28 namespace { |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 SearchProviderInstallDataTest::SearchProviderInstallDataTest() | 146 SearchProviderInstallDataTest::SearchProviderInstallDataTest() |
| 146 : install_data_(NULL) { | 147 : install_data_(NULL) { |
| 147 } | 148 } |
| 148 | 149 |
| 149 void SearchProviderInstallDataTest::SetUp() { | 150 void SearchProviderInstallDataTest::SetUp() { |
| 150 testing::Test::SetUp(); | 151 testing::Test::SetUp(); |
| 151 #if defined(OS_ANDROID) | 152 #if defined(OS_ANDROID) |
| 152 TemplateURLPrepopulateData::InitCountryCode( | 153 TemplateURLPrepopulateData::InitCountryCode( |
| 153 std::string() /* unknown country code */); | 154 std::string() /* unknown country code */); |
| 154 #endif | 155 #endif |
| 155 util_.SetUp(); | |
| 156 process_.reset(new content::MockRenderProcessHost(util_.profile())); | 156 process_.reset(new content::MockRenderProcessHost(util_.profile())); |
| 157 install_data_ = | 157 install_data_ = new SearchProviderInstallData( |
| 158 new SearchProviderInstallData(util_.profile(), process_.get()); | 158 util_.model(), SearchTermsData().GoogleBaseURLValue(), NULL, |
| 159 process_.get()); |
| 159 } | 160 } |
| 160 | 161 |
| 161 void SearchProviderInstallDataTest::TearDown() { | 162 void SearchProviderInstallDataTest::TearDown() { |
| 162 BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, install_data_); | 163 BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, install_data_); |
| 163 install_data_ = NULL; | 164 install_data_ = NULL; |
| 164 | 165 |
| 165 // Make sure that the install data class on the UI thread gets cleaned up. | 166 // Make sure that the install data class on the UI thread gets cleaned up. |
| 166 // It doesn't matter that this happens after install_data_ is deleted. | 167 // It doesn't matter that this happens after install_data_ is deleted. |
| 167 process_.reset(); | 168 process_.reset(); |
| 168 | 169 |
| 169 util_.TearDown(); | |
| 170 testing::Test::TearDown(); | 170 testing::Test::TearDown(); |
| 171 } | 171 } |
| 172 | 172 |
| 173 TemplateURL* SearchProviderInstallDataTest::AddNewTemplateURL( | 173 TemplateURL* SearchProviderInstallDataTest::AddNewTemplateURL( |
| 174 const std::string& url, | 174 const std::string& url, |
| 175 const base::string16& keyword) { | 175 const base::string16& keyword) { |
| 176 TemplateURLData data; | 176 TemplateURLData data; |
| 177 data.short_name = keyword; | 177 data.short_name = keyword; |
| 178 data.SetKeyword(keyword); | 178 data.SetKeyword(keyword); |
| 179 data.SetURL(url); | 179 data.SetURL(url); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 // Verify the search providers install state (with no default set). | 270 // Verify the search providers install state (with no default set). |
| 271 test_get_install_state.RunTests(google_host, std::string()); | 271 test_get_install_state.RunTests(google_host, std::string()); |
| 272 | 272 |
| 273 // Change the Google base url. | 273 // Change the Google base url. |
| 274 google_host = "foo.com"; | 274 google_host = "foo.com"; |
| 275 SetGoogleBaseURLAndProcessOnIOThread(GURL("http://" + google_host + "/")); | 275 SetGoogleBaseURLAndProcessOnIOThread(GURL("http://" + google_host + "/")); |
| 276 | 276 |
| 277 // Verify that the change got picked up. | 277 // Verify that the change got picked up. |
| 278 test_get_install_state.RunTests(google_host, std::string()); | 278 test_get_install_state.RunTests(google_host, std::string()); |
| 279 } | 279 } |
| OLD | NEW |