OLD | NEW |
---|---|
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 "sync/test/engine/test_directory_setter_upper.h" | 5 #include "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/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
11 #include "sync/syncable/directory.h" | 11 #include "sync/syncable/directory.h" |
12 #include "sync/syncable/in_memory_directory_backing_store.h" | 12 #include "sync/syncable/in_memory_directory_backing_store.h" |
13 #include "sync/syncable/mutable_entry.h" | |
13 #include "sync/syncable/read_transaction.h" | 14 #include "sync/syncable/read_transaction.h" |
14 #include "sync/test/null_transaction_observer.h" | 15 #include "sync/syncable/write_transaction.h" |
16 #include "sync/test/mock_transaction_observer.h" | |
15 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
16 | 18 |
17 namespace syncer { | 19 namespace syncer { |
18 | 20 |
19 using syncable::NullTransactionObserver; | |
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 mock_transaction_observer_.reset(new syncable::MockTransactionObserver()); | |
27 WeakHandle<syncable::TransactionObserver> transaction_observer = | |
28 MakeWeakHandle(mock_transaction_observer_->AsWeakPtr()); | |
29 | |
26 directory_.reset(new syncable::Directory( | 30 directory_.reset(new syncable::Directory( |
27 new syncable::InMemoryDirectoryBackingStore(name_), | 31 new syncable::InMemoryDirectoryBackingStore(name_), |
28 &handler_, | 32 &handler_, |
29 NULL, | 33 NULL, |
30 &encryption_handler_, | 34 &encryption_handler_, |
31 encryption_handler_.cryptographer())); | 35 encryption_handler_.cryptographer())); |
32 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | |
Nicolas Zea
2012/09/14 19:15:08
was this not being used before?
rlarocque
2012/09/15 01:36:37
Nope. I must have forgotten to remove the temp_di
| |
33 ASSERT_EQ(syncable::OPENED, directory_->Open( | 36 ASSERT_EQ(syncable::OPENED, directory_->Open( |
34 name_, &delegate_, NullTransactionObserver())); | 37 name_, &delegate_, transaction_observer)); |
35 } | 38 } |
36 | 39 |
37 void TestDirectorySetterUpper::TearDown() { | 40 void TestDirectorySetterUpper::TearDown() { |
38 if (!directory()->good()) | 41 if (!directory()->good()) |
39 return; | 42 return; |
40 | 43 |
41 RunInvariantCheck(); | 44 RunInvariantCheck(); |
42 directory()->SaveChanges(); | 45 directory()->SaveChanges(); |
43 RunInvariantCheck(); | 46 RunInvariantCheck(); |
44 directory()->SaveChanges(); | 47 directory()->SaveChanges(); |
45 | 48 |
46 directory_.reset(); | 49 directory_.reset(); |
47 | |
48 ASSERT_TRUE(temp_dir_.Delete()); | |
49 } | 50 } |
50 | 51 |
51 void TestDirectorySetterUpper::RunInvariantCheck() { | 52 void TestDirectorySetterUpper::RunInvariantCheck() { |
52 // Check invariants for all items. | 53 // Check invariants for all items. |
53 syncable::ReadTransaction trans(FROM_HERE, directory()); | 54 syncable::ReadTransaction trans(FROM_HERE, directory()); |
54 | 55 |
55 // The TestUnrecoverableErrorHandler that this directory was constructed with | 56 // The TestUnrecoverableErrorHandler that this directory was constructed with |
56 // will handle error reporting, so we can safely ignore the return value. | 57 // will handle error reporting, so we can safely ignore the return value. |
57 directory()->FullyCheckTreeInvariants(&trans); | 58 directory()->FullyCheckTreeInvariants(&trans); |
58 } | 59 } |
59 | 60 |
60 } // namespace syncer | 61 } // namespace syncer |
OLD | NEW |