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

Side by Side Diff: chrome/browser/chromeos/drive/resource_metadata_unittest.cc

Issue 296463002: drive: Stop using FileCacheEntry related methods in FileCache (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Do not overwrite cache state with RefreshEntry 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
« no previous file with comments | « chrome/browser/chromeos/drive/resource_metadata_storage_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/resource_metadata.h" 5 #include "chrome/browser/chromeos/drive/resource_metadata.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 std::string local_id; 345 std::string local_id;
346 EXPECT_EQ(FILE_ERROR_OK, resource_metadata_->AddEntry(new_entry, &local_id)); 346 EXPECT_EQ(FILE_ERROR_OK, resource_metadata_->AddEntry(new_entry, &local_id));
347 347
348 // Try to refresh the new entry with a used resource ID. 348 // Try to refresh the new entry with a used resource ID.
349 new_entry.set_local_id(local_id); 349 new_entry.set_local_id(local_id);
350 new_entry.set_resource_id(entry.resource_id()); 350 new_entry.set_resource_id(entry.resource_id());
351 EXPECT_EQ(FILE_ERROR_INVALID_OPERATION, 351 EXPECT_EQ(FILE_ERROR_INVALID_OPERATION,
352 resource_metadata_->RefreshEntry(new_entry)); 352 resource_metadata_->RefreshEntry(new_entry));
353 } 353 }
354 354
355 TEST_F(ResourceMetadataTest, RefreshEntry_DoNotOverwriteCacheState) {
356 ResourceEntry entry;
357 EXPECT_EQ(FILE_ERROR_OK, resource_metadata_->GetResourceEntryByPath(
358 base::FilePath::FromUTF8Unsafe("drive/root/dir1/file4"), &entry));
359
360 // Try to set MD5 with RefreshEntry.
361 entry.mutable_file_specific_info()->mutable_cache_state()->set_md5("md5");
362 EXPECT_EQ(FILE_ERROR_OK, resource_metadata_->RefreshEntry(entry));
363
364 // Cache state is unchanged.
365 EXPECT_EQ(FILE_ERROR_OK, resource_metadata_->GetResourceEntryByPath(
366 base::FilePath::FromUTF8Unsafe("drive/root/dir1/file4"), &entry));
367 EXPECT_TRUE(entry.file_specific_info().cache_state().md5().empty());
368
369 // Pin the file.
370 EXPECT_EQ(FILE_ERROR_OK, cache_->Pin(entry.local_id()));
371
372 // Try to clear the cache state with RefreshEntry.
373 EXPECT_EQ(FILE_ERROR_OK, resource_metadata_->GetResourceEntryByPath(
374 base::FilePath::FromUTF8Unsafe("drive/root/dir1/file4"), &entry));
375 entry.mutable_file_specific_info()->clear_cache_state();
376 EXPECT_EQ(FILE_ERROR_OK, resource_metadata_->RefreshEntry(entry));
377
378 // Cache state is not cleared.
379 EXPECT_EQ(FILE_ERROR_OK, resource_metadata_->GetResourceEntryByPath(
380 base::FilePath::FromUTF8Unsafe("drive/root/dir1/file4"), &entry));
381 EXPECT_TRUE(entry.file_specific_info().cache_state().is_pinned());
382 }
383
355 TEST_F(ResourceMetadataTest, GetSubDirectoriesRecursively) { 384 TEST_F(ResourceMetadataTest, GetSubDirectoriesRecursively) {
356 std::set<base::FilePath> sub_directories; 385 std::set<base::FilePath> sub_directories;
357 386
358 // file9: not a directory, so no children. 387 // file9: not a directory, so no children.
359 std::string local_id; 388 std::string local_id;
360 EXPECT_EQ(FILE_ERROR_OK, resource_metadata_->GetIdByPath( 389 EXPECT_EQ(FILE_ERROR_OK, resource_metadata_->GetIdByPath(
361 base::FilePath::FromUTF8Unsafe("drive/root/dir1/dir3/file9"), &local_id)); 390 base::FilePath::FromUTF8Unsafe("drive/root/dir1/dir3/file9"), &local_id));
362 EXPECT_EQ(FILE_ERROR_OK, resource_metadata_->GetSubDirectoriesRecursively( 391 EXPECT_EQ(FILE_ERROR_OK, resource_metadata_->GetSubDirectoriesRecursively(
363 local_id, &sub_directories)); 392 local_id, &sub_directories));
364 EXPECT_TRUE(sub_directories.empty()); 393 EXPECT_TRUE(sub_directories.empty());
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
669 698
670 // The "trash" directory should be empty. 699 // The "trash" directory should be empty.
671 ASSERT_EQ(FILE_ERROR_OK, 700 ASSERT_EQ(FILE_ERROR_OK,
672 resource_metadata_->ReadDirectoryByPath( 701 resource_metadata_->ReadDirectoryByPath(
673 base::FilePath::FromUTF8Unsafe("drive/trash"), &entries)); 702 base::FilePath::FromUTF8Unsafe("drive/trash"), &entries));
674 EXPECT_TRUE(entries.empty()); 703 EXPECT_TRUE(entries.empty());
675 } 704 }
676 705
677 } // namespace internal 706 } // namespace internal
678 } // namespace drive 707 } // namespace drive
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/drive/resource_metadata_storage_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698