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

Unified Diff: chrome/browser/sync/sessions/sessions_sync_manager_unittest.cc

Issue 2507543002: Revert of [Sync] Put session tracker in charge of maintaining local state. (Closed)
Patch Set: Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | components/sync_sessions/sessions_sync_manager.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/sync/sessions/sessions_sync_manager_unittest.cc
diff --git a/chrome/browser/sync/sessions/sessions_sync_manager_unittest.cc b/chrome/browser/sync/sessions/sessions_sync_manager_unittest.cc
index 9bdd5d189980df5c361a27bc42e4d3c209644332..11e35ef315a9d6316815258f98c946ca4e5770d7 100644
--- a/chrome/browser/sync/sessions/sessions_sync_manager_unittest.cc
+++ b/chrome/browser/sync/sessions/sessions_sync_manager_unittest.cc
@@ -549,17 +549,11 @@
int GetEntryCount() const override { return entries_.size(); }
SessionID::id_type GetWindowId() const override {
- return window_id_;
- }
- void SetWindowId(SessionID::id_type window_id) {
- window_id_ = window_id;
+ return SessionID::id_type();
}
SessionID::id_type GetSessionId() const override {
- return tab_id_;
- }
- void SetSessionId(SessionID::id_type id) {
- tab_id_ = id;
+ return SessionID::id_type();
}
bool IsBeingDestroyed() const override { return false; }
@@ -600,8 +594,6 @@
int current_entry_index_;
bool is_supervised_;
int sync_id_;
- SessionID::id_type tab_id_ = 0;
- SessionID::id_type window_id_ = 0;
std::vector<std::unique_ptr<const sessions::SerializedNavigationEntry>>
blocked_navigations_;
std::vector<std::unique_ptr<content::NavigationEntry>> entries_;
@@ -996,9 +988,7 @@
ASSERT_EQ(1U, windows.size());
SyncedTabDelegateFake t1_override, t2_override;
t1_override.SetSyncId(1); // No WebContents by default.
- t1_override.SetSessionId(kNewTabId);
t2_override.SetSyncId(2); // No WebContents by default.
- t2_override.SetSessionId(t2_entity.session().tab().tab_id());
SyncedWindowDelegateOverride window_override(*windows.begin());
window_override.OverrideTabAt(1, &t1_override, kNewTabId);
window_override.OverrideTabAt(2, &t2_override,
@@ -1016,15 +1006,12 @@
new syncer::SyncErrorFactoryMock()));
// There should be two changes, one for the fully associated tab, and
- // one each for the tab_id updates to t1 and t2.
- ASSERT_EQ(3U, FilterOutLocalHeaderChanges(&out)->size());
+ // one for the tab_id update to t1. t2 shouldn't need to be updated.
+ ASSERT_EQ(2U, FilterOutLocalHeaderChanges(&out)->size());
EXPECT_EQ(SyncChange::ACTION_UPDATE, out[0].change_type());
EXPECT_EQ(SyncChange::ACTION_UPDATE, out[1].change_type());
- EXPECT_EQ(SyncChange::ACTION_UPDATE, out[2].change_type());
EXPECT_EQ(kNewTabId,
out[1].sync_data().GetSpecifics().session().tab().tab_id());
- EXPECT_EQ(t2_entity.session().tab().tab_id(),
- out[2].sync_data().GetSpecifics().session().tab().tab_id());
// Verify TabLinks.
SessionsSyncManager::TabLinksMap tab_map = manager()->local_tab_map_;
@@ -1034,6 +1021,10 @@
EXPECT_EQ(1, tab_map.find(kNewTabId)->second->tab_node_id());
int t0_tab_id = out[0].sync_data().GetSpecifics().session().tab().tab_id();
EXPECT_EQ(0, tab_map.find(t0_tab_id)->second->tab_node_id());
+ // TODO(tim): Once bug 337057 is fixed, we can issue an OnLocalTabModified
+ // from here (using an override similar to above) to return a new tab id
+ // and verify that we don't see any node creations in the SyncChangeProcessor
+ // (similar to how SessionsSyncManagerTest.OnLocalTabModified works.)
}
// Ensure model association updates the window ID for tabs whose window's ID has
@@ -1059,7 +1050,6 @@
// SyncedTabDelegateFake is a placeholder (no WebContents) by default.
SyncedTabDelegateFake t0_override;
t0_override.SetSyncId(t0_entity.session().tab_node_id());
- t0_override.SetWindowId(kNewWindowId);
// Set up the window override with the new window ID and placeholder tab.
const std::set<const SyncedWindowDelegate*>& windows =
@@ -1317,10 +1307,10 @@
tag, tab_nums1, &tabs));
// Update associator with the session's meta node, window, and tabs.
- manager()->UpdateTrackerWithSpecifics(meta, base::Time());
+ manager()->UpdateTrackerWithForeignSession(meta, base::Time());
for (std::vector<sync_pb::SessionSpecifics>::iterator iter = tabs.begin();
iter != tabs.end(); ++iter) {
- manager()->UpdateTrackerWithSpecifics(*iter, base::Time());
+ manager()->UpdateTrackerWithForeignSession(*iter, base::Time());
}
ASSERT_TRUE(manager()->GetAllForeignSessions(&foreign_sessions));
ASSERT_EQ(1U, foreign_sessions.size());
@@ -2080,9 +2070,13 @@
// Tabs are ordered by sessionid in tab_map, so should be able to traverse
// the tree based on order of tabs created
SessionsSyncManager::TabLinksMap::iterator iter = tab_map.begin();
- EXPECT_EQ(GURL("http://foo2"), iter->second->url());
+ ASSERT_EQ(2, iter->second->tab()->GetEntryCount());
+ EXPECT_EQ(GURL("http://foo1"), iter->second->tab()->GetVirtualURLAtIndex(0));
+ EXPECT_EQ(GURL("http://foo2"), iter->second->tab()->GetVirtualURLAtIndex(1));
iter++;
- EXPECT_EQ(GURL("http://bar2"), iter->second->url());
+ ASSERT_EQ(2, iter->second->tab()->GetEntryCount());
+ EXPECT_EQ(GURL("http://bar1"), iter->second->tab()->GetVirtualURLAtIndex(0));
+ EXPECT_EQ(GURL("http://bar2"), iter->second->tab()->GetVirtualURLAtIndex(1));
}
TEST_F(SessionsSyncManagerTest, ForeignSessionModifiedTime) {
« no previous file with comments | « no previous file | components/sync_sessions/sessions_sync_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698