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

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

Issue 15663006: drive: Merge 'persistent' and 'tmp' directories to 'files' (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments 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/test_util.h" 5 #include "chrome/browser/chromeos/drive/test_util.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/files/scoped_temp_dir.h" 10 #include "base/files/scoped_temp_dir.h"
(...skipping 24 matching lines...) Expand all
35 "md5_tmp_alphanumeric", 35 "md5_tmp_alphanumeric",
36 false, 36 false,
37 false), 37 false),
38 // Cache resource in tmp dir, i.e. not pinned or dirty, with resource_id 38 // Cache resource in tmp dir, i.e. not pinned or dirty, with resource_id
39 // containing non-alphanumeric characters. 39 // containing non-alphanumeric characters.
40 TestCacheResource("cache2.png", 40 TestCacheResource("cache2.png",
41 "tmp:`~!@#$%^&*()-_=+[{|]}\\;',<.>/?", 41 "tmp:`~!@#$%^&*()-_=+[{|]}\\;',<.>/?",
42 "md5_tmp_non_alphanumeric", 42 "md5_tmp_non_alphanumeric",
43 false, 43 false,
44 false), 44 false),
45 // Cache resource that is pinned and persistent. 45 // Cache resource that is pinned and present.
46 TestCacheResource("pinned/cache.mp3", 46 TestCacheResource("pinned/cache.mp3",
47 "pinned:existing", 47 "pinned:existing",
48 "md5_pinned_existing", 48 "md5_pinned_existing",
49 true, 49 true,
50 false), 50 false),
51 // Cache resource with a non-existent source file that is pinned. 51 // Cache resource with a non-existent source file that is pinned.
52 TestCacheResource("", 52 TestCacheResource("",
53 "pinned:non-existent", 53 "pinned:non-existent",
54 "md5_pinned_non_existent", 54 "md5_pinned_non_existent",
55 true, 55 true,
(...skipping 15 matching lines...) Expand all
71 resources, 71 resources,
72 resources + ARRAYSIZE_UNSAFE(resources)); 72 resources + ARRAYSIZE_UNSAFE(resources));
73 } 73 }
74 74
75 FileCacheEntry ToCacheEntry(int cache_state) { 75 FileCacheEntry ToCacheEntry(int cache_state) {
76 FileCacheEntry cache_entry; 76 FileCacheEntry cache_entry;
77 cache_entry.set_is_present(cache_state & TEST_CACHE_STATE_PRESENT); 77 cache_entry.set_is_present(cache_state & TEST_CACHE_STATE_PRESENT);
78 cache_entry.set_is_pinned(cache_state & TEST_CACHE_STATE_PINNED); 78 cache_entry.set_is_pinned(cache_state & TEST_CACHE_STATE_PINNED);
79 cache_entry.set_is_dirty(cache_state & TEST_CACHE_STATE_DIRTY); 79 cache_entry.set_is_dirty(cache_state & TEST_CACHE_STATE_DIRTY);
80 cache_entry.set_is_mounted(cache_state & TEST_CACHE_STATE_MOUNTED); 80 cache_entry.set_is_mounted(cache_state & TEST_CACHE_STATE_MOUNTED);
81 cache_entry.set_is_persistent(cache_state & TEST_CACHE_STATE_PERSISTENT);
82 return cache_entry; 81 return cache_entry;
83 } 82 }
84 83
85 bool CacheStatesEqual(const FileCacheEntry& a, const FileCacheEntry& b) { 84 bool CacheStatesEqual(const FileCacheEntry& a, const FileCacheEntry& b) {
86 return (a.is_present() == b.is_present() && 85 return a.is_present() == b.is_present() &&
87 a.is_pinned() == b.is_pinned() && 86 a.is_pinned() == b.is_pinned() &&
88 a.is_dirty() == b.is_dirty() && 87 a.is_dirty() == b.is_dirty() &&
89 a.is_mounted() == b.is_mounted() && 88 a.is_mounted() == b.is_mounted();
90 a.is_persistent() == b.is_persistent());
91 } 89 }
92 90
93 bool PrepareTestCacheResources( 91 bool PrepareTestCacheResources(
94 internal::FileCache* cache, 92 internal::FileCache* cache,
95 const std::vector<TestCacheResource>& resources) { 93 const std::vector<TestCacheResource>& resources) {
96 // cache->StoreOnUIThread requires real file to be stored. As a dummy data for 94 // cache->StoreOnUIThread requires real file to be stored. As a dummy data for
97 // testing, an empty temporary file is created. 95 // testing, an empty temporary file is created.
98 base::ScopedTempDir temp_dir; 96 base::ScopedTempDir temp_dir;
99 if (!temp_dir.CreateUniqueTempDir()) 97 if (!temp_dir.CreateUniqueTempDir())
100 return false; 98 return false;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 google_apis::test_util::RunBlockingPoolTask(); 135 google_apis::test_util::RunBlockingPoolTask();
138 if (error != FILE_ERROR_OK) 136 if (error != FILE_ERROR_OK)
139 return false; 137 return false;
140 } 138 }
141 } 139 }
142 return true; 140 return true;
143 } 141 }
144 142
145 } // namespace test_util 143 } // namespace test_util
146 } // namespace drive 144 } // namespace drive
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/drive/test_util.h ('k') | chrome/browser/resources/chromeos/drive_internals.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698