Chromium Code Reviews| 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/search_terms_data.h" |
| 19 #include "components/search_engines/template_url.h" | 19 #include "components/search_engines/template_url.h" |
| 20 #include "components/search_engines/template_url_prepopulate_data.h" | 20 #include "components/search_engines/template_url_prepopulate_data.h" |
| 21 #include "components/search_engines/template_url_service.h" | 21 #include "components/search_engines/template_url_service.h" |
| 22 #include "content/public/browser/browser_thread.h" | |
| 22 #include "content/public/test/mock_render_process_host.h" | 23 #include "content/public/test/mock_render_process_host.h" |
| 23 #include "content/public/test/test_browser_thread.h" | 24 #include "content/public/test/test_browser_thread_bundle.h" |
| 24 #include "testing/gtest/include/gtest/gtest.h" | 25 #include "testing/gtest/include/gtest/gtest.h" |
| 25 | 26 |
| 26 using content::BrowserThread; | 27 using content::BrowserThread; |
| 27 | 28 |
| 28 namespace { | 29 namespace { |
| 29 | 30 |
| 30 // TestGetInstallState -------------------------------------------------------- | 31 // TestGetInstallState -------------------------------------------------------- |
| 31 | 32 |
| 32 // Test the SearchProviderInstallData::GetInstallState. | 33 // Test the SearchProviderInstallData::GetInstallState. |
| 33 class TestGetInstallState { | 34 class TestGetInstallState { |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 123 virtual void TearDown() OVERRIDE; | 124 virtual void TearDown() OVERRIDE; |
| 124 | 125 |
| 125 protected: | 126 protected: |
| 126 TemplateURL* AddNewTemplateURL(const std::string& url, | 127 TemplateURL* AddNewTemplateURL(const std::string& url, |
| 127 const base::string16& keyword); | 128 const base::string16& keyword); |
| 128 | 129 |
| 129 // Sets the Google base URL to |base_url| and runs the IO thread for | 130 // Sets the Google base URL to |base_url| and runs the IO thread for |
| 130 // |SearchProviderInstallData| to process the update. | 131 // |SearchProviderInstallData| to process the update. |
| 131 void SetGoogleBaseURLAndProcessOnIOThread(GURL base_url); | 132 void SetGoogleBaseURLAndProcessOnIOThread(GURL base_url); |
| 132 | 133 |
| 134 content::TestBrowserThreadBundle thread_bundle_; | |
|
Peter Kasting
2014/08/28 19:06:19
Nit: Add comments about why we need this.
While h
hashimoto
2014/08/29 08:06:26
Added comments and made all data members private.
| |
| 133 TemplateURLServiceTestUtil util_; | 135 TemplateURLServiceTestUtil util_; |
| 134 | 136 |
| 135 // Provides the search provider install state on the I/O thread. It must be | 137 // Provides the search provider install state on the I/O thread. It must be |
| 136 // deleted on the I/O thread, which is why it isn't a scoped_ptr. | 138 // deleted on the I/O thread, which is why it isn't a scoped_ptr. |
| 137 SearchProviderInstallData* install_data_; | 139 SearchProviderInstallData* install_data_; |
| 138 | 140 |
| 139 // A mock RenderProcessHost that the SearchProviderInstallData will scope its | 141 // A mock RenderProcessHost that the SearchProviderInstallData will scope its |
| 140 // lifetime to. | 142 // lifetime to. |
| 141 scoped_ptr<content::MockRenderProcessHost> process_; | 143 scoped_ptr<content::MockRenderProcessHost> process_; |
| 142 | 144 |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 270 // Verify the search providers install state (with no default set). | 272 // Verify the search providers install state (with no default set). |
| 271 test_get_install_state.RunTests(google_host, std::string()); | 273 test_get_install_state.RunTests(google_host, std::string()); |
| 272 | 274 |
| 273 // Change the Google base url. | 275 // Change the Google base url. |
| 274 google_host = "foo.com"; | 276 google_host = "foo.com"; |
| 275 SetGoogleBaseURLAndProcessOnIOThread(GURL("http://" + google_host + "/")); | 277 SetGoogleBaseURLAndProcessOnIOThread(GURL("http://" + google_host + "/")); |
| 276 | 278 |
| 277 // Verify that the change got picked up. | 279 // Verify that the change got picked up. |
| 278 test_get_install_state.RunTests(google_host, std::string()); | 280 test_get_install_state.RunTests(google_host, std::string()); |
| 279 } | 281 } |
| OLD | NEW |