OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/files/important_file_writer.h" | 5 #include "base/files/important_file_writer.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
11 #include "base/files/scoped_temp_dir.h" | 11 #include "base/files/scoped_temp_dir.h" |
12 #include "base/location.h" | 12 #include "base/location.h" |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "base/run_loop.h" | 14 #include "base/run_loop.h" |
15 #include "base/single_thread_task_runner.h" | 15 #include "base/single_thread_task_runner.h" |
16 #include "base/thread_task_runner_handle.h" | 16 #include "base/thread_task_runner_handle.h" |
17 #include "base/threading/thread.h" | 17 #include "base/threading/thread.h" |
18 #include "base/time/time.h" | 18 #include "base/time/time.h" |
19 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/googletest/include/gtest/gtest.h" |
20 | 20 |
21 namespace base { | 21 namespace base { |
22 | 22 |
23 namespace { | 23 namespace { |
24 | 24 |
25 std::string GetFileContent(const FilePath& path) { | 25 std::string GetFileContent(const FilePath& path) { |
26 std::string content; | 26 std::string content; |
27 if (!ReadFileToString(path, &content)) { | 27 if (!ReadFileToString(path, &content)) { |
28 NOTREACHED(); | 28 NOTREACHED(); |
29 } | 29 } |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 writer.ScheduleWrite(&baz); | 187 writer.ScheduleWrite(&baz); |
188 ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 188 ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
189 FROM_HERE, MessageLoop::QuitWhenIdleClosure(), | 189 FROM_HERE, MessageLoop::QuitWhenIdleClosure(), |
190 TimeDelta::FromMilliseconds(100)); | 190 TimeDelta::FromMilliseconds(100)); |
191 MessageLoop::current()->Run(); | 191 MessageLoop::current()->Run(); |
192 ASSERT_TRUE(PathExists(writer.path())); | 192 ASSERT_TRUE(PathExists(writer.path())); |
193 EXPECT_EQ("baz", GetFileContent(writer.path())); | 193 EXPECT_EQ("baz", GetFileContent(writer.path())); |
194 } | 194 } |
195 | 195 |
196 } // namespace base | 196 } // namespace base |
OLD | NEW |