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

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

Issue 10989063: Changed DB to store node positions as Ordinals. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Implemented feedback changes. Created 8 years, 2 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 (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 <string> 5 #include <string>
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/file_path.h" 8 #include "base/file_path.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 17 matching lines...) Expand all
28 #include "sync/syncable/syncable_proto_util.h" 28 #include "sync/syncable/syncable_proto_util.h"
29 #include "sync/syncable/syncable_util.h" 29 #include "sync/syncable/syncable_util.h"
30 #include "sync/syncable/write_transaction.h" 30 #include "sync/syncable/write_transaction.h"
31 #include "sync/test/engine/test_id_factory.h" 31 #include "sync/test/engine/test_id_factory.h"
32 #include "sync/test/engine/test_syncable_utils.h" 32 #include "sync/test/engine/test_syncable_utils.h"
33 #include "sync/test/fake_encryptor.h" 33 #include "sync/test/fake_encryptor.h"
34 #include "sync/test/null_directory_change_delegate.h" 34 #include "sync/test/null_directory_change_delegate.h"
35 #include "sync/test/null_transaction_observer.h" 35 #include "sync/test/null_transaction_observer.h"
36 #include "sync/util/test_unrecoverable_error_handler.h" 36 #include "sync/util/test_unrecoverable_error_handler.h"
37 #include "testing/gtest/include/gtest/gtest.h" 37 #include "testing/gtest/include/gtest/gtest.h"
38 #include "sync/internal_api/public/base/ordinal.h"
rlarocque 2012/10/01 21:45:55 Fix include ordering.
vishwath 2012/10/02 01:06:33 Done.
39 #include "sync/internal_api/public/base/node_ordinal.h"
38 40
39 namespace syncer { 41 namespace syncer {
40 namespace syncable { 42 namespace syncable {
41 43
42 using base::ExpectDictBooleanValue; 44 using base::ExpectDictBooleanValue;
43 using base::ExpectDictStringValue; 45 using base::ExpectDictStringValue;
44 46
45 class SyncableKernelTest : public testing::Test {}; 47 class SyncableKernelTest : public testing::Test {};
46 48
47 // TODO(akalin): Add unit tests for EntryKernel::ContainsString(). 49 // TODO(akalin): Add unit tests for EntryKernel::ContainsString().
(...skipping 1311 matching lines...) Expand 10 before | Expand all | Expand 10 after
1359 EXPECT_TRUE(server_knows.good()); 1361 EXPECT_TRUE(server_knows.good());
1360 1362
1361 Entry not_is_del(&trans, GET_BY_ID, not_is_del_id); 1363 Entry not_is_del(&trans, GET_BY_ID, not_is_del_id);
1362 EXPECT_TRUE(not_is_del.good()); 1364 EXPECT_TRUE(not_is_del.good());
1363 1365
1364 Entry zombie(&trans, GET_BY_ID, zombie_id); 1366 Entry zombie(&trans, GET_BY_ID, zombie_id);
1365 EXPECT_FALSE(zombie.good()); 1367 EXPECT_FALSE(zombie.good());
1366 } 1368 }
1367 } 1369 }
1368 1370
1371 TEST_F(SyncableDirectoryTest, OrdinalHandlesNullValues) {
1372 TestIdFactory id_factory;
1373 Id null_child_id;
1374 int64 null_ord = NodeOrdinalToInt64(
1375 NodeOrdinal("Thisshould\0workfine"));
rlarocque 2012/10/01 21:45:55 IIRC, only the first 8 bytes will be maintained af
vishwath 2012/10/02 01:06:33 Done.
1376
1377 {
1378 WriteTransaction trans(FROM_HERE, UNITTEST, dir_.get());
1379
1380 MutableEntry parent(&trans, CREATE, id_factory.root(), "parent");
1381 parent.Put(IS_DIR, true);
1382 parent.Put(IS_UNSYNCED, true);
1383
1384 MutableEntry child(&trans, CREATE, parent.Get(ID), "child");
1385 child.Put(IS_UNSYNCED, true);
1386 child.Put(SERVER_POSITION_IN_PARENT, null_ord);
1387
1388 null_child_id = child.Get(ID);
1389 }
1390
1391 EXPECT_EQ(OPENED, SimulateSaveAndReloadDir());
1392
1393 {
1394 ReadTransaction trans(FROM_HERE, dir_.get());
1395
1396 Entry null_ordinal_child(&trans, GET_BY_ID, null_child_id);
1397 EXPECT_EQ(null_ord,
1398 null_ordinal_child.Get(SERVER_POSITION_IN_PARENT));
1399 }
1400
1401 }
1402
1369 // An OnDirectoryBackingStore that can be set to always fail SaveChanges. 1403 // An OnDirectoryBackingStore that can be set to always fail SaveChanges.
1370 class TestBackingStore : public OnDiskDirectoryBackingStore { 1404 class TestBackingStore : public OnDiskDirectoryBackingStore {
1371 public: 1405 public:
1372 TestBackingStore(const std::string& dir_name, 1406 TestBackingStore(const std::string& dir_name,
1373 const FilePath& backing_filepath); 1407 const FilePath& backing_filepath);
1374 1408
1375 virtual ~TestBackingStore(); 1409 virtual ~TestBackingStore();
1376 1410
1377 virtual bool SaveChanges(const Directory::SaveChangesSnapshot& snapshot) 1411 virtual bool SaveChanges(const Directory::SaveChangesSnapshot& snapshot)
1378 OVERRIDE; 1412 OVERRIDE;
(...skipping 711 matching lines...) Expand 10 before | Expand all | Expand 10 after
2090 EXPECT_TRUE(CreateWithDefaultTag(factory_.NewServerId(), true)); 2124 EXPECT_TRUE(CreateWithDefaultTag(factory_.NewServerId(), true));
2091 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewServerId(), true)); 2125 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewServerId(), true));
2092 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewServerId(), false)); 2126 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewServerId(), false));
2093 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewLocalId(), false)); 2127 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewLocalId(), false));
2094 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewLocalId(), true)); 2128 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewLocalId(), true));
2095 } 2129 }
2096 2130
2097 } // namespace 2131 } // namespace
2098 } // namespace syncable 2132 } // namespace syncable
2099 } // namespace syncer 2133 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698