diff options
author | levin@chromium.org <levin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-28 01:54:15 +0000 |
---|---|---|
committer | levin@chromium.org <levin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-28 01:54:15 +0000 |
commit | 3b63f8f451afcf414a59c529f627c620e4d449d9 (patch) | |
tree | 2dcbab1c060b29a260c29bb19b67bf97a8293ca3 /base/scoped_temp_dir_unittest.cc | |
parent | 9174a108509c2aafe513da68e6e63fbc7df38c85 (diff) | |
download | chromium_src-3b63f8f451afcf414a59c529f627c620e4d449d9.zip chromium_src-3b63f8f451afcf414a59c529f627c620e4d449d9.tar.gz chromium_src-3b63f8f451afcf414a59c529f627c620e4d449d9.tar.bz2 |
Move some files from base to base/memory.
raw_scoped_refptr_mismatch_checker.h
ref_counted.cc
ref_counted.h
ref_counted_memory.cc
ref_counted_memory.h
ref_counted_unittest.cc
scoped_callback_factory.h
scoped_comptr_win.h
scoped_handle.h
scoped_native_library.cc
scoped_native_library.h
scoped_native_library_unittest.cc
scoped_nsobject.h
scoped_open_process.h
scoped_ptr.h
scoped_ptr_unittest.cc
scoped_temp_dir.cc
scoped_temp_dir.h
scoped_temp_dir_unittest.cc
scoped_vector.h
singleton.h
singleton_objc.h
singleton_unittest.cc
linked_ptr.h
linked_ptr_unittest.cc
weak_ptr.cc
weak_ptr.h
weak_ptr_unittest.cc
BUG=None
TEST=Compile
Review URL: http://codereview.chromium.org/6714032
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@79524 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/scoped_temp_dir_unittest.cc')
-rw-r--r-- | base/scoped_temp_dir_unittest.cc | 110 |
1 files changed, 0 insertions, 110 deletions
diff --git a/base/scoped_temp_dir_unittest.cc b/base/scoped_temp_dir_unittest.cc deleted file mode 100644 index 135c2fd..0000000 --- a/base/scoped_temp_dir_unittest.cc +++ /dev/null @@ -1,110 +0,0 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "base/file_util.h" -#include "base/platform_file.h" -#include "base/scoped_temp_dir.h" -#include "testing/gtest/include/gtest/gtest.h" - -TEST(ScopedTempDir, FullPath) { - FilePath test_path; - file_util::CreateNewTempDirectory(FILE_PATH_LITERAL("scoped_temp_dir"), - &test_path); - - // Against an existing dir, it should get destroyed when leaving scope. - EXPECT_TRUE(file_util::DirectoryExists(test_path)); - { - ScopedTempDir dir; - EXPECT_TRUE(dir.Set(test_path)); - EXPECT_TRUE(dir.IsValid()); - } - EXPECT_FALSE(file_util::DirectoryExists(test_path)); - - { - ScopedTempDir dir; - 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. - FilePath path = dir.Take(); - EXPECT_EQ(path.value(), test_path.value()); - EXPECT_FALSE(dir.IsValid()); - } - EXPECT_TRUE(file_util::DirectoryExists(test_path)); - - // Clean up. - { - ScopedTempDir dir; - EXPECT_TRUE(dir.Set(test_path)); - } - EXPECT_FALSE(file_util::DirectoryExists(test_path)); -} - -TEST(ScopedTempDir, TempDir) { - // In this case, just verify that a directory was created and that it's a - // child of TempDir. - FilePath test_path; - { - ScopedTempDir dir; - EXPECT_TRUE(dir.CreateUniqueTempDir()); - test_path = dir.path(); - EXPECT_TRUE(file_util::DirectoryExists(test_path)); - FilePath tmp_dir; - EXPECT_TRUE(file_util::GetTempDir(&tmp_dir)); - EXPECT_TRUE(test_path.value().find(tmp_dir.value()) != std::string::npos); - } - EXPECT_FALSE(file_util::DirectoryExists(test_path)); -} - -TEST(ScopedTempDir, UniqueTempDirUnderPath) { - // Create a path which will contain a unique temp path. - FilePath base_path; - file_util::CreateNewTempDirectory(FILE_PATH_LITERAL("base_dir"), - &base_path); - - FilePath test_path; - { - ScopedTempDir dir; - EXPECT_TRUE(dir.CreateUniqueTempDirUnderPath(base_path)); - test_path = dir.path(); - EXPECT_TRUE(file_util::DirectoryExists(test_path)); - EXPECT_TRUE(base_path.IsParent(test_path)); - EXPECT_TRUE(test_path.value().find(base_path.value()) != std::string::npos); - } - EXPECT_FALSE(file_util::DirectoryExists(test_path)); -} - -TEST(ScopedTempDir, MultipleInvocations) { - ScopedTempDir dir; - EXPECT_TRUE(dir.CreateUniqueTempDir()); - EXPECT_FALSE(dir.CreateUniqueTempDir()); - EXPECT_TRUE(dir.Delete()); - EXPECT_TRUE(dir.CreateUniqueTempDir()); - EXPECT_FALSE(dir.CreateUniqueTempDir()); - ScopedTempDir other_dir; - EXPECT_TRUE(other_dir.Set(dir.Take())); - EXPECT_TRUE(dir.CreateUniqueTempDir()); - EXPECT_FALSE(dir.CreateUniqueTempDir()); - EXPECT_FALSE(other_dir.CreateUniqueTempDir()); -} - -#if defined(OS_WIN) -TEST(ScopedTempDir, LockedTempDir) { - ScopedTempDir dir; - EXPECT_TRUE(dir.CreateUniqueTempDir()); - int file_flags = base::PLATFORM_FILE_CREATE_ALWAYS | - base::PLATFORM_FILE_WRITE; - base::PlatformFileError error_code = base::PLATFORM_FILE_OK; - FilePath file_path(dir.path().Append(FILE_PATH_LITERAL("temp"))); - base::PlatformFile file = base::CreatePlatformFile(file_path, file_flags, - NULL, &error_code); - EXPECT_NE(base::kInvalidPlatformFileValue, file); - EXPECT_EQ(base::PLATFORM_FILE_OK, error_code); - EXPECT_FALSE(dir.Delete()); // We should not be able to delete. - EXPECT_FALSE(dir.path().empty()); // We should still have a valid path. - EXPECT_TRUE(base::ClosePlatformFile(file)); - // Now, we should be able to delete. - EXPECT_TRUE(dir.Delete()); -} -#endif // defined(OS_WIN) |