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

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

Issue 246098: Sync: Remove pthreads from auth_watcher. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 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
OLDNEW
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 // A handy class that takes care of setting up and destroying a 5 // A handy class that takes care of setting up and destroying a
6 // syncable::Directory instance for unit tests that require one. 6 // syncable::Directory instance for unit tests that require one.
7 // 7 //
8 // The expected usage is to make this a component of your test fixture: 8 // The expected usage is to make this a component of your test fixture:
9 // 9 //
10 // class AwesomenessTest : public testing::Test { 10 // class AwesomenessTest : public testing::Test {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 52
53 // Undo everything done by SetUp(): close the directory and delete the 53 // Undo everything done by SetUp(): close the directory and delete the
54 // backing files. Before closing the directory, this will run the directory 54 // backing files. Before closing the directory, this will run the directory
55 // invariant checks and perform the SaveChanges action on the directory. 55 // invariant checks and perform the SaveChanges action on the directory.
56 virtual void TearDown(); 56 virtual void TearDown();
57 57
58 syncable::DirectoryManager* manager() const { return manager_.get(); } 58 syncable::DirectoryManager* manager() const { return manager_.get(); }
59 const PathString& name() const { return name_; } 59 const PathString& name() const { return name_; }
60 60
61 protected: 61 protected:
62 // Subclasses may want to use a different directory name.
63 explicit TestDirectorySetterUpper(const PathString& name);
62 virtual void Init(); 64 virtual void Init();
63 65
64 private: 66 private:
65 void RunInvariantCheck(const syncable::ScopedDirLookup& dir); 67 void RunInvariantCheck(const syncable::ScopedDirLookup& dir);
66 68
67 scoped_ptr<syncable::DirectoryManager> manager_; 69 scoped_ptr<syncable::DirectoryManager> manager_;
68 const PathString name_; 70 const PathString name_;
69 PathString file_path_; 71 PathString file_path_;
70 }; 72 };
71 73
72 // A variant of the above where SetUp does not actually open the directory. 74 // A variant of the above where SetUp does not actually open the directory.
73 // You must manually invoke Open(). This is useful if you are writing a test 75 // You must manually invoke Open(). This is useful if you are writing a test
74 // that depends on the DirectoryManager::OPENED event. 76 // that depends on the DirectoryManager::OPENED event.
75 class ManuallyOpenedTestDirectorySetterUpper : public TestDirectorySetterUpper { 77 class ManuallyOpenedTestDirectorySetterUpper : public TestDirectorySetterUpper {
76 public: 78 public:
77 ManuallyOpenedTestDirectorySetterUpper() : was_opened_(false) {} 79 ManuallyOpenedTestDirectorySetterUpper() : was_opened_(false) {}
78 virtual void SetUp(); 80 virtual void SetUp();
79 virtual void TearDown(); 81 virtual void TearDown();
80 void Open(); 82 void Open();
81 private: 83 private:
82 bool was_opened_; 84 bool was_opened_;
83 }; 85 };
84 86
87 // Use this flavor if you have a test that will trigger the opening event to
88 // happen automagically. It is careful on teardown to close only if needed.
89 class TriggeredOpenTestDirectorySetterUpper : public TestDirectorySetterUpper {
90 public:
91 // A triggered open is typically in response to a successful auth event just
92 // as in "real life". In this case, the name that will be used should be
93 // deterministically known at construction, and is passed in |name|.
94 TriggeredOpenTestDirectorySetterUpper(const std::string& name);
95 virtual void SetUp();
96 virtual void TearDown();
97 };
98
85 } // namespace browser_sync 99 } // namespace browser_sync
86 100
87 #endif // CHROME_TEST_SYNC_ENGINE_TEST_DIRECTORY_SETTER_UPPER_H_ 101 #endif // CHROME_TEST_SYNC_ENGINE_TEST_DIRECTORY_SETTER_UPPER_H_
OLDNEW
« no previous file with comments | « chrome/test/sync/engine/mock_server_connection.cc ('k') | chrome/test/sync/engine/test_directory_setter_upper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698