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

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

Issue 15663006: drive: Merge 'persistent' and 'tmp' directories to 'files' (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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 (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/file_cache_metadata.h" 5 #include "chrome/browser/chromeos/drive/file_cache_metadata.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/files/scoped_temp_dir.h" 8 #include "base/files/scoped_temp_dir.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_system_util.h" 10 #include "chrome/browser/chromeos/drive/file_system_util.h"
(...skipping 29 matching lines...) Expand all
40 ASSERT_EQ(FileCacheMetadata::INITIALIZE_CREATED, 40 ASSERT_EQ(FileCacheMetadata::INITIALIZE_CREATED,
41 metadata_->Initialize(temp_dir_.path())); 41 metadata_->Initialize(temp_dir_.path()));
42 42
43 // Save an initial entry. 43 // Save an initial entry.
44 std::string test_resource_id("test_resource_id"); 44 std::string test_resource_id("test_resource_id");
45 std::string test_md5("test_md5"); 45 std::string test_md5("test_md5");
46 { 46 {
47 FileCacheEntry new_cache_entry; 47 FileCacheEntry new_cache_entry;
48 new_cache_entry.set_md5(test_md5); 48 new_cache_entry.set_md5(test_md5);
49 new_cache_entry.set_is_present(true); 49 new_cache_entry.set_is_present(true);
50 new_cache_entry.set_is_persistent(true);
51 metadata_->AddOrUpdateCacheEntry(test_resource_id, new_cache_entry); 50 metadata_->AddOrUpdateCacheEntry(test_resource_id, new_cache_entry);
52 } 51 }
53 52
54 // Test that the entry can be retrieved. 53 // Test that the entry can be retrieved.
55 FileCacheEntry cache_entry; 54 FileCacheEntry cache_entry;
56 ASSERT_TRUE(metadata_->GetCacheEntry(test_resource_id, &cache_entry)); 55 ASSERT_TRUE(metadata_->GetCacheEntry(test_resource_id, &cache_entry));
57 EXPECT_EQ(test_md5, cache_entry.md5()); 56 EXPECT_EQ(test_md5, cache_entry.md5());
58 EXPECT_TRUE(cache_entry.is_present()); 57 EXPECT_TRUE(cache_entry.is_present());
59 EXPECT_TRUE(cache_entry.is_persistent());
60 58
61 // resource_id doesn't exist. 59 // resource_id doesn't exist.
62 EXPECT_FALSE(metadata_->GetCacheEntry("not_found_resource_id", &cache_entry)); 60 EXPECT_FALSE(metadata_->GetCacheEntry("not_found_resource_id", &cache_entry));
63 61
64 // Update all attributes. 62 // Update all attributes.
65 test_md5 = "test_md5_2"; 63 test_md5 = "test_md5_2";
66 { 64 {
67 FileCacheEntry updated_cache_entry; 65 FileCacheEntry updated_cache_entry;
68 updated_cache_entry.set_md5(test_md5); 66 updated_cache_entry.set_md5(test_md5);
69 updated_cache_entry.set_is_pinned(true); 67 updated_cache_entry.set_is_pinned(true);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 124
127 // Try to open a nonexistent path. 125 // Try to open a nonexistent path.
128 base::FilePath non_existent_path(FILE_PATH_LITERAL("/somewhere/nonexistent")); 126 base::FilePath non_existent_path(FILE_PATH_LITERAL("/somewhere/nonexistent"));
129 metadata_.reset(new FileCacheMetadata(NULL)); 127 metadata_.reset(new FileCacheMetadata(NULL));
130 EXPECT_EQ(FileCacheMetadata::INITIALIZE_FAILED, 128 EXPECT_EQ(FileCacheMetadata::INITIALIZE_FAILED,
131 metadata_->Initialize(non_existent_path)); 129 metadata_->Initialize(non_existent_path));
132 } 130 }
133 131
134 } // namespace internal 132 } // namespace internal
135 } // namespace drive 133 } // namespace drive
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698