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

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

Issue 194065: Initial commit of sync engine code to browser/sync.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Fixes to gtest include path, reverted syncapi. Created 11 years, 3 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 | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/test/sync/engine/test_directory_setter_upper.h"
6
7 #include "chrome/browser/sync/syncable/directory_manager.h"
8 #include "chrome/browser/sync/syncable/syncable.h"
9 #include "chrome/browser/sync/util/compat-file.h"
10 #include "chrome/browser/sync/util/event_sys-inl.h"
11 #include "testing/gtest/include/gtest/gtest.h"
12
13 using syncable::DirectoryManager;
14 using syncable::ReadTransaction;
15 using syncable::ScopedDirLookup;
16
17 namespace browser_sync {
18
19 TestDirectorySetterUpper::TestDirectorySetterUpper() : name_(PSTR("Test")) {}
20
21 TestDirectorySetterUpper::~TestDirectorySetterUpper() {}
22
23 void TestDirectorySetterUpper::SetUp() {
24 PathString test_data_dir_ = PSTR(".");
25 manager_.reset(new DirectoryManager(test_data_dir_));
26 file_path_ = manager_->GetSyncDataDatabasePath();
27 PathRemove(file_path_.c_str());
28
29 ASSERT_TRUE(manager()->Open(name()));
30 }
31
32 void TestDirectorySetterUpper::TearDown() {
33 if (!manager())
34 return;
35
36 {
37 // A small scope so we don't have the dir open when we close it and
38 // reset the DirectoryManager below.
39 ScopedDirLookup dir(manager(), name());
40 CHECK(dir.good()) << "Bad directory during tear down check";
41 RunInvariantCheck(dir);
42 dir->SaveChanges();
43 RunInvariantCheck(dir);
44 dir->SaveChanges();
45 }
46
47 manager()->FinalSaveChangesForAll();
48 manager()->Close(name());
49 manager_.reset();
50 EXPECT_EQ(0, PathRemove(file_path_.c_str()));
51 file_path_.clear();
52 }
53
54 void TestDirectorySetterUpper::RunInvariantCheck(const ScopedDirLookup& dir) {
55 {
56 // Check invariants for in-memory items.
57 ReadTransaction trans(dir, __FILE__, __LINE__);
58 dir->CheckTreeInvariants(&trans, false);
59 }
60 {
61 // Check invariants for all items.
62 ReadTransaction trans(dir, __FILE__, __LINE__);
63 dir->CheckTreeInvariants(&trans, true);
64 }
65 }
66
67 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698