OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/browser/sync/test/engine/test_directory_setter_upper.h" | |
6 | |
7 #include "base/compiler_specific.h" | |
8 #include "base/file_util.h" | |
9 #include "base/location.h" | |
10 #include "base/string_util.h" | |
11 #include "chrome/browser/sync/syncable/syncable.h" | |
12 #include "chrome/browser/sync/test/null_transaction_observer.h" | |
13 #include "testing/gtest/include/gtest/gtest.h" | |
14 | |
15 using syncable::NullTransactionObserver; | |
16 using syncable::ReadTransaction; | |
17 | |
18 namespace browser_sync { | |
19 | |
20 TestDirectorySetterUpper::TestDirectorySetterUpper() : name_("Test") {} | |
21 | |
22 TestDirectorySetterUpper::~TestDirectorySetterUpper() {} | |
23 | |
24 void TestDirectorySetterUpper::SetUp() { | |
25 directory_.reset(new syncable::Directory(&encryptor_, &handler_, NULL)); | |
26 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | |
27 ASSERT_EQ(syncable::OPENED, directory_->OpenInMemoryForTest( | |
28 name_, &delegate_, NullTransactionObserver())); | |
29 } | |
30 | |
31 void TestDirectorySetterUpper::TearDown() { | |
32 if (!directory()->good()) | |
33 return; | |
34 | |
35 { | |
36 RunInvariantCheck(); | |
37 directory()->SaveChanges(); | |
38 RunInvariantCheck(); | |
39 directory()->SaveChanges(); | |
40 } | |
41 directory_.reset(); | |
42 | |
43 ASSERT_TRUE(temp_dir_.Delete()); | |
44 } | |
45 | |
46 void TestDirectorySetterUpper::RunInvariantCheck() { | |
47 { | |
48 // Check invariants for in-memory items. | |
49 ReadTransaction trans(FROM_HERE, directory()); | |
50 directory()->CheckTreeInvariants(&trans, false); | |
51 } | |
52 { | |
53 // Check invariants for all items. | |
54 ReadTransaction trans(FROM_HERE, directory()); | |
55 directory()->CheckTreeInvariants(&trans, true); | |
56 } | |
57 } | |
58 | |
59 } // namespace browser_sync | |
OLD | NEW |