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

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

Issue 214033: Use chrome/base synchronization primitives and threads instead of... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' 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
« no previous file with comments | « chrome/common/chrome_switches.cc ('k') | chrome/test/sync/engine/mock_server_connection.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // Mock ServerConnectionManager class for use in client unit tests. 5 // Mock ServerConnectionManager class for use in client unit tests.
6 6
7 #ifndef CHROME_TEST_SYNC_ENGINE_MOCK_SERVER_CONNECTION_H_ 7 #ifndef CHROME_TEST_SYNC_ENGINE_MOCK_SERVER_CONNECTION_H_
8 #define CHROME_TEST_SYNC_ENGINE_MOCK_SERVER_CONNECTION_H_ 8 #define CHROME_TEST_SYNC_ENGINE_MOCK_SERVER_CONNECTION_H_
9 9
10 #include <string> 10 #include <string>
(...skipping 13 matching lines...) Expand all
24 namespace browser_sync { 24 namespace browser_sync {
25 struct HttpResponse; 25 struct HttpResponse;
26 } 26 }
27 27
28 class MockConnectionManager : public browser_sync::ServerConnectionManager { 28 class MockConnectionManager : public browser_sync::ServerConnectionManager {
29 public: 29 public:
30 // A callback function type. These can be set to be called when server 30 // A callback function type. These can be set to be called when server
31 // activity would normally take place. This aids simulation of race 31 // activity would normally take place. This aids simulation of race
32 // conditions. 32 // conditions.
33 typedef bool (*TestCallbackFunction)(syncable::Directory* dir); 33 typedef bool (*TestCallbackFunction)(syncable::Directory* dir);
34 class MidCommitObserver {
35 public:
36 virtual void Observe() = 0;
37 };
34 38
35 MockConnectionManager(syncable::DirectoryManager* dirmgr, PathString name); 39 MockConnectionManager(syncable::DirectoryManager* dirmgr, PathString name);
36 virtual ~MockConnectionManager(); 40 virtual ~MockConnectionManager();
37 41
38 // Overridden ServerConnectionManager functions. 42 // Overridden ServerConnectionManager functions.
39 virtual bool PostBufferToPath(const PostBufferParams*, 43 virtual bool PostBufferToPath(const PostBufferParams*,
40 const string& path, 44 const string& path,
41 const string& auth_token); 45 const string& auth_token);
42 46
43 virtual bool IsServerReachable(); 47 virtual bool IsServerReachable();
44 virtual bool IsUserAuthenticated(); 48 virtual bool IsUserAuthenticated();
45 49
46 // Control of commit response. 50 // Control of commit response.
47 void SetMidCommitCallbackFunction(TestCallbackFunction callback); 51 void SetMidCommitCallbackFunction(TestCallbackFunction callback);
52 void SetMidCommitObserver(MidCommitObserver* observer);
48 53
49 // Set this if you want commit to perform commit time rename. Will request 54 // Set this if you want commit to perform commit time rename. Will request
50 // that the client renames all commited entries, prepending this string. 55 // that the client renames all commited entries, prepending this string.
51 void SetCommitTimeRename(string prepend); 56 void SetCommitTimeRename(string prepend);
52 57
53 // Control of get updates response. All updates set will only be returned 58 // Control of get updates response. All updates set will only be returned
54 // once. This mock object doesn't simulate a changelist, it simulates server 59 // once. This mock object doesn't simulate a changelist, it simulates server
55 // responses. 60 // responses.
56 void ResetUpdates(); 61 void ResetUpdates();
57 // Generic versions of AddUpdate functions. Tests using these function should 62 // Generic versions of AddUpdate functions. Tests using these function should
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 // The store birthday we send to the client. 175 // The store birthday we send to the client.
171 string store_birthday_; 176 string store_birthday_;
172 bool store_birthday_sent_; 177 bool store_birthday_sent_;
173 bool client_stuck_; 178 bool client_stuck_;
174 string commit_time_rename_prepended_string_; 179 string commit_time_rename_prepended_string_;
175 180
176 // Fail on the next call to PostBufferToPath(). 181 // Fail on the next call to PostBufferToPath().
177 bool fail_next_postbuffer_; 182 bool fail_next_postbuffer_;
178 183
179 // Our directory. 184 // Our directory.
180 syncable::ScopedDirLookup directory_; 185 syncable::DirectoryManager* directory_manager_;
186 PathString directory_name_;
181 187
182 // The updates we'll return to the next request. 188 // The updates we'll return to the next request.
183 sync_pb::GetUpdatesResponse updates_; 189 sync_pb::GetUpdatesResponse updates_;
184 TestCallbackFunction mid_commit_callback_function_; 190 TestCallbackFunction mid_commit_callback_function_;
191 MidCommitObserver* mid_commit_observer_;
185 192
186 scoped_ptr<sync_pb::ClientCommand> client_command_; 193 scoped_ptr<sync_pb::ClientCommand> client_command_;
187 194
188 // The next value to use for the position_in_parent property. 195 // The next value to use for the position_in_parent property.
189 int64 next_position_in_parent_; 196 int64 next_position_in_parent_;
190 197
191 DISALLOW_COPY_AND_ASSIGN(MockConnectionManager); 198 DISALLOW_COPY_AND_ASSIGN(MockConnectionManager);
192 }; 199 };
193 200
194 #endif // CHROME_TEST_SYNC_ENGINE_MOCK_SERVER_CONNECTION_H_ 201 #endif // CHROME_TEST_SYNC_ENGINE_MOCK_SERVER_CONNECTION_H_
OLDNEW
« no previous file with comments | « chrome/common/chrome_switches.cc ('k') | chrome/test/sync/engine/mock_server_connection.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698