diff options
author | rsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-08 05:36:04 +0000 |
---|---|---|
committer | rsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-08 05:36:04 +0000 |
commit | 812b3a3ee935e0398382eb5e112dd93f6df9510c (patch) | |
tree | 3d4df126a2c5d828b834bb5f78c5998f621a0148 /chrome/test/testing_profile.h | |
parent | b9289a192e590565ae012fd6f613fd1c1a7b244a (diff) | |
download | chromium_src-812b3a3ee935e0398382eb5e112dd93f6df9510c.zip chromium_src-812b3a3ee935e0398382eb5e112dd93f6df9510c.tar.gz chromium_src-812b3a3ee935e0398382eb5e112dd93f6df9510c.tar.bz2 |
Move code duplicated in two tests up into the TestingProfile.
Move TestURLRequestContextGetter and friends from CookieTreeModelTest and
CookiesWindowControllerTest into TestingProfile. In the TestingProfile, return
a valid CookieMonster and URLRequstContextGetter, if CreateRequestContext() is
called.
Original CL: http://codereview.chromium.org/525072/show
BUG=None
TEST=Covered by unit tests
Review URL: http://codereview.chromium.org/525106
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@35776 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/testing_profile.h')
-rw-r--r-- | chrome/test/testing_profile.h | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/chrome/test/testing_profile.h b/chrome/test/testing_profile.h index f59a18b..77fdd40 100644 --- a/chrome/test/testing_profile.h +++ b/chrome/test/testing_profile.h @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2009-2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -13,10 +13,12 @@ #include "chrome/browser/browser_theme_provider.h" #include "chrome/browser/favicon_service.h" #include "chrome/browser/history/history.h" +#include "chrome/browser/net/url_request_context_getter.h" #include "chrome/browser/profile.h" #include "chrome/browser/search_engines/template_url_model.h" #include "chrome/browser/sessions/session_service.h" #include "chrome/common/pref_service.h" +#include "net/base/cookie_monster.h" class TestingProfile : public Profile { public: @@ -100,6 +102,14 @@ class TestingProfile : public Profile { void set_has_history_service(bool has_history_service) { has_history_service_ = has_history_service; } + // The CookieMonster will only be returned if a Context has been created. Do + // this by calling CreateRequestContext(). See the note at GetRequestContext + // for more information. + net::CookieMonster* GetCookieMonster() { + if (!GetRequestContext()) + return NULL; + return GetRequestContext()->GetCookieStore()->GetCookieMonster(); + } virtual SearchVersusNavigateClassifier* GetSearchVersusNavigateClassifier() { return NULL; } @@ -139,11 +149,23 @@ class TestingProfile : public Profile { InitThemes(); return theme_provider_.get(); } - virtual URLRequestContextGetter* GetRequestContext() { return NULL; } + + // Returns a testing ContextGetter (if one has been created via + // CreateRequestContext) or NULL. This is not done on-demand for two reasons: + // (1) Some tests depend on GetRequestContext() returning NULL. (2) Because + // of the special memory management considerations for the + // TestURLRequestContextGetter class, many tests would find themseleves + // leaking if they called this method without the necessary IO thread. This + // getter is currently only capable of returning a Context that helps test + // the CookieMonster. See implementation comments for more details. + virtual URLRequestContextGetter* GetRequestContext(); + void CreateRequestContext(); + virtual URLRequestContextGetter* GetRequestContextForMedia() { return NULL; } virtual URLRequestContextGetter* GetRequestContextForExtensions() { return NULL; } + virtual net::SSLConfigService* GetSSLConfigService() { return NULL; } virtual BlacklistManager* GetBlacklistManager() { return NULL; } virtual HostZoomMap* GetHostZoomMap() { return NULL; } @@ -230,6 +252,10 @@ class TestingProfile : public Profile { scoped_ptr<BrowserThemeProvider> theme_provider_; bool created_theme_provider_; + // Internally, this is a TestURLRequestContextGetter that creates a dummy + // request context. Currently, only the CookieMonster is hooked up. + scoped_refptr<URLRequestContextGetter> request_context_; + // Do we have a history service? This defaults to the value of // history_service, but can be explicitly set. bool has_history_service_; |