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/file_system/get_file_for_saving_operation.h" | 5 #include "components/drive/file_system/get_file_for_saving_operation.h" |
6 | 6 |
| 7 #include <stdint.h> |
| 8 |
7 #include "base/callback.h" | 9 #include "base/callback.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/run_loop.h" | 12 #include "base/run_loop.h" |
11 #include "base/task_runner_util.h" | 13 #include "base/task_runner_util.h" |
12 #include "components/drive/drive.pb.h" | 14 #include "components/drive/drive.pb.h" |
13 #include "components/drive/file_change.h" | 15 #include "components/drive/file_change.h" |
14 #include "components/drive/file_errors.h" | 16 #include "components/drive/file_errors.h" |
15 #include "components/drive/file_system/operation_test_base.h" | 17 #include "components/drive/file_system/operation_test_base.h" |
16 #include "components/drive/file_write_watcher.h" | 18 #include "components/drive/file_write_watcher.h" |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 base::FilePath local_path; | 124 base::FilePath local_path; |
123 operation_->GetFileForSaving( | 125 operation_->GetFileForSaving( |
124 drive_path, | 126 drive_path, |
125 google_apis::test_util::CreateCopyResultCallback( | 127 google_apis::test_util::CreateCopyResultCallback( |
126 &error, &local_path, &entry)); | 128 &error, &local_path, &entry)); |
127 content::RunAllBlockingPoolTasksUntilIdle(); | 129 content::RunAllBlockingPoolTasksUntilIdle(); |
128 | 130 |
129 // Checks that the file is created and retrieved. | 131 // Checks that the file is created and retrieved. |
130 EXPECT_EQ(FILE_ERROR_OK, error); | 132 EXPECT_EQ(FILE_ERROR_OK, error); |
131 EXPECT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(drive_path, &src_entry)); | 133 EXPECT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(drive_path, &src_entry)); |
132 int64 size = -1; | 134 int64_t size = -1; |
133 EXPECT_TRUE(base::GetFileSize(local_path, &size)); | 135 EXPECT_TRUE(base::GetFileSize(local_path, &size)); |
134 EXPECT_EQ(0, size); | 136 EXPECT_EQ(0, size); |
135 } | 137 } |
136 | 138 |
137 TEST_F(GetFileForSavingOperationTest, GetFileForSaving_Directory) { | 139 TEST_F(GetFileForSavingOperationTest, GetFileForSaving_Directory) { |
138 base::FilePath drive_path(FILE_PATH_LITERAL("drive/root/Directory 1")); | 140 base::FilePath drive_path(FILE_PATH_LITERAL("drive/root/Directory 1")); |
139 ResourceEntry src_entry; | 141 ResourceEntry src_entry; |
140 ASSERT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(drive_path, &src_entry)); | 142 ASSERT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(drive_path, &src_entry)); |
141 ASSERT_TRUE(src_entry.file_info().is_directory()); | 143 ASSERT_TRUE(src_entry.file_info().is_directory()); |
142 | 144 |
143 // Run the operation. | 145 // Run the operation. |
144 FileError error = FILE_ERROR_FAILED; | 146 FileError error = FILE_ERROR_FAILED; |
145 scoped_ptr<ResourceEntry> entry; | 147 scoped_ptr<ResourceEntry> entry; |
146 base::FilePath local_path; | 148 base::FilePath local_path; |
147 operation_->GetFileForSaving( | 149 operation_->GetFileForSaving( |
148 drive_path, | 150 drive_path, |
149 google_apis::test_util::CreateCopyResultCallback( | 151 google_apis::test_util::CreateCopyResultCallback( |
150 &error, &local_path, &entry)); | 152 &error, &local_path, &entry)); |
151 content::RunAllBlockingPoolTasksUntilIdle(); | 153 content::RunAllBlockingPoolTasksUntilIdle(); |
152 | 154 |
153 // Checks that an error is returned. | 155 // Checks that an error is returned. |
154 EXPECT_EQ(FILE_ERROR_EXISTS, error); | 156 EXPECT_EQ(FILE_ERROR_EXISTS, error); |
155 } | 157 } |
156 | 158 |
157 } // namespace file_system | 159 } // namespace file_system |
158 } // namespace drive | 160 } // namespace drive |
OLD | NEW |