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..3434b879130ef53cc0c43b7290eeb5ed6aacebcd 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" |
| +#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,40 @@ TEST_F(SyncableDirectoryTest, OldClientLeftUnsyncedDeletedLocalItem) { |
| } |
| } |
| +TEST_F(SyncableDirectoryTest, OrdinalHandlesNullValues) { |
| + TestIdFactory id_factory; |
| + Id null_child_id; |
| + const char null_cstr[] = "\0null\0test"; |
| + std::string null_str(null_cstr, null_cstr + 9); |
|
rlarocque
2012/10/02 01:39:50
That second parameter is likely to be bigger than
|
| + int64 null_ord = NodeOrdinalToInt64( |
| + 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_POSITION_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_EQ(null_ord, |
| + null_ordinal_child.Get(SERVER_POSITION_IN_PARENT)); |
| + } |
| + |
| +} |
| + |
| // An OnDirectoryBackingStore that can be set to always fail SaveChanges. |
| class TestBackingStore : public OnDiskDirectoryBackingStore { |
| public: |