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 "chrome/browser/chromeos/drive/file_system/touch_operation.h" | 5 #include "chrome/browser/chromeos/drive/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 "chrome/browser/chromeos/drive/drive.pb.h" | 9 #include "chrome/browser/chromeos/drive/drive.pb.h" |
10 #include "chrome/browser/chromeos/drive/file_errors.h" | 10 #include "chrome/browser/chromeos/drive/file_errors.h" |
11 #include "chrome/browser/chromeos/drive/file_system/operation_test_base.h" | 11 #include "chrome/browser/chromeos/drive/file_system/operation_test_base.h" |
12 #include "chrome/browser/chromeos/drive/resource_metadata.h" | 12 #include "chrome/browser/chromeos/drive/resource_metadata.h" |
13 #include "content/public/test/test_utils.h" | 13 #include "content/public/test/test_utils.h" |
14 #include "google_apis/drive/test_util.h" | 14 #include "google_apis/drive/test_util.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
16 | 16 |
17 namespace drive { | 17 namespace drive { |
18 namespace file_system { | 18 namespace file_system { |
19 | 19 |
20 typedef OperationTestBase TouchOperationTest; | 20 typedef OperationTestBase TouchOperationTest; |
21 | 21 |
22 TEST_F(TouchOperationTest, TouchFile) { | 22 TEST_F(TouchOperationTest, TouchFile) { |
23 TouchOperation operation(blocking_task_runner(), | 23 TouchOperation operation(blocking_task_runner(), |
24 observer(), | 24 delegate(), |
25 metadata()); | 25 metadata()); |
26 | 26 |
27 const base::FilePath kTestPath(FILE_PATH_LITERAL("drive/root/File 1.txt")); | 27 const base::FilePath kTestPath(FILE_PATH_LITERAL("drive/root/File 1.txt")); |
28 const base::Time::Exploded kLastAccessTime = { | 28 const base::Time::Exploded kLastAccessTime = { |
29 2012, 7, 0, 19, 15, 59, 13, 123 | 29 2012, 7, 0, 19, 15, 59, 13, 123 |
30 }; | 30 }; |
31 const base::Time::Exploded kLastModifiedTime = { | 31 const base::Time::Exploded kLastModifiedTime = { |
32 2013, 7, 0, 19, 15, 59, 13, 123 | 32 2013, 7, 0, 19, 15, 59, 13, 123 |
33 }; | 33 }; |
34 | 34 |
35 FileError error = FILE_ERROR_FAILED; | 35 FileError error = FILE_ERROR_FAILED; |
36 operation.TouchFile( | 36 operation.TouchFile( |
37 kTestPath, | 37 kTestPath, |
38 base::Time::FromUTCExploded(kLastAccessTime), | 38 base::Time::FromUTCExploded(kLastAccessTime), |
39 base::Time::FromUTCExploded(kLastModifiedTime), | 39 base::Time::FromUTCExploded(kLastModifiedTime), |
40 google_apis::test_util::CreateCopyResultCallback(&error)); | 40 google_apis::test_util::CreateCopyResultCallback(&error)); |
41 content::RunAllBlockingPoolTasksUntilIdle(); | 41 content::RunAllBlockingPoolTasksUntilIdle(); |
42 EXPECT_EQ(FILE_ERROR_OK, error); | 42 EXPECT_EQ(FILE_ERROR_OK, error); |
43 | 43 |
44 ResourceEntry entry; | 44 ResourceEntry entry; |
45 EXPECT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(kTestPath, &entry)); | 45 EXPECT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(kTestPath, &entry)); |
46 EXPECT_EQ(base::Time::FromUTCExploded(kLastAccessTime), | 46 EXPECT_EQ(base::Time::FromUTCExploded(kLastAccessTime), |
47 base::Time::FromInternalValue(entry.file_info().last_accessed())); | 47 base::Time::FromInternalValue(entry.file_info().last_accessed())); |
48 EXPECT_EQ(base::Time::FromUTCExploded(kLastModifiedTime), | 48 EXPECT_EQ(base::Time::FromUTCExploded(kLastModifiedTime), |
49 base::Time::FromInternalValue(entry.file_info().last_modified())); | 49 base::Time::FromInternalValue(entry.file_info().last_modified())); |
50 EXPECT_EQ(ResourceEntry::DIRTY, entry.metadata_edit_state()); | 50 EXPECT_EQ(ResourceEntry::DIRTY, entry.metadata_edit_state()); |
51 | 51 |
52 EXPECT_EQ(1U, observer()->get_changed_files().size()); | 52 EXPECT_EQ(1U, delegate()->get_changed_files().size()); |
53 EXPECT_TRUE(observer()->get_changed_files().count(kTestPath)); | 53 EXPECT_TRUE(delegate()->get_changed_files().count(kTestPath)); |
54 | 54 |
55 EXPECT_EQ(1U, observer()->updated_local_ids().size()); | 55 EXPECT_EQ(1U, delegate()->updated_local_ids().size()); |
56 EXPECT_TRUE(observer()->updated_local_ids().count(entry.local_id())); | 56 EXPECT_TRUE(delegate()->updated_local_ids().count(entry.local_id())); |
57 } | 57 } |
58 | 58 |
59 } // namespace file_system | 59 } // namespace file_system |
60 } // namespace drive | 60 } // namespace drive |
OLD | NEW |