Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(471)

Side by Side Diff: chrome/test/ui/ui_test.cc

Issue 159658: Remove duplication of DieFileDie, and move it to proper location. (Closed)
Patch Set: Created 11 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/test/ui/ui_test.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/test/ui/ui_test.h" 5 #include "chrome/test/ui/ui_test.h"
6 6
7 #include <set> 7 #include <set>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/base_switches.h" 10 #include "base/base_switches.h"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 76
77 // By default error dialogs are hidden, which makes debugging failures in the 77 // By default error dialogs are hidden, which makes debugging failures in the
78 // slave process frustrating. By passing this in error dialogs are enabled. 78 // slave process frustrating. By passing this in error dialogs are enabled.
79 const wchar_t kEnableErrorDialogs[] = L"enable-errdialogs"; 79 const wchar_t kEnableErrorDialogs[] = L"enable-errdialogs";
80 80
81 // Uncomment this line to have the spawned process wait for the debugger to 81 // Uncomment this line to have the spawned process wait for the debugger to
82 // attach. This only works on Windows. On posix systems, you can set the 82 // attach. This only works on Windows. On posix systems, you can set the
83 // BROWSER_WRAPPER env variable to wrap the browser process. 83 // BROWSER_WRAPPER env variable to wrap the browser process.
84 // #define WAIT_FOR_DEBUGGER_ON_OPEN 1 84 // #define WAIT_FOR_DEBUGGER_ON_OPEN 1
85 85
86 bool UITest::DieFileDie(const FilePath& file, bool recurse) {
87 if (!file_util::PathExists(file))
88 return true;
89
90 // Sometimes Delete fails, so try a few more times.
91 for (int i = 0; i < 25; ++i) {
92 if (file_util::Delete(file, recurse))
93 return true;
94 PlatformThread::Sleep(action_max_timeout_ms() / 25);
95 }
96 return false;
97 }
98
99 UITest::UITest() 86 UITest::UITest()
100 : testing::Test(), 87 : testing::Test(),
101 launch_arguments_(L""), 88 launch_arguments_(L""),
102 expected_errors_(0), 89 expected_errors_(0),
103 expected_crashes_(0), 90 expected_crashes_(0),
104 homepage_(L"about:blank"), 91 homepage_(L"about:blank"),
105 wait_for_initial_loads_(true), 92 wait_for_initial_loads_(true),
106 dom_automation_enabled_(false), 93 dom_automation_enabled_(false),
107 process_(0), // NULL on Windows, 0 PID on POSIX. 94 process_(0), // NULL on Windows, 0 PID on POSIX.
108 show_window_(false), 95 show_window_(false),
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 command_line.AppendArguments(arguments, false); 409 command_line.AppendArguments(arguments, false);
423 410
424 // Clear user data directory to make sure test environment is consistent 411 // Clear user data directory to make sure test environment is consistent
425 // We balk on really short (absolute) user_data_dir directory names, because 412 // We balk on really short (absolute) user_data_dir directory names, because
426 // we're worried that they'd accidentally be root or something. 413 // we're worried that they'd accidentally be root or something.
427 ASSERT_LT(10, static_cast<int>(user_data_dir_.value().size())) << 414 ASSERT_LT(10, static_cast<int>(user_data_dir_.value().size())) <<
428 "The user data directory name passed into this test was too " 415 "The user data directory name passed into this test was too "
429 "short to delete safely. Please check the user-data-dir " 416 "short to delete safely. Please check the user-data-dir "
430 "argument and try again."; 417 "argument and try again.";
431 if (clear_profile) 418 if (clear_profile)
432 ASSERT_TRUE(DieFileDie(user_data_dir_, true)); 419 ASSERT_TRUE(file_util::DieFileDie(user_data_dir_, true));
433 420
434 if (!template_user_data_.empty()) { 421 if (!template_user_data_.empty()) {
435 // Recursively copy the template directory to the user_data_dir. 422 // Recursively copy the template directory to the user_data_dir.
436 ASSERT_TRUE(file_util::CopyRecursiveDirNoCache( 423 ASSERT_TRUE(file_util::CopyRecursiveDirNoCache(
437 template_user_data_, 424 template_user_data_,
438 user_data_dir_.ToWStringHack())); 425 user_data_dir_.ToWStringHack()));
439 } 426 }
440 427
441 browser_launch_time_ = TimeTicks::Now(); 428 browser_launch_time_ = TimeTicks::Now();
442 429
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after
969 } 956 }
970 957
971 bool UITest::EvictFileFromSystemCacheWrapper(const FilePath& path) { 958 bool UITest::EvictFileFromSystemCacheWrapper(const FilePath& path) {
972 for (int i = 0; i < 10; i++) { 959 for (int i = 0; i < 10; i++) {
973 if (file_util::EvictFileFromSystemCache(path)) 960 if (file_util::EvictFileFromSystemCache(path))
974 return true; 961 return true;
975 PlatformThread::Sleep(sleep_timeout_ms() / 10); 962 PlatformThread::Sleep(sleep_timeout_ms() / 10);
976 } 963 }
977 return false; 964 return false;
978 } 965 }
OLDNEW
« no previous file with comments | « chrome/test/ui/ui_test.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698