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

Side by Side Diff: components/sync/syncable/directory_unittest.cc

Issue 2427803002: [Sync] Replacing NULL with nullptr in code and null in comments for components/sync/ (Closed)
Patch Set: Fixing start of sentence capitlization. Created 4 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/sync/syncable/directory_unittest.h" 5 #include "components/sync/syncable/directory_unittest.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <cstdlib> 9 #include <cstdlib>
10 10
(...skipping 1328 matching lines...) Expand 10 before | Expand all | Expand 10 after
1339 EXPECT_FALSE(zombie.good()); 1339 EXPECT_FALSE(zombie.good());
1340 } 1340 }
1341 } 1341 }
1342 1342
1343 TEST_F(SyncableDirectoryTest, PositionWithNullSurvivesSaveAndReload) { 1343 TEST_F(SyncableDirectoryTest, PositionWithNullSurvivesSaveAndReload) {
1344 TestIdFactory id_factory; 1344 TestIdFactory id_factory;
1345 Id null_child_id; 1345 Id null_child_id;
1346 const char null_cstr[] = "\0null\0test"; 1346 const char null_cstr[] = "\0null\0test";
1347 std::string null_str(null_cstr, arraysize(null_cstr) - 1); 1347 std::string null_str(null_cstr, arraysize(null_cstr) - 1);
1348 // Pad up to the minimum length with 0x7f characters, then add a string that 1348 // Pad up to the minimum length with 0x7f characters, then add a string that
1349 // contains a few NULLs to the end. This is slightly wrong, since the suffix 1349 // contains a few nulls to the end. This is slightly wrong, since the suffix
1350 // part of a UniquePosition shouldn't contain NULLs, but it's good enough for 1350 // part of a UniquePosition shouldn't contain nulls, but it's good enough for
1351 // this test. 1351 // this test.
1352 std::string suffix = 1352 std::string suffix =
1353 std::string(UniquePosition::kSuffixLength - null_str.length(), '\x7f') + 1353 std::string(UniquePosition::kSuffixLength - null_str.length(), '\x7f') +
1354 null_str; 1354 null_str;
1355 UniquePosition null_pos = UniquePosition::FromInt64(10, suffix); 1355 UniquePosition null_pos = UniquePosition::FromInt64(10, suffix);
1356 1356
1357 { 1357 {
1358 WriteTransaction trans(FROM_HERE, UNITTEST, dir().get()); 1358 WriteTransaction trans(FROM_HERE, UNITTEST, dir().get());
1359 1359
1360 MutableEntry parent(&trans, CREATE, BOOKMARKS, id_factory.root(), "parent"); 1360 MutableEntry parent(&trans, CREATE, BOOKMARKS, id_factory.root(), "parent");
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
1614 } 1614 }
1615 } 1615 }
1616 1616
1617 TEST_F(SyncableDirectoryTest, ToValue) { 1617 TEST_F(SyncableDirectoryTest, ToValue) {
1618 const Id id = TestIdFactory::FromNumber(99); 1618 const Id id = TestIdFactory::FromNumber(99);
1619 { 1619 {
1620 ReadTransaction rtrans(FROM_HERE, dir().get()); 1620 ReadTransaction rtrans(FROM_HERE, dir().get());
1621 Entry e(&rtrans, GET_BY_ID, id); 1621 Entry e(&rtrans, GET_BY_ID, id);
1622 EXPECT_FALSE(e.good()); // Hasn't been written yet. 1622 EXPECT_FALSE(e.good()); // Hasn't been written yet.
1623 1623
1624 std::unique_ptr<base::DictionaryValue> value(e.ToValue(NULL)); 1624 std::unique_ptr<base::DictionaryValue> value(e.ToValue(nullptr));
1625 ExpectDictBooleanValue(false, *value, "good"); 1625 ExpectDictBooleanValue(false, *value, "good");
1626 EXPECT_EQ(1u, value->size()); 1626 EXPECT_EQ(1u, value->size());
1627 } 1627 }
1628 1628
1629 // Test creating a new meta entry. 1629 // Test creating a new meta entry.
1630 { 1630 {
1631 WriteTransaction wtrans(FROM_HERE, UNITTEST, dir().get()); 1631 WriteTransaction wtrans(FROM_HERE, UNITTEST, dir().get());
1632 MutableEntry me(&wtrans, CREATE, BOOKMARKS, wtrans.root_id(), "new"); 1632 MutableEntry me(&wtrans, CREATE, BOOKMARKS, wtrans.root_id(), "new");
1633 ASSERT_TRUE(me.good()); 1633 ASSERT_TRUE(me.good());
1634 me.PutId(id); 1634 me.PutId(id);
1635 me.PutBaseVersion(1); 1635 me.PutBaseVersion(1);
1636 1636
1637 std::unique_ptr<base::DictionaryValue> value(me.ToValue(NULL)); 1637 std::unique_ptr<base::DictionaryValue> value(me.ToValue(nullptr));
1638 ExpectDictBooleanValue(true, *value, "good"); 1638 ExpectDictBooleanValue(true, *value, "good");
1639 EXPECT_TRUE(value->HasKey("kernel")); 1639 EXPECT_TRUE(value->HasKey("kernel"));
1640 ExpectDictStringValue("Bookmarks", *value, "modelType"); 1640 ExpectDictStringValue("Bookmarks", *value, "modelType");
1641 ExpectDictBooleanValue(true, *value, "existsOnClientBecauseNameIsNonEmpty"); 1641 ExpectDictBooleanValue(true, *value, "existsOnClientBecauseNameIsNonEmpty");
1642 ExpectDictBooleanValue(false, *value, "isRoot"); 1642 ExpectDictBooleanValue(false, *value, "isRoot");
1643 } 1643 }
1644 1644
1645 dir()->SaveChanges(); 1645 dir()->SaveChanges();
1646 } 1646 }
1647 1647
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after
2138 2138
2139 const base::DictionaryValue* first_result; 2139 const base::DictionaryValue* first_result;
2140 ASSERT_TRUE(nodes->GetDictionary(0, &first_result)); 2140 ASSERT_TRUE(nodes->GetDictionary(0, &first_result));
2141 EXPECT_TRUE(first_result->HasKey("ID")); 2141 EXPECT_TRUE(first_result->HasKey("ID"));
2142 EXPECT_TRUE(first_result->HasKey("NON_UNIQUE_NAME")); 2142 EXPECT_TRUE(first_result->HasKey("NON_UNIQUE_NAME"));
2143 } 2143 }
2144 2144
2145 } // namespace syncable 2145 } // namespace syncable
2146 2146
2147 } // namespace syncer 2147 } // namespace syncer
OLDNEW
« no previous file with comments | « components/sync/syncable/directory_backing_store_unittest.cc ('k') | components/sync/syncable/entry.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698