| 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 | |
| 60 ProfileSyncService* sync_service() { return sync_service_.get(); } | 59 ProfileSyncService* sync_service() { return sync_service_.get(); } |
| 61 | 60 |
| 62 TestIdFactory* ids() { return sync_service_->id_factory(); } | 61 TestIdFactory* ids() { return sync_service_->id_factory(); } |
| 63 | 62 |
| 64 protected: | 63 protected: |
| 65 SessionService* service() { return helper_.service(); } | 64 SessionService* service() { return helper_.service(); } |
| 66 | 65 |
| 67 virtual void SetUp() { | 66 virtual void SetUp() { |
| 67 // BrowserWithTestWindowTest implementation. |
| 68 BrowserWithTestWindowTest::SetUp(); | 68 BrowserWithTestWindowTest::SetUp(); |
| 69 |
| 69 profile()->set_has_history_service(true); | 70 profile()->set_has_history_service(true); |
| 70 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 71 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 71 SessionService* session_service = new SessionService(temp_dir_.path()); | 72 SessionService* session_service = new SessionService(temp_dir_.path()); |
| 72 helper_.set_service(session_service); | 73 helper_.set_service(session_service); |
| 73 service()->SetWindowType(window_id_, Browser::TYPE_NORMAL); | 74 service()->SetWindowType(window_id_, Browser::TYPE_NORMAL); |
| 74 service()->SetWindowBounds(window_id_, window_bounds_, false); | 75 service()->SetWindowBounds(window_id_, window_bounds_, false); |
| 75 registrar_.Add(this, NotificationType::FOREIGN_SESSION_UPDATED, | 76 registrar_.Add(this, NotificationType::FOREIGN_SESSION_UPDATED, |
| 76 NotificationService::AllSources()); | 77 NotificationService::AllSources()); |
| 77 } | 78 } |
| 78 | 79 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 91 | 92 |
| 92 virtual void TearDown() { | 93 virtual void TearDown() { |
| 93 helper_.set_service(NULL); | 94 helper_.set_service(NULL); |
| 94 profile()->set_session_service(NULL); | 95 profile()->set_session_service(NULL); |
| 95 sync_service_.reset(); | 96 sync_service_.reset(); |
| 96 } | 97 } |
| 97 | 98 |
| 98 bool StartSyncService(Task* task, bool will_fail_association) { | 99 bool StartSyncService(Task* task, bool will_fail_association) { |
| 99 if (sync_service_.get()) | 100 if (sync_service_.get()) |
| 100 return false; | 101 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 */); |
| 109 change_processor_ = new SessionChangeProcessor( | 110 change_processor_ = new SessionChangeProcessor( |
| 110 sync_service_.get(), model_associator_); | 111 sync_service_.get(), model_associator_, |
| 112 true /* setup_for_test */); |
| 111 EXPECT_CALL(factory_, CreateSessionSyncComponents(_, _)). | 113 EXPECT_CALL(factory_, CreateSessionSyncComponents(_, _)). |
| 112 WillOnce(Return(ProfileSyncFactory::SyncComponents( | 114 WillOnce(Return(ProfileSyncFactory::SyncComponents( |
| 113 model_associator_, change_processor_))); | 115 model_associator_, change_processor_))); |
| 114 EXPECT_CALL(factory_, CreateDataTypeManager(_, _)). | 116 EXPECT_CALL(factory_, CreateDataTypeManager(_, _)). |
| 115 WillOnce(ReturnNewDataTypeManager()); | 117 WillOnce(ReturnNewDataTypeManager()); |
| 116 sync_service_->set_num_expected_resumes(will_fail_association ? 0 : 1); | 118 sync_service_->set_num_expected_resumes(will_fail_association ? 0 : 1); |
| 117 sync_service_->RegisterDataTypeController( | 119 sync_service_->RegisterDataTypeController( |
| 118 new SessionDataTypeController(&factory_, sync_service_.get())); | 120 new SessionDataTypeController(&factory_, sync_service_.get())); |
| 119 profile()->GetTokenService()->IssueAuthTokenForTest( | 121 profile()->GetTokenService()->IssueAuthTokenForTest( |
| 120 GaiaConstants::kSyncService, "token"); | 122 GaiaConstants::kSyncService, "token"); |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 ASSERT_FALSE(model_associator_->tab_pool_.full()); | 417 ASSERT_FALSE(model_associator_->tab_pool_.full()); |
| 416 for (size_t i = 0; i < num_ids; ++i) { | 418 for (size_t i = 0; i < num_ids; ++i) { |
| 417 model_associator_->tab_pool_.FreeTabNode(node_ids[i]); | 419 model_associator_->tab_pool_.FreeTabNode(node_ids[i]); |
| 418 } | 420 } |
| 419 ASSERT_EQ(num_ids, model_associator_->tab_pool_.capacity()); | 421 ASSERT_EQ(num_ids, model_associator_->tab_pool_.capacity()); |
| 420 ASSERT_FALSE(model_associator_->tab_pool_.empty()); | 422 ASSERT_FALSE(model_associator_->tab_pool_.empty()); |
| 421 ASSERT_TRUE(model_associator_->tab_pool_.full()); | 423 ASSERT_TRUE(model_associator_->tab_pool_.full()); |
| 422 } | 424 } |
| 423 | 425 |
| 424 } // namespace browser_sync | 426 } // namespace browser_sync |
| OLD | NEW |