Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(39)

Side by Side Diff: components/sync_sessions/sessions_sync_manager_unittest.cc

Issue 2750163003: Prevent tabs sync during browser shutdown.
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/sync_sessions/sessions_sync_manager.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <stdint.h> 7 #include <stdint.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 1742 matching lines...) Expand 10 before | Expand all | Expand 10 after
1753 // The associate windows after the tab navigation. 1753 // The associate windows after the tab navigation.
1754 VerifyLocalHeaderChange(out[index++], 1, i + 1); 1754 VerifyLocalHeaderChange(out[index++], 1, i + 1);
1755 } 1755 }
1756 } 1756 }
1757 1757
1758 // Verify tab delegates have Sync ids. 1758 // Verify tab delegates have Sync ids.
1759 EXPECT_EQ(0, window->GetTabAt(0)->GetSyncId()); 1759 EXPECT_EQ(0, window->GetTabAt(0)->GetSyncId());
1760 EXPECT_EQ(1, window->GetTabAt(1)->GetSyncId()); 1760 EXPECT_EQ(1, window->GetTabAt(1)->GetSyncId());
1761 } 1761 }
1762 1762
1763 TEST_F(SessionsSyncManagerTest, TabSyncChangesOnShutdown) {
1764 SyncChangeList out;
1765 // Init with no local data, relies on MergeLocalSessionNoTabs.
1766 TestSyncedWindowDelegate* window = AddWindow();
1767 SessionID::id_type window_id = window->GetSessionId();
1768 InitWithSyncDataTakeOutput(syncer::SyncDataList(), &out);
1769 EXPECT_FALSE(manager()->current_machine_tag().empty());
1770 EXPECT_EQ(2U, out.size());
1771
1772 NavigateTab(AddTab(window_id, kFoo1), kFoo2);
1773 NavigateTab(AddTab(window_id, kBar1), kBar2);
1774 out.clear();
1775
1776 EXPECT_FALSE(manager()->GetAllBrowsersClosingForTesting());
1777 manager()->SetAllBrowsersClosing(true);
1778 browser()->tab_strip_model()->CloseWebContentsAt(1,
1779 TabStripModel::CLOSE_NONE);
1780 EXPECT_EQ(0U, out.size());
1781
1782 manager()->SetAllBrowsersClosing(false);
1783 browser()->tab_strip_model()->CloseAllTabs();
1784 EXPECT_EQ(1U, out.size());
1785 }
1786
1763 TEST_F(SessionsSyncManagerTest, ForeignSessionModifiedTime) { 1787 TEST_F(SessionsSyncManagerTest, ForeignSessionModifiedTime) {
1764 SyncDataList foreign_data; 1788 SyncDataList foreign_data;
1765 base::Time newest_time = base::Time::Now() - base::TimeDelta::FromDays(1); 1789 base::Time newest_time = base::Time::Now() - base::TimeDelta::FromDays(1);
1766 base::Time middle_time = base::Time::Now() - base::TimeDelta::FromDays(2); 1790 base::Time middle_time = base::Time::Now() - base::TimeDelta::FromDays(2);
1767 base::Time oldest_time = base::Time::Now() - base::TimeDelta::FromDays(3); 1791 base::Time oldest_time = base::Time::Now() - base::TimeDelta::FromDays(3);
1768 1792
1769 { 1793 {
1770 std::string session_tag = "tag1"; 1794 std::string session_tag = "tag1";
1771 SessionID::id_type n[] = {1, 2}; 1795 SessionID::id_type n[] = {1, 2};
1772 std::vector<SessionID::id_type> tab_list(n, n + arraysize(n)); 1796 std::vector<SessionID::id_type> tab_list(n, n + arraysize(n));
(...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after
2397 // Because tab 2 is a placeholder, tab 1's URL will be preserved. 2421 // Because tab 2 is a placeholder, tab 1's URL will be preserved.
2398 VerifyLocalTabChange(out[1], 1, kFoo1); 2422 VerifyLocalTabChange(out[1], 1, kFoo1);
2399 EXPECT_EQ(sync_id, out[1].sync_data().GetSpecifics().session().tab_node_id()); 2423 EXPECT_EQ(sync_id, out[1].sync_data().GetSpecifics().session().tab_node_id());
2400 EXPECT_EQ(tab2.GetSessionId(), 2424 EXPECT_EQ(tab2.GetSessionId(),
2401 out[1].sync_data().GetSpecifics().session().tab().tab_id()); 2425 out[1].sync_data().GetSpecifics().session().tab().tab_id());
2402 EXPECT_EQ(window2->GetSessionId(), 2426 EXPECT_EQ(window2->GetSessionId(),
2403 out[1].sync_data().GetSpecifics().session().tab().window_id()); 2427 out[1].sync_data().GetSpecifics().session().tab().window_id());
2404 } 2428 }
2405 2429
2406 } // namespace sync_sessions 2430 } // namespace sync_sessions
OLDNEW
« no previous file with comments | « components/sync_sessions/sessions_sync_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698