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

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

Issue 15060002: drive: Rename FileCache methods in a blocking pool centric manner (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove virtual Created 7 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/sync_client.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/sync_client.h" 5 #include "chrome/browser/chromeos/drive/sync_client.h"
6 6
7 #include <vector> 7 #include <vector>
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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 // Sets up cache for tests. 91 // Sets up cache for tests.
92 void SetUpCache() { 92 void SetUpCache() {
93 // Prepare a temp file. 93 // Prepare a temp file.
94 base::FilePath temp_file; 94 base::FilePath temp_file;
95 EXPECT_TRUE(file_util::CreateTemporaryFileInDir(temp_dir_.path(), 95 EXPECT_TRUE(file_util::CreateTemporaryFileInDir(temp_dir_.path(),
96 &temp_file)); 96 &temp_file));
97 ASSERT_TRUE(google_apis::test_util::WriteStringToFile(temp_file, "hello")); 97 ASSERT_TRUE(google_apis::test_util::WriteStringToFile(temp_file, "hello"));
98 98
99 // Prepare 3 pinned-but-not-present files. 99 // Prepare 3 pinned-but-not-present files.
100 FileError error = FILE_ERROR_OK; 100 FileError error = FILE_ERROR_OK;
101 cache_->Pin("resource_id_not_fetched_foo", "", 101 cache_->PinOnUIThread(
102 google_apis::test_util::CreateCopyResultCallback(&error)); 102 "resource_id_not_fetched_foo", "",
103 google_apis::test_util::CreateCopyResultCallback(&error));
103 google_apis::test_util::RunBlockingPoolTask(); 104 google_apis::test_util::RunBlockingPoolTask();
104 EXPECT_EQ(FILE_ERROR_OK, error); 105 EXPECT_EQ(FILE_ERROR_OK, error);
105 106
106 cache_->Pin("resource_id_not_fetched_bar", "", 107 cache_->PinOnUIThread(
107 google_apis::test_util::CreateCopyResultCallback(&error)); 108 "resource_id_not_fetched_bar", "",
109 google_apis::test_util::CreateCopyResultCallback(&error));
108 google_apis::test_util::RunBlockingPoolTask(); 110 google_apis::test_util::RunBlockingPoolTask();
109 EXPECT_EQ(FILE_ERROR_OK, error); 111 EXPECT_EQ(FILE_ERROR_OK, error);
110 112
111 cache_->Pin("resource_id_not_fetched_baz", "", 113 cache_->PinOnUIThread(
112 google_apis::test_util::CreateCopyResultCallback(&error)); 114 "resource_id_not_fetched_baz", "",
115 google_apis::test_util::CreateCopyResultCallback(&error));
113 google_apis::test_util::RunBlockingPoolTask(); 116 google_apis::test_util::RunBlockingPoolTask();
114 EXPECT_EQ(FILE_ERROR_OK, error); 117 EXPECT_EQ(FILE_ERROR_OK, error);
115 118
116 // Prepare a pinned-and-fetched file. 119 // Prepare a pinned-and-fetched file.
117 const std::string resource_id_fetched = "resource_id_fetched"; 120 const std::string resource_id_fetched = "resource_id_fetched";
118 const std::string md5_fetched = "md5"; 121 const std::string md5_fetched = "md5";
119 cache_->Store(resource_id_fetched, md5_fetched, temp_file, 122 cache_->StoreOnUIThread(
120 internal::FileCache::FILE_OPERATION_COPY, 123 resource_id_fetched, md5_fetched, temp_file,
121 google_apis::test_util::CreateCopyResultCallback(&error)); 124 internal::FileCache::FILE_OPERATION_COPY,
125 google_apis::test_util::CreateCopyResultCallback(&error));
122 google_apis::test_util::RunBlockingPoolTask(); 126 google_apis::test_util::RunBlockingPoolTask();
123 EXPECT_EQ(FILE_ERROR_OK, error); 127 EXPECT_EQ(FILE_ERROR_OK, error);
124 cache_->Pin(resource_id_fetched, md5_fetched, 128 cache_->PinOnUIThread(
125 google_apis::test_util::CreateCopyResultCallback(&error)); 129 resource_id_fetched, md5_fetched,
130 google_apis::test_util::CreateCopyResultCallback(&error));
126 google_apis::test_util::RunBlockingPoolTask(); 131 google_apis::test_util::RunBlockingPoolTask();
127 EXPECT_EQ(FILE_ERROR_OK, error); 132 EXPECT_EQ(FILE_ERROR_OK, error);
128 133
129 // Prepare a pinned-and-fetched-and-dirty file. 134 // Prepare a pinned-and-fetched-and-dirty file.
130 const std::string resource_id_dirty = "resource_id_dirty"; 135 const std::string resource_id_dirty = "resource_id_dirty";
131 const std::string md5_dirty = ""; // Don't care. 136 const std::string md5_dirty = ""; // Don't care.
132 cache_->Store(resource_id_dirty, md5_dirty, temp_file, 137 cache_->StoreOnUIThread(
133 internal::FileCache::FILE_OPERATION_COPY, 138 resource_id_dirty, md5_dirty, temp_file,
134 google_apis::test_util::CreateCopyResultCallback(&error)); 139 internal::FileCache::FILE_OPERATION_COPY,
140 google_apis::test_util::CreateCopyResultCallback(&error));
135 google_apis::test_util::RunBlockingPoolTask(); 141 google_apis::test_util::RunBlockingPoolTask();
136 EXPECT_EQ(FILE_ERROR_OK, error); 142 EXPECT_EQ(FILE_ERROR_OK, error);
137 cache_->Pin(resource_id_dirty, md5_dirty, 143 cache_->PinOnUIThread(
138 google_apis::test_util::CreateCopyResultCallback(&error));
139 google_apis::test_util::RunBlockingPoolTask();
140 EXPECT_EQ(FILE_ERROR_OK, error);
141 cache_->MarkDirty(
142 resource_id_dirty, md5_dirty, 144 resource_id_dirty, md5_dirty,
143 google_apis::test_util::CreateCopyResultCallback(&error)); 145 google_apis::test_util::CreateCopyResultCallback(&error));
144 google_apis::test_util::RunBlockingPoolTask(); 146 google_apis::test_util::RunBlockingPoolTask();
145 EXPECT_EQ(FILE_ERROR_OK, error); 147 EXPECT_EQ(FILE_ERROR_OK, error);
146 cache_->CommitDirty( 148 cache_->MarkDirtyOnUIThread(
147 resource_id_dirty, md5_dirty, 149 resource_id_dirty, md5_dirty,
148 google_apis::test_util::CreateCopyResultCallback(&error)); 150 google_apis::test_util::CreateCopyResultCallback(&error));
149 google_apis::test_util::RunBlockingPoolTask(); 151 google_apis::test_util::RunBlockingPoolTask();
152 EXPECT_EQ(FILE_ERROR_OK, error);
153 cache_->CommitDirtyOnUIThread(
154 resource_id_dirty, md5_dirty,
155 google_apis::test_util::CreateCopyResultCallback(&error));
156 google_apis::test_util::RunBlockingPoolTask();
150 EXPECT_EQ(FILE_ERROR_OK, error); 157 EXPECT_EQ(FILE_ERROR_OK, error);
151 } 158 }
152 159
153 // Sets the expectation for MockFileSystem::GetFileByResourceId(), 160 // Sets the expectation for MockFileSystem::GetFileByResourceId(),
154 // that simulates successful retrieval of a file for the given resource ID. 161 // that simulates successful retrieval of a file for the given resource ID.
155 void SetExpectationForGetFileByResourceId(const std::string& resource_id) { 162 void SetExpectationForGetFileByResourceId(const std::string& resource_id) {
156 EXPECT_CALL(*mock_file_system_, 163 EXPECT_CALL(*mock_file_system_,
157 GetFileByResourceId(resource_id, _, _, _)) 164 GetFileByResourceId(resource_id, _, _, _))
158 .WillOnce( 165 .WillOnce(
159 MockGetFileByResourceId( 166 MockGetFileByResourceId(
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 // Start checking the existing pinned files. This will collect the resource 292 // Start checking the existing pinned files. This will collect the resource
286 // IDs of pinned files, with stale local cache files. 293 // IDs of pinned files, with stale local cache files.
287 sync_client_->StartCheckingExistingPinnedFiles(); 294 sync_client_->StartCheckingExistingPinnedFiles();
288 295
289 SetExpectationForGetFileByResourceId("resource_id_fetched"); 296 SetExpectationForGetFileByResourceId("resource_id_fetched");
290 297
291 google_apis::test_util::RunBlockingPoolTask(); 298 google_apis::test_util::RunBlockingPoolTask();
292 } 299 }
293 300
294 } // namespace drive 301 } // namespace drive
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/drive/sync_client.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698