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

Side by Side Diff: components/drive/sync/entry_update_performer_unittest.cc

Issue 1546143002: Switch to standard integer types in components/, part 1 of 4. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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
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 "components/drive/sync/entry_update_performer.h" 5 #include "components/drive/sync/entry_update_performer.h"
6 6
7 #include <stdint.h>
8
7 #include "base/callback_helpers.h" 9 #include "base/callback_helpers.h"
8 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
9 #include "base/md5.h" 11 #include "base/md5.h"
10 #include "base/task_runner_util.h" 12 #include "base/task_runner_util.h"
11 #include "components/drive/drive_api_util.h" 13 #include "components/drive/drive_api_util.h"
12 #include "components/drive/file_cache.h" 14 #include "components/drive/file_cache.h"
13 #include "components/drive/file_system/download_operation.h" 15 #include "components/drive/file_system/download_operation.h"
14 #include "components/drive/file_system/operation_test_base.h" 16 #include "components/drive/file_system/operation_test_base.h"
15 #include "components/drive/job_scheduler.h" 17 #include "components/drive/job_scheduler.h"
16 #include "components/drive/resource_metadata.h" 18 #include "components/drive/resource_metadata.h"
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 TEST_F(EntryUpdatePerformerTest, UpdateEntry_ContentUpdate) { 258 TEST_F(EntryUpdatePerformerTest, UpdateEntry_ContentUpdate) {
257 const base::FilePath kFilePath(FILE_PATH_LITERAL("drive/root/File 1.txt")); 259 const base::FilePath kFilePath(FILE_PATH_LITERAL("drive/root/File 1.txt"));
258 const std::string kResourceId("2_file_resource_id"); 260 const std::string kResourceId("2_file_resource_id");
259 261
260 const std::string local_id = GetLocalId(kFilePath); 262 const std::string local_id = GetLocalId(kFilePath);
261 EXPECT_FALSE(local_id.empty()); 263 EXPECT_FALSE(local_id.empty());
262 264
263 const std::string kTestFileContent = "I'm being uploaded! Yay!"; 265 const std::string kTestFileContent = "I'm being uploaded! Yay!";
264 EXPECT_EQ(FILE_ERROR_OK, StoreAndMarkDirty(local_id, kTestFileContent)); 266 EXPECT_EQ(FILE_ERROR_OK, StoreAndMarkDirty(local_id, kTestFileContent));
265 267
266 int64 original_changestamp = 268 int64_t original_changestamp =
267 fake_service()->about_resource().largest_change_id(); 269 fake_service()->about_resource().largest_change_id();
268 270
269 // The callback will be called upon completion of UpdateEntry(). 271 // The callback will be called upon completion of UpdateEntry().
270 FileError error = FILE_ERROR_FAILED; 272 FileError error = FILE_ERROR_FAILED;
271 performer_->UpdateEntry( 273 performer_->UpdateEntry(
272 local_id, 274 local_id,
273 ClientContext(USER_INITIATED), 275 ClientContext(USER_INITIATED),
274 google_apis::test_util::CreateCopyResultCallback(&error)); 276 google_apis::test_util::CreateCopyResultCallback(&error));
275 content::RunAllBlockingPoolTasksUntilIdle(); 277 content::RunAllBlockingPoolTasksUntilIdle();
276 EXPECT_EQ(FILE_ERROR_OK, error); 278 EXPECT_EQ(FILE_ERROR_OK, error);
277 279
278 // Check that the server has received an update. 280 // Check that the server has received an update.
279 EXPECT_LT(original_changestamp, 281 EXPECT_LT(original_changestamp,
280 fake_service()->about_resource().largest_change_id()); 282 fake_service()->about_resource().largest_change_id());
281 283
282 // Check that the file size is updated to that of the updated content. 284 // Check that the file size is updated to that of the updated content.
283 google_apis::DriveApiErrorCode gdata_error = google_apis::DRIVE_OTHER_ERROR; 285 google_apis::DriveApiErrorCode gdata_error = google_apis::DRIVE_OTHER_ERROR;
284 scoped_ptr<google_apis::FileResource> server_entry; 286 scoped_ptr<google_apis::FileResource> server_entry;
285 fake_service()->GetFileResource( 287 fake_service()->GetFileResource(
286 kResourceId, 288 kResourceId,
287 google_apis::test_util::CreateCopyResultCallback(&gdata_error, 289 google_apis::test_util::CreateCopyResultCallback(&gdata_error,
288 &server_entry)); 290 &server_entry));
289 content::RunAllBlockingPoolTasksUntilIdle(); 291 content::RunAllBlockingPoolTasksUntilIdle();
290 EXPECT_EQ(google_apis::HTTP_SUCCESS, gdata_error); 292 EXPECT_EQ(google_apis::HTTP_SUCCESS, gdata_error);
291 EXPECT_EQ(static_cast<int64>(kTestFileContent.size()), 293 EXPECT_EQ(static_cast<int64_t>(kTestFileContent.size()),
292 server_entry->file_size()); 294 server_entry->file_size());
293 295
294 // Make sure that the cache is no longer dirty. 296 // Make sure that the cache is no longer dirty.
295 ResourceEntry entry; 297 ResourceEntry entry;
296 EXPECT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(kFilePath, &entry)); 298 EXPECT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(kFilePath, &entry));
297 EXPECT_FALSE(entry.file_specific_info().cache_state().is_dirty()); 299 EXPECT_FALSE(entry.file_specific_info().cache_state().is_dirty());
298 } 300 }
299 301
300 TEST_F(EntryUpdatePerformerTest, UpdateEntry_ContentUpdateMd5Check) { 302 TEST_F(EntryUpdatePerformerTest, UpdateEntry_ContentUpdateMd5Check) {
301 const base::FilePath kFilePath(FILE_PATH_LITERAL("drive/root/File 1.txt")); 303 const base::FilePath kFilePath(FILE_PATH_LITERAL("drive/root/File 1.txt"));
302 const std::string kResourceId("2_file_resource_id"); 304 const std::string kResourceId("2_file_resource_id");
303 305
304 const std::string local_id = GetLocalId(kFilePath); 306 const std::string local_id = GetLocalId(kFilePath);
305 EXPECT_FALSE(local_id.empty()); 307 EXPECT_FALSE(local_id.empty());
306 308
307 const std::string kTestFileContent = "I'm being uploaded! Yay!"; 309 const std::string kTestFileContent = "I'm being uploaded! Yay!";
308 EXPECT_EQ(FILE_ERROR_OK, StoreAndMarkDirty(local_id, kTestFileContent)); 310 EXPECT_EQ(FILE_ERROR_OK, StoreAndMarkDirty(local_id, kTestFileContent));
309 311
310 int64 original_changestamp = 312 int64_t original_changestamp =
311 fake_service()->about_resource().largest_change_id(); 313 fake_service()->about_resource().largest_change_id();
312 314
313 // The callback will be called upon completion of UpdateEntry(). 315 // The callback will be called upon completion of UpdateEntry().
314 FileError error = FILE_ERROR_FAILED; 316 FileError error = FILE_ERROR_FAILED;
315 performer_->UpdateEntry( 317 performer_->UpdateEntry(
316 local_id, 318 local_id,
317 ClientContext(USER_INITIATED), 319 ClientContext(USER_INITIATED),
318 google_apis::test_util::CreateCopyResultCallback(&error)); 320 google_apis::test_util::CreateCopyResultCallback(&error));
319 content::RunAllBlockingPoolTasksUntilIdle(); 321 content::RunAllBlockingPoolTasksUntilIdle();
320 EXPECT_EQ(FILE_ERROR_OK, error); 322 EXPECT_EQ(FILE_ERROR_OK, error);
321 323
322 // Check that the server has received an update. 324 // Check that the server has received an update.
323 EXPECT_LT(original_changestamp, 325 EXPECT_LT(original_changestamp,
324 fake_service()->about_resource().largest_change_id()); 326 fake_service()->about_resource().largest_change_id());
325 327
326 // Check that the file size is updated to that of the updated content. 328 // Check that the file size is updated to that of the updated content.
327 google_apis::DriveApiErrorCode gdata_error = google_apis::DRIVE_OTHER_ERROR; 329 google_apis::DriveApiErrorCode gdata_error = google_apis::DRIVE_OTHER_ERROR;
328 scoped_ptr<google_apis::FileResource> server_entry; 330 scoped_ptr<google_apis::FileResource> server_entry;
329 fake_service()->GetFileResource( 331 fake_service()->GetFileResource(
330 kResourceId, 332 kResourceId,
331 google_apis::test_util::CreateCopyResultCallback(&gdata_error, 333 google_apis::test_util::CreateCopyResultCallback(&gdata_error,
332 &server_entry)); 334 &server_entry));
333 content::RunAllBlockingPoolTasksUntilIdle(); 335 content::RunAllBlockingPoolTasksUntilIdle();
334 EXPECT_EQ(google_apis::HTTP_SUCCESS, gdata_error); 336 EXPECT_EQ(google_apis::HTTP_SUCCESS, gdata_error);
335 EXPECT_EQ(static_cast<int64>(kTestFileContent.size()), 337 EXPECT_EQ(static_cast<int64_t>(kTestFileContent.size()),
336 server_entry->file_size()); 338 server_entry->file_size());
337 339
338 // Make sure that the cache is no longer dirty. 340 // Make sure that the cache is no longer dirty.
339 ResourceEntry entry; 341 ResourceEntry entry;
340 EXPECT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(kFilePath, &entry)); 342 EXPECT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(kFilePath, &entry));
341 EXPECT_FALSE(entry.file_specific_info().cache_state().is_dirty()); 343 EXPECT_FALSE(entry.file_specific_info().cache_state().is_dirty());
342 344
343 // Again mark the cache file dirty. 345 // Again mark the cache file dirty.
344 scoped_ptr<base::ScopedClosureRunner> file_closer; 346 scoped_ptr<base::ScopedClosureRunner> file_closer;
345 error = FILE_ERROR_FAILED; 347 error = FILE_ERROR_FAILED;
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
649 651
650 // This should result in reverting the local change. 652 // This should result in reverting the local change.
651 ResourceEntry result_entry; 653 ResourceEntry result_entry;
652 EXPECT_EQ(FILE_ERROR_OK, 654 EXPECT_EQ(FILE_ERROR_OK,
653 GetLocalResourceEntryById(src_entry.local_id(), &result_entry)); 655 GetLocalResourceEntryById(src_entry.local_id(), &result_entry));
654 EXPECT_EQ(src_entry.title(), result_entry.title()); 656 EXPECT_EQ(src_entry.title(), result_entry.title());
655 } 657 }
656 658
657 } // namespace internal 659 } // namespace internal
658 } // namespace drive 660 } // namespace drive
OLDNEW
« no previous file with comments | « components/drive/sync/entry_update_performer.cc ('k') | components/drive/sync/remove_performer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698