| 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 "chrome/browser/sync/sessions/sessions_sync_manager.h" | 5 #include "chrome/browser/sync/sessions/sessions_sync_manager.h" |
| 6 | 6 |
| 7 #include "base/strings/string_util.h" | 7 #include "base/strings/string_util.h" |
| 8 #include "chrome/browser/chrome_notification_types.h" | 8 #include "chrome/browser/chrome_notification_types.h" |
| 9 #include "chrome/browser/sessions/session_tab_helper.h" | 9 #include "chrome/browser/sessions/session_tab_helper.h" |
| 10 #include "chrome/browser/sync/chrome_sync_client.h" |
| 10 #include "chrome/browser/sync/glue/session_sync_test_helper.h" | 11 #include "chrome/browser/sync/glue/session_sync_test_helper.h" |
| 11 #include "chrome/browser/sync/glue/synced_tab_delegate.h" | |
| 12 #include "chrome/browser/sync/sessions/notification_service_sessions_router.h" | 12 #include "chrome/browser/sync/sessions/notification_service_sessions_router.h" |
| 13 #include "chrome/browser/ui/sync/browser_synced_window_delegates_getter.h" | 13 #include "chrome/browser/ui/sync/browser_synced_window_delegates_getter.h" |
| 14 #include "chrome/browser/ui/sync/tab_contents_synced_tab_delegate.h" | 14 #include "chrome/browser/ui/sync/tab_contents_synced_tab_delegate.h" |
| 15 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 15 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 16 #include "chrome/test/base/browser_with_test_window_test.h" | 16 #include "chrome/test/base/browser_with_test_window_test.h" |
| 17 #include "components/sessions/content/content_serialized_navigation_builder.h" |
| 17 #include "components/sessions/core/serialized_navigation_entry_test_helper.h" | 18 #include "components/sessions/core/serialized_navigation_entry_test_helper.h" |
| 18 #include "components/sessions/core/session_id.h" | 19 #include "components/sessions/core/session_id.h" |
| 19 #include "components/sessions/core/session_types.h" | 20 #include "components/sessions/core/session_types.h" |
| 20 #include "components/sync_driver/device_info.h" | 21 #include "components/sync_driver/device_info.h" |
| 21 #include "components/sync_driver/glue/synced_window_delegate.h" | 22 #include "components/sync_driver/glue/synced_window_delegate.h" |
| 22 #include "components/sync_driver/local_device_info_provider_mock.h" | 23 #include "components/sync_driver/local_device_info_provider_mock.h" |
| 23 #include "components/sync_driver/sessions/synced_window_delegates_getter.h" | 24 #include "components/sync_driver/sessions/synced_window_delegates_getter.h" |
| 25 #include "components/sync_driver/sync_api_component_factory.h" |
| 26 #include "components/sync_sessions/synced_tab_delegate.h" |
| 24 #include "content/public/browser/navigation_entry.h" | 27 #include "content/public/browser/navigation_entry.h" |
| 25 #include "content/public/browser/notification_details.h" | 28 #include "content/public/browser/notification_details.h" |
| 26 #include "content/public/browser/notification_service.h" | 29 #include "content/public/browser/notification_service.h" |
| 27 #include "content/public/browser/notification_source.h" | 30 #include "content/public/browser/notification_source.h" |
| 28 #include "content/public/browser/web_contents.h" | 31 #include "content/public/browser/web_contents.h" |
| 29 #include "sync/api/attachments/attachment_id.h" | 32 #include "sync/api/attachments/attachment_id.h" |
| 30 #include "sync/api/sync_error_factory_mock.h" | 33 #include "sync/api/sync_error_factory_mock.h" |
| 31 #include "sync/internal_api/public/attachments/attachment_service_proxy_for_test
.h" | 34 #include "sync/internal_api/public/attachments/attachment_service_proxy_for_test
.h" |
| 32 #include "testing/gmock/include/gmock/gmock.h" | 35 #include "testing/gmock/include/gmock/gmock.h" |
| 33 #include "testing/gtest/include/gtest/gtest.h" | 36 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 "Chrome 10k", | 257 "Chrome 10k", |
| 255 sync_pb::SyncEnums_DeviceType_TYPE_LINUX, | 258 sync_pb::SyncEnums_DeviceType_TYPE_LINUX, |
| 256 "device_id")); | 259 "device_id")); |
| 257 } | 260 } |
| 258 | 261 |
| 259 void SetUp() override { | 262 void SetUp() override { |
| 260 BrowserWithTestWindowTest::SetUp(); | 263 BrowserWithTestWindowTest::SetUp(); |
| 261 browser_sync::NotificationServiceSessionsRouter* router( | 264 browser_sync::NotificationServiceSessionsRouter* router( |
| 262 new browser_sync::NotificationServiceSessionsRouter( | 265 new browser_sync::NotificationServiceSessionsRouter( |
| 263 profile(), syncer::SyncableService::StartSyncFlare())); | 266 profile(), syncer::SyncableService::StartSyncFlare())); |
| 267 sync_client_.reset(new browser_sync::ChromeSyncClient(profile(), nullptr)); |
| 264 manager_.reset(new SessionsSyncManager( | 268 manager_.reset(new SessionsSyncManager( |
| 265 profile(), local_device_.get(), | 269 GetSyncSessionsClient(), profile(), local_device_.get(), |
| 266 scoped_ptr<LocalSessionEventRouter>(router), | 270 scoped_ptr<LocalSessionEventRouter>(router), NewBrowserWindowGetter())); |
| 267 NewBrowserWindowGetter())); | |
| 268 } | 271 } |
| 269 | 272 |
| 270 void TearDown() override { | 273 void TearDown() override { |
| 271 test_processor_ = NULL; | 274 test_processor_ = NULL; |
| 272 helper()->Reset(); | 275 helper()->Reset(); |
| 273 manager_.reset(); | 276 manager_.reset(); |
| 274 BrowserWithTestWindowTest::TearDown(); | 277 BrowserWithTestWindowTest::TearDown(); |
| 275 } | 278 } |
| 276 | 279 |
| 277 const DeviceInfo* GetLocalDeviceInfo() { | 280 const DeviceInfo* GetLocalDeviceInfo() { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 it = list->erase(it); | 322 it = list->erase(it); |
| 320 found = true; | 323 found = true; |
| 321 } else { | 324 } else { |
| 322 ++it; | 325 ++it; |
| 323 } | 326 } |
| 324 } | 327 } |
| 325 EXPECT_TRUE(found); | 328 EXPECT_TRUE(found); |
| 326 return list; | 329 return list; |
| 327 } | 330 } |
| 328 | 331 |
| 332 sync_sessions::SyncSessionsClient* GetSyncSessionsClient() { |
| 333 return sync_client_->GetSyncSessionsClient(); |
| 334 } |
| 335 |
| 329 private: | 336 private: |
| 337 scoped_ptr<browser_sync::ChromeSyncClient> sync_client_; |
| 330 scoped_ptr<SessionsSyncManager> manager_; | 338 scoped_ptr<SessionsSyncManager> manager_; |
| 331 SessionSyncTestHelper helper_; | 339 SessionSyncTestHelper helper_; |
| 332 TestSyncProcessorStub* test_processor_; | 340 TestSyncProcessorStub* test_processor_; |
| 333 scoped_ptr<LocalDeviceInfoProviderMock> local_device_; | 341 scoped_ptr<LocalDeviceInfoProviderMock> local_device_; |
| 334 }; | 342 }; |
| 335 | 343 |
| 336 // Test that the SyncSessionManager can properly fill in a SessionHeader. | 344 // Test that the SyncSessionManager can properly fill in a SessionHeader. |
| 337 TEST_F(SessionsSyncManagerTest, PopulateSessionHeader) { | 345 TEST_F(SessionsSyncManagerTest, PopulateSessionHeader) { |
| 338 sync_pb::SessionHeader header_s; | 346 sync_pb::SessionHeader header_s; |
| 339 header_s.set_client_name("Client 1"); | 347 header_s.set_client_name("Client 1"); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 365 ASSERT_EQ(sessions::SessionWindow::TYPE_TABBED, session->windows[0]->type); | 373 ASSERT_EQ(sessions::SessionWindow::TYPE_TABBED, session->windows[0]->type); |
| 366 ASSERT_EQ(1U, manager()->session_tracker_.num_synced_sessions()); | 374 ASSERT_EQ(1U, manager()->session_tracker_.num_synced_sessions()); |
| 367 ASSERT_EQ(1U, | 375 ASSERT_EQ(1U, |
| 368 manager()->session_tracker_.num_synced_tabs(std::string("tag"))); | 376 manager()->session_tracker_.num_synced_tabs(std::string("tag"))); |
| 369 } | 377 } |
| 370 | 378 |
| 371 namespace { | 379 namespace { |
| 372 | 380 |
| 373 class SyncedTabDelegateFake : public SyncedTabDelegate { | 381 class SyncedTabDelegateFake : public SyncedTabDelegate { |
| 374 public: | 382 public: |
| 375 SyncedTabDelegateFake() : current_entry_index_(0), | 383 SyncedTabDelegateFake() |
| 376 pending_entry_index_(-1), | 384 : current_entry_index_(0), |
| 377 is_supervised_(false), | 385 is_supervised_(false), |
| 378 sync_id_(-1), | 386 sync_id_(-1) {} |
| 379 blocked_navigations_(NULL) {} | |
| 380 ~SyncedTabDelegateFake() override {} | 387 ~SyncedTabDelegateFake() override {} |
| 381 | 388 |
| 382 bool IsInitialBlankNavigation() const override { | 389 bool IsInitialBlankNavigation() const override { |
| 383 // This differs from NavigationControllerImpl, which has an initial blank | 390 // This differs from NavigationControllerImpl, which has an initial blank |
| 384 // NavigationEntry. | 391 // NavigationEntry. |
| 385 return GetEntryCount() == 0; | 392 return GetEntryCount() == 0; |
| 386 } | 393 } |
| 387 int GetCurrentEntryIndex() const override { return current_entry_index_; } | 394 int GetCurrentEntryIndex() const override { return current_entry_index_; } |
| 388 void set_current_entry_index(int i) { | 395 void set_current_entry_index(int i) { |
| 389 current_entry_index_ = i; | 396 current_entry_index_ = i; |
| 390 } | 397 } |
| 391 | 398 |
| 392 content::NavigationEntry* GetEntryAtIndex(int i) const override { | |
| 393 const int size = entries_.size(); | |
| 394 return (size < i + 1) ? NULL : entries_[i]; | |
| 395 } | |
| 396 | |
| 397 void AppendEntry(scoped_ptr<content::NavigationEntry> entry) { | 399 void AppendEntry(scoped_ptr<content::NavigationEntry> entry) { |
| 398 entries_.push_back(entry.Pass()); | 400 entries_.push_back(entry.Pass()); |
| 399 } | 401 } |
| 400 | 402 |
| 403 GURL GetVirtualURLAtIndex(int i) const override { |
| 404 if (static_cast<size_t>(i) >= entries_.size()) |
| 405 return GURL(); |
| 406 return entries_[i]->GetVirtualURL(); |
| 407 } |
| 408 |
| 409 GURL GetFaviconURLAtIndex(int i) const override { return GURL(); } |
| 410 |
| 411 ui::PageTransition GetTransitionAtIndex(int i) const override { |
| 412 if (static_cast<size_t>(i) >= entries_.size()) |
| 413 return ui::PAGE_TRANSITION_LINK; |
| 414 return entries_[i]->GetTransitionType(); |
| 415 } |
| 416 |
| 417 void GetSerializedNavigationAtIndex( |
| 418 int i, |
| 419 sessions::SerializedNavigationEntry* serialized_entry) const override { |
| 420 if (static_cast<size_t>(i) >= entries_.size()) |
| 421 return; |
| 422 *serialized_entry = |
| 423 sessions::ContentSerializedNavigationBuilder::FromNavigationEntry( |
| 424 i, *entries_[i]); |
| 425 } |
| 426 |
| 401 int GetEntryCount() const override { return entries_.size(); } | 427 int GetEntryCount() const override { return entries_.size(); } |
| 402 | 428 |
| 403 int GetPendingEntryIndex() const override { return pending_entry_index_; } | |
| 404 void set_pending_entry_index(int i) { | |
| 405 pending_entry_index_ = i; | |
| 406 } | |
| 407 | |
| 408 SessionID::id_type GetWindowId() const override { | 429 SessionID::id_type GetWindowId() const override { |
| 409 return SessionID::id_type(); | 430 return SessionID::id_type(); |
| 410 } | 431 } |
| 411 | 432 |
| 412 SessionID::id_type GetSessionId() const override { | 433 SessionID::id_type GetSessionId() const override { |
| 413 return SessionID::id_type(); | 434 return SessionID::id_type(); |
| 414 } | 435 } |
| 415 | 436 |
| 416 bool IsBeingDestroyed() const override { return false; } | 437 bool IsBeingDestroyed() const override { return false; } |
| 417 Profile* profile() const override { return NULL; } | |
| 418 std::string GetExtensionAppId() const override { return std::string(); } | 438 std::string GetExtensionAppId() const override { return std::string(); } |
| 419 content::NavigationEntry* GetPendingEntry() const override { return NULL; } | |
| 420 content::NavigationEntry* GetActiveEntry() const override { return NULL; } | |
| 421 bool ProfileIsSupervised() const override { return is_supervised_; } | 439 bool ProfileIsSupervised() const override { return is_supervised_; } |
| 422 void set_is_supervised(bool is_supervised) { is_supervised_ = is_supervised; } | 440 void set_is_supervised(bool is_supervised) { is_supervised_ = is_supervised; } |
| 423 const std::vector<const content::NavigationEntry*>* GetBlockedNavigations() | 441 const std::vector<const sessions::SerializedNavigationEntry*>* |
| 424 const override { | 442 GetBlockedNavigations() const override { |
| 425 return blocked_navigations_; | 443 return &blocked_navigations_.get(); |
| 426 } | 444 } |
| 427 void set_blocked_navigations( | 445 void set_blocked_navigations( |
| 428 std::vector<const content::NavigationEntry*>* navs) { | 446 std::vector<const content::NavigationEntry*>* navs) { |
| 429 blocked_navigations_ = navs; | 447 for (auto* entry : *navs) { |
| 448 scoped_ptr<sessions::SerializedNavigationEntry> serialized_entry( |
| 449 new sessions::SerializedNavigationEntry()); |
| 450 *serialized_entry = |
| 451 sessions::ContentSerializedNavigationBuilder::FromNavigationEntry( |
| 452 blocked_navigations_.size(), *entry); |
| 453 blocked_navigations_.push_back(serialized_entry.release()); |
| 454 } |
| 430 } | 455 } |
| 431 bool IsPinned() const override { return false; } | 456 bool IsPinned() const override { return false; } |
| 432 bool HasWebContents() const override { return false; } | 457 bool HasWebContents() const override { return false; } |
| 433 content::WebContents* GetWebContents() const override { return NULL; } | |
| 434 | 458 |
| 435 // Session sync related methods. | 459 // Session sync related methods. |
| 436 int GetSyncId() const override { return sync_id_; } | 460 int GetSyncId() const override { return sync_id_; } |
| 437 void SetSyncId(int sync_id) override { sync_id_ = sync_id; } | 461 void SetSyncId(int sync_id) override { sync_id_ = sync_id; } |
| 438 | 462 |
| 439 void reset() { | 463 void reset() { |
| 440 current_entry_index_ = 0; | 464 current_entry_index_ = 0; |
| 441 pending_entry_index_ = -1; | |
| 442 sync_id_ = -1; | 465 sync_id_ = -1; |
| 443 entries_.clear(); | 466 entries_.clear(); |
| 444 } | 467 } |
| 445 | 468 |
| 446 private: | 469 private: |
| 447 int current_entry_index_; | 470 int current_entry_index_; |
| 448 int pending_entry_index_; | |
| 449 bool is_supervised_; | 471 bool is_supervised_; |
| 450 int sync_id_; | 472 int sync_id_; |
| 451 std::vector<const content::NavigationEntry*>* blocked_navigations_; | 473 ScopedVector<const sessions::SerializedNavigationEntry> blocked_navigations_; |
| 452 ScopedVector<content::NavigationEntry> entries_; | 474 ScopedVector<content::NavigationEntry> entries_; |
| 453 }; | 475 }; |
| 454 | 476 |
| 455 } // namespace | 477 } // namespace |
| 456 | 478 |
| 457 // Make sure GetCurrentVirtualURL() returns the virtual URL of the pending | |
| 458 // entry if the current entry is pending. | |
| 459 TEST_F(SessionsSyncManagerTest, GetCurrentVirtualURLPending) { | |
| 460 SyncedTabDelegateFake tab; | |
| 461 scoped_ptr<content::NavigationEntry> entry( | |
| 462 content::NavigationEntry::Create()); | |
| 463 GURL url("http://www.google.com/"); | |
| 464 entry->SetVirtualURL(url); | |
| 465 tab.AppendEntry(entry.Pass()); | |
| 466 EXPECT_EQ(url, manager()->GetCurrentVirtualURL(tab)); | |
| 467 } | |
| 468 | |
| 469 // Make sure GetCurrentVirtualURL() returns the virtual URL of the current | |
| 470 // entry if the current entry is non-pending. | |
| 471 TEST_F(SessionsSyncManagerTest, GetCurrentVirtualURLNonPending) { | |
| 472 SyncedTabDelegateFake tab; | |
| 473 scoped_ptr<content::NavigationEntry> entry( | |
| 474 content::NavigationEntry::Create()); | |
| 475 GURL url("http://www.google.com/"); | |
| 476 entry->SetVirtualURL(url); | |
| 477 tab.AppendEntry(entry.Pass()); | |
| 478 EXPECT_EQ(url, manager()->GetCurrentVirtualURL(tab)); | |
| 479 } | |
| 480 | |
| 481 static const base::Time kTime0 = base::Time::FromInternalValue(100); | 479 static const base::Time kTime0 = base::Time::FromInternalValue(100); |
| 482 static const base::Time kTime1 = base::Time::FromInternalValue(110); | 480 static const base::Time kTime1 = base::Time::FromInternalValue(110); |
| 483 static const base::Time kTime2 = base::Time::FromInternalValue(120); | 481 static const base::Time kTime2 = base::Time::FromInternalValue(120); |
| 484 static const base::Time kTime3 = base::Time::FromInternalValue(130); | 482 static const base::Time kTime3 = base::Time::FromInternalValue(130); |
| 485 static const base::Time kTime4 = base::Time::FromInternalValue(140); | 483 static const base::Time kTime4 = base::Time::FromInternalValue(140); |
| 486 static const base::Time kTime5 = base::Time::FromInternalValue(150); | 484 static const base::Time kTime5 = base::Time::FromInternalValue(150); |
| 487 static const base::Time kTime6 = base::Time::FromInternalValue(160); | 485 static const base::Time kTime6 = base::Time::FromInternalValue(160); |
| 488 static const base::Time kTime7 = base::Time::FromInternalValue(170); | 486 static const base::Time kTime7 = base::Time::FromInternalValue(170); |
| 489 static const base::Time kTime8 = base::Time::FromInternalValue(180); | 487 static const base::Time kTime8 = base::Time::FromInternalValue(180); |
| 490 static const base::Time kTime9 = base::Time::FromInternalValue(190); | 488 static const base::Time kTime9 = base::Time::FromInternalValue(190); |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 811 | 809 |
| 812 // Now take that header node and feed it in as input. | 810 // Now take that header node and feed it in as input. |
| 813 SyncData d(SyncData::CreateRemoteData( | 811 SyncData d(SyncData::CreateRemoteData( |
| 814 1, | 812 1, |
| 815 data.GetSpecifics(), | 813 data.GetSpecifics(), |
| 816 base::Time(), | 814 base::Time(), |
| 817 syncer::AttachmentIdList(), | 815 syncer::AttachmentIdList(), |
| 818 syncer::AttachmentServiceProxyForTest::Create())); | 816 syncer::AttachmentServiceProxyForTest::Create())); |
| 819 syncer::SyncDataList in(&d, &d + 1); | 817 syncer::SyncDataList in(&d, &d + 1); |
| 820 out.clear(); | 818 out.clear(); |
| 821 SessionsSyncManager manager2(profile(), local_device(), NewDummyRouter(), | 819 SessionsSyncManager manager2(GetSyncSessionsClient(), profile(), |
| 820 local_device(), NewDummyRouter(), |
| 822 NewBrowserWindowGetter()); | 821 NewBrowserWindowGetter()); |
| 823 syncer::SyncMergeResult result = manager2.MergeDataAndStartSyncing( | 822 syncer::SyncMergeResult result = manager2.MergeDataAndStartSyncing( |
| 824 syncer::SESSIONS, in, | 823 syncer::SESSIONS, in, |
| 825 scoped_ptr<syncer::SyncChangeProcessor>( | 824 scoped_ptr<syncer::SyncChangeProcessor>( |
| 826 new TestSyncProcessorStub(&out)), | 825 new TestSyncProcessorStub(&out)), |
| 827 scoped_ptr<syncer::SyncErrorFactory>( | 826 scoped_ptr<syncer::SyncErrorFactory>( |
| 828 new syncer::SyncErrorFactoryMock())); | 827 new syncer::SyncErrorFactoryMock())); |
| 829 ASSERT_FALSE(result.error().IsSet()); | 828 ASSERT_FALSE(result.error().IsSet()); |
| 830 | 829 |
| 831 EXPECT_EQ(1U, out.size()); | 830 EXPECT_EQ(1U, out.size()); |
| (...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1313 EXPECT_TRUE(manager()->local_tab_pool_out_of_sync_); | 1312 EXPECT_TRUE(manager()->local_tab_pool_out_of_sync_); |
| 1314 EXPECT_TRUE(out.empty()); // ChangeProcessor shouldn't see any activity. | 1313 EXPECT_TRUE(out.empty()); // ChangeProcessor shouldn't see any activity. |
| 1315 | 1314 |
| 1316 // This should trigger repair of the TabNodePool. | 1315 // This should trigger repair of the TabNodePool. |
| 1317 const GURL foo1("http://foo/1"); | 1316 const GURL foo1("http://foo/1"); |
| 1318 AddTab(browser(), foo1); | 1317 AddTab(browser(), foo1); |
| 1319 EXPECT_FALSE(manager()->local_tab_pool_out_of_sync_); | 1318 EXPECT_FALSE(manager()->local_tab_pool_out_of_sync_); |
| 1320 | 1319 |
| 1321 // AddTab triggers two notifications, one for the tab insertion and one for | 1320 // AddTab triggers two notifications, one for the tab insertion and one for |
| 1322 // committing the NavigationEntry. The first notification results in a tab | 1321 // committing the NavigationEntry. The first notification results in a tab |
| 1323 // we don't associate although we do update the header node. The second | 1322 // with a pending entry, which we ignore. The second notification triggers |
| 1324 // notification triggers association of the tab, and the subsequent window | 1323 // association of the tab, and the subsequent window update. So we should see |
| 1325 // update. So we should see 4 changes at the SyncChangeProcessor. | 1324 // 3 changes at the SyncChangeProcessor. |
| 1326 ASSERT_EQ(4U, out.size()); | 1325 EXPECT_EQ(3U, out.size()); |
| 1327 | 1326 |
| 1328 EXPECT_EQ(SyncChange::ACTION_UPDATE, out[0].change_type()); | 1327 EXPECT_EQ(SyncChange::ACTION_ADD, out[0].change_type()); |
| 1329 ASSERT_TRUE(out[0].sync_data().GetSpecifics().session().has_header()); | 1328 int tab_node_id = out[0].sync_data().GetSpecifics().session().tab_node_id(); |
| 1330 EXPECT_EQ(SyncChange::ACTION_ADD, out[1].change_type()); | |
| 1331 int tab_node_id = out[1].sync_data().GetSpecifics().session().tab_node_id(); | |
| 1332 EXPECT_EQ(TabNodePool::TabIdToTag( | 1329 EXPECT_EQ(TabNodePool::TabIdToTag( |
| 1333 manager()->current_machine_tag(), tab_node_id), | 1330 manager()->current_machine_tag(), tab_node_id), |
| 1334 syncer::SyncDataLocal(out[1].sync_data()).GetTag()); | 1331 syncer::SyncDataLocal(out[0].sync_data()).GetTag()); |
| 1332 EXPECT_EQ(SyncChange::ACTION_UPDATE, out[1].change_type()); |
| 1333 ASSERT_TRUE(out[1].sync_data().GetSpecifics().session().has_tab()); |
| 1335 EXPECT_EQ(SyncChange::ACTION_UPDATE, out[2].change_type()); | 1334 EXPECT_EQ(SyncChange::ACTION_UPDATE, out[2].change_type()); |
| 1336 ASSERT_TRUE(out[2].sync_data().GetSpecifics().session().has_tab()); | 1335 ASSERT_TRUE(out[2].sync_data().GetSpecifics().session().has_header()); |
| 1337 EXPECT_EQ(SyncChange::ACTION_UPDATE, out[3].change_type()); | |
| 1338 ASSERT_TRUE(out[3].sync_data().GetSpecifics().session().has_header()); | |
| 1339 | 1336 |
| 1340 // Verify the actual content. | 1337 // Verify the actual content. |
| 1341 const sync_pb::SessionHeader& session_header = | 1338 const sync_pb::SessionHeader& session_header = |
| 1342 out[3].sync_data().GetSpecifics().session().header(); | 1339 out[2].sync_data().GetSpecifics().session().header(); |
| 1343 ASSERT_EQ(1, session_header.window_size()); | 1340 ASSERT_EQ(1, session_header.window_size()); |
| 1344 EXPECT_EQ(1, session_header.window(0).tab_size()); | 1341 EXPECT_EQ(1, session_header.window(0).tab_size()); |
| 1345 const sync_pb::SessionTab& tab1 = | 1342 const sync_pb::SessionTab& tab1 = |
| 1346 out[2].sync_data().GetSpecifics().session().tab(); | 1343 out[1].sync_data().GetSpecifics().session().tab(); |
| 1347 ASSERT_EQ(1, tab1.navigation_size()); | 1344 ASSERT_EQ(1, tab1.navigation_size()); |
| 1348 EXPECT_EQ(foo1.spec(), tab1.navigation(0).virtual_url()); | 1345 EXPECT_EQ(foo1.spec(), tab1.navigation(0).virtual_url()); |
| 1349 | 1346 |
| 1350 // Verify TabNodePool integrity. | 1347 // Verify TabNodePool integrity. |
| 1351 EXPECT_EQ(1U, manager()->local_tab_pool_.Capacity()); | 1348 EXPECT_EQ(1U, manager()->local_tab_pool_.Capacity()); |
| 1352 EXPECT_TRUE(manager()->local_tab_pool_.Empty()); | 1349 EXPECT_TRUE(manager()->local_tab_pool_.Empty()); |
| 1353 | 1350 |
| 1354 // Verify TabLinks. | 1351 // Verify TabLinks. |
| 1355 SessionsSyncManager::TabLinksMap tab_map = manager()->local_tab_map_; | 1352 SessionsSyncManager::TabLinksMap tab_map = manager()->local_tab_map_; |
| 1356 ASSERT_EQ(1U, tab_map.size()); | 1353 ASSERT_EQ(1U, tab_map.size()); |
| 1357 int tab_id = out[2].sync_data().GetSpecifics().session().tab().tab_id(); | 1354 int tab_id = out[1].sync_data().GetSpecifics().session().tab().tab_id(); |
| 1358 EXPECT_EQ(tab_node_id, tab_map.find(tab_id)->second->tab_node_id()); | 1355 EXPECT_EQ(tab_node_id, tab_map.find(tab_id)->second->tab_node_id()); |
| 1359 } | 1356 } |
| 1360 | 1357 |
| 1361 // Test that receiving a session delete from sync removes the session | 1358 // Test that receiving a session delete from sync removes the session |
| 1362 // from tracking. | 1359 // from tracking. |
| 1363 TEST_F(SessionsSyncManagerTest, ProcessForeignDelete) { | 1360 TEST_F(SessionsSyncManagerTest, ProcessForeignDelete) { |
| 1364 InitWithNoSyncData(); | 1361 InitWithNoSyncData(); |
| 1365 SessionID::id_type n[] = {5}; | 1362 SessionID::id_type n[] = {5}; |
| 1366 std::vector<sync_pb::SessionSpecifics> tabs1; | 1363 std::vector<sync_pb::SessionSpecifics> tabs1; |
| 1367 std::vector<SessionID::id_type> tab_list(n, n + arraysize(n)); | 1364 std::vector<SessionID::id_type> tab_list(n, n + arraysize(n)); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1401 sync_pb::EntitySpecifics entity(changes[0].sync_data().GetSpecifics()); | 1398 sync_pb::EntitySpecifics entity(changes[0].sync_data().GetSpecifics()); |
| 1402 entity.mutable_session()->mutable_tab()->set_tab_id(1); | 1399 entity.mutable_session()->mutable_tab()->set_tab_id(1); |
| 1403 SyncData d(SyncData::CreateRemoteData( | 1400 SyncData d(SyncData::CreateRemoteData( |
| 1404 1, | 1401 1, |
| 1405 entity, | 1402 entity, |
| 1406 base::Time(), | 1403 base::Time(), |
| 1407 syncer::AttachmentIdList(), | 1404 syncer::AttachmentIdList(), |
| 1408 syncer::AttachmentServiceProxyForTest::Create())); | 1405 syncer::AttachmentServiceProxyForTest::Create())); |
| 1409 syncer::SyncDataList in(&d, &d + 1); | 1406 syncer::SyncDataList in(&d, &d + 1); |
| 1410 changes.clear(); | 1407 changes.clear(); |
| 1411 SessionsSyncManager manager2(profile(), local_device(), NewDummyRouter(), | 1408 SessionsSyncManager manager2(GetSyncSessionsClient(), profile(), |
| 1409 local_device(), NewDummyRouter(), |
| 1412 NewBrowserWindowGetter()); | 1410 NewBrowserWindowGetter()); |
| 1413 syncer::SyncMergeResult result = manager2.MergeDataAndStartSyncing( | 1411 syncer::SyncMergeResult result = manager2.MergeDataAndStartSyncing( |
| 1414 syncer::SESSIONS, in, | 1412 syncer::SESSIONS, in, |
| 1415 scoped_ptr<syncer::SyncChangeProcessor>( | 1413 scoped_ptr<syncer::SyncChangeProcessor>( |
| 1416 new TestSyncProcessorStub(&changes)), | 1414 new TestSyncProcessorStub(&changes)), |
| 1417 scoped_ptr<syncer::SyncErrorFactory>( | 1415 scoped_ptr<syncer::SyncErrorFactory>( |
| 1418 new syncer::SyncErrorFactoryMock())); | 1416 new syncer::SyncErrorFactoryMock())); |
| 1419 ASSERT_FALSE(result.error().IsSet()); | 1417 ASSERT_FALSE(result.error().IsSet()); |
| 1420 EXPECT_TRUE(FilterOutLocalHeaderChanges(&changes)->empty()); | 1418 EXPECT_TRUE(FilterOutLocalHeaderChanges(&changes)->empty()); |
| 1421 } | 1419 } |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1504 | 1502 |
| 1505 const GURL foo1("http://foo/1"); | 1503 const GURL foo1("http://foo/1"); |
| 1506 const GURL foo2("http://foo/2"); | 1504 const GURL foo2("http://foo/2"); |
| 1507 const GURL bar1("http://bar/1"); | 1505 const GURL bar1("http://bar/1"); |
| 1508 const GURL bar2("http://bar/2"); | 1506 const GURL bar2("http://bar/2"); |
| 1509 AddTab(browser(), foo1); | 1507 AddTab(browser(), foo1); |
| 1510 NavigateAndCommitActiveTab(foo2); | 1508 NavigateAndCommitActiveTab(foo2); |
| 1511 AddTab(browser(), bar1); | 1509 AddTab(browser(), bar1); |
| 1512 NavigateAndCommitActiveTab(bar2); | 1510 NavigateAndCommitActiveTab(bar2); |
| 1513 | 1511 |
| 1514 // One add, one update for each AddTab. | 1512 // One add, one update changes for each AddTab. |
| 1515 // One update for each NavigateAndCommit. | 1513 // One update for each NavigateAndCommit. |
| 1516 // = 6 total tab updates. | 1514 // = 6 total tab updates. |
| 1517 // One header update corresponding to each of those. | 1515 // One header update corresponding to each navigation. |
| 1518 // = 6 total header updates. | 1516 // = 4 total header updates. |
| 1519 // 12 total updates. | 1517 // 10 total updates. |
| 1520 ASSERT_EQ(12U, out.size()); | 1518 ASSERT_EQ(10U, out.size()); |
| 1521 | 1519 |
| 1522 // Verify the tab node creations and updates to ensure the SyncProcessor | 1520 // Verify the tab node creations and updates to ensure the SyncProcessor |
| 1523 // sees the right operations. | 1521 // sees the right operations. |
| 1524 for (int i = 0; i < 12; i++) { | 1522 for (int i = 0; i < 10; i++) { |
| 1525 SCOPED_TRACE(i); | 1523 SCOPED_TRACE(i); |
| 1526 EXPECT_TRUE(out[i].IsValid()); | 1524 EXPECT_TRUE(out[i].IsValid()); |
| 1527 const SyncData data(out[i].sync_data()); | 1525 const SyncData data(out[i].sync_data()); |
| 1528 EXPECT_TRUE(base::StartsWith(syncer::SyncDataLocal(data).GetTag(), | 1526 EXPECT_TRUE(base::StartsWith(syncer::SyncDataLocal(data).GetTag(), |
| 1529 manager()->current_machine_tag(), | 1527 manager()->current_machine_tag(), |
| 1530 base::CompareCase::SENSITIVE)); | 1528 base::CompareCase::SENSITIVE)); |
| 1531 const sync_pb::SessionSpecifics& specifics(data.GetSpecifics().session()); | 1529 const sync_pb::SessionSpecifics& specifics(data.GetSpecifics().session()); |
| 1532 EXPECT_EQ(manager()->current_machine_tag(), specifics.session_tag()); | 1530 EXPECT_EQ(manager()->current_machine_tag(), specifics.session_tag()); |
| 1533 if (i % 6 == 0) { | 1531 if (i % 5 == 0) { |
| 1534 // First thing on an AddTab is a no-op header update for parented tab. | |
| 1535 EXPECT_EQ(header.SerializeAsString(), | |
| 1536 data.GetSpecifics().SerializeAsString()); | |
| 1537 EXPECT_EQ(manager()->current_machine_tag(), | |
| 1538 syncer::SyncDataLocal(data).GetTag()); | |
| 1539 } else if (i % 6 == 1) { | |
| 1540 // Next, the TabNodePool should create the tab node. | 1532 // Next, the TabNodePool should create the tab node. |
| 1541 EXPECT_EQ(SyncChange::ACTION_ADD, out[i].change_type()); | 1533 EXPECT_EQ(SyncChange::ACTION_ADD, out[i].change_type()); |
| 1542 EXPECT_EQ(TabNodePool::TabIdToTag( | 1534 EXPECT_EQ(TabNodePool::TabIdToTag( |
| 1543 manager()->current_machine_tag(), | 1535 manager()->current_machine_tag(), |
| 1544 data.GetSpecifics().session().tab_node_id()), | 1536 data.GetSpecifics().session().tab_node_id()), |
| 1545 syncer::SyncDataLocal(data).GetTag()); | 1537 syncer::SyncDataLocal(data).GetTag()); |
| 1546 } else if (i % 6 == 2) { | 1538 } else if (i % 5 == 1) { |
| 1547 // Then we see the tab update to the URL. | 1539 // Then we see the tab update to the URL. |
| 1548 EXPECT_EQ(SyncChange::ACTION_UPDATE, out[i].change_type()); | 1540 EXPECT_EQ(SyncChange::ACTION_UPDATE, out[i].change_type()); |
| 1549 EXPECT_EQ(TabNodePool::TabIdToTag( | 1541 EXPECT_EQ(TabNodePool::TabIdToTag( |
| 1550 manager()->current_machine_tag(), | 1542 manager()->current_machine_tag(), |
| 1551 data.GetSpecifics().session().tab_node_id()), | 1543 data.GetSpecifics().session().tab_node_id()), |
| 1552 syncer::SyncDataLocal(data).GetTag()); | 1544 syncer::SyncDataLocal(data).GetTag()); |
| 1553 ASSERT_TRUE(specifics.has_tab()); | 1545 EXPECT_TRUE(specifics.has_tab()); |
| 1554 } else if (i % 6 == 3) { | 1546 } else if (i % 5 == 2) { |
| 1555 // The header needs to be updated to reflect the new window state. | 1547 // The header needs to be updated to reflect the new window state. |
| 1556 EXPECT_EQ(SyncChange::ACTION_UPDATE, out[i].change_type()); | 1548 EXPECT_EQ(SyncChange::ACTION_UPDATE, out[i].change_type()); |
| 1557 EXPECT_TRUE(specifics.has_header()); | 1549 EXPECT_TRUE(specifics.has_header()); |
| 1558 } else if (i % 6 == 4) { | 1550 } else if (i % 5 == 3) { |
| 1559 // Now we move on to NavigateAndCommit. Update the tab. | 1551 // Now we move on to NavigateAndCommit. Update the tab. |
| 1560 EXPECT_EQ(SyncChange::ACTION_UPDATE, out[i].change_type()); | 1552 EXPECT_EQ(SyncChange::ACTION_UPDATE, out[i].change_type()); |
| 1561 EXPECT_EQ(TabNodePool::TabIdToTag( | 1553 EXPECT_EQ(TabNodePool::TabIdToTag( |
| 1562 manager()->current_machine_tag(), | 1554 manager()->current_machine_tag(), |
| 1563 data.GetSpecifics().session().tab_node_id()), | 1555 data.GetSpecifics().session().tab_node_id()), |
| 1564 syncer::SyncDataLocal(data).GetTag()); | 1556 syncer::SyncDataLocal(data).GetTag()); |
| 1565 ASSERT_TRUE(specifics.has_tab()); | 1557 EXPECT_TRUE(specifics.has_tab()); |
| 1566 } else if (i % 6 == 5) { | 1558 } else if (i % 5 == 4) { |
| 1567 // The header needs to be updated to reflect the new window state. | 1559 // The header needs to be updated to reflect the new window state. |
| 1568 EXPECT_EQ(SyncChange::ACTION_UPDATE, out[i].change_type()); | 1560 EXPECT_EQ(SyncChange::ACTION_UPDATE, out[i].change_type()); |
| 1569 ASSERT_TRUE(specifics.has_header()); | 1561 EXPECT_TRUE(specifics.has_header()); |
| 1570 header = data.GetSpecifics(); | 1562 header = data.GetSpecifics(); |
| 1571 } | 1563 } |
| 1572 } | 1564 } |
| 1573 | 1565 |
| 1574 // Verify the actual content to ensure sync sees the right data. | 1566 // Verify the actual content to ensure sync sees the right data. |
| 1575 // When it's all said and done, the header should reflect two tabs. | 1567 // When it's all said and done, the header should reflect two tabs. |
| 1576 const sync_pb::SessionHeader& session_header = header.session().header(); | 1568 const sync_pb::SessionHeader& session_header = header.session().header(); |
| 1577 ASSERT_EQ(1, session_header.window_size()); | 1569 ASSERT_EQ(1, session_header.window_size()); |
| 1578 EXPECT_EQ(2, session_header.window(0).tab_size()); | 1570 EXPECT_EQ(2, session_header.window(0).tab_size()); |
| 1579 | 1571 |
| 1580 // ASSERT_TRUEs above allow us to dive in freely here. | 1572 // ASSERT_TRUEs above allow us to dive in freely here. |
| 1581 // Verify first tab. | 1573 // Verify first tab. |
| 1582 const sync_pb::SessionTab& tab1_1 = | 1574 const sync_pb::SessionTab& tab1_1 = |
| 1583 out[2].sync_data().GetSpecifics().session().tab(); | 1575 out[1].sync_data().GetSpecifics().session().tab(); |
| 1584 ASSERT_EQ(1, tab1_1.navigation_size()); | 1576 ASSERT_EQ(1, tab1_1.navigation_size()); |
| 1585 EXPECT_EQ(foo1.spec(), tab1_1.navigation(0).virtual_url()); | 1577 EXPECT_EQ(foo1.spec(), tab1_1.navigation(0).virtual_url()); |
| 1586 const sync_pb::SessionTab& tab1_2 = | 1578 const sync_pb::SessionTab& tab1_2 = |
| 1587 out[4].sync_data().GetSpecifics().session().tab(); | 1579 out[3].sync_data().GetSpecifics().session().tab(); |
| 1588 ASSERT_EQ(2, tab1_2.navigation_size()); | 1580 ASSERT_EQ(2, tab1_2.navigation_size()); |
| 1589 EXPECT_EQ(foo1.spec(), tab1_2.navigation(0).virtual_url()); | 1581 EXPECT_EQ(foo1.spec(), tab1_2.navigation(0).virtual_url()); |
| 1590 EXPECT_EQ(foo2.spec(), tab1_2.navigation(1).virtual_url()); | 1582 EXPECT_EQ(foo2.spec(), tab1_2.navigation(1).virtual_url()); |
| 1591 | 1583 |
| 1592 // Verify second tab. | 1584 // Verify second tab. |
| 1593 const sync_pb::SessionTab& tab2_1 = | 1585 const sync_pb::SessionTab& tab2_1 = |
| 1594 out[8].sync_data().GetSpecifics().session().tab(); | 1586 out[6].sync_data().GetSpecifics().session().tab(); |
| 1595 ASSERT_EQ(1, tab2_1.navigation_size()); | 1587 ASSERT_EQ(1, tab2_1.navigation_size()); |
| 1596 EXPECT_EQ(bar1.spec(), tab2_1.navigation(0).virtual_url()); | 1588 EXPECT_EQ(bar1.spec(), tab2_1.navigation(0).virtual_url()); |
| 1597 const sync_pb::SessionTab& tab2_2 = | 1589 const sync_pb::SessionTab& tab2_2 = |
| 1598 out[10].sync_data().GetSpecifics().session().tab(); | 1590 out[8].sync_data().GetSpecifics().session().tab(); |
| 1599 ASSERT_EQ(2, tab2_2.navigation_size()); | 1591 ASSERT_EQ(2, tab2_2.navigation_size()); |
| 1600 EXPECT_EQ(bar1.spec(), tab2_2.navigation(0).virtual_url()); | 1592 EXPECT_EQ(bar1.spec(), tab2_2.navigation(0).virtual_url()); |
| 1601 EXPECT_EQ(bar2.spec(), tab2_2.navigation(1).virtual_url()); | 1593 EXPECT_EQ(bar2.spec(), tab2_2.navigation(1).virtual_url()); |
| 1602 } | 1594 } |
| 1603 | 1595 |
| 1604 // Ensure model association associates the pre-existing tabs. | 1596 // Ensure model association associates the pre-existing tabs. |
| 1605 TEST_F(SessionsSyncManagerTest, MergeLocalSessionExistingTabs) { | 1597 TEST_F(SessionsSyncManagerTest, MergeLocalSessionExistingTabs) { |
| 1606 AddTab(browser(), GURL("http://foo1")); | 1598 AddTab(browser(), GURL("http://foo1")); |
| 1607 NavigateAndCommitActiveTab(GURL("http://foo2")); // Adds back entry. | 1599 NavigateAndCommitActiveTab(GURL("http://foo2")); // Adds back entry. |
| 1608 AddTab(browser(), GURL("http://bar1")); | 1600 AddTab(browser(), GURL("http://bar1")); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1659 const sync_pb::SessionHeader& header_s2 = specifics2.header(); | 1651 const sync_pb::SessionHeader& header_s2 = specifics2.header(); |
| 1660 EXPECT_EQ(1, header_s2.window_size()); | 1652 EXPECT_EQ(1, header_s2.window_size()); |
| 1661 | 1653 |
| 1662 // Verify TabLinks. | 1654 // Verify TabLinks. |
| 1663 SessionsSyncManager::TabLinksMap tab_map = manager()->local_tab_map_; | 1655 SessionsSyncManager::TabLinksMap tab_map = manager()->local_tab_map_; |
| 1664 ASSERT_EQ(2U, tab_map.size()); | 1656 ASSERT_EQ(2U, tab_map.size()); |
| 1665 // Tabs are ordered by sessionid in tab_map, so should be able to traverse | 1657 // Tabs are ordered by sessionid in tab_map, so should be able to traverse |
| 1666 // the tree based on order of tabs created | 1658 // the tree based on order of tabs created |
| 1667 SessionsSyncManager::TabLinksMap::iterator iter = tab_map.begin(); | 1659 SessionsSyncManager::TabLinksMap::iterator iter = tab_map.begin(); |
| 1668 ASSERT_EQ(2, iter->second->tab()->GetEntryCount()); | 1660 ASSERT_EQ(2, iter->second->tab()->GetEntryCount()); |
| 1669 EXPECT_EQ(GURL("http://foo1"), iter->second->tab()-> | 1661 EXPECT_EQ(GURL("http://foo1"), iter->second->tab()->GetVirtualURLAtIndex(0)); |
| 1670 GetEntryAtIndex(0)->GetVirtualURL()); | 1662 EXPECT_EQ(GURL("http://foo2"), iter->second->tab()->GetVirtualURLAtIndex(1)); |
| 1671 EXPECT_EQ(GURL("http://foo2"), iter->second->tab()-> | |
| 1672 GetEntryAtIndex(1)->GetVirtualURL()); | |
| 1673 iter++; | 1663 iter++; |
| 1674 ASSERT_EQ(2, iter->second->tab()->GetEntryCount()); | 1664 ASSERT_EQ(2, iter->second->tab()->GetEntryCount()); |
| 1675 EXPECT_EQ(GURL("http://bar1"), iter->second->tab()-> | 1665 EXPECT_EQ(GURL("http://bar1"), iter->second->tab()->GetVirtualURLAtIndex(0)); |
| 1676 GetEntryAtIndex(0)->GetVirtualURL()); | 1666 EXPECT_EQ(GURL("http://bar2"), iter->second->tab()->GetVirtualURLAtIndex(1)); |
| 1677 EXPECT_EQ(GURL("http://bar2"), iter->second->tab()-> | |
| 1678 GetEntryAtIndex(1)->GetVirtualURL()); | |
| 1679 } | 1667 } |
| 1680 | 1668 |
| 1681 // Test garbage collection of stale foreign sessions. | 1669 // Test garbage collection of stale foreign sessions. |
| 1682 TEST_F(SessionsSyncManagerTest, DoGarbageCollection) { | 1670 TEST_F(SessionsSyncManagerTest, DoGarbageCollection) { |
| 1683 // Fill two instances of session specifics with a foreign session's data. | 1671 // Fill two instances of session specifics with a foreign session's data. |
| 1684 std::string tag1 = "tag1"; | 1672 std::string tag1 = "tag1"; |
| 1685 SessionID::id_type n1[] = {5, 10, 13, 17}; | 1673 SessionID::id_type n1[] = {5, 10, 13, 17}; |
| 1686 std::vector<SessionID::id_type> tab_list1(n1, n1 + arraysize(n1)); | 1674 std::vector<SessionID::id_type> tab_list1(n1, n1 + arraysize(n1)); |
| 1687 std::vector<sync_pb::SessionSpecifics> tabs1; | 1675 std::vector<sync_pb::SessionSpecifics> tabs1; |
| 1688 sync_pb::SessionSpecifics meta(helper()->BuildForeignSession( | 1676 sync_pb::SessionSpecifics meta(helper()->BuildForeignSession( |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1842 // Delete old WebContents. This should not crash. | 1830 // Delete old WebContents. This should not crash. |
| 1843 old_web_contents.reset(); | 1831 old_web_contents.reset(); |
| 1844 | 1832 |
| 1845 // Try more navigations and verify output size. This can also reveal | 1833 // Try more navigations and verify output size. This can also reveal |
| 1846 // bugs (leaks) on memcheck bots if the SessionSyncManager | 1834 // bugs (leaks) on memcheck bots if the SessionSyncManager |
| 1847 // didn't properly clean up the tab pool or session tracker. | 1835 // didn't properly clean up the tab pool or session tracker. |
| 1848 NavigateAndCommitActiveTab(GURL("http://bar3")); | 1836 NavigateAndCommitActiveTab(GURL("http://bar3")); |
| 1849 | 1837 |
| 1850 AddTab(browser(), GURL("http://bar4")); | 1838 AddTab(browser(), GURL("http://bar4")); |
| 1851 NavigateAndCommitActiveTab(GURL("http://bar5")); | 1839 NavigateAndCommitActiveTab(GURL("http://bar5")); |
| 1852 ASSERT_EQ(19U, out.size()); | 1840 ASSERT_EQ(18U, out.size()); |
| 1853 } | 1841 } |
| 1854 | 1842 |
| 1855 namespace { | 1843 namespace { |
| 1856 class SessionNotificationObserver : public content::NotificationObserver { | 1844 class SessionNotificationObserver : public content::NotificationObserver { |
| 1857 public: | 1845 public: |
| 1858 SessionNotificationObserver() : notified_of_update_(false), | 1846 SessionNotificationObserver() : notified_of_update_(false), |
| 1859 notified_of_refresh_(false) { | 1847 notified_of_refresh_(false) { |
| 1860 registrar_.Add(this, chrome::NOTIFICATION_FOREIGN_SESSION_UPDATED, | 1848 registrar_.Add(this, chrome::NOTIFICATION_FOREIGN_SESSION_UPDATED, |
| 1861 content::NotificationService::AllSources()); | 1849 content::NotificationService::AllSources()); |
| 1862 registrar_.Add(this, chrome::NOTIFICATION_SYNC_REFRESH_LOCAL, | 1850 registrar_.Add(this, chrome::NOTIFICATION_SYNC_REFRESH_LOCAL, |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2209 base::Time last_time; | 2197 base::Time last_time; |
| 2210 for (size_t i = 0; i < tabs.size(); ++i) { | 2198 for (size_t i = 0; i < tabs.size(); ++i) { |
| 2211 base::Time this_time = tabs[i]->timestamp; | 2199 base::Time this_time = tabs[i]->timestamp; |
| 2212 if (i > 0) | 2200 if (i > 0) |
| 2213 ASSERT_GE(last_time, this_time); | 2201 ASSERT_GE(last_time, this_time); |
| 2214 last_time = tabs[i]->timestamp; | 2202 last_time = tabs[i]->timestamp; |
| 2215 } | 2203 } |
| 2216 } | 2204 } |
| 2217 | 2205 |
| 2218 } // namespace browser_sync | 2206 } // namespace browser_sync |
| OLD | NEW |