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

Side by Side Diff: 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
« no previous file with comments | « sync/test/engine/test_directory_setter_upper.h ('k') | sync/test/engine/test_id_factory.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "sync/test/engine/test_directory_setter_upper.h"
6
7 #include "base/compiler_specific.h"
8 #include "base/files/file_util.h"
9 #include "base/location.h"
10 #include "base/strings/string_util.h"
11 #include "sync/syncable/directory.h"
12 #include "sync/syncable/in_memory_directory_backing_store.h"
13 #include "sync/syncable/mutable_entry.h"
14 #include "sync/syncable/syncable_read_transaction.h"
15 #include "sync/syncable/syncable_write_transaction.h"
16 #include "sync/test/test_transaction_observer.h"
17 #include "testing/gtest/include/gtest/gtest.h"
18
19 namespace syncer {
20
21 TestDirectorySetterUpper::TestDirectorySetterUpper() : name_("Test") {}
22
23 TestDirectorySetterUpper::~TestDirectorySetterUpper() {}
24
25 void TestDirectorySetterUpper::SetUp() {
26 test_transaction_observer_.reset(new syncable::TestTransactionObserver());
27 WeakHandle<syncable::TransactionObserver> transaction_observer =
28 MakeWeakHandle(test_transaction_observer_->AsWeakPtr());
29
30 directory_.reset(new syncable::Directory(
31 new syncable::InMemoryDirectoryBackingStore(name_),
32 MakeWeakHandle(handler_.GetWeakPtr()), base::Closure(),
33 &encryption_handler_, encryption_handler_.cryptographer()));
34 ASSERT_EQ(syncable::OPENED, directory_->Open(
35 name_, &delegate_, transaction_observer));
36 }
37
38 void TestDirectorySetterUpper::SetUpWith(
39 syncer::syncable::DirectoryBackingStore* directory_store) {
40 CHECK(directory_store);
41 test_transaction_observer_.reset(new syncable::TestTransactionObserver());
42 WeakHandle<syncable::TransactionObserver> transaction_observer =
43 MakeWeakHandle(test_transaction_observer_->AsWeakPtr());
44
45 directory_.reset(new syncable::Directory(
46 directory_store, MakeWeakHandle(handler_.GetWeakPtr()), base::Closure(),
47 &encryption_handler_, encryption_handler_.cryptographer()));
48 ASSERT_EQ(syncable::OPENED, directory_->Open(
49 name_, &delegate_, transaction_observer));
50 }
51
52 void TestDirectorySetterUpper::TearDown() {
53 if (!directory()->good())
54 return;
55
56 RunInvariantCheck();
57 directory()->SaveChanges();
58 RunInvariantCheck();
59 directory()->SaveChanges();
60
61 directory_.reset();
62 }
63
64 void TestDirectorySetterUpper::RunInvariantCheck() {
65 // Check invariants for all items.
66 syncable::ReadTransaction trans(FROM_HERE, directory());
67
68 // The TestUnrecoverableErrorHandler that this directory was constructed with
69 // will handle error reporting, so we can safely ignore the return value.
70 directory()->FullyCheckTreeInvariants(&trans);
71 }
72
73 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/test/engine/test_directory_setter_upper.h ('k') | sync/test/engine/test_id_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698