| 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" |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 return was_successful_write_observed; | 81 return was_successful_write_observed; |
| 82 } | 82 } |
| 83 | 83 |
| 84 } // namespace | 84 } // namespace |
| 85 | 85 |
| 86 class ImportantFileWriterTest : public testing::Test { | 86 class ImportantFileWriterTest : public testing::Test { |
| 87 public: | 87 public: |
| 88 ImportantFileWriterTest() { } | 88 ImportantFileWriterTest() { } |
| 89 void SetUp() override { | 89 void SetUp() override { |
| 90 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 90 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 91 file_ = temp_dir_.path().AppendASCII("test-file"); | 91 file_ = temp_dir_.GetPath().AppendASCII("test-file"); |
| 92 } | 92 } |
| 93 | 93 |
| 94 protected: | 94 protected: |
| 95 SuccessfulWriteObserver successful_write_observer_; | 95 SuccessfulWriteObserver successful_write_observer_; |
| 96 FilePath file_; | 96 FilePath file_; |
| 97 MessageLoop loop_; | 97 MessageLoop loop_; |
| 98 | 98 |
| 99 private: | 99 private: |
| 100 ScopedTempDir temp_dir_; | 100 ScopedTempDir temp_dir_; |
| 101 }; | 101 }; |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 writer.ScheduleWrite(&baz); | 189 writer.ScheduleWrite(&baz); |
| 190 ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 190 ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 191 FROM_HERE, MessageLoop::QuitWhenIdleClosure(), | 191 FROM_HERE, MessageLoop::QuitWhenIdleClosure(), |
| 192 TimeDelta::FromMilliseconds(100)); | 192 TimeDelta::FromMilliseconds(100)); |
| 193 RunLoop().Run(); | 193 RunLoop().Run(); |
| 194 ASSERT_TRUE(PathExists(writer.path())); | 194 ASSERT_TRUE(PathExists(writer.path())); |
| 195 EXPECT_EQ("baz", GetFileContent(writer.path())); | 195 EXPECT_EQ("baz", GetFileContent(writer.path())); |
| 196 } | 196 } |
| 197 | 197 |
| 198 } // namespace base | 198 } // namespace base |
| OLD | NEW |