summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--base/scoped_temp_dir.h8
-rw-r--r--base/scoped_temp_dir_unittest.cc6
-rw-r--r--chrome/browser/extensions/convert_web_app_unittest.cc4
-rw-r--r--chrome/browser/extensions/extension_websocket_apitest.cc3
-rw-r--r--chrome/browser/extensions/sandboxed_extension_unpacker_unittest.cc8
-rw-r--r--chrome/browser/process_singleton_linux.cc3
-rw-r--r--chrome/browser/process_singleton_mac_unittest.cc3
-rw-r--r--chrome/browser/process_singleton_uitest.cc2
-rw-r--r--chrome/service/service_utility_process_host.cc3
-rw-r--r--chrome/test/automation/automation_proxy_uitest.cc6
-rw-r--r--chrome/test/automation/proxy_launcher.cc3
-rw-r--r--chrome/test/ui_test_utils.cc21
-rw-r--r--chrome/test/ui_test_utils.h12
-rw-r--r--chrome/worker/worker_uitest.cc3
-rw-r--r--webkit/fileapi/file_system_operation_unittest.cc3
-rw-r--r--webkit/fileapi/file_system_path_manager_unittest.cc3
-rw-r--r--webkit/tools/test_shell/simple_database_system.cc2
17 files changed, 60 insertions, 33 deletions
diff --git a/base/scoped_temp_dir.h b/base/scoped_temp_dir.h
index f44bcca8..4286d28 100644
--- a/base/scoped_temp_dir.h
+++ b/base/scoped_temp_dir.h
@@ -28,17 +28,17 @@ class ScopedTempDir {
// Creates a unique directory in TempPath, and takes ownership of it.
// See file_util::CreateNewTemporaryDirectory.
- bool CreateUniqueTempDir();
+ bool CreateUniqueTempDir() WARN_UNUSED_RESULT;
// Creates a unique directory under a given path, and takes ownership of it.
- bool CreateUniqueTempDirUnderPath(const FilePath& path);
+ bool CreateUniqueTempDirUnderPath(const FilePath& path) WARN_UNUSED_RESULT;
// Takes ownership of directory at |path|, creating it if necessary.
// Don't call multiple times unless Take() has been called first.
- bool Set(const FilePath& path);
+ bool Set(const FilePath& path) WARN_UNUSED_RESULT;
// Deletes the temporary directory wrapped by this object.
- bool Delete();
+ bool Delete() WARN_UNUSED_RESULT;
// Caller takes ownership of the temporary directory so it won't be destroyed
// when this object goes out of scope.
diff --git a/base/scoped_temp_dir_unittest.cc b/base/scoped_temp_dir_unittest.cc
index 039a1ed..135c2fd 100644
--- a/base/scoped_temp_dir_unittest.cc
+++ b/base/scoped_temp_dir_unittest.cc
@@ -23,7 +23,7 @@ TEST(ScopedTempDir, FullPath) {
{
ScopedTempDir dir;
- dir.Set(test_path);
+ EXPECT_TRUE(dir.Set(test_path));
// Now the dir doesn't exist, so ensure that it gets created.
EXPECT_TRUE(file_util::DirectoryExists(test_path));
// When we call Release(), it shouldn't get destroyed when leaving scope.
@@ -36,7 +36,7 @@ TEST(ScopedTempDir, FullPath) {
// Clean up.
{
ScopedTempDir dir;
- dir.Set(test_path);
+ EXPECT_TRUE(dir.Set(test_path));
}
EXPECT_FALSE(file_util::DirectoryExists(test_path));
}
@@ -83,7 +83,7 @@ TEST(ScopedTempDir, MultipleInvocations) {
EXPECT_TRUE(dir.CreateUniqueTempDir());
EXPECT_FALSE(dir.CreateUniqueTempDir());
ScopedTempDir other_dir;
- other_dir.Set(dir.Take());
+ EXPECT_TRUE(other_dir.Set(dir.Take()));
EXPECT_TRUE(dir.CreateUniqueTempDir());
EXPECT_FALSE(dir.CreateUniqueTempDir());
EXPECT_FALSE(other_dir.CreateUniqueTempDir());
diff --git a/chrome/browser/extensions/convert_web_app_unittest.cc b/chrome/browser/extensions/convert_web_app_unittest.cc
index eab9b8f..6424ae7 100644
--- a/chrome/browser/extensions/convert_web_app_unittest.cc
+++ b/chrome/browser/extensions/convert_web_app_unittest.cc
@@ -110,7 +110,7 @@ TEST(ExtensionFromWebApp, Basic) {
ASSERT_TRUE(extension.get());
ScopedTempDir extension_dir;
- extension_dir.Set(extension->path());
+ EXPECT_TRUE(extension_dir.Set(extension->path()));
EXPECT_TRUE(extension->is_app());
EXPECT_TRUE(extension->is_hosted_app());
@@ -153,7 +153,7 @@ TEST(ExtensionFromWebApp, Minimal) {
ASSERT_TRUE(extension.get());
ScopedTempDir extension_dir;
- extension_dir.Set(extension->path());
+ EXPECT_TRUE(extension_dir.Set(extension->path()));
EXPECT_TRUE(extension->is_app());
EXPECT_TRUE(extension->is_hosted_app());
diff --git a/chrome/browser/extensions/extension_websocket_apitest.cc b/chrome/browser/extensions/extension_websocket_apitest.cc
index 227a01a..f8cbebc 100644
--- a/chrome/browser/extensions/extension_websocket_apitest.cc
+++ b/chrome/browser/extensions/extension_websocket_apitest.cc
@@ -20,6 +20,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MAYBE_WebSocket) {
PathService::Get(chrome::DIR_TEST_DATA, &websocket_root_dir);
websocket_root_dir = websocket_root_dir.AppendASCII("layout_tests")
.AppendASCII("LayoutTests");
- ui_test_utils::TestWebSocketServer server(websocket_root_dir);
+ ui_test_utils::TestWebSocketServer server;
+ ASSERT_TRUE(server.Start(websocket_root_dir));
ASSERT_TRUE(RunExtensionTest("websocket")) << message_;
}
diff --git a/chrome/browser/extensions/sandboxed_extension_unpacker_unittest.cc b/chrome/browser/extensions/sandboxed_extension_unpacker_unittest.cc
index 19cd379..6246a6f 100644
--- a/chrome/browser/extensions/sandboxed_extension_unpacker_unittest.cc
+++ b/chrome/browser/extensions/sandboxed_extension_unpacker_unittest.cc
@@ -100,16 +100,18 @@ class SandboxedExtensionUnpackerTest : public testing::Test {
// Hack since SandboxedExtensionUnpacker gets its background thread id from
// the Start call, but we don't call it here.
sandboxed_unpacker_->thread_identifier_ = BrowserThread::FILE;
- PrepareUnpackerEnv();
+ EXPECT_TRUE(PrepareUnpackerEnv());
}
- void PrepareUnpackerEnv() {
+ bool PrepareUnpackerEnv() {
sandboxed_unpacker_->extension_root_ =
install_dir_.AppendASCII(extension_filenames::kTempExtensionName);
- sandboxed_unpacker_->temp_dir_.Set(install_dir_);
+ if (!sandboxed_unpacker_->temp_dir_.Set(install_dir_))
+ return false;
sandboxed_unpacker_->public_key_ =
"ocnapchkplbmjmpfehjocmjnipfmogkh";
+ return true;
}
void OnUnpackSucceeded() {
diff --git a/chrome/browser/process_singleton_linux.cc b/chrome/browser/process_singleton_linux.cc
index 982f370..7c7cb47 100644
--- a/chrome/browser/process_singleton_linux.cc
+++ b/chrome/browser/process_singleton_linux.cc
@@ -951,7 +951,8 @@ bool ProcessSingleton::Create() {
// We've already locked things, so we can't have lost the startup race,
// but something doesn't like us.
LOG(ERROR) << "Failed to create symlinks.";
- socket_dir_.Delete();
+ if (!socket_dir_.Delete())
+ LOG(ERROR) << "Encountered a problem when deleting socket directory.";
return false;
}
diff --git a/chrome/browser/process_singleton_mac_unittest.cc b/chrome/browser/process_singleton_mac_unittest.cc
index bdbeff6..978f6f9 100644
--- a/chrome/browser/process_singleton_mac_unittest.cc
+++ b/chrome/browser/process_singleton_mac_unittest.cc
@@ -25,8 +25,7 @@ class ProcessSingletonMacTest : public PlatformTest {
// Put the lock in a temporary directory. Doesn't need to be a
// full profile to test this code.
- temp_dir_.CreateUniqueTempDir();
- ASSERT_TRUE(temp_dir_.IsValid());
+ ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
lock_path_ = temp_dir_.path().Append(chrome::kSingletonLockFilename);
}
diff --git a/chrome/browser/process_singleton_uitest.cc b/chrome/browser/process_singleton_uitest.cc
index 235f181..38a0e48 100644
--- a/chrome/browser/process_singleton_uitest.cc
+++ b/chrome/browser/process_singleton_uitest.cc
@@ -136,7 +136,7 @@ class ProcessSingletonTest : public UITest {
// We use a manual reset so that all threads wake up at once when signaled
// and thus we must manually reset it for each attempt.
: threads_waker_(true /* manual */, false /* signaled */) {
- temp_profile_dir_.CreateUniqueTempDir();
+ EXPECT_TRUE(temp_profile_dir_.CreateUniqueTempDir());
}
void SetUp() {
diff --git a/chrome/service/service_utility_process_host.cc b/chrome/service/service_utility_process_host.cc
index f531169..07ba931 100644
--- a/chrome/service/service_utility_process_host.cc
+++ b/chrome/service/service_utility_process_host.cc
@@ -198,7 +198,8 @@ void ServiceUtilityProcessHost::Client::MetafileAvailable(
// The metafile was created in a temp folder which needs to get deleted after
// we have processed it.
ScopedTempDir scratch_metafile_dir;
- scratch_metafile_dir.Set(metafile_path.DirName());
+ if (!scratch_metafile_dir.Set(metafile_path.DirName()))
+ LOG(WARNING) << "Unable to set scratch metafile directory";
#if defined(OS_WIN)
printing::NativeMetafile metafile;
if (!metafile.CreateFromFile(metafile_path)) {
diff --git a/chrome/test/automation/automation_proxy_uitest.cc b/chrome/test/automation/automation_proxy_uitest.cc
index cbf3e13..7796679 100644
--- a/chrome/test/automation/automation_proxy_uitest.cc
+++ b/chrome/test/automation/automation_proxy_uitest.cc
@@ -1575,8 +1575,10 @@ class AutomationProxySnapshotTest : public UITest {
protected:
AutomationProxySnapshotTest() {
dom_automation_enabled_ = true;
- snapshot_dir_.CreateUniqueTempDir();
- snapshot_path_ = snapshot_dir_.path().AppendASCII("snapshot.png");
+ if (!snapshot_dir_.CreateUniqueTempDir())
+ ADD_FAILURE() << "Unable to create temporary directory";
+ else
+ snapshot_path_ = snapshot_dir_.path().AppendASCII("snapshot.png");
}
// Asserts that the given png file can be read and decoded into the given
diff --git a/chrome/test/automation/proxy_launcher.cc b/chrome/test/automation/proxy_launcher.cc
index d30f212..028849d 100644
--- a/chrome/test/automation/proxy_launcher.cc
+++ b/chrome/test/automation/proxy_launcher.cc
@@ -161,7 +161,8 @@ void ProxyLauncher::CloseBrowserAndServer(ShutdownType shutdown_type) {
void ProxyLauncher::LaunchBrowser(const LaunchState& state) {
if (state.clear_profile || !temp_profile_dir_.IsValid()) {
- temp_profile_dir_.Delete();
+ if (temp_profile_dir_.IsValid())
+ ASSERT_TRUE(temp_profile_dir_.Delete());
ASSERT_TRUE(temp_profile_dir_.CreateUniqueTempDir());
ASSERT_TRUE(test_launcher_utils::OverrideUserDataDir(user_data_dir()));
diff --git a/chrome/test/ui_test_utils.cc b/chrome/test/ui_test_utils.cc
index c0113707..0618011 100644
--- a/chrome/test/ui_test_utils.cc
+++ b/chrome/test/ui_test_utils.cc
@@ -799,17 +799,30 @@ void AppendToPythonPath(const FilePath& dir) {
} // anonymous namespace
-TestWebSocketServer::TestWebSocketServer(const FilePath& root_directory) {
+TestWebSocketServer::TestWebSocketServer() : started_(false) {
+}
+
+bool TestWebSocketServer::Start(const FilePath& root_directory) {
+ if (started_)
+ return true;
scoped_ptr<CommandLine> cmd_line(CreateWebSocketServerCommandLine());
cmd_line->AppendSwitchASCII("server", "start");
cmd_line->AppendSwitch("chromium");
cmd_line->AppendSwitch("register_cygwin");
cmd_line->AppendSwitchPath("root", root_directory);
- temp_dir_.CreateUniqueTempDir();
+ if (!temp_dir_.CreateUniqueTempDir()) {
+ LOG(ERROR) << "Unable to create a temporary directory.";
+ return false;
+ }
websocket_pid_file_ = temp_dir_.path().AppendASCII("websocket.pid");
cmd_line->AppendSwitchPath("pidfile", websocket_pid_file_);
SetPythonPath();
- base::LaunchApp(*cmd_line.get(), true, false, NULL);
+ if (!base::LaunchApp(*cmd_line.get(), true, false, NULL)) {
+ LOG(ERROR) << "Unable to launch websocket server.";
+ return false;
+ }
+ started_ = true;
+ return true;
}
CommandLine* TestWebSocketServer::CreatePythonCommandLine() {
@@ -846,6 +859,8 @@ CommandLine* TestWebSocketServer::CreateWebSocketServerCommandLine() {
}
TestWebSocketServer::~TestWebSocketServer() {
+ if (!started_)
+ return;
scoped_ptr<CommandLine> cmd_line(CreateWebSocketServerCommandLine());
cmd_line->AppendSwitchASCII("server", "stop");
cmd_line->AppendSwitch("chromium");
diff --git a/chrome/test/ui_test_utils.h b/chrome/test/ui_test_utils.h
index 4902396..a0deb1c 100644
--- a/chrome/test/ui_test_utils.h
+++ b/chrome/test/ui_test_utils.h
@@ -321,12 +321,15 @@ class TimedMessageLoopRunner {
// server.
class TestWebSocketServer {
public:
- // Creates and starts a python websocket server with |root_directory|.
- explicit TestWebSocketServer(const FilePath& root_directory);
+ TestWebSocketServer();
- // Destroys and stops the server.
+ // Stops the python websocket server if it was already started.
~TestWebSocketServer();
+ // Starts the python websocket server using |root_directory|. Returns whether
+ // the server was successfully started.
+ bool Start(const FilePath& root_directory);
+
private:
// Sets up PYTHONPATH to run websocket_server.py.
void SetPythonPath();
@@ -337,6 +340,9 @@ class TestWebSocketServer {
// Creates a CommandLine for invoking the python websocker server.
CommandLine* CreateWebSocketServerCommandLine();
+ // Has the server been started?
+ bool started_;
+
// A Scoped temporary directory for holding the python pid file.
ScopedTempDir temp_dir_;
diff --git a/chrome/worker/worker_uitest.cc b/chrome/worker/worker_uitest.cc
index 058ced8..3abfa8c 100644
--- a/chrome/worker/worker_uitest.cc
+++ b/chrome/worker/worker_uitest.cc
@@ -468,7 +468,8 @@ TEST_F(WorkerTest, WorkerWebSocketLayoutTests) {
FilePath websocket_root_dir(temp_test_dir_);
websocket_root_dir = websocket_root_dir.AppendASCII("LayoutTests");
- ui_test_utils::TestWebSocketServer websocket_server(websocket_root_dir);
+ ui_test_utils::TestWebSocketServer websocket_server;
+ ASSERT_TRUE(websocket_server.Start(websocket_root_dir));
StartHttpServer(new_http_root_dir_);
for (size_t i = 0; i < arraysize(kLayoutTestFiles); ++i)
diff --git a/webkit/fileapi/file_system_operation_unittest.cc b/webkit/fileapi/file_system_operation_unittest.cc
index dffcc33..7917d31 100644
--- a/webkit/fileapi/file_system_operation_unittest.cc
+++ b/webkit/fileapi/file_system_operation_unittest.cc
@@ -27,8 +27,7 @@ class FileSystemOperationTest : public testing::Test {
public:
FileSystemOperationTest()
: status_(kFileOperationStatusNotSet) {
- base_.CreateUniqueTempDir();
- EXPECT_TRUE(base_.IsValid());
+ EXPECT_TRUE(base_.CreateUniqueTempDir());
}
FileSystemOperation* operation();
diff --git a/webkit/fileapi/file_system_path_manager_unittest.cc b/webkit/fileapi/file_system_path_manager_unittest.cc
index 7fa3672..2201215c 100644
--- a/webkit/fileapi/file_system_path_manager_unittest.cc
+++ b/webkit/fileapi/file_system_path_manager_unittest.cc
@@ -165,8 +165,7 @@ class FileSystemPathManagerTest : public testing::Test {
void SetUp() {
data_dir_.reset(new ScopedTempDir);
- data_dir_->CreateUniqueTempDir();
- ASSERT_TRUE(data_dir_->IsValid());
+ ASSERT_TRUE(data_dir_->CreateUniqueTempDir());
root_path_callback_status_ = false;
root_path_.clear();
file_system_name_.clear();
diff --git a/webkit/tools/test_shell/simple_database_system.cc b/webkit/tools/test_shell/simple_database_system.cc
index 4c591e6..29b78f1 100644
--- a/webkit/tools/test_shell/simple_database_system.cc
+++ b/webkit/tools/test_shell/simple_database_system.cc
@@ -28,7 +28,7 @@ SimpleDatabaseSystem* SimpleDatabaseSystem::GetInstance() {
SimpleDatabaseSystem::SimpleDatabaseSystem()
: waiting_for_dbs_to_close_(false) {
- temp_dir_.CreateUniqueTempDir();
+ CHECK(temp_dir_.CreateUniqueTempDir());
db_tracker_ = new DatabaseTracker(temp_dir_.path(), false);
db_tracker_->AddObserver(this);
DCHECK(!instance_);