OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #ifndef CHROME_TEST_SYNC_ENGINE_SYNCER_COMMAND_TEST_H_ | 5 #ifndef CHROME_TEST_SYNC_ENGINE_SYNCER_COMMAND_TEST_H_ |
6 #define CHROME_TEST_SYNC_ENGINE_SYNCER_COMMAND_TEST_H_ | 6 #define CHROME_TEST_SYNC_ENGINE_SYNCER_COMMAND_TEST_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "chrome/test/sync/engine/test_directory_setter_upper.h" | 10 #include "chrome/test/sync/engine/test_directory_setter_upper.h" |
11 #include "chrome/browser/sync/engine/model_safe_worker.h" | 11 #include "chrome/browser/sync/engine/model_safe_worker.h" |
12 #include "chrome/browser/sync/sessions/sync_session.h" | 12 #include "chrome/browser/sync/sessions/sync_session.h" |
13 #include "chrome/browser/sync/sessions/sync_session_context.h" | 13 #include "chrome/browser/sync/sessions/sync_session_context.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
15 | 15 |
16 namespace browser_sync { | 16 namespace browser_sync { |
17 | 17 |
18 // A test fixture that simplifies writing unit tests for individual | 18 // A test fixture that simplifies writing unit tests for individual |
19 // SyncerCommands, providing convenient access to a test directory | 19 // SyncerCommands, providing convenient access to a test directory |
20 // and a syncer session. | 20 // and a syncer session. |
21 class SyncerCommandTest : public testing::Test, | 21 template<typename T> |
22 public sessions::SyncSession::Delegate, | 22 class SyncerCommandTestWithParam : public testing::TestWithParam<T>, |
23 public ModelSafeWorkerRegistrar { | 23 public sessions::SyncSession::Delegate, |
| 24 public ModelSafeWorkerRegistrar { |
24 public: | 25 public: |
25 // SyncSession::Delegate implementation. | 26 // SyncSession::Delegate implementation. |
26 virtual void OnSilencedUntil(const base::TimeTicks& silenced_until) { | 27 virtual void OnSilencedUntil(const base::TimeTicks& silenced_until) { |
27 FAIL() << "Should not get silenced."; | 28 FAIL() << "Should not get silenced."; |
28 } | 29 } |
29 virtual bool IsSyncingCurrentlySilenced() { | 30 virtual bool IsSyncingCurrentlySilenced() { |
30 ADD_FAILURE() << "No requests for silenced state should be made."; | 31 ADD_FAILURE() << "No requests for silenced state should be made."; |
31 return false; | 32 return false; |
32 } | 33 } |
33 virtual void OnReceivedLongPollIntervalUpdate( | 34 virtual void OnReceivedLongPollIntervalUpdate( |
(...skipping 10 matching lines...) Expand all Loading... |
44 std::vector<scoped_refptr<ModelSafeWorker> >::iterator it; | 45 std::vector<scoped_refptr<ModelSafeWorker> >::iterator it; |
45 for (it = workers_.begin(); it != workers_.end(); ++it) | 46 for (it = workers_.begin(); it != workers_.end(); ++it) |
46 out->push_back(*it); | 47 out->push_back(*it); |
47 } | 48 } |
48 virtual void GetModelSafeRoutingInfo(ModelSafeRoutingInfo* out) { | 49 virtual void GetModelSafeRoutingInfo(ModelSafeRoutingInfo* out) { |
49 ModelSafeRoutingInfo copy(routing_info_); | 50 ModelSafeRoutingInfo copy(routing_info_); |
50 out->swap(copy); | 51 out->swap(copy); |
51 } | 52 } |
52 | 53 |
53 protected: | 54 protected: |
54 SyncerCommandTest() {} | 55 SyncerCommandTestWithParam() {} |
55 virtual ~SyncerCommandTest() {} | 56 virtual ~SyncerCommandTestWithParam() {} |
56 virtual void SetUp() { | 57 virtual void SetUp() { |
57 syncdb_.SetUp(); | 58 syncdb_.SetUp(); |
58 context_.reset(new sessions::SyncSessionContext(NULL, NULL, | 59 context_.reset(new sessions::SyncSessionContext(NULL, NULL, |
59 syncdb_.manager(), registrar())); | 60 syncdb_.manager(), registrar())); |
60 context_->set_account_name(syncdb_.name()); | 61 context_->set_account_name(syncdb_.name()); |
61 } | 62 } |
62 virtual void TearDown() { | 63 virtual void TearDown() { |
63 syncdb_.TearDown(); | 64 syncdb_.TearDown(); |
64 } | 65 } |
65 | 66 |
(...skipping 17 matching lines...) Expand all Loading... |
83 | 84 |
84 const ModelSafeRoutingInfo& routing_info() {return routing_info_; } | 85 const ModelSafeRoutingInfo& routing_info() {return routing_info_; } |
85 ModelSafeRoutingInfo* mutable_routing_info() { return &routing_info_; } | 86 ModelSafeRoutingInfo* mutable_routing_info() { return &routing_info_; } |
86 | 87 |
87 private: | 88 private: |
88 TestDirectorySetterUpper syncdb_; | 89 TestDirectorySetterUpper syncdb_; |
89 scoped_ptr<sessions::SyncSessionContext> context_; | 90 scoped_ptr<sessions::SyncSessionContext> context_; |
90 scoped_ptr<sessions::SyncSession> session_; | 91 scoped_ptr<sessions::SyncSession> session_; |
91 std::vector<scoped_refptr<ModelSafeWorker> > workers_; | 92 std::vector<scoped_refptr<ModelSafeWorker> > workers_; |
92 ModelSafeRoutingInfo routing_info_; | 93 ModelSafeRoutingInfo routing_info_; |
93 DISALLOW_COPY_AND_ASSIGN(SyncerCommandTest); | 94 DISALLOW_COPY_AND_ASSIGN(SyncerCommandTestWithParam); |
94 }; | 95 }; |
95 | 96 |
| 97 class SyncerCommandTest : public SyncerCommandTestWithParam<void*> {}; |
| 98 |
96 } // namespace browser_sync | 99 } // namespace browser_sync |
97 | 100 |
98 #endif // CHROME_TEST_SYNC_ENGINE_SYNCER_COMMAND_TEST_H_ | 101 #endif // CHROME_TEST_SYNC_ENGINE_SYNCER_COMMAND_TEST_H_ |
OLD | NEW |