OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/sync_sessions/sessions_sync_manager.h" | 5 #include "components/sync_sessions/sessions_sync_manager.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <utility> | 10 #include <utility> |
(...skipping 24 matching lines...) Expand all Loading... |
35 #include "components/sync_sessions/synced_window_delegate.h" | 35 #include "components/sync_sessions/synced_window_delegate.h" |
36 #include "components/sync_sessions/synced_window_delegates_getter.h" | 36 #include "components/sync_sessions/synced_window_delegates_getter.h" |
37 #include "content/public/browser/navigation_entry.h" | 37 #include "content/public/browser/navigation_entry.h" |
38 #include "content/public/browser/web_contents.h" | 38 #include "content/public/browser/web_contents.h" |
39 #include "testing/gmock/include/gmock/gmock.h" | 39 #include "testing/gmock/include/gmock/gmock.h" |
40 #include "testing/gtest/include/gtest/gtest.h" | 40 #include "testing/gtest/include/gtest/gtest.h" |
41 | 41 |
42 using content::WebContents; | 42 using content::WebContents; |
43 using sessions::SerializedNavigationEntry; | 43 using sessions::SerializedNavigationEntry; |
44 using sessions::SerializedNavigationEntryTestHelper; | 44 using sessions::SerializedNavigationEntryTestHelper; |
45 using sync_driver::DeviceInfo; | 45 using syncer::DeviceInfo; |
46 using sync_driver::LocalDeviceInfoProvider; | 46 using syncer::LocalDeviceInfoProvider; |
47 using sync_driver::LocalDeviceInfoProviderMock; | 47 using syncer::LocalDeviceInfoProviderMock; |
48 using syncer::SyncChange; | 48 using syncer::SyncChange; |
49 using syncer::SyncData; | 49 using syncer::SyncData; |
50 | 50 |
51 namespace sync_sessions { | 51 namespace sync_sessions { |
52 | 52 |
53 namespace { | 53 namespace { |
54 | 54 |
55 class SessionNotificationObserver { | 55 class SessionNotificationObserver { |
56 public: | 56 public: |
57 SessionNotificationObserver() | 57 SessionNotificationObserver() |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 | 325 |
326 void SetUp() override { | 326 void SetUp() override { |
327 BrowserWithTestWindowTest::SetUp(); | 327 BrowserWithTestWindowTest::SetUp(); |
328 sync_client_.reset(new browser_sync::ChromeSyncClient(profile())); | 328 sync_client_.reset(new browser_sync::ChromeSyncClient(profile())); |
329 sessions_client_shim_.reset( | 329 sessions_client_shim_.reset( |
330 new SyncSessionsClientShim(sync_client_->GetSyncSessionsClient())); | 330 new SyncSessionsClientShim(sync_client_->GetSyncSessionsClient())); |
331 NotificationServiceSessionsRouter* router( | 331 NotificationServiceSessionsRouter* router( |
332 new NotificationServiceSessionsRouter( | 332 new NotificationServiceSessionsRouter( |
333 profile(), GetSyncSessionsClient(), | 333 profile(), GetSyncSessionsClient(), |
334 syncer::SyncableService::StartSyncFlare())); | 334 syncer::SyncableService::StartSyncFlare())); |
335 sync_prefs_.reset(new sync_driver::SyncPrefs(profile()->GetPrefs())); | 335 sync_prefs_.reset(new syncer::SyncPrefs(profile()->GetPrefs())); |
336 manager_.reset(new SessionsSyncManager( | 336 manager_.reset(new SessionsSyncManager( |
337 GetSyncSessionsClient(), sync_prefs_.get(), local_device_.get(), | 337 GetSyncSessionsClient(), sync_prefs_.get(), local_device_.get(), |
338 std::unique_ptr<LocalSessionEventRouter>(router), | 338 std::unique_ptr<LocalSessionEventRouter>(router), |
339 base::Bind(&SessionNotificationObserver::NotifyOfUpdate, | 339 base::Bind(&SessionNotificationObserver::NotifyOfUpdate, |
340 base::Unretained(&observer_)), | 340 base::Unretained(&observer_)), |
341 base::Bind(&SessionNotificationObserver::NotifyOfRefresh, | 341 base::Bind(&SessionNotificationObserver::NotifyOfRefresh, |
342 base::Unretained(&observer_)))); | 342 base::Unretained(&observer_)))); |
343 } | 343 } |
344 | 344 |
345 void TearDown() override { | 345 void TearDown() override { |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 } | 401 } |
402 } | 402 } |
403 EXPECT_TRUE(found); | 403 EXPECT_TRUE(found); |
404 return list; | 404 return list; |
405 } | 405 } |
406 | 406 |
407 SyncSessionsClient* GetSyncSessionsClient() { | 407 SyncSessionsClient* GetSyncSessionsClient() { |
408 return sessions_client_shim_.get(); | 408 return sessions_client_shim_.get(); |
409 } | 409 } |
410 | 410 |
411 sync_driver::SyncPrefs* sync_prefs() { return sync_prefs_.get(); } | 411 syncer::SyncPrefs* sync_prefs() { return sync_prefs_.get(); } |
412 | 412 |
413 SyncedWindowDelegatesGetter* get_synced_window_getter() { | 413 SyncedWindowDelegatesGetter* get_synced_window_getter() { |
414 return manager()->synced_window_delegates_getter(); | 414 return manager()->synced_window_delegates_getter(); |
415 } | 415 } |
416 | 416 |
417 void set_synced_window_getter( | 417 void set_synced_window_getter( |
418 SyncedWindowDelegatesGetter* synced_window_getter) { | 418 SyncedWindowDelegatesGetter* synced_window_getter) { |
419 sessions_client_shim_->set_synced_window_getter(synced_window_getter); | 419 sessions_client_shim_->set_synced_window_getter(synced_window_getter); |
420 } | 420 } |
421 | 421 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
459 // The server ID is never relevant to these tests, so just use 1. | 459 // The server ID is never relevant to these tests, so just use 1. |
460 return SyncData::CreateRemoteData( | 460 return SyncData::CreateRemoteData( |
461 1, entity, mtime, syncer::AttachmentIdList(), | 461 1, entity, mtime, syncer::AttachmentIdList(), |
462 syncer::AttachmentServiceProxyForTest::Create(), | 462 syncer::AttachmentServiceProxyForTest::Create(), |
463 SessionsSyncManager::TagHashFromSpecifics(entity.session())); | 463 SessionsSyncManager::TagHashFromSpecifics(entity.session())); |
464 } | 464 } |
465 | 465 |
466 private: | 466 private: |
467 std::unique_ptr<browser_sync::ChromeSyncClient> sync_client_; | 467 std::unique_ptr<browser_sync::ChromeSyncClient> sync_client_; |
468 std::unique_ptr<SyncSessionsClientShim> sessions_client_shim_; | 468 std::unique_ptr<SyncSessionsClientShim> sessions_client_shim_; |
469 std::unique_ptr<sync_driver::SyncPrefs> sync_prefs_; | 469 std::unique_ptr<syncer::SyncPrefs> sync_prefs_; |
470 SessionNotificationObserver observer_; | 470 SessionNotificationObserver observer_; |
471 std::unique_ptr<SessionsSyncManager> manager_; | 471 std::unique_ptr<SessionsSyncManager> manager_; |
472 SessionSyncTestHelper helper_; | 472 SessionSyncTestHelper helper_; |
473 TestSyncProcessorStub* test_processor_; | 473 TestSyncProcessorStub* test_processor_; |
474 std::unique_ptr<LocalDeviceInfoProviderMock> local_device_; | 474 std::unique_ptr<LocalDeviceInfoProviderMock> local_device_; |
475 }; | 475 }; |
476 | 476 |
477 // Test that the SyncSessionManager can properly fill in a SessionHeader. | 477 // Test that the SyncSessionManager can properly fill in a SessionHeader. |
478 TEST_F(SessionsSyncManagerTest, PopulateSessionHeader) { | 478 TEST_F(SessionsSyncManagerTest, PopulateSessionHeader) { |
479 sync_pb::SessionHeader header_s; | 479 sync_pb::SessionHeader header_s; |
(...skipping 2132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2612 base::Time last_time; | 2612 base::Time last_time; |
2613 for (size_t i = 0; i < tabs.size(); ++i) { | 2613 for (size_t i = 0; i < tabs.size(); ++i) { |
2614 base::Time this_time = tabs[i]->timestamp; | 2614 base::Time this_time = tabs[i]->timestamp; |
2615 if (i > 0) | 2615 if (i > 0) |
2616 ASSERT_GE(last_time, this_time); | 2616 ASSERT_GE(last_time, this_time); |
2617 last_time = tabs[i]->timestamp; | 2617 last_time = tabs[i]->timestamp; |
2618 } | 2618 } |
2619 } | 2619 } |
2620 | 2620 |
2621 } // namespace sync_sessions | 2621 } // namespace sync_sessions |
OLD | NEW |