summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/test/in_process_browser_test.cc6
-rw-r--r--chrome/test/in_process_browser_test.h7
2 files changed, 12 insertions, 1 deletions
diff --git a/chrome/test/in_process_browser_test.cc b/chrome/test/in_process_browser_test.cc
index 0815941..6c07e41 100644
--- a/chrome/test/in_process_browser_test.cc
+++ b/chrome/test/in_process_browser_test.cc
@@ -54,6 +54,9 @@ InProcessBrowserTest::InProcessBrowserTest()
}
void InProcessBrowserTest::SetUp() {
+ // This method does nothing in default case. But can be overridden
+ // to set user data dir for test.
+ SetUpUserDataDirForTest();
// Cleanup the user data dir.
FilePath user_data_dir;
PathService::Get(chrome::DIR_USER_DATA, &user_data_dir);
@@ -61,7 +64,8 @@ void InProcessBrowserTest::SetUp() {
"The user data directory name passed into this test was too "
"short to delete safely. Please check the user-data-dir "
"argument and try again.";
- ASSERT_TRUE(file_util::DieFileDie(user_data_dir, true));
+ if (ShouldDeleteProfile())
+ ASSERT_TRUE(file_util::DieFileDie(user_data_dir, true));
// The unit test suite creates a testingbrowser, but we want the real thing.
// Delete the current one. We'll install the testing one in TearDown.
diff --git a/chrome/test/in_process_browser_test.h b/chrome/test/in_process_browser_test.h
index 11a2880..250c52e 100644
--- a/chrome/test/in_process_browser_test.h
+++ b/chrome/test/in_process_browser_test.h
@@ -52,6 +52,13 @@ class InProcessBrowserTest : public testing::Test {
// Restores state configured in SetUp.
virtual void TearDown();
+ // This method can be overridden to set user data directory for test.
+ virtual void SetUpUserDataDirForTest() {}
+
+ // This method is used to decide if user data dir
+ // needs to be deleted or not.
+ virtual bool ShouldDeleteProfile() { return true; }
+
protected:
// Returns the browser created by CreateBrowser.
Browser* browser() const { return browser_; }