diff options
author | viettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-23 23:21:41 +0000 |
---|---|---|
committer | viettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-23 23:21:41 +0000 |
commit | 61539616259c0c7719a4024eaea49f06377c0a72 (patch) | |
tree | 9c90d4f22de4cdeac5af45ed5f0c5a7641392a3e | |
parent | 657bde3c11047cb781c56f11585073fd872d15b7 (diff) | |
download | chromium_src-61539616259c0c7719a4024eaea49f06377c0a72.zip chromium_src-61539616259c0c7719a4024eaea49f06377c0a72.tar.gz chromium_src-61539616259c0c7719a4024eaea49f06377c0a72.tar.bz2 |
Mojo: Delete temporary files created in tests.
Because apparently things aren't smart enough to do this automatically.
R=yzshen@chromium.org
Review URL: https://codereview.chromium.org/350033002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@279223 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | mojo/embedder/platform_channel_pair_posix_unittest.cc | 17 | ||||
-rw-r--r-- | mojo/system/multiprocess_message_pipe_unittest.cc | 7 | ||||
-rw-r--r-- | mojo/system/platform_handle_dispatcher_unittest.cc | 13 | ||||
-rw-r--r-- | mojo/system/remote_message_pipe_unittest.cc | 7 |
4 files changed, 36 insertions, 8 deletions
diff --git a/mojo/embedder/platform_channel_pair_posix_unittest.cc b/mojo/embedder/platform_channel_pair_posix_unittest.cc index 6568e7a..02f1900 100644 --- a/mojo/embedder/platform_channel_pair_posix_unittest.cc +++ b/mojo/embedder/platform_channel_pair_posix_unittest.cc @@ -18,6 +18,7 @@ #include "base/file_util.h" #include "base/files/file_path.h" #include "base/files/scoped_file.h" +#include "base/files/scoped_temp_dir.h" #include "base/logging.h" #include "base/macros.h" #include "mojo/common/test/test_utils.h" @@ -129,6 +130,9 @@ TEST_F(PlatformChannelPairPosixTest, SendReceiveData) { } TEST_F(PlatformChannelPairPosixTest, SendReceiveFDs) { + base::ScopedTempDir temp_dir; + ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); + static const char kHello[] = "hello"; PlatformChannelPair channel_pair; @@ -139,8 +143,9 @@ TEST_F(PlatformChannelPairPosixTest, SendReceiveFDs) { // Make |i| files, with the j-th file consisting of j copies of the digit i. PlatformHandleVector platform_handles; for (size_t j = 1; j <= i; j++) { - base::FilePath ignored; - base::ScopedFILE fp(base::CreateAndOpenTemporaryFile(&ignored)); + base::FilePath unused; + base::ScopedFILE fp( + base::CreateAndOpenTemporaryFileInDir(temp_dir.path(), &unused)); ASSERT_TRUE(fp); fwrite(std::string(j, '0' + i).data(), 1, j, fp.get()); platform_handles.push_back( @@ -182,6 +187,9 @@ TEST_F(PlatformChannelPairPosixTest, SendReceiveFDs) { } TEST_F(PlatformChannelPairPosixTest, AppendReceivedFDs) { + base::ScopedTempDir temp_dir; + ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); + static const char kHello[] = "hello"; PlatformChannelPair channel_pair; @@ -191,8 +199,9 @@ TEST_F(PlatformChannelPairPosixTest, AppendReceivedFDs) { const std::string file_contents("hello world"); { - base::FilePath ignored; - base::ScopedFILE fp(base::CreateAndOpenTemporaryFile(&ignored)); + base::FilePath unused; + base::ScopedFILE fp(base::CreateAndOpenTemporaryFileInDir(temp_dir.path(), + &unused)); ASSERT_TRUE(fp); fwrite(file_contents.data(), 1, file_contents.size(), fp.get()); PlatformHandleVector platform_handles; diff --git a/mojo/system/multiprocess_message_pipe_unittest.cc b/mojo/system/multiprocess_message_pipe_unittest.cc index 5552778..c3305c1 100644 --- a/mojo/system/multiprocess_message_pipe_unittest.cc +++ b/mojo/system/multiprocess_message_pipe_unittest.cc @@ -13,6 +13,7 @@ #include "base/file_util.h" #include "base/files/file_path.h" #include "base/files/scoped_file.h" +#include "base/files/scoped_temp_dir.h" #include "base/location.h" #include "base/logging.h" #include "base/macros.h" @@ -504,6 +505,9 @@ MOJO_MULTIPROCESS_TEST_CHILD_MAIN(CheckPlatformHandleFile) { #define MAYBE_PlatformHandlePassing DISABLED_PlatformHandlePassing #endif TEST_F(MultiprocessMessagePipeTest, MAYBE_PlatformHandlePassing) { + base::ScopedTempDir temp_dir; + ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); + helper()->StartChild("CheckPlatformHandleFile"); scoped_refptr<MessagePipe> mp(new MessagePipe( @@ -512,7 +516,8 @@ TEST_F(MultiprocessMessagePipeTest, MAYBE_PlatformHandlePassing) { Init(mp); base::FilePath unused; - base::ScopedFILE fp(CreateAndOpenTemporaryFile(&unused)); + base::ScopedFILE fp(CreateAndOpenTemporaryFileInDir(temp_dir.path(), + &unused)); const std::string world("world"); ASSERT_EQ(fwrite(&world[0], 1, world.size(), fp.get()), world.size()); fflush(fp.get()); diff --git a/mojo/system/platform_handle_dispatcher_unittest.cc b/mojo/system/platform_handle_dispatcher_unittest.cc index 5c22f55..7ff7d10 100644 --- a/mojo/system/platform_handle_dispatcher_unittest.cc +++ b/mojo/system/platform_handle_dispatcher_unittest.cc @@ -9,6 +9,7 @@ #include "base/file_util.h" #include "base/files/file_path.h" #include "base/files/scoped_file.h" +#include "base/files/scoped_temp_dir.h" #include "base/memory/ref_counted.h" #include "mojo/common/test/test_utils.h" #include "testing/gtest/include/gtest/gtest.h" @@ -18,10 +19,14 @@ namespace system { namespace { TEST(PlatformHandleDispatcherTest, Basic) { + base::ScopedTempDir temp_dir; + ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); + static const char kHelloWorld[] = "hello world"; base::FilePath unused; - base::ScopedFILE fp(CreateAndOpenTemporaryFile(&unused)); + base::ScopedFILE fp(CreateAndOpenTemporaryFileInDir(temp_dir.path(), + &unused)); ASSERT_TRUE(fp); EXPECT_EQ(sizeof(kHelloWorld), fwrite(kHelloWorld, 1, sizeof(kHelloWorld), fp.get())); @@ -57,10 +62,14 @@ TEST(PlatformHandleDispatcherTest, Basic) { } TEST(PlatformHandleDispatcherTest, CreateEquivalentDispatcherAndClose) { + base::ScopedTempDir temp_dir; + ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); + static const char kFooBar[] = "foo bar"; base::FilePath unused; - base::ScopedFILE fp(CreateAndOpenTemporaryFile(&unused)); + base::ScopedFILE fp(CreateAndOpenTemporaryFileInDir(temp_dir.path(), + &unused)); EXPECT_EQ(sizeof(kFooBar), fwrite(kFooBar, 1, sizeof(kFooBar), fp.get())); scoped_refptr<PlatformHandleDispatcher> dispatcher( diff --git a/mojo/system/remote_message_pipe_unittest.cc b/mojo/system/remote_message_pipe_unittest.cc index e1f5557..12530c3 100644 --- a/mojo/system/remote_message_pipe_unittest.cc +++ b/mojo/system/remote_message_pipe_unittest.cc @@ -13,6 +13,7 @@ #include "base/file_util.h" #include "base/files/file_path.h" #include "base/files/scoped_file.h" +#include "base/files/scoped_temp_dir.h" #include "base/location.h" #include "base/logging.h" #include "base/message_loop/message_loop.h" @@ -706,6 +707,9 @@ TEST_F(RemoteMessagePipeTest, MAYBE_SharedBufferPassing) { #define MAYBE_PlatformHandlePassing DISABLED_PlatformHandlePassing #endif TEST_F(RemoteMessagePipeTest, MAYBE_PlatformHandlePassing) { + base::ScopedTempDir temp_dir; + ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); + static const char kHello[] = "hello"; static const char kWorld[] = "world"; Waiter waiter; @@ -720,7 +724,8 @@ TEST_F(RemoteMessagePipeTest, MAYBE_PlatformHandlePassing) { ConnectMessagePipes(mp0, mp1); base::FilePath unused; - base::ScopedFILE fp(CreateAndOpenTemporaryFile(&unused)); + base::ScopedFILE fp(CreateAndOpenTemporaryFileInDir(temp_dir.path(), + &unused)); EXPECT_EQ(sizeof(kHello), fwrite(kHello, 1, sizeof(kHello), fp.get())); // We'll try to pass this dispatcher, which will cause a |PlatformHandle| to // be passed. |