diff options
author | rsimha@chromium.org <rsimha@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-15 18:12:47 +0000 |
---|---|---|
committer | rsimha@chromium.org <rsimha@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-15 18:12:47 +0000 |
commit | fc82ccf02a4c4ba88ee343d6f1eb385f9a5297ee (patch) | |
tree | 687473745e0ac8169c47ad745b3449b367072a75 /chrome/test/in_process_browser_test.h | |
parent | be144168e271095870be5c5c910ad181fdd53b54 (diff) | |
download | chromium_src-fc82ccf02a4c4ba88ee343d6f1eb385f9a5297ee.zip chromium_src-fc82ccf02a4c4ba88ee343d6f1eb385f9a5297ee.tar.gz chromium_src-fc82ccf02a4c4ba88ee343d6f1eb385f9a5297ee.tar.bz2 |
Create temp user data dir in InProcessBrowserTest if one is not specified.
Chrome tests that use InProcessBrowserTest are typically run using
out_of_proc_test_runner, that creates a temporary user data directory.
However, while debugging a single test, this becomes problematic,
because the test attempts to use the default chromium user data
directory and fails.
This patch creates a ScopedTempDir for a test if no user data dir is
specified, making debugging a lot easier.
BUG=58204
TEST=Run one of the sync_integration_tests under a debugger; should pass.
Review URL: http://codereview.chromium.org/3565016
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@62758 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/in_process_browser_test.h')
-rw-r--r-- | chrome/test/in_process_browser_test.h | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/chrome/test/in_process_browser_test.h b/chrome/test/in_process_browser_test.h index fdccf57..67736f7 100644 --- a/chrome/test/in_process_browser_test.h +++ b/chrome/test/in_process_browser_test.h @@ -9,6 +9,7 @@ #include "base/compiler_specific.h" #include "base/ref_counted.h" #include "base/scoped_ptr.h" +#include "base/scoped_temp_dir.h" #include "net/test/test_server.h" #include "testing/gtest/include/gtest/gtest.h" @@ -69,11 +70,12 @@ class InProcessBrowserTest : public testing::Test { // Override this rather than TestBody. virtual void RunTestOnMainThread() = 0; - // Helper to initialize the user data directory. Called by SetUp() after - // erasing the user data directory, but before any browser is launched. - // If a test wishes to set up some initial non-empty state in the user - // data directory before the browser starts up, it can do so here. - virtual void SetUpUserDataDirectory() {}; + // Initializes the contents of the user data directory. Called by SetUp() + // after creating the user data directory, but before any browser is launched. + // If a test wishes to set up some initial non-empty state in the user data + // directory before the browser starts up, it can do so here. Returns true if + // successful. + virtual bool SetUpUserDataDirectory() WARN_UNUSED_RESULT { return true; } // We need these special methods because InProcessBrowserTest::SetUp is the // bottom of the stack that winds up calling your test method, so it is not @@ -123,6 +125,10 @@ class InProcessBrowserTest : public testing::Test { } private: + // Creates a user data directory for the test if one is needed. Returns true + // if successful. + virtual bool CreateUserDataDirectory() WARN_UNUSED_RESULT; + // This is invoked from main after browser_init/browser_main have completed. // This prepares for the test by creating a new browser, runs the test // (RunTestOnMainThread), quits the browsers and returns. @@ -159,6 +165,10 @@ class InProcessBrowserTest : public testing::Test { // Host resolver to use during the test. scoped_refptr<net::RuleBasedHostResolverProc> host_resolver_; + // Temporary user data directory. Used only when a user data directory is not + // specified in the command line. + ScopedTempDir temp_user_data_dir_; + DISALLOW_COPY_AND_ASSIGN(InProcessBrowserTest); }; |