Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(589)

Side by Side Diff: chrome/browser/chromeos/drive/file_system/copy_operation_unittest.cc

Issue 285323002: drive: Remove FileCache::GetCacheEntry (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/copy_operation.h" 5 #include "chrome/browser/chromeos/drive/file_system/copy_operation.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/task_runner_util.h" 8 #include "base/task_runner_util.h"
9 #include "chrome/browser/chromeos/drive/file_cache.h" 9 #include "chrome/browser/chromeos/drive/file_cache.h"
10 #include "chrome/browser/chromeos/drive/file_system/operation_test_base.h" 10 #include "chrome/browser/chromeos/drive/file_system/operation_test_base.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 operation_->TransferFileFromLocalToRemote( 52 operation_->TransferFileFromLocalToRemote(
53 local_src_path, 53 local_src_path,
54 remote_dest_path, 54 remote_dest_path,
55 google_apis::test_util::CreateCopyResultCallback(&error)); 55 google_apis::test_util::CreateCopyResultCallback(&error));
56 test_util::RunBlockingPoolTask(); 56 test_util::RunBlockingPoolTask();
57 EXPECT_EQ(FILE_ERROR_OK, error); 57 EXPECT_EQ(FILE_ERROR_OK, error);
58 58
59 // TransferFileFromLocalToRemote stores a copy of the local file in the cache, 59 // TransferFileFromLocalToRemote stores a copy of the local file in the cache,
60 // marks it dirty and requests the observer to upload the file. 60 // marks it dirty and requests the observer to upload the file.
61 EXPECT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(remote_dest_path, &entry)); 61 EXPECT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(remote_dest_path, &entry));
62 EXPECT_EQ(1U, observer()->updated_local_ids().count( 62 EXPECT_EQ(1U, observer()->updated_local_ids().count(entry.local_id()));
63 GetLocalId(remote_dest_path))); 63 EXPECT_TRUE(entry.file_specific_info().cache_state().is_present());
64 FileCacheEntry cache_entry; 64 EXPECT_TRUE(entry.file_specific_info().cache_state().is_dirty());
65 base::PostTaskAndReplyWithResult(
66 blocking_task_runner(),
67 FROM_HERE,
68 base::Bind(&internal::FileCache::GetCacheEntry,
69 base::Unretained(cache()),
70 GetLocalId(remote_dest_path),
71 &cache_entry),
72 google_apis::test_util::CreateCopyResultCallback(&error));
73 test_util::RunBlockingPoolTask();
74 EXPECT_EQ(FILE_ERROR_OK, error);
75 EXPECT_TRUE(cache_entry.is_present());
76 EXPECT_TRUE(cache_entry.is_dirty());
77 65
78 EXPECT_EQ(1U, observer()->get_changed_paths().size()); 66 EXPECT_EQ(1U, observer()->get_changed_paths().size());
79 EXPECT_TRUE(observer()->get_changed_paths().count( 67 EXPECT_TRUE(observer()->get_changed_paths().count(
80 remote_dest_path.DirName())); 68 remote_dest_path.DirName()));
81 } 69 }
82 70
83 TEST_F(CopyOperationTest, TransferFileFromLocalToRemote_Overwrite) { 71 TEST_F(CopyOperationTest, TransferFileFromLocalToRemote_Overwrite) {
84 const base::FilePath local_src_path = temp_dir().AppendASCII("local.txt"); 72 const base::FilePath local_src_path = temp_dir().AppendASCII("local.txt");
85 const base::FilePath remote_dest_path( 73 const base::FilePath remote_dest_path(
86 FILE_PATH_LITERAL("drive/root/File 1.txt")); 74 FILE_PATH_LITERAL("drive/root/File 1.txt"));
(...skipping 11 matching lines...) Expand all
98 local_src_path, 86 local_src_path,
99 remote_dest_path, 87 remote_dest_path,
100 google_apis::test_util::CreateCopyResultCallback(&error)); 88 google_apis::test_util::CreateCopyResultCallback(&error));
101 test_util::RunBlockingPoolTask(); 89 test_util::RunBlockingPoolTask();
102 EXPECT_EQ(FILE_ERROR_OK, error); 90 EXPECT_EQ(FILE_ERROR_OK, error);
103 91
104 // TransferFileFromLocalToRemote stores a copy of the local file in the cache, 92 // TransferFileFromLocalToRemote stores a copy of the local file in the cache,
105 // marks it dirty and requests the observer to upload the file. 93 // marks it dirty and requests the observer to upload the file.
106 EXPECT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(remote_dest_path, &entry)); 94 EXPECT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(remote_dest_path, &entry));
107 EXPECT_EQ(1U, observer()->updated_local_ids().count(entry.local_id())); 95 EXPECT_EQ(1U, observer()->updated_local_ids().count(entry.local_id()));
108 FileCacheEntry cache_entry; 96 EXPECT_TRUE(entry.file_specific_info().cache_state().is_present());
109 base::PostTaskAndReplyWithResult( 97 EXPECT_TRUE(entry.file_specific_info().cache_state().is_dirty());
110 blocking_task_runner(),
111 FROM_HERE,
112 base::Bind(&internal::FileCache::GetCacheEntry,
113 base::Unretained(cache()), entry.local_id(), &cache_entry),
114 google_apis::test_util::CreateCopyResultCallback(&error));
115 test_util::RunBlockingPoolTask();
116 EXPECT_EQ(FILE_ERROR_OK, error);
117 EXPECT_TRUE(cache_entry.is_present());
118 EXPECT_TRUE(cache_entry.is_dirty());
119 98
120 EXPECT_EQ(1U, observer()->get_changed_paths().size()); 99 EXPECT_EQ(1U, observer()->get_changed_paths().size());
121 EXPECT_TRUE(observer()->get_changed_paths().count( 100 EXPECT_TRUE(observer()->get_changed_paths().count(
122 remote_dest_path.DirName())); 101 remote_dest_path.DirName()));
123 } 102 }
124 103
125 TEST_F(CopyOperationTest, 104 TEST_F(CopyOperationTest,
126 TransferFileFromLocalToRemote_ExistingHostedDocument) { 105 TransferFileFromLocalToRemote_ExistingHostedDocument) {
127 const base::FilePath local_src_path = temp_dir().AppendASCII("local.gdoc"); 106 const base::FilePath local_src_path = temp_dir().AppendASCII("local.gdoc");
128 const base::FilePath remote_dest_path(FILE_PATH_LITERAL( 107 const base::FilePath remote_dest_path(FILE_PATH_LITERAL(
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 ResourceEntry dest_entry; 321 ResourceEntry dest_entry;
343 EXPECT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(dest_path, &dest_entry)); 322 EXPECT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(dest_path, &dest_entry));
344 EXPECT_EQ(ResourceEntry::DIRTY, dest_entry.metadata_edit_state()); 323 EXPECT_EQ(ResourceEntry::DIRTY, dest_entry.metadata_edit_state());
345 324
346 EXPECT_EQ(1u, observer()->updated_local_ids().size()); 325 EXPECT_EQ(1u, observer()->updated_local_ids().size());
347 EXPECT_TRUE(observer()->updated_local_ids().count(dest_entry.local_id())); 326 EXPECT_TRUE(observer()->updated_local_ids().count(dest_entry.local_id()));
348 EXPECT_EQ(1u, observer()->get_changed_paths().size()); 327 EXPECT_EQ(1u, observer()->get_changed_paths().size());
349 EXPECT_TRUE(observer()->get_changed_paths().count(dest_path.DirName())); 328 EXPECT_TRUE(observer()->get_changed_paths().count(dest_path.DirName()));
350 329
351 // Copied cache file should be dirty. 330 // Copied cache file should be dirty.
352 FileCacheEntry cache_entry; 331 EXPECT_TRUE(dest_entry.file_specific_info().cache_state().is_dirty());
353 base::PostTaskAndReplyWithResult(
354 blocking_task_runner(),
355 FROM_HERE,
356 base::Bind(&internal::FileCache::GetCacheEntry,
357 base::Unretained(cache()),
358 dest_entry.local_id(),
359 &cache_entry),
360 google_apis::test_util::CreateCopyResultCallback(&error));
361 test_util::RunBlockingPoolTask();
362 EXPECT_EQ(FILE_ERROR_OK, error);
363 EXPECT_TRUE(cache_entry.is_dirty());
364 332
365 // File contents should match. 333 // File contents should match.
366 base::FilePath cache_file_path; 334 base::FilePath cache_file_path;
367 base::PostTaskAndReplyWithResult( 335 base::PostTaskAndReplyWithResult(
368 blocking_task_runner(), 336 blocking_task_runner(),
369 FROM_HERE, 337 FROM_HERE,
370 base::Bind(&internal::FileCache::GetFile, 338 base::Bind(&internal::FileCache::GetFile,
371 base::Unretained(cache()), 339 base::Unretained(cache()),
372 dest_entry.local_id(), 340 dest_entry.local_id(),
373 &cache_file_path), 341 &cache_file_path),
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 424
457 ResourceEntry entry2; 425 ResourceEntry entry2;
458 EXPECT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(src_path, &entry)); 426 EXPECT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(src_path, &entry));
459 EXPECT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(dest_path, &entry2)); 427 EXPECT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(dest_path, &entry2));
460 EXPECT_EQ(entry.file_info().last_modified(), 428 EXPECT_EQ(entry.file_info().last_modified(),
461 entry2.file_info().last_modified()); 429 entry2.file_info().last_modified());
462 } 430 }
463 431
464 } // namespace file_system 432 } // namespace file_system
465 } // namespace drive 433 } // namespace drive
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698