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 #include <map> | 5 #include <map> |
6 #include <string> | 6 #include <string> |
7 | 7 |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/scoped_ptr.h" | 9 #include "base/scoped_ptr.h" |
10 #include "base/scoped_temp_dir.h" | 10 #include "base/scoped_temp_dir.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 | 49 |
50 namespace browser_sync { | 50 namespace browser_sync { |
51 | 51 |
52 class ProfileSyncServiceSessionTest | 52 class ProfileSyncServiceSessionTest |
53 : public BrowserWithTestWindowTest, | 53 : public BrowserWithTestWindowTest, |
54 public NotificationObserver { | 54 public NotificationObserver { |
55 public: | 55 public: |
56 ProfileSyncServiceSessionTest() | 56 ProfileSyncServiceSessionTest() |
57 : window_bounds_(0, 1, 2, 3), | 57 : window_bounds_(0, 1, 2, 3), |
58 notified_of_update_(false) {} | 58 notified_of_update_(false) {} |
| 59 |
59 ProfileSyncService* sync_service() { return sync_service_.get(); } | 60 ProfileSyncService* sync_service() { return sync_service_.get(); } |
60 | 61 |
61 TestIdFactory* ids() { return sync_service_->id_factory(); } | 62 TestIdFactory* ids() { return sync_service_->id_factory(); } |
62 | 63 |
63 protected: | 64 protected: |
64 SessionService* service() { return helper_.service(); } | 65 SessionService* service() { return helper_.service(); } |
65 | 66 |
66 virtual void SetUp() { | 67 virtual void SetUp() { |
67 // BrowserWithTestWindowTest implementation. | |
68 BrowserWithTestWindowTest::SetUp(); | 68 BrowserWithTestWindowTest::SetUp(); |
69 | |
70 profile()->set_has_history_service(true); | 69 profile()->set_has_history_service(true); |
71 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 70 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
72 SessionService* session_service = new SessionService(temp_dir_.path()); | 71 SessionService* session_service = new SessionService(temp_dir_.path()); |
73 helper_.set_service(session_service); | 72 helper_.set_service(session_service); |
74 service()->SetWindowType(window_id_, Browser::TYPE_NORMAL); | 73 service()->SetWindowType(window_id_, Browser::TYPE_NORMAL); |
75 service()->SetWindowBounds(window_id_, window_bounds_, false); | 74 service()->SetWindowBounds(window_id_, window_bounds_, false); |
76 registrar_.Add(this, NotificationType::FOREIGN_SESSION_UPDATED, | 75 registrar_.Add(this, NotificationType::FOREIGN_SESSION_UPDATED, |
77 NotificationService::AllSources()); | 76 NotificationService::AllSources()); |
78 } | 77 } |
79 | 78 |
(...skipping 12 matching lines...) Expand all Loading... |
92 | 91 |
93 virtual void TearDown() { | 92 virtual void TearDown() { |
94 helper_.set_service(NULL); | 93 helper_.set_service(NULL); |
95 profile()->set_session_service(NULL); | 94 profile()->set_session_service(NULL); |
96 sync_service_.reset(); | 95 sync_service_.reset(); |
97 } | 96 } |
98 | 97 |
99 bool StartSyncService(Task* task, bool will_fail_association) { | 98 bool StartSyncService(Task* task, bool will_fail_association) { |
100 if (sync_service_.get()) | 99 if (sync_service_.get()) |
101 return false; | 100 return false; |
| 101 |
102 sync_service_.reset(new TestProfileSyncService( | 102 sync_service_.reset(new TestProfileSyncService( |
103 &factory_, profile(), "test user", false, task)); | 103 &factory_, profile(), "test user", false, task)); |
104 profile()->set_session_service(helper_.service()); | 104 profile()->set_session_service(helper_.service()); |
105 | 105 |
106 // Register the session data type. | 106 // Register the session data type. |
107 model_associator_ = | 107 model_associator_ = |
108 new SessionModelAssociator(sync_service_.get(), | 108 new SessionModelAssociator(sync_service_.get()); |
109 true /* setup_for_test */); | |
110 change_processor_ = new SessionChangeProcessor( | 109 change_processor_ = new SessionChangeProcessor( |
111 sync_service_.get(), model_associator_, | 110 sync_service_.get(), model_associator_); |
112 true /* setup_for_test */); | |
113 EXPECT_CALL(factory_, CreateSessionSyncComponents(_, _)). | 111 EXPECT_CALL(factory_, CreateSessionSyncComponents(_, _)). |
114 WillOnce(Return(ProfileSyncFactory::SyncComponents( | 112 WillOnce(Return(ProfileSyncFactory::SyncComponents( |
115 model_associator_, change_processor_))); | 113 model_associator_, change_processor_))); |
116 EXPECT_CALL(factory_, CreateDataTypeManager(_, _)). | 114 EXPECT_CALL(factory_, CreateDataTypeManager(_, _)). |
117 WillOnce(ReturnNewDataTypeManager()); | 115 WillOnce(ReturnNewDataTypeManager()); |
118 sync_service_->set_num_expected_resumes(will_fail_association ? 0 : 1); | 116 sync_service_->set_num_expected_resumes(will_fail_association ? 0 : 1); |
119 sync_service_->RegisterDataTypeController( | 117 sync_service_->RegisterDataTypeController( |
120 new SessionDataTypeController(&factory_, sync_service_.get())); | 118 new SessionDataTypeController(&factory_, sync_service_.get())); |
121 profile()->GetTokenService()->IssueAuthTokenForTest( | 119 profile()->GetTokenService()->IssueAuthTokenForTest( |
122 GaiaConstants::kSyncService, "token"); | 120 GaiaConstants::kSyncService, "token"); |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
417 ASSERT_FALSE(model_associator_->tab_pool_.full()); | 415 ASSERT_FALSE(model_associator_->tab_pool_.full()); |
418 for (size_t i = 0; i < num_ids; ++i) { | 416 for (size_t i = 0; i < num_ids; ++i) { |
419 model_associator_->tab_pool_.FreeTabNode(node_ids[i]); | 417 model_associator_->tab_pool_.FreeTabNode(node_ids[i]); |
420 } | 418 } |
421 ASSERT_EQ(num_ids, model_associator_->tab_pool_.capacity()); | 419 ASSERT_EQ(num_ids, model_associator_->tab_pool_.capacity()); |
422 ASSERT_FALSE(model_associator_->tab_pool_.empty()); | 420 ASSERT_FALSE(model_associator_->tab_pool_.empty()); |
423 ASSERT_TRUE(model_associator_->tab_pool_.full()); | 421 ASSERT_TRUE(model_associator_->tab_pool_.full()); |
424 } | 422 } |
425 | 423 |
426 } // namespace browser_sync | 424 } // namespace browser_sync |
OLD | NEW |