OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/message_loop.h" | 5 #include "base/message_loop.h" |
6 #include "base/time.h" | 6 #include "base/time.h" |
7 #include "chrome/browser/sync/engine/mock_model_safe_workers.h" | |
8 #include "chrome/browser/sync/engine/sync_scheduler.h" | 7 #include "chrome/browser/sync/engine/sync_scheduler.h" |
9 #include "chrome/browser/sync/sessions/sync_session_context.h" | 8 #include "chrome/browser/sync/sessions/sync_session_context.h" |
10 #include "chrome/browser/sync/sessions/test_util.h" | 9 #include "chrome/browser/sync/sessions/test_util.h" |
| 10 #include "chrome/browser/sync/test/engine/fake_model_safe_worker_registrar.h" |
11 #include "chrome/browser/sync/test/engine/mock_connection_manager.h" | 11 #include "chrome/browser/sync/test/engine/mock_connection_manager.h" |
12 #include "chrome/browser/sync/test/engine/test_directory_setter_upper.h" | 12 #include "chrome/browser/sync/test/engine/test_directory_setter_upper.h" |
13 #include "testing/gmock/include/gmock/gmock.h" | 13 #include "testing/gmock/include/gmock/gmock.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
15 | 15 |
16 using base::TimeDelta; | 16 using base::TimeDelta; |
17 using base::TimeTicks; | 17 using base::TimeTicks; |
18 | 18 |
19 namespace browser_sync { | 19 namespace browser_sync { |
20 using sessions::SyncSessionContext; | 20 using sessions::SyncSessionContext; |
21 using browser_sync::Syncer; | 21 using browser_sync::Syncer; |
22 | 22 |
23 class SyncSchedulerWhiteboxTest : public testing::Test { | 23 class SyncSchedulerWhiteboxTest : public testing::Test { |
24 public: | 24 public: |
25 virtual void SetUp() { | 25 virtual void SetUp() { |
26 syncdb_.SetUp(); | 26 syncdb_.SetUp(); |
27 Syncer* syncer = new Syncer(); | 27 Syncer* syncer = new Syncer(); |
28 registrar_.reset(MockModelSafeWorkerRegistrar::PassiveBookmarks()); | 28 ModelSafeRoutingInfo routes; |
| 29 routes[syncable::BOOKMARKS] = GROUP_UI; |
| 30 routes[syncable::NIGORI] = GROUP_PASSIVE; |
| 31 registrar_.reset(new FakeModelSafeWorkerRegistrar(routes)); |
29 connection_.reset(new MockConnectionManager(syncdb_.manager(), "Test")); | 32 connection_.reset(new MockConnectionManager(syncdb_.manager(), "Test")); |
30 connection_->SetServerReachable(); | 33 connection_->SetServerReachable(); |
31 context_ = new SyncSessionContext(connection_.get(), syncdb_.manager(), | 34 context_ = new SyncSessionContext(connection_.get(), syncdb_.manager(), |
32 registrar_.get(), std::vector<SyncEngineEventListener*>(), NULL); | 35 registrar_.get(), std::vector<SyncEngineEventListener*>(), NULL); |
33 context_->set_notifications_enabled(true); | 36 context_->set_notifications_enabled(true); |
34 context_->set_account_name("Test"); | 37 context_->set_account_name("Test"); |
35 scheduler_.reset( | 38 scheduler_.reset( |
36 new SyncScheduler("TestSyncSchedulerWhitebox", context_, syncer)); | 39 new SyncScheduler("TestSyncSchedulerWhitebox", context_, syncer)); |
37 } | 40 } |
38 | 41 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 job.purpose = purpose; | 94 job.purpose = purpose; |
92 job.scheduled_start = TimeTicks::Now(); | 95 job.scheduled_start = TimeTicks::Now(); |
93 return DecideOnJob(job); | 96 return DecideOnJob(job); |
94 } | 97 } |
95 | 98 |
96 private: | 99 private: |
97 MessageLoop message_loop_; | 100 MessageLoop message_loop_; |
98 scoped_ptr<SyncScheduler> scheduler_; | 101 scoped_ptr<SyncScheduler> scheduler_; |
99 scoped_ptr<MockConnectionManager> connection_; | 102 scoped_ptr<MockConnectionManager> connection_; |
100 SyncSessionContext* context_; | 103 SyncSessionContext* context_; |
101 scoped_ptr<MockModelSafeWorkerRegistrar> registrar_; | 104 scoped_ptr<FakeModelSafeWorkerRegistrar> registrar_; |
102 MockDirectorySetterUpper syncdb_; | 105 MockDirectorySetterUpper syncdb_; |
103 }; | 106 }; |
104 | 107 |
105 TEST_F(SyncSchedulerWhiteboxTest, SaveNudge) { | 108 TEST_F(SyncSchedulerWhiteboxTest, SaveNudge) { |
106 InitializeSyncerOnNormalMode(); | 109 InitializeSyncerOnNormalMode(); |
107 | 110 |
108 // Now set the mode to configure. | 111 // Now set the mode to configure. |
109 SetMode(SyncScheduler::CONFIGURATION_MODE); | 112 SetMode(SyncScheduler::CONFIGURATION_MODE); |
110 | 113 |
111 SyncScheduler::JobProcessDecision decision = | 114 SyncScheduler::JobProcessDecision decision = |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 struct SyncScheduler::SyncSessionJob job; | 227 struct SyncScheduler::SyncSessionJob job; |
225 job.purpose = SyncScheduler::SyncSessionJob::CONFIGURATION; | 228 job.purpose = SyncScheduler::SyncSessionJob::CONFIGURATION; |
226 job.scheduled_start = TimeTicks::Now(); | 229 job.scheduled_start = TimeTicks::Now(); |
227 job.is_canary_job = true; | 230 job.is_canary_job = true; |
228 SyncScheduler::JobProcessDecision decision = DecideOnJob(job); | 231 SyncScheduler::JobProcessDecision decision = DecideOnJob(job); |
229 | 232 |
230 EXPECT_EQ(decision, SyncScheduler::CONTINUE); | 233 EXPECT_EQ(decision, SyncScheduler::CONTINUE); |
231 } | 234 } |
232 | 235 |
233 } // namespace browser_sync | 236 } // namespace browser_sync |
OLD | NEW |