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

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

Issue 1866243002: Convert //sync from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 "sync/syncable/directory_unittest.h" 5 #include "sync/syncable/directory_unittest.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <cstdlib> 10 #include <cstdlib>
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 } 193 }
194 194
195 bool SyncableDirectoryTest::IsInDirtyMetahandles(int64_t metahandle) { 195 bool SyncableDirectoryTest::IsInDirtyMetahandles(int64_t metahandle) {
196 return 1 == dir_->kernel()->dirty_metahandles.count(metahandle); 196 return 1 == dir_->kernel()->dirty_metahandles.count(metahandle);
197 } 197 }
198 198
199 bool SyncableDirectoryTest::IsInMetahandlesToPurge(int64_t metahandle) { 199 bool SyncableDirectoryTest::IsInMetahandlesToPurge(int64_t metahandle) {
200 return 1 == dir_->kernel()->metahandles_to_purge.count(metahandle); 200 return 1 == dir_->kernel()->metahandles_to_purge.count(metahandle);
201 } 201 }
202 202
203 scoped_ptr<Directory>& SyncableDirectoryTest::dir() { 203 std::unique_ptr<Directory>& SyncableDirectoryTest::dir() {
204 return dir_; 204 return dir_;
205 } 205 }
206 206
207 DirectoryChangeDelegate* SyncableDirectoryTest::directory_change_delegate() { 207 DirectoryChangeDelegate* SyncableDirectoryTest::directory_change_delegate() {
208 return &delegate_; 208 return &delegate_;
209 } 209 }
210 210
211 Encryptor* SyncableDirectoryTest::encryptor() { 211 Encryptor* SyncableDirectoryTest::encryptor() {
212 return &encryptor_; 212 return &encryptor_;
213 } 213 }
(...skipping 1407 matching lines...) Expand 10 before | Expand all | Expand 10 after
1621 } 1621 }
1622 } 1622 }
1623 1623
1624 TEST_F(SyncableDirectoryTest, ToValue) { 1624 TEST_F(SyncableDirectoryTest, ToValue) {
1625 const Id id = TestIdFactory::FromNumber(99); 1625 const Id id = TestIdFactory::FromNumber(99);
1626 { 1626 {
1627 ReadTransaction rtrans(FROM_HERE, dir().get()); 1627 ReadTransaction rtrans(FROM_HERE, dir().get());
1628 Entry e(&rtrans, GET_BY_ID, id); 1628 Entry e(&rtrans, GET_BY_ID, id);
1629 EXPECT_FALSE(e.good()); // Hasn't been written yet. 1629 EXPECT_FALSE(e.good()); // Hasn't been written yet.
1630 1630
1631 scoped_ptr<base::DictionaryValue> value(e.ToValue(NULL)); 1631 std::unique_ptr<base::DictionaryValue> value(e.ToValue(NULL));
1632 ExpectDictBooleanValue(false, *value, "good"); 1632 ExpectDictBooleanValue(false, *value, "good");
1633 EXPECT_EQ(1u, value->size()); 1633 EXPECT_EQ(1u, value->size());
1634 } 1634 }
1635 1635
1636 // Test creating a new meta entry. 1636 // Test creating a new meta entry.
1637 { 1637 {
1638 WriteTransaction wtrans(FROM_HERE, UNITTEST, dir().get()); 1638 WriteTransaction wtrans(FROM_HERE, UNITTEST, dir().get());
1639 MutableEntry me(&wtrans, CREATE, BOOKMARKS, wtrans.root_id(), "new"); 1639 MutableEntry me(&wtrans, CREATE, BOOKMARKS, wtrans.root_id(), "new");
1640 ASSERT_TRUE(me.good()); 1640 ASSERT_TRUE(me.good());
1641 me.PutId(id); 1641 me.PutId(id);
1642 me.PutBaseVersion(1); 1642 me.PutBaseVersion(1);
1643 1643
1644 scoped_ptr<base::DictionaryValue> value(me.ToValue(NULL)); 1644 std::unique_ptr<base::DictionaryValue> value(me.ToValue(NULL));
1645 ExpectDictBooleanValue(true, *value, "good"); 1645 ExpectDictBooleanValue(true, *value, "good");
1646 EXPECT_TRUE(value->HasKey("kernel")); 1646 EXPECT_TRUE(value->HasKey("kernel"));
1647 ExpectDictStringValue("Bookmarks", *value, "modelType"); 1647 ExpectDictStringValue("Bookmarks", *value, "modelType");
1648 ExpectDictBooleanValue(true, *value, "existsOnClientBecauseNameIsNonEmpty"); 1648 ExpectDictBooleanValue(true, *value, "existsOnClientBecauseNameIsNonEmpty");
1649 ExpectDictBooleanValue(false, *value, "isRoot"); 1649 ExpectDictBooleanValue(false, *value, "isRoot");
1650 } 1650 }
1651 1651
1652 dir()->SaveChanges(); 1652 dir()->SaveChanges();
1653 } 1653 }
1654 1654
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1692 } 1692 }
1693 } 1693 }
1694 1694
1695 DISALLOW_COPY_AND_ASSIGN(StressTransactionsDelegate); 1695 DISALLOW_COPY_AND_ASSIGN(StressTransactionsDelegate);
1696 }; 1696 };
1697 1697
1698 // Stress test Directory by accessing it from several threads concurrently. 1698 // Stress test Directory by accessing it from several threads concurrently.
1699 TEST_F(SyncableDirectoryTest, StressTransactions) { 1699 TEST_F(SyncableDirectoryTest, StressTransactions) {
1700 const int kThreadCount = 7; 1700 const int kThreadCount = 7;
1701 base::PlatformThreadHandle threads[kThreadCount]; 1701 base::PlatformThreadHandle threads[kThreadCount];
1702 scoped_ptr<StressTransactionsDelegate> thread_delegates[kThreadCount]; 1702 std::unique_ptr<StressTransactionsDelegate> thread_delegates[kThreadCount];
1703 1703
1704 for (int i = 0; i < kThreadCount; ++i) { 1704 for (int i = 0; i < kThreadCount; ++i) {
1705 thread_delegates[i].reset(new StressTransactionsDelegate(dir().get(), i)); 1705 thread_delegates[i].reset(new StressTransactionsDelegate(dir().get(), i));
1706 ASSERT_TRUE(base::PlatformThread::Create( 1706 ASSERT_TRUE(base::PlatformThread::Create(
1707 0, thread_delegates[i].get(), &threads[i])); 1707 0, thread_delegates[i].get(), &threads[i]));
1708 } 1708 }
1709 1709
1710 for (int i = 0; i < kThreadCount; ++i) { 1710 for (int i = 0; i < kThreadCount; ++i) {
1711 base::PlatformThread::Join(threads[i]); 1711 base::PlatformThread::Join(threads[i]);
1712 } 1712 }
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
2131 EXPECT_FALSE(dir()->InitialSyncEndedForType(&trans, PREFERENCES)); 2131 EXPECT_FALSE(dir()->InitialSyncEndedForType(&trans, PREFERENCES));
2132 2132
2133 // Mark as complete and verify. 2133 // Mark as complete and verify.
2134 dir()->MarkInitialSyncEndedForType(&trans, PREFERENCES); 2134 dir()->MarkInitialSyncEndedForType(&trans, PREFERENCES);
2135 EXPECT_TRUE(dir()->InitialSyncEndedForType(&trans, PREFERENCES)); 2135 EXPECT_TRUE(dir()->InitialSyncEndedForType(&trans, PREFERENCES));
2136 } 2136 }
2137 2137
2138 } // namespace syncable 2138 } // namespace syncable
2139 2139
2140 } // namespace syncer 2140 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698