diff options
author | ajwong@chromium.org <ajwong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-23 23:39:35 +0000 |
---|---|---|
committer | ajwong@chromium.org <ajwong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-23 23:39:35 +0000 |
commit | 37ac95b451ae3cdddf327b9bfc3ba350b149b5ff (patch) | |
tree | e4f65b78b410d48cb7ff06c0193fb34980e5334b /components | |
parent | b785a42692ee2b57600f8b2df66f785387d3f7c0 (diff) | |
download | chromium_src-37ac95b451ae3cdddf327b9bfc3ba350b149b5ff.zip chromium_src-37ac95b451ae3cdddf327b9bfc3ba350b149b5ff.tar.gz chromium_src-37ac95b451ae3cdddf327b9bfc3ba350b149b5ff.tar.bz2 |
Correctly integrate StoragePartition into TestingProfile.
Until this CL, TestingProfile had 3 distinct URLRequestContexts it would return to the user: one via profile->GetDefaultStoragePartition()->GetRequestContext(), one via profile->GetRequestContext(), and one via profile->GetResourceContext->GetRequestContext(). All of these had different cookie stores. This CL unified them so they all return the one from profile->GetDefaultStoragePartition()->GetRequestContext(). This correctly mimics how production code works.
Doing this had a bunch of implications:
(1) Removes TestingProfile::CreateRequestContext()/ResetRequestContext()
(2) Changes MockRequestContext to share the URLRequestContext with TestingProfile.
(3) TestingProfile now requires all BrowserThreads.
Point (3) effectively adds TestBrowserThreadBundle into a bunch more spots. Because of that, we also have the following changes:
(a) AshTestBase now has a TestBrowserThreadBundle
(b) Removed a bunch of real threads from tests.
(c) TemplateUrlService has reworked synchronization semantics.
(d) Removed MultiThreadTestHelper.
(e) Added TestingIOThread class + testing API in IOThread to mock out various IO thread tasks which enervated with the new TestBrowserThreadBundle.
TBR=bauerb,brettw,isherman,joth,jyasskin,mattm,mmenke,mnissler,pkasting,rkc,rlp,satorux,tim,xians,joth
BUG=159193
Review URL: https://chromiumcodereview.appspot.com/17127002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@213272 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'components')
7 files changed, 15 insertions, 41 deletions
diff --git a/components/autofill/content/browser/autocheckout_manager_unittest.cc b/components/autofill/content/browser/autocheckout_manager_unittest.cc index e5d5aa5..3b39631 100644 --- a/components/autofill/content/browser/autocheckout_manager_unittest.cc +++ b/components/autofill/content/browser/autocheckout_manager_unittest.cc @@ -7,7 +7,6 @@ #include "base/strings/utf_string_conversions.h" #include "base/tuple.h" #include "chrome/test/base/chrome_render_view_host_test_harness.h" -#include "chrome/test/base/testing_profile.h" #include "components/autofill/content/browser/autocheckout_manager.h" #include "components/autofill/core/browser/autofill_common_test.h" #include "components/autofill/core/browser/autofill_manager.h" @@ -417,7 +416,6 @@ class AutocheckoutManagerTest : public ChromeRenderViewHostTestHarness { virtual void SetUp() OVERRIDE { SetThreadBundleOptions(content::TestBrowserThreadBundle::REAL_IO_THREAD); ChromeRenderViewHostTestHarness::SetUp(); - profile()->CreateRequestContext(); autofill_manager_delegate_.reset(new MockAutofillManagerDelegate()); autofill_driver_.reset(new TestAutofillDriver(web_contents())); autofill_manager_.reset(new TestAutofillManager( @@ -432,7 +430,6 @@ class AutocheckoutManagerTest : public ChromeRenderViewHostTestHarness { autofill_manager_delegate_.reset(); autofill_manager_.reset(); autofill_driver_.reset(); - profile()->ResetRequestContext(); ChromeRenderViewHostTestHarness::TearDown(); } diff --git a/components/autofill/content/browser/wallet/wallet_client_unittest.cc b/components/autofill/content/browser/wallet/wallet_client_unittest.cc index 6536c3e..9360b95 100644 --- a/components/autofill/content/browser/wallet/wallet_client_unittest.cc +++ b/components/autofill/content/browser/wallet/wallet_client_unittest.cc @@ -20,7 +20,7 @@ #include "components/autofill/core/browser/autofill_metrics.h" #include "components/autofill/core/common/autocheckout_status.h" #include "content/public/test/test_browser_context.h" -#include "content/public/test/test_browser_thread.h" +#include "content/public/test/test_browser_thread_bundle.h" #include "net/base/escape.h" #include "net/base/net_errors.h" #include "net/http/http_request_headers.h" @@ -658,8 +658,6 @@ class MockWalletClientDelegate : public WalletClientDelegate { class WalletClientTest : public testing::Test { public: - WalletClientTest() {} - virtual void SetUp() OVERRIDE { wallet_client_.reset( new WalletClient(browser_context_.GetRequestContext(), &delegate_)); @@ -772,6 +770,9 @@ class WalletClientTest : public testing::Test { return clean_upload_data; } + // The profile's request context must be released on the IO thread. + content::TestBrowserThreadBundle thread_bundle_; + net::TestURLFetcherFactory factory_; }; diff --git a/components/autofill/content/browser/wallet/wallet_signin_helper_unittest.cc b/components/autofill/content/browser/wallet/wallet_signin_helper_unittest.cc index a4f2bd9..c980fba 100644 --- a/components/autofill/content/browser/wallet/wallet_signin_helper_unittest.cc +++ b/components/autofill/content/browser/wallet/wallet_signin_helper_unittest.cc @@ -78,9 +78,7 @@ class WalletSigninHelperForTesting : public WalletSigninHelper { } // namespace class WalletSigninHelperTest : public testing::Test { - public: - WalletSigninHelperTest() {} - + protected: virtual void SetUp() OVERRIDE { signin_helper_.reset(new WalletSigninHelperForTesting( &mock_delegate_, @@ -92,7 +90,6 @@ class WalletSigninHelperTest : public testing::Test { signin_helper_.reset(); } - protected: // Sets up a response for the mock URLFetcher and completes the request. void SetUpFetcherResponseAndCompleteRequest( const std::string& url, @@ -158,8 +155,9 @@ class WalletSigninHelperTest : public testing::Test { content::TestBrowserContext browser_context_; private: - net::TestURLFetcherFactory factory_; + // The profile's request context must be released on the IO thread. content::TestBrowserThreadBundle thread_bundle_; + net::TestURLFetcherFactory factory_; }; TEST_F(WalletSigninHelperTest, PassiveSigninSuccessful) { diff --git a/components/autofill/core/browser/autofill_download_unittest.cc b/components/autofill/core/browser/autofill_download_unittest.cc index ec6bad1..ed2c705 100644 --- a/components/autofill/core/browser/autofill_download_unittest.cc +++ b/components/autofill/core/browser/autofill_download_unittest.cc @@ -15,14 +15,13 @@ #include "components/autofill/core/browser/autofill_type.h" #include "components/autofill/core/browser/form_structure.h" #include "components/autofill/core/common/form_data.h" -#include "content/public/test/test_browser_thread.h" +#include "content/public/test/test_browser_thread_bundle.h" #include "net/url_request/test_url_fetcher_factory.h" #include "net/url_request/url_request_status.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/WebKit/public/web/WebInputElement.h" -using content::BrowserThread; using WebKit::WebInputElement; namespace autofill { @@ -65,18 +64,7 @@ class AutofillDownloadTest : public AutofillDownloadManager::Observer, public testing::Test { public: AutofillDownloadTest() - : download_manager_(&profile_, this), - io_thread_(BrowserThread::IO) { - } - - virtual void SetUp() { - io_thread_.StartIOThread(); - profile_.CreateRequestContext(); - } - - virtual void TearDown() { - profile_.ResetRequestContext(); - io_thread_.Stop(); + : download_manager_(&profile_, this) { } void LimitCache(size_t cache_size) { @@ -128,16 +116,12 @@ class AutofillDownloadTest : public AutofillDownloadManager::Observer, }; std::list<ResponseData> responses_; + content::TestBrowserThreadBundle thread_bundle_; TestingProfile profile_; AutofillDownloadManager download_manager_; - - private: - // The profile's request context must be released on the IO thread. - content::TestBrowserThread io_thread_; }; TEST_F(AutofillDownloadTest, QueryAndUploadTest) { - base::MessageLoopForUI message_loop; // Create and register factory. net::TestURLFetcherFactory factory; @@ -349,7 +333,6 @@ TEST_F(AutofillDownloadTest, QueryAndUploadTest) { } TEST_F(AutofillDownloadTest, CacheQueryTest) { - base::MessageLoopForUI message_loop; // Create and register factory. net::TestURLFetcherFactory factory; diff --git a/components/autofill/core/browser/autofill_manager_unittest.cc b/components/autofill/core/browser/autofill_manager_unittest.cc index d133cf3..35b1e6a0 100644 --- a/components/autofill/core/browser/autofill_manager_unittest.cc +++ b/components/autofill/core/browser/autofill_manager_unittest.cc @@ -770,12 +770,6 @@ class AutofillManagerTest : public ChromeRenderViewHostTestHarness { personal_data_.SetBrowserContext(NULL); } - virtual content::BrowserContext* CreateBrowserContext() OVERRIDE { - TestingProfile* profile = new TestingProfile(); - profile->CreateRequestContext(); - return profile; - } - void GetAutofillSuggestions(int query_id, const FormData& form, const FormFieldData& field) { diff --git a/components/autofill/core/browser/autofill_metrics_unittest.cc b/components/autofill/core/browser/autofill_metrics_unittest.cc index a5e58b5..8b83255 100644 --- a/components/autofill/core/browser/autofill_metrics_unittest.cc +++ b/components/autofill/core/browser/autofill_metrics_unittest.cc @@ -287,7 +287,6 @@ void AutofillMetricsTest::SetUp() { // Ensure Mac OS X does not pop up a modal dialog for the Address Book. autofill::test::DisableSystemServices(profile()); - profile()->CreateRequestContext(); PersonalDataManagerFactory::GetInstance()->SetTestingFactory(profile(), NULL); TabAutofillManagerDelegate::CreateForWebContents(web_contents()); @@ -315,7 +314,6 @@ void AutofillMetricsTest::TearDown() { autofill_manager_.reset(); autofill_driver_.reset(); personal_data_.reset(); - profile()->ResetRequestContext(); ChromeRenderViewHostTestHarness::TearDown(); } diff --git a/components/navigation_interception/intercept_navigation_resource_throttle_unittest.cc b/components/navigation_interception/intercept_navigation_resource_throttle_unittest.cc index dfccb30..e1bd566 100644 --- a/components/navigation_interception/intercept_navigation_resource_throttle_unittest.cc +++ b/components/navigation_interception/intercept_navigation_resource_throttle_unittest.cc @@ -26,13 +26,14 @@ #include "net/http/http_response_headers.h" #include "net/http/http_response_info.h" #include "net/url_request/url_request.h" +#include "net/url_request/url_request_test_util.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" using testing::_; using testing::Eq; -using testing::Property; using testing::Ne; +using testing::Property; using testing::Return; namespace navigation_interception { @@ -117,7 +118,8 @@ class TestIOThreadState { const std::string& request_method, RedirectMode redirect_mode, MockInterceptCallbackReceiver* callback_receiver) - : request_(url, NULL, resource_context_.GetRequestContext()) { + : resource_context_(&test_url_request_context_), + request_(url, NULL, resource_context_.GetRequestContext()) { DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); if (render_process_id != MSG_ROUTING_NONE && render_view_id != MSG_ROUTING_NONE) { @@ -164,6 +166,7 @@ class TestIOThreadState { } private: + net::TestURLRequestContext test_url_request_context_; content::MockResourceContext resource_context_; net::URLRequest request_; scoped_ptr<InterceptNavigationResourceThrottle> throttle_; |