summaryrefslogtreecommitdiffstats
path: root/chrome/test
diff options
context:
space:
mode:
authorphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-30 21:27:01 +0000
committerphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-30 21:27:01 +0000
commit23cc9a18ab9c4893e3cad94c3683e7ffecefcbf0 (patch)
treed446ad54b3e2ee91a4309243310e0a36d48299e6 /chrome/test
parentee12b724955c00af4f29b054fea44dca986b2396 (diff)
downloadchromium_src-23cc9a18ab9c4893e3cad94c3683e7ffecefcbf0.zip
chromium_src-23cc9a18ab9c4893e3cad94c3683e7ffecefcbf0.tar.gz
chromium_src-23cc9a18ab9c4893e3cad94c3683e7ffecefcbf0.tar.bz2
Remove duplication of DieFileDie, and move it to proper location.
TEST=none http://crbug.com/18085 Review URL: http://codereview.chromium.org/159658 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22103 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test')
-rw-r--r--chrome/test/in_process_browser_test.cc27
-rw-r--r--chrome/test/ui/ui_test.cc15
-rw-r--r--chrome/test/ui/ui_test.h8
3 files changed, 7 insertions, 43 deletions
diff --git a/chrome/test/in_process_browser_test.cc b/chrome/test/in_process_browser_test.cc
index 50f4dd5..78b2333 100644
--- a/chrome/test/in_process_browser_test.cc
+++ b/chrome/test/in_process_browser_test.cc
@@ -8,6 +8,7 @@
#include "base/file_path.h"
#include "base/file_util.h"
#include "base/path_service.h"
+#include "base/test_file_util.h"
#include "chrome/browser/browser.h"
#include "chrome/browser/browser_list.h"
#include "chrome/browser/browser_process.h"
@@ -42,23 +43,6 @@ const int kInitialTimeoutInMS = 30000;
// Delay for sub-sequent time-outs once the initial time-out happened.
const int kSubsequentTimeoutInMS = 5000;
-namespace {
-
-bool DieFileDie(const std::wstring& file, bool recurse) {
- if (!file_util::PathExists(file))
- return true;
-
- // Sometimes Delete fails, so try a few more times.
- for (int i = 0; i < 10; ++i) {
- if (file_util::Delete(file, recurse))
- return true;
- PlatformThread::Sleep(100);
- }
- return false;
-}
-
-} // namespace
-
InProcessBrowserTest::InProcessBrowserTest()
: browser_(NULL),
show_window_(false),
@@ -70,13 +54,13 @@ InProcessBrowserTest::InProcessBrowserTest()
void InProcessBrowserTest::SetUp() {
// Cleanup the user data dir.
- std::wstring user_data_dir;
+ FilePath user_data_dir;
PathService::Get(chrome::DIR_USER_DATA, &user_data_dir);
- ASSERT_LT(10, static_cast<int>(user_data_dir.size())) <<
+ ASSERT_LT(10, static_cast<int>(user_data_dir.value().size())) <<
"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(DieFileDie(user_data_dir, true));
+ 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.
@@ -109,7 +93,8 @@ void InProcessBrowserTest::SetUp() {
// http://crbug.com/17725
// command_line->AppendSwitch(switches::kEnableWebResources);
- command_line->AppendSwitchWithValue(switches::kUserDataDir, user_data_dir);
+ command_line->AppendSwitchWithValue(switches::kUserDataDir,
+ user_data_dir.ToWStringHack());
// For some reason the sandbox wasn't happy running in test mode. These
// tests aren't intended to test the sandbox, so we turn it off.
diff --git a/chrome/test/ui/ui_test.cc b/chrome/test/ui/ui_test.cc
index 98929dd..25ec701 100644
--- a/chrome/test/ui/ui_test.cc
+++ b/chrome/test/ui/ui_test.cc
@@ -83,19 +83,6 @@ const wchar_t kEnableErrorDialogs[] = L"enable-errdialogs";
// BROWSER_WRAPPER env variable to wrap the browser process.
// #define WAIT_FOR_DEBUGGER_ON_OPEN 1
-bool UITest::DieFileDie(const FilePath& file, bool recurse) {
- if (!file_util::PathExists(file))
- return true;
-
- // Sometimes Delete fails, so try a few more times.
- for (int i = 0; i < 25; ++i) {
- if (file_util::Delete(file, recurse))
- return true;
- PlatformThread::Sleep(action_max_timeout_ms() / 25);
- }
- return false;
-}
-
UITest::UITest()
: testing::Test(),
launch_arguments_(L""),
@@ -429,7 +416,7 @@ void UITest::LaunchBrowser(const CommandLine& arguments, bool clear_profile) {
"short to delete safely. Please check the user-data-dir "
"argument and try again.";
if (clear_profile)
- ASSERT_TRUE(DieFileDie(user_data_dir_, true));
+ ASSERT_TRUE(file_util::DieFileDie(user_data_dir_, true));
if (!template_user_data_.empty()) {
// Recursively copy the template directory to the user_data_dir.
diff --git a/chrome/test/ui/ui_test.h b/chrome/test/ui/ui_test.h
index 2ccff54..1d4374d 100644
--- a/chrome/test/ui/ui_test.h
+++ b/chrome/test/ui/ui_test.h
@@ -64,14 +64,6 @@ class UITest : public testing::Test {
// ********* Utility functions *********
- // Tries to delete the specified file/directory returning true on
- // success. This differs from file_util::Delete in that it
- // repeatedly invokes Delete until successful, or a timeout is
- // reached. (This retrying is to work around Windows file locks
- // and shouldn't be necessary on POSIX, but it can't hurt.)
- // Returns true on success.
- bool DieFileDie(const FilePath& file, bool recurse);
-
// Launches the browser and IPC testing server.
void LaunchBrowserAndServer();