Improve test coverage for PutTabInWindow()
Most notably, the scenario where the tab is initially mapped was not
exercised in any test. We now cover this case as well as some other
common updates for both local and remote sessions, which also includes
test coverage for UpdateTrackerWithSpecifics() itself.
This requires some minor API changes in SyncedSessionTracker.
Bug: 814423
Change-Id: If65494ef2f505eb6b49569e4d1d1f0a132f92e08
Reviewed-on: https://chromium-review.googlesource.com/1005176
Commit-Queue: Mikel Astiz <[email protected]>
Reviewed-by: Jan Krcal <[email protected]>
Cr-Commit-Position: refs/heads/master@{#550150}
diff --git a/components/sync_sessions/synced_session_tracker.cc b/components/sync_sessions/synced_session_tracker.cc
index dead372..404f9f0 100644
--- a/components/sync_sessions/synced_session_tracker.cc
+++ b/components/sync_sessions/synced_session_tracker.cc
@@ -199,21 +199,19 @@
return tab_iter->second;
}
-void SyncedSessionTracker::LookupForeignTabNodeIds(
- const std::string& session_tag,
- std::set<int>* tab_node_ids) const {
- tab_node_ids->clear();
+std::set<int> SyncedSessionTracker::LookupTabNodeIds(
+ const std::string& session_tag) const {
const TrackedSession* session = LookupTrackedSession(session_tag);
- if (session) {
- tab_node_ids->insert(session->tab_node_ids.begin(),
- session->tab_node_ids.end());
- }
- // In case an invalid node id was included, remove it.
- tab_node_ids->erase(TabNodePool::kInvalidTabNodeID);
+ return session ? session->tab_node_ids : std::set<int>();
}
const SyncedSession* SyncedSessionTracker::LookupLocalSession() const {
- const TrackedSession* session = LookupTrackedSession(local_session_tag_);
+ return LookupSession(local_session_tag_);
+}
+
+const SyncedSession* SyncedSessionTracker::LookupSession(
+ const std::string& session_tag) const {
+ const TrackedSession* session = LookupTrackedSession(session_tag);
return session ? &session->synced_session : nullptr;
}
@@ -319,12 +317,6 @@
return session->unmapped_tabs.count(tab_id) != 0;
}
-std::set<int> SyncedSessionTracker::GetTabNodeIdsForTesting(
- const std::string& session_tag) const {
- const TrackedSession* session = LookupTrackedSession(session_tag);
- return session ? session->tab_node_ids : std::set<int>();
-}
-
void SyncedSessionTracker::PutWindowInSession(const std::string& session_tag,
SessionID window_id) {
TrackedSession* session = GetTrackedSession(session_tag);
@@ -420,7 +412,9 @@
void SyncedSessionTracker::OnTabNodeSeen(const std::string& session_tag,
int tab_node_id) {
- GetTrackedSession(session_tag)->tab_node_ids.insert(tab_node_id);
+ if (tab_node_id != TabNodePool::kInvalidTabNodeID) {
+ GetTrackedSession(session_tag)->tab_node_ids.insert(tab_node_id);
+ }
}
sessions::SessionTab* SyncedSessionTracker::GetTab(