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

Side by Side Diff: components/sync/test/engine/test_directory_setter_upper.cc

Issue 2130453004: [Sync] Move //sync to //components/sync. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 4 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 "sync/test/engine/test_directory_setter_upper.h" 5 #include "components/sync/test/engine/test_directory_setter_upper.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/files/file_util.h" 8 #include "base/files/file_util.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
11 #include "sync/syncable/directory.h" 11 #include "components/sync/syncable/directory.h"
12 #include "sync/syncable/in_memory_directory_backing_store.h" 12 #include "components/sync/syncable/in_memory_directory_backing_store.h"
13 #include "sync/syncable/mutable_entry.h" 13 #include "components/sync/syncable/mutable_entry.h"
14 #include "sync/syncable/syncable_read_transaction.h" 14 #include "components/sync/syncable/syncable_read_transaction.h"
15 #include "sync/syncable/syncable_write_transaction.h" 15 #include "components/sync/syncable/syncable_write_transaction.h"
16 #include "sync/test/test_transaction_observer.h" 16 #include "components/sync/test/test_transaction_observer.h"
17 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
18 18
19 namespace syncer { 19 namespace syncer {
20 20
21 TestDirectorySetterUpper::TestDirectorySetterUpper() : name_("Test") {} 21 TestDirectorySetterUpper::TestDirectorySetterUpper() : name_("Test") {}
22 22
23 TestDirectorySetterUpper::~TestDirectorySetterUpper() {} 23 TestDirectorySetterUpper::~TestDirectorySetterUpper() {}
24 24
25 void TestDirectorySetterUpper::SetUp() { 25 void TestDirectorySetterUpper::SetUp() {
26 test_transaction_observer_.reset(new syncable::TestTransactionObserver()); 26 test_transaction_observer_.reset(new syncable::TestTransactionObserver());
27 WeakHandle<syncable::TransactionObserver> transaction_observer = 27 WeakHandle<syncable::TransactionObserver> transaction_observer =
28 MakeWeakHandle(test_transaction_observer_->AsWeakPtr()); 28 MakeWeakHandle(test_transaction_observer_->AsWeakPtr());
29 29
30 directory_.reset(new syncable::Directory( 30 directory_.reset(new syncable::Directory(
31 new syncable::InMemoryDirectoryBackingStore(name_), 31 new syncable::InMemoryDirectoryBackingStore(name_),
32 MakeWeakHandle(handler_.GetWeakPtr()), base::Closure(), 32 MakeWeakHandle(handler_.GetWeakPtr()), base::Closure(),
33 &encryption_handler_, encryption_handler_.cryptographer())); 33 &encryption_handler_, encryption_handler_.cryptographer()));
34 ASSERT_EQ(syncable::OPENED, directory_->Open( 34 ASSERT_EQ(syncable::OPENED,
35 name_, &delegate_, transaction_observer)); 35 directory_->Open(name_, &delegate_, transaction_observer));
36 } 36 }
37 37
38 void TestDirectorySetterUpper::SetUpWith( 38 void TestDirectorySetterUpper::SetUpWith(
39 syncer::syncable::DirectoryBackingStore* directory_store) { 39 syncer::syncable::DirectoryBackingStore* directory_store) {
40 CHECK(directory_store); 40 CHECK(directory_store);
41 test_transaction_observer_.reset(new syncable::TestTransactionObserver()); 41 test_transaction_observer_.reset(new syncable::TestTransactionObserver());
42 WeakHandle<syncable::TransactionObserver> transaction_observer = 42 WeakHandle<syncable::TransactionObserver> transaction_observer =
43 MakeWeakHandle(test_transaction_observer_->AsWeakPtr()); 43 MakeWeakHandle(test_transaction_observer_->AsWeakPtr());
44 44
45 directory_.reset(new syncable::Directory( 45 directory_.reset(new syncable::Directory(
46 directory_store, MakeWeakHandle(handler_.GetWeakPtr()), base::Closure(), 46 directory_store, MakeWeakHandle(handler_.GetWeakPtr()), base::Closure(),
47 &encryption_handler_, encryption_handler_.cryptographer())); 47 &encryption_handler_, encryption_handler_.cryptographer()));
48 ASSERT_EQ(syncable::OPENED, directory_->Open( 48 ASSERT_EQ(syncable::OPENED,
49 name_, &delegate_, transaction_observer)); 49 directory_->Open(name_, &delegate_, transaction_observer));
50 } 50 }
51 51
52 void TestDirectorySetterUpper::TearDown() { 52 void TestDirectorySetterUpper::TearDown() {
53 if (!directory()->good()) 53 if (!directory()->good())
54 return; 54 return;
55 55
56 RunInvariantCheck(); 56 RunInvariantCheck();
57 directory()->SaveChanges(); 57 directory()->SaveChanges();
58 RunInvariantCheck(); 58 RunInvariantCheck();
59 directory()->SaveChanges(); 59 directory()->SaveChanges();
60 60
61 directory_.reset(); 61 directory_.reset();
62 } 62 }
63 63
64 void TestDirectorySetterUpper::RunInvariantCheck() { 64 void TestDirectorySetterUpper::RunInvariantCheck() {
65 // Check invariants for all items. 65 // Check invariants for all items.
66 syncable::ReadTransaction trans(FROM_HERE, directory()); 66 syncable::ReadTransaction trans(FROM_HERE, directory());
67 67
68 // The TestUnrecoverableErrorHandler that this directory was constructed with 68 // The TestUnrecoverableErrorHandler that this directory was constructed with
69 // will handle error reporting, so we can safely ignore the return value. 69 // will handle error reporting, so we can safely ignore the return value.
70 directory()->FullyCheckTreeInvariants(&trans); 70 directory()->FullyCheckTreeInvariants(&trans);
71 } 71 }
72 72
73 } // namespace syncer 73 } // namespace syncer
OLDNEW
« no previous file with comments | « components/sync/test/engine/test_directory_setter_upper.h ('k') | components/sync/test/engine/test_id_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698