OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "chrome/test/sync/engine/test_directory_setter_upper.h" | 5 #include "chrome/test/sync/engine/test_directory_setter_upper.h" |
6 | 6 |
7 #include "chrome/browser/sync/syncable/directory_manager.h" | 7 #include "chrome/browser/sync/syncable/directory_manager.h" |
8 #include "chrome/browser/sync/syncable/syncable.h" | 8 #include "chrome/browser/sync/syncable/syncable.h" |
9 #include "chrome/browser/sync/util/compat_file.h" | 9 #include "chrome/browser/sync/util/compat_file.h" |
10 #include "chrome/browser/sync/util/event_sys-inl.h" | 10 #include "chrome/browser/sync/util/event_sys-inl.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
12 | 12 |
13 using syncable::DirectoryManager; | 13 using syncable::DirectoryManager; |
14 using syncable::ReadTransaction; | 14 using syncable::ReadTransaction; |
15 using syncable::ScopedDirLookup; | 15 using syncable::ScopedDirLookup; |
16 | 16 |
17 namespace browser_sync { | 17 namespace browser_sync { |
18 | 18 |
19 TestDirectorySetterUpper::TestDirectorySetterUpper() : name_(PSTR("Test")) {} | 19 TestDirectorySetterUpper::TestDirectorySetterUpper() : name_(PSTR("Test")) {} |
20 | 20 |
21 TestDirectorySetterUpper::~TestDirectorySetterUpper() {} | 21 TestDirectorySetterUpper::~TestDirectorySetterUpper() {} |
22 | 22 |
23 void TestDirectorySetterUpper::SetUp() { | 23 void TestDirectorySetterUpper::Init() { |
24 PathString test_data_dir_ = PSTR("."); | 24 PathString test_data_dir_ = PSTR("."); |
25 manager_.reset(new DirectoryManager(test_data_dir_)); | 25 manager_.reset(new DirectoryManager(test_data_dir_)); |
26 file_path_ = manager_->GetSyncDataDatabasePath(); | 26 file_path_ = manager_->GetSyncDataDatabasePath(); |
27 PathRemove(file_path_.c_str()); | 27 PathRemove(file_path_.c_str()); |
| 28 } |
28 | 29 |
| 30 void TestDirectorySetterUpper::SetUp() { |
| 31 Init(); |
29 ASSERT_TRUE(manager()->Open(name())); | 32 ASSERT_TRUE(manager()->Open(name())); |
30 } | 33 } |
31 | 34 |
32 void TestDirectorySetterUpper::TearDown() { | 35 void TestDirectorySetterUpper::TearDown() { |
33 if (!manager()) | 36 if (!manager()) |
34 return; | 37 return; |
35 | 38 |
36 { | 39 { |
37 // A small scope so we don't have the dir open when we close it and reset | 40 // A small scope so we don't have the dir open when we close it and reset |
38 // the DirectoryManager below. | 41 // the DirectoryManager below. |
(...skipping 18 matching lines...) Expand all Loading... |
57 ReadTransaction trans(dir, __FILE__, __LINE__); | 60 ReadTransaction trans(dir, __FILE__, __LINE__); |
58 dir->CheckTreeInvariants(&trans, false); | 61 dir->CheckTreeInvariants(&trans, false); |
59 } | 62 } |
60 { | 63 { |
61 // Check invariants for all items. | 64 // Check invariants for all items. |
62 ReadTransaction trans(dir, __FILE__, __LINE__); | 65 ReadTransaction trans(dir, __FILE__, __LINE__); |
63 dir->CheckTreeInvariants(&trans, true); | 66 dir->CheckTreeInvariants(&trans, true); |
64 } | 67 } |
65 } | 68 } |
66 | 69 |
| 70 void ManuallyOpenedTestDirectorySetterUpper::SetUp() { |
| 71 Init(); |
| 72 } |
| 73 |
| 74 void ManuallyOpenedTestDirectorySetterUpper::Open() { |
| 75 ASSERT_TRUE(manager()->Open(name())); |
| 76 was_opened_ = true; |
| 77 } |
| 78 |
| 79 void ManuallyOpenedTestDirectorySetterUpper::TearDown() { |
| 80 if (was_opened_) { |
| 81 TestDirectorySetterUpper::TearDown(); |
| 82 } |
| 83 } |
| 84 |
67 } // namespace browser_sync | 85 } // namespace browser_sync |
OLD | NEW |