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/open_file_operation.h" | 5 #include "chrome/browser/chromeos/drive/file_system/open_file_operation.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 | 8 |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 EXPECT_EQ(FILE_ERROR_OK, error); | 156 EXPECT_EQ(FILE_ERROR_OK, error); |
157 ASSERT_TRUE(base::PathExists(file_path)); | 157 ASSERT_TRUE(base::PathExists(file_path)); |
158 int64 local_file_size; | 158 int64 local_file_size; |
159 ASSERT_TRUE(base::GetFileSize(file_path, &local_file_size)); | 159 ASSERT_TRUE(base::GetFileSize(file_path, &local_file_size)); |
160 EXPECT_EQ(file_size, local_file_size); | 160 EXPECT_EQ(file_size, local_file_size); |
161 | 161 |
162 ASSERT_FALSE(close_callback.is_null()); | 162 ASSERT_FALSE(close_callback.is_null()); |
163 close_callback.Run(); | 163 close_callback.Run(); |
164 EXPECT_EQ(1U, observer()->updated_local_ids().count(src_entry.local_id())); | 164 EXPECT_EQ(1U, observer()->updated_local_ids().count(src_entry.local_id())); |
165 | 165 |
166 bool success = false; | |
167 FileCacheEntry cache_entry; | 166 FileCacheEntry cache_entry; |
168 base::PostTaskAndReplyWithResult( | 167 base::PostTaskAndReplyWithResult( |
169 blocking_task_runner(), | 168 blocking_task_runner(), |
170 FROM_HERE, | 169 FROM_HERE, |
171 base::Bind(&internal::FileCache::GetCacheEntry, | 170 base::Bind(&internal::FileCache::GetCacheEntry, |
172 base::Unretained(cache()), | 171 base::Unretained(cache()), |
173 src_entry.local_id(), | 172 src_entry.local_id(), |
174 &cache_entry), | 173 &cache_entry), |
175 google_apis::test_util::CreateCopyResultCallback(&success)); | 174 google_apis::test_util::CreateCopyResultCallback(&error)); |
176 test_util::RunBlockingPoolTask(); | 175 test_util::RunBlockingPoolTask(); |
177 EXPECT_TRUE(success); | 176 EXPECT_EQ(FILE_ERROR_OK, error); |
178 EXPECT_TRUE(cache_entry.is_present()); | 177 EXPECT_TRUE(cache_entry.is_present()); |
179 EXPECT_TRUE(cache_entry.is_dirty()); | 178 EXPECT_TRUE(cache_entry.is_dirty()); |
180 } | 179 } |
181 | 180 |
182 TEST_F(OpenFileOperationTest, OpenOrCreateNonExistingFile) { | 181 TEST_F(OpenFileOperationTest, OpenOrCreateNonExistingFile) { |
183 const base::FilePath file_in_root( | 182 const base::FilePath file_in_root( |
184 FILE_PATH_LITERAL("drive/root/not-exist.txt")); | 183 FILE_PATH_LITERAL("drive/root/not-exist.txt")); |
185 | 184 |
186 FileError error = FILE_ERROR_FAILED; | 185 FileError error = FILE_ERROR_FAILED; |
187 base::FilePath file_path; | 186 base::FilePath file_path; |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 EXPECT_TRUE(observer()->updated_local_ids().empty()); | 255 EXPECT_TRUE(observer()->updated_local_ids().empty()); |
257 | 256 |
258 close_callback2.Run(); | 257 close_callback2.Run(); |
259 | 258 |
260 // Here, all the clients close the file, so it should be uploaded then. | 259 // Here, all the clients close the file, so it should be uploaded then. |
261 EXPECT_EQ(1U, observer()->updated_local_ids().count(src_entry.local_id())); | 260 EXPECT_EQ(1U, observer()->updated_local_ids().count(src_entry.local_id())); |
262 } | 261 } |
263 | 262 |
264 } // namespace file_system | 263 } // namespace file_system |
265 } // namespace drive | 264 } // namespace drive |
OLD | NEW |