| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 #include "content/public/test/test_browser_thread.h" | 38 #include "content/public/test/test_browser_thread.h" |
| 39 #include "googleurl/src/gurl.h" | 39 #include "googleurl/src/gurl.h" |
| 40 #include "sync/internal_api/public/base/model_type.h" | 40 #include "sync/internal_api/public/base/model_type.h" |
| 41 #include "sync/internal_api/public/change_record.h" | 41 #include "sync/internal_api/public/change_record.h" |
| 42 #include "sync/internal_api/public/read_node.h" | 42 #include "sync/internal_api/public/read_node.h" |
| 43 #include "sync/internal_api/public/read_transaction.h" | 43 #include "sync/internal_api/public/read_transaction.h" |
| 44 #include "sync/internal_api/public/write_node.h" | 44 #include "sync/internal_api/public/write_node.h" |
| 45 #include "sync/internal_api/public/write_transaction.h" | 45 #include "sync/internal_api/public/write_transaction.h" |
| 46 #include "sync/protocol/session_specifics.pb.h" | 46 #include "sync/protocol/session_specifics.pb.h" |
| 47 #include "sync/protocol/sync.pb.h" | 47 #include "sync/protocol/sync.pb.h" |
| 48 #include "sync/test/engine/test_id_factory.h" | |
| 49 #include "testing/gmock/include/gmock/gmock.h" | 48 #include "testing/gmock/include/gmock/gmock.h" |
| 50 #include "testing/gtest/include/gtest/gtest.h" | 49 #include "testing/gtest/include/gtest/gtest.h" |
| 51 #include "ui/base/ui_base_types.h" | 50 #include "ui/base/ui_base_types.h" |
| 52 | 51 |
| 53 using browser_sync::SessionChangeProcessor; | 52 using browser_sync::SessionChangeProcessor; |
| 54 using browser_sync::SessionDataTypeController; | 53 using browser_sync::SessionDataTypeController; |
| 55 using browser_sync::SessionModelAssociator; | 54 using browser_sync::SessionModelAssociator; |
| 56 using browser_sync::SyncBackendHost; | 55 using browser_sync::SyncBackendHost; |
| 57 using content::BrowserThread; | 56 using content::BrowserThread; |
| 58 using syncer::ChangeRecord; | 57 using syncer::ChangeRecord; |
| 59 using testing::_; | 58 using testing::_; |
| 60 using testing::Return; | 59 using testing::Return; |
| 61 using syncer::TestIdFactory; | |
| 62 | 60 |
| 63 namespace browser_sync { | 61 namespace browser_sync { |
| 64 | 62 |
| 65 namespace { | 63 namespace { |
| 66 | 64 |
| 67 void BuildSessionSpecifics(const std::string& tag, | 65 void BuildSessionSpecifics(const std::string& tag, |
| 68 sync_pb::SessionSpecifics* meta) { | 66 sync_pb::SessionSpecifics* meta) { |
| 69 meta->set_session_tag(tag); | 67 meta->set_session_tag(tag); |
| 70 sync_pb::SessionHeader* header = meta->mutable_header(); | 68 sync_pb::SessionHeader* header = meta->mutable_header(); |
| 71 header->set_device_type(sync_pb::SessionHeader_DeviceType_TYPE_LINUX); | 69 header->set_device_type(sync_pb::SessionHeader_DeviceType_TYPE_LINUX); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 : public BrowserWithTestWindowTest, | 151 : public BrowserWithTestWindowTest, |
| 154 public content::NotificationObserver { | 152 public content::NotificationObserver { |
| 155 public: | 153 public: |
| 156 ProfileSyncServiceSessionTest() | 154 ProfileSyncServiceSessionTest() |
| 157 : io_thread_(BrowserThread::IO), | 155 : io_thread_(BrowserThread::IO), |
| 158 window_bounds_(0, 1, 2, 3), | 156 window_bounds_(0, 1, 2, 3), |
| 159 notified_of_update_(false), | 157 notified_of_update_(false), |
| 160 notified_of_refresh_(false) {} | 158 notified_of_refresh_(false) {} |
| 161 ProfileSyncService* sync_service() { return sync_service_.get(); } | 159 ProfileSyncService* sync_service() { return sync_service_.get(); } |
| 162 | 160 |
| 163 TestIdFactory* ids() { return sync_service_->id_factory(); } | |
| 164 | |
| 165 protected: | 161 protected: |
| 166 virtual TestingProfile* CreateProfile() OVERRIDE { | 162 virtual TestingProfile* CreateProfile() OVERRIDE { |
| 167 TestingProfile* profile = new TestingProfile(); | 163 TestingProfile* profile = new TestingProfile(); |
| 168 // Don't want the profile to create a real ProfileSyncService. | 164 // Don't want the profile to create a real ProfileSyncService. |
| 169 ProfileSyncServiceFactory::GetInstance()->SetTestingFactory(profile, | 165 ProfileSyncServiceFactory::GetInstance()->SetTestingFactory(profile, |
| 170 NULL); | 166 NULL); |
| 171 return profile; | 167 return profile; |
| 172 } | 168 } |
| 173 | 169 |
| 174 virtual void SetUp() { | 170 virtual void SetUp() { |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 } | 277 } |
| 282 | 278 |
| 283 virtual ~CreateRootHelper() {} | 279 virtual ~CreateRootHelper() {} |
| 284 | 280 |
| 285 const base::Closure& callback() const { return callback_; } | 281 const base::Closure& callback() const { return callback_; } |
| 286 bool success() { return success_; } | 282 bool success() { return success_; } |
| 287 | 283 |
| 288 private: | 284 private: |
| 289 void CreateRootCallback(ProfileSyncServiceSessionTest* test) { | 285 void CreateRootCallback(ProfileSyncServiceSessionTest* test) { |
| 290 success_ = ProfileSyncServiceTestHelper::CreateRoot( | 286 success_ = ProfileSyncServiceTestHelper::CreateRoot( |
| 291 syncer::SESSIONS, test->sync_service()->GetUserShare(), test->ids()); | 287 syncer::SESSIONS, test->sync_service()->GetUserShare()); |
| 292 } | 288 } |
| 293 | 289 |
| 294 base::Closure callback_; | 290 base::Closure callback_; |
| 295 bool success_; | 291 bool success_; |
| 296 }; | 292 }; |
| 297 | 293 |
| 298 // Test that we can write this machine's session to a node and retrieve it. | 294 // Test that we can write this machine's session to a node and retrieve it. |
| 299 TEST_F(ProfileSyncServiceSessionTest, WriteSessionToNode) { | 295 TEST_F(ProfileSyncServiceSessionTest, WriteSessionToNode) { |
| 300 CreateRootHelper create_root(this); | 296 CreateRootHelper create_root(this); |
| 301 ASSERT_TRUE(StartSyncService(create_root.callback(), false)); | 297 ASSERT_TRUE(StartSyncService(create_root.callback(), false)); |
| (...skipping 893 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1195 sync_pb::SessionSpecifics specifics; | 1191 sync_pb::SessionSpecifics specifics; |
| 1196 header.SetSessionSpecifics(specifics); | 1192 header.SetSessionSpecifics(specifics); |
| 1197 } | 1193 } |
| 1198 // Ensure we associate properly despite the pre-existing node with our local | 1194 // Ensure we associate properly despite the pre-existing node with our local |
| 1199 // tag. | 1195 // tag. |
| 1200 error = model_associator_->AssociateModels(); | 1196 error = model_associator_->AssociateModels(); |
| 1201 ASSERT_FALSE(error.IsSet()); | 1197 ASSERT_FALSE(error.IsSet()); |
| 1202 } | 1198 } |
| 1203 | 1199 |
| 1204 } // namespace browser_sync | 1200 } // namespace browser_sync |
| OLD | NEW |