| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "components/drive/chromeos/file_system/touch_operation.h" | 5 #include "components/drive/chromeos/file_system/touch_operation.h" |
| 6 | 6 |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/time/time.h" | 8 #include "base/time/time.h" |
| 9 #include "components/drive/chromeos/resource_metadata.h" | 9 #include "components/drive/chromeos/resource_metadata.h" |
| 10 #include "components/drive/drive.pb.h" | 10 #include "components/drive/drive.pb.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 | 25 |
| 26 const base::FilePath kTestPath(FILE_PATH_LITERAL("drive/root/File 1.txt")); | 26 const base::FilePath kTestPath(FILE_PATH_LITERAL("drive/root/File 1.txt")); |
| 27 const base::Time::Exploded kLastAccessTime = { | 27 const base::Time::Exploded kLastAccessTime = { |
| 28 2012, 7, 0, 19, 15, 59, 13, 123 | 28 2012, 7, 0, 19, 15, 59, 13, 123 |
| 29 }; | 29 }; |
| 30 const base::Time::Exploded kLastModifiedTime = { | 30 const base::Time::Exploded kLastModifiedTime = { |
| 31 2013, 7, 0, 19, 15, 59, 13, 123 | 31 2013, 7, 0, 19, 15, 59, 13, 123 |
| 32 }; | 32 }; |
| 33 | 33 |
| 34 FileError error = FILE_ERROR_FAILED; | 34 FileError error = FILE_ERROR_FAILED; |
| 35 operation.TouchFile( | 35 base::Time last_access_time_utc; |
| 36 kTestPath, | 36 base::Time last_modified_time_utc; |
| 37 base::Time::FromUTCExploded(kLastAccessTime), | 37 EXPECT_TRUE( |
| 38 base::Time::FromUTCExploded(kLastModifiedTime), | 38 base::Time::FromUTCExploded(kLastAccessTime, &last_access_time_utc)); |
| 39 google_apis::test_util::CreateCopyResultCallback(&error)); | 39 EXPECT_TRUE( |
| 40 base::Time::FromUTCExploded(kLastModifiedTime, &last_modified_time_utc)); |
| 41 operation.TouchFile(kTestPath, last_access_time_utc, last_modified_time_utc, |
| 42 google_apis::test_util::CreateCopyResultCallback(&error)); |
| 40 content::RunAllBlockingPoolTasksUntilIdle(); | 43 content::RunAllBlockingPoolTasksUntilIdle(); |
| 41 EXPECT_EQ(FILE_ERROR_OK, error); | 44 EXPECT_EQ(FILE_ERROR_OK, error); |
| 42 | 45 |
| 43 ResourceEntry entry; | 46 ResourceEntry entry; |
| 44 EXPECT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(kTestPath, &entry)); | 47 EXPECT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(kTestPath, &entry)); |
| 45 EXPECT_EQ(base::Time::FromUTCExploded(kLastAccessTime), | 48 EXPECT_EQ(last_access_time_utc, |
| 46 base::Time::FromInternalValue(entry.file_info().last_accessed())); | 49 base::Time::FromInternalValue(entry.file_info().last_accessed())); |
| 47 EXPECT_EQ(base::Time::FromUTCExploded(kLastModifiedTime), | 50 EXPECT_EQ(last_modified_time_utc, |
| 48 base::Time::FromInternalValue(entry.file_info().last_modified())); | 51 base::Time::FromInternalValue(entry.file_info().last_modified())); |
| 49 EXPECT_EQ(ResourceEntry::DIRTY, entry.metadata_edit_state()); | 52 EXPECT_EQ(ResourceEntry::DIRTY, entry.metadata_edit_state()); |
| 50 | 53 |
| 51 EXPECT_EQ(1U, delegate()->get_changed_files().size()); | 54 EXPECT_EQ(1U, delegate()->get_changed_files().size()); |
| 52 EXPECT_TRUE(delegate()->get_changed_files().count(kTestPath)); | 55 EXPECT_TRUE(delegate()->get_changed_files().count(kTestPath)); |
| 53 | 56 |
| 54 EXPECT_EQ(1U, delegate()->updated_local_ids().size()); | 57 EXPECT_EQ(1U, delegate()->updated_local_ids().size()); |
| 55 EXPECT_TRUE(delegate()->updated_local_ids().count(entry.local_id())); | 58 EXPECT_TRUE(delegate()->updated_local_ids().count(entry.local_id())); |
| 56 } | 59 } |
| 57 | 60 |
| 58 } // namespace file_system | 61 } // namespace file_system |
| 59 } // namespace drive | 62 } // namespace drive |
| OLD | NEW |