| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <stdint.h> |
| 6 |
| 5 #include <set> | 7 #include <set> |
| 6 | 8 |
| 7 #include "base/files/file.h" | 9 #include "base/files/file.h" |
| 8 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| 9 #include "base/files/file_util.h" | 11 #include "base/files/file_util.h" |
| 10 #include "base/files/scoped_temp_dir.h" | 12 #include "base/files/scoped_temp_dir.h" |
| 13 #include "base/macros.h" |
| 11 #include "storage/browser/fileapi/native_file_util.h" | 14 #include "storage/browser/fileapi/native_file_util.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 13 | 16 |
| 14 using storage::FileSystemFileUtil; | 17 using storage::FileSystemFileUtil; |
| 15 using storage::FileSystemOperation; | 18 using storage::FileSystemOperation; |
| 16 using storage::NativeFileUtil; | 19 using storage::NativeFileUtil; |
| 17 | 20 |
| 18 namespace content { | 21 namespace content { |
| 19 | 22 |
| 20 class NativeFileUtilTest : public testing::Test { | 23 class NativeFileUtilTest : public testing::Test { |
| 21 public: | 24 public: |
| 22 NativeFileUtilTest() {} | 25 NativeFileUtilTest() {} |
| 23 | 26 |
| 24 void SetUp() override { ASSERT_TRUE(data_dir_.CreateUniqueTempDir()); } | 27 void SetUp() override { ASSERT_TRUE(data_dir_.CreateUniqueTempDir()); } |
| 25 | 28 |
| 26 protected: | 29 protected: |
| 27 base::FilePath Path() { | 30 base::FilePath Path() { |
| 28 return data_dir_.path(); | 31 return data_dir_.path(); |
| 29 } | 32 } |
| 30 | 33 |
| 31 base::FilePath Path(const char* file_name) { | 34 base::FilePath Path(const char* file_name) { |
| 32 return data_dir_.path().AppendASCII(file_name); | 35 return data_dir_.path().AppendASCII(file_name); |
| 33 } | 36 } |
| 34 | 37 |
| 35 bool FileExists(const base::FilePath& path) { | 38 bool FileExists(const base::FilePath& path) { |
| 36 return base::PathExists(path) && | 39 return base::PathExists(path) && |
| 37 !base::DirectoryExists(path); | 40 !base::DirectoryExists(path); |
| 38 } | 41 } |
| 39 | 42 |
| 40 int64 GetSize(const base::FilePath& path) { | 43 int64_t GetSize(const base::FilePath& path) { |
| 41 base::File::Info info; | 44 base::File::Info info; |
| 42 base::GetFileInfo(path, &info); | 45 base::GetFileInfo(path, &info); |
| 43 return info.size; | 46 return info.size; |
| 44 } | 47 } |
| 45 | 48 |
| 46 private: | 49 private: |
| 47 base::ScopedTempDir data_dir_; | 50 base::ScopedTempDir data_dir_; |
| 48 | 51 |
| 49 DISALLOW_COPY_AND_ASSIGN(NativeFileUtilTest); | 52 DISALLOW_COPY_AND_ASSIGN(NativeFileUtilTest); |
| 50 }; | 53 }; |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 FileSystemOperation::OPTION_PRESERVE_LAST_MODIFIED, | 401 FileSystemOperation::OPTION_PRESERVE_LAST_MODIFIED, |
| 399 NativeFileUtil::MOVE)); | 402 NativeFileUtil::MOVE)); |
| 400 | 403 |
| 401 ASSERT_TRUE(FileExists(to_file3)); | 404 ASSERT_TRUE(FileExists(to_file3)); |
| 402 ASSERT_EQ(base::File::FILE_OK, | 405 ASSERT_EQ(base::File::FILE_OK, |
| 403 NativeFileUtil::GetFileInfo(to_file2, &file_info2)); | 406 NativeFileUtil::GetFileInfo(to_file2, &file_info2)); |
| 404 EXPECT_EQ(file_info1.last_modified, file_info2.last_modified); | 407 EXPECT_EQ(file_info1.last_modified, file_info2.last_modified); |
| 405 } | 408 } |
| 406 | 409 |
| 407 } // namespace content | 410 } // namespace content |
| OLD | NEW |