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

Side by Side Diff: sync/syncable/syncable_unittest.cc

Issue 1545553003: Switch to standard integer types in sync/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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
« no previous file with comments | « sync/syncable/syncable_read_transaction.h ('k') | sync/syncable/syncable_util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 <stdint.h>
6
5 #include <string> 7 #include <string>
6 8
7 #include "base/basictypes.h"
8 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
9 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
10 #include "base/files/file_util.h" 11 #include "base/files/file_util.h"
11 #include "base/files/scoped_temp_dir.h" 12 #include "base/files/scoped_temp_dir.h"
12 #include "base/location.h" 13 #include "base/location.h"
13 #include "base/logging.h" 14 #include "base/logging.h"
14 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
15 #include "base/message_loop/message_loop.h" 16 #include "base/message_loop/message_loop.h"
16 #include "base/stl_util.h" 17 #include "base/stl_util.h"
17 #include "base/synchronization/condition_variable.h" 18 #include "base/synchronization/condition_variable.h"
18 #include "base/test/values_test_util.h" 19 #include "base/test/values_test_util.h"
19 #include "base/threading/platform_thread.h" 20 #include "base/threading/platform_thread.h"
20 #include "base/values.h" 21 #include "base/values.h"
22 #include "build/build_config.h"
21 #include "sync/protocol/bookmark_specifics.pb.h" 23 #include "sync/protocol/bookmark_specifics.pb.h"
22 #include "sync/syncable/directory_backing_store.h" 24 #include "sync/syncable/directory_backing_store.h"
23 #include "sync/syncable/directory_change_delegate.h" 25 #include "sync/syncable/directory_change_delegate.h"
24 #include "sync/syncable/directory_unittest.h" 26 #include "sync/syncable/directory_unittest.h"
25 #include "sync/syncable/in_memory_directory_backing_store.h" 27 #include "sync/syncable/in_memory_directory_backing_store.h"
26 #include "sync/syncable/metahandle_set.h" 28 #include "sync/syncable/metahandle_set.h"
27 #include "sync/syncable/mutable_entry.h" 29 #include "sync/syncable/mutable_entry.h"
28 #include "sync/syncable/on_disk_directory_backing_store.h" 30 #include "sync/syncable/on_disk_directory_backing_store.h"
29 #include "sync/syncable/syncable_proto_util.h" 31 #include "sync/syncable/syncable_proto_util.h"
30 #include "sync/syncable/syncable_read_transaction.h" 32 #include "sync/syncable/syncable_read_transaction.h"
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 { 367 {
366 ReadTransaction trans(FROM_HERE, dir().get()); 368 ReadTransaction trans(FROM_HERE, dir().get());
367 Entry create(&trans, GET_BY_ID, create_id); 369 Entry create(&trans, GET_BY_ID, create_id);
368 EXPECT_EQ(1, CountEntriesWithName(&trans, trans.root_id(), create_name)); 370 EXPECT_EQ(1, CountEntriesWithName(&trans, trans.root_id(), create_name));
369 Entry update(&trans, GET_BY_ID, update_id); 371 Entry update(&trans, GET_BY_ID, update_id);
370 create_post_save = create.GetKernelCopy(); 372 create_post_save = create.GetKernelCopy();
371 update_post_save = update.GetKernelCopy(); 373 update_post_save = update.GetKernelCopy();
372 } 374 }
373 int i = BEGIN_FIELDS; 375 int i = BEGIN_FIELDS;
374 for ( ; i < INT64_FIELDS_END ; ++i) { 376 for ( ; i < INT64_FIELDS_END ; ++i) {
375 EXPECT_EQ(create_pre_save.ref((Int64Field)i) + 377 EXPECT_EQ(
376 (i == TRANSACTION_VERSION ? 1 : 0), 378 create_pre_save.ref((Int64Field)i) + (i == TRANSACTION_VERSION ? 1 : 0),
377 create_post_save.ref((Int64Field)i)) 379 create_post_save.ref((Int64Field)i))
378 << "int64 field #" << i << " changed during save/load"; 380 << "int64_t field #" << i << " changed during save/load";
379 EXPECT_EQ(update_pre_save.ref((Int64Field)i), 381 EXPECT_EQ(update_pre_save.ref((Int64Field)i),
380 update_post_save.ref((Int64Field)i)) 382 update_post_save.ref((Int64Field)i))
381 << "int64 field #" << i << " changed during save/load"; 383 << "int64_t field #" << i << " changed during save/load";
382 } 384 }
383 for ( ; i < TIME_FIELDS_END ; ++i) { 385 for ( ; i < TIME_FIELDS_END ; ++i) {
384 EXPECT_EQ(create_pre_save.ref((TimeField)i), 386 EXPECT_EQ(create_pre_save.ref((TimeField)i),
385 create_post_save.ref((TimeField)i)) 387 create_post_save.ref((TimeField)i))
386 << "time field #" << i << " changed during save/load"; 388 << "time field #" << i << " changed during save/load";
387 EXPECT_EQ(update_pre_save.ref((TimeField)i), 389 EXPECT_EQ(update_pre_save.ref((TimeField)i),
388 update_post_save.ref((TimeField)i)) 390 update_post_save.ref((TimeField)i))
389 << "time field #" << i << " changed during save/load"; 391 << "time field #" << i << " changed during save/load";
390 } 392 }
391 for ( ; i < ID_FIELDS_END ; ++i) { 393 for ( ; i < ID_FIELDS_END ; ++i) {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 EXPECT_TRUE(create_pre_save.ref((UniquePositionField)i).Equals( 426 EXPECT_TRUE(create_pre_save.ref((UniquePositionField)i).Equals(
425 create_post_save.ref((UniquePositionField)i))) 427 create_post_save.ref((UniquePositionField)i)))
426 << "Position field #" << i << " changed during save/load"; 428 << "Position field #" << i << " changed during save/load";
427 EXPECT_TRUE(update_pre_save.ref((UniquePositionField)i).Equals( 429 EXPECT_TRUE(update_pre_save.ref((UniquePositionField)i).Equals(
428 update_post_save.ref((UniquePositionField)i))) 430 update_post_save.ref((UniquePositionField)i)))
429 << "Position field #" << i << " changed during save/load"; 431 << "Position field #" << i << " changed during save/load";
430 } 432 }
431 } 433 }
432 434
433 TEST_F(OnDiskSyncableDirectoryTest, TestSaveChangesFailure) { 435 TEST_F(OnDiskSyncableDirectoryTest, TestSaveChangesFailure) {
434 int64 handle1 = 0; 436 int64_t handle1 = 0;
435 // Set up an item using a regular, saveable directory. 437 // Set up an item using a regular, saveable directory.
436 { 438 {
437 WriteTransaction trans(FROM_HERE, UNITTEST, dir().get()); 439 WriteTransaction trans(FROM_HERE, UNITTEST, dir().get());
438 440
439 MutableEntry e1(&trans, CREATE, BOOKMARKS, trans.root_id(), "aguilera"); 441 MutableEntry e1(&trans, CREATE, BOOKMARKS, trans.root_id(), "aguilera");
440 ASSERT_TRUE(e1.good()); 442 ASSERT_TRUE(e1.good());
441 EXPECT_TRUE(e1.GetKernelCopy().is_dirty()); 443 EXPECT_TRUE(e1.GetKernelCopy().is_dirty());
442 handle1 = e1.GetMetahandle(); 444 handle1 = e1.GetMetahandle();
443 e1.PutBaseVersion(1); 445 e1.PutBaseVersion(1);
444 e1.PutIsDir(true); 446 e1.PutIsDir(true);
(...skipping 15 matching lines...) Expand all
460 aguilera.PutNonUniqueName("overwritten"); 462 aguilera.PutNonUniqueName("overwritten");
461 EXPECT_TRUE(aguilera.GetKernelCopy().is_dirty()); 463 EXPECT_TRUE(aguilera.GetKernelCopy().is_dirty());
462 EXPECT_TRUE(IsInDirtyMetahandles(handle1)); 464 EXPECT_TRUE(IsInDirtyMetahandles(handle1));
463 } 465 }
464 ASSERT_TRUE(dir()->SaveChanges()); 466 ASSERT_TRUE(dir()->SaveChanges());
465 467
466 // Now do some operations when SaveChanges() will fail. 468 // Now do some operations when SaveChanges() will fail.
467 StartFailingSaveChanges(); 469 StartFailingSaveChanges();
468 ASSERT_TRUE(dir()->good()); 470 ASSERT_TRUE(dir()->good());
469 471
470 int64 handle2 = 0; 472 int64_t handle2 = 0;
471 { 473 {
472 WriteTransaction trans(FROM_HERE, UNITTEST, dir().get()); 474 WriteTransaction trans(FROM_HERE, UNITTEST, dir().get());
473 475
474 MutableEntry aguilera(&trans, GET_BY_HANDLE, handle1); 476 MutableEntry aguilera(&trans, GET_BY_HANDLE, handle1);
475 ASSERT_TRUE(aguilera.good()); 477 ASSERT_TRUE(aguilera.good());
476 EXPECT_FALSE(aguilera.GetKernelCopy().is_dirty()); 478 EXPECT_FALSE(aguilera.GetKernelCopy().is_dirty());
477 EXPECT_EQ(aguilera.GetNonUniqueName(), "overwritten"); 479 EXPECT_EQ(aguilera.GetNonUniqueName(), "overwritten");
478 EXPECT_FALSE(aguilera.GetKernelCopy().is_dirty()); 480 EXPECT_FALSE(aguilera.GetKernelCopy().is_dirty());
479 EXPECT_FALSE(IsInDirtyMetahandles(handle1)); 481 EXPECT_FALSE(IsInDirtyMetahandles(handle1));
480 aguilera.PutNonUniqueName("christina"); 482 aguilera.PutNonUniqueName("christina");
(...skipping 25 matching lines...) Expand all
506 Entry kids(&trans, GET_BY_HANDLE, handle2); 508 Entry kids(&trans, GET_BY_HANDLE, handle2);
507 ASSERT_TRUE(kids.good()); 509 ASSERT_TRUE(kids.good());
508 EXPECT_TRUE(kids.GetKernelCopy().is_dirty()); 510 EXPECT_TRUE(kids.GetKernelCopy().is_dirty());
509 EXPECT_TRUE(IsInDirtyMetahandles(handle2)); 511 EXPECT_TRUE(IsInDirtyMetahandles(handle2));
510 EXPECT_TRUE(aguilera.is_dirty()); 512 EXPECT_TRUE(aguilera.is_dirty());
511 EXPECT_TRUE(IsInDirtyMetahandles(handle1)); 513 EXPECT_TRUE(IsInDirtyMetahandles(handle1));
512 } 514 }
513 } 515 }
514 516
515 TEST_F(OnDiskSyncableDirectoryTest, TestSaveChangesFailureWithPurge) { 517 TEST_F(OnDiskSyncableDirectoryTest, TestSaveChangesFailureWithPurge) {
516 int64 handle1 = 0; 518 int64_t handle1 = 0;
517 // Set up an item and progress marker using a regular, saveable directory. 519 // Set up an item and progress marker using a regular, saveable directory.
518 dir()->SetDownloadProgress(BOOKMARKS, BuildProgress(BOOKMARKS)); 520 dir()->SetDownloadProgress(BOOKMARKS, BuildProgress(BOOKMARKS));
519 { 521 {
520 WriteTransaction trans(FROM_HERE, UNITTEST, dir().get()); 522 WriteTransaction trans(FROM_HERE, UNITTEST, dir().get());
521 523
522 MutableEntry e1(&trans, CREATE, BOOKMARKS, trans.root_id(), "aguilera"); 524 MutableEntry e1(&trans, CREATE, BOOKMARKS, trans.root_id(), "aguilera");
523 ASSERT_TRUE(e1.good()); 525 ASSERT_TRUE(e1.good());
524 EXPECT_TRUE(e1.GetKernelCopy().is_dirty()); 526 EXPECT_TRUE(e1.GetKernelCopy().is_dirty());
525 handle1 = e1.GetMetahandle(); 527 handle1 = e1.GetMetahandle();
526 e1.PutBaseVersion(1); 528 e1.PutBaseVersion(1);
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
668 TEST_F(SyncableClientTagTest, TestClientTagIndexDuplicateServer) { 670 TEST_F(SyncableClientTagTest, TestClientTagIndexDuplicateServer) {
669 EXPECT_TRUE(CreateWithDefaultTag(factory_.NewServerId(), true)); 671 EXPECT_TRUE(CreateWithDefaultTag(factory_.NewServerId(), true));
670 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewServerId(), true)); 672 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewServerId(), true));
671 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewServerId(), false)); 673 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewServerId(), false));
672 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewLocalId(), false)); 674 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewLocalId(), false));
673 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewLocalId(), true)); 675 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewLocalId(), true));
674 } 676 }
675 677
676 } // namespace syncable 678 } // namespace syncable
677 } // namespace syncer 679 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/syncable/syncable_read_transaction.h ('k') | sync/syncable/syncable_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698