Chromium Code Reviews| Index: sync/syncable/syncable_unittest.cc |
| diff --git a/sync/syncable/syncable_unittest.cc b/sync/syncable/syncable_unittest.cc |
| index f69347b75e7453b18879ac477e2130be19da82c5..edca3926bd16ec2014dce7864910bdfca675c03d 100644 |
| --- a/sync/syncable/syncable_unittest.cc |
| +++ b/sync/syncable/syncable_unittest.cc |
| @@ -17,6 +17,8 @@ |
| #include "base/test/values_test_util.h" |
| #include "base/threading/platform_thread.h" |
| #include "base/values.h" |
| +#include "sync/internal_api/public/base/ordinal.h" |
|
akalin
2012/10/05 22:40:27
no need for ordinal.h
vishwath
2012/10/08 20:17:49
Done.
|
| +#include "sync/internal_api/public/base/node_ordinal.h" |
| #include "sync/protocol/bookmark_specifics.pb.h" |
| #include "sync/syncable/directory_backing_store.h" |
| #include "sync/syncable/directory_change_delegate.h" |
| @@ -1366,6 +1368,39 @@ TEST_F(SyncableDirectoryTest, OldClientLeftUnsyncedDeletedLocalItem) { |
| } |
| } |
| +TEST_F(SyncableDirectoryTest, OrdinalHandlesNullValues) { |
|
akalin
2012/10/05 22:40:27
maybe a better name would be OrdinalWithNullSurviv
vishwath
2012/10/08 20:17:49
Done.
|
| + TestIdFactory id_factory; |
| + Id null_child_id; |
| + const char null_cstr[] = "\0null\0test"; |
| + std::string null_str(null_cstr, 9); |
|
akalin
2012/10/05 22:40:27
9 -> arraysize(null_cstr)
(include basictypes.h f
vishwath
2012/10/08 20:17:49
Done.
|
| + NodeOrdinal null_ord = NodeOrdinal(null_str); |
| + |
| + { |
| + WriteTransaction trans(FROM_HERE, UNITTEST, dir_.get()); |
| + |
| + MutableEntry parent(&trans, CREATE, id_factory.root(), "parent"); |
| + parent.Put(IS_DIR, true); |
| + parent.Put(IS_UNSYNCED, true); |
| + |
| + MutableEntry child(&trans, CREATE, parent.Get(ID), "child"); |
| + child.Put(IS_UNSYNCED, true); |
| + child.Put(SERVER_ORDINAL_IN_PARENT, null_ord); |
| + |
| + null_child_id = child.Get(ID); |
| + } |
| + |
| + EXPECT_EQ(OPENED, SimulateSaveAndReloadDir()); |
| + |
| + { |
| + ReadTransaction trans(FROM_HERE, dir_.get()); |
| + |
| + Entry null_ordinal_child(&trans, GET_BY_ID, null_child_id); |
| + EXPECT_TRUE( |
| + null_ord.Equals(null_ordinal_child.Get(SERVER_ORDINAL_IN_PARENT))); |
| + } |
| + |
| +} |
| + |
| // An OnDirectoryBackingStore that can be set to always fail SaveChanges. |
| class TestBackingStore : public OnDiskDirectoryBackingStore { |
| public: |
| @@ -1714,6 +1749,15 @@ TEST_F(OnDiskSyncableDirectoryTest, |
| update_post_save.ref((ProtoField)i).SerializeAsString()) |
| << "Blob field #" << i << " changed during save/load"; |
| } |
| + for ( ; i < ORDINAL_FIELDS_END; ++i) { |
| + EXPECT_EQ(create_pre_save.ref((OrdinalField)i).ToInternalValue(), |
| + create_post_save.ref((OrdinalField)i).ToInternalValue()) |
| + << "Blob field #" << i << " changed during save/load"; |
| + EXPECT_EQ(update_pre_save.ref((OrdinalField)i).ToInternalValue(), |
| + update_post_save.ref((OrdinalField)i).ToInternalValue()) |
| + << "Blob field #" << i << " changed during save/load"; |
| + } |
| + |
| } |
| TEST_F(OnDiskSyncableDirectoryTest, TestSaveChangesFailure) { |