| 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 <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 2033 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2044 // Verify second tab. | 2044 // Verify second tab. |
| 2045 const sync_pb::SessionTab& tab2_1 = | 2045 const sync_pb::SessionTab& tab2_1 = |
| 2046 out[6].sync_data().GetSpecifics().session().tab(); | 2046 out[6].sync_data().GetSpecifics().session().tab(); |
| 2047 ASSERT_EQ(1, tab2_1.navigation_size()); | 2047 ASSERT_EQ(1, tab2_1.navigation_size()); |
| 2048 EXPECT_EQ(bar1.spec(), tab2_1.navigation(0).virtual_url()); | 2048 EXPECT_EQ(bar1.spec(), tab2_1.navigation(0).virtual_url()); |
| 2049 const sync_pb::SessionTab& tab2_2 = | 2049 const sync_pb::SessionTab& tab2_2 = |
| 2050 out[8].sync_data().GetSpecifics().session().tab(); | 2050 out[8].sync_data().GetSpecifics().session().tab(); |
| 2051 ASSERT_EQ(2, tab2_2.navigation_size()); | 2051 ASSERT_EQ(2, tab2_2.navigation_size()); |
| 2052 EXPECT_EQ(bar1.spec(), tab2_2.navigation(0).virtual_url()); | 2052 EXPECT_EQ(bar1.spec(), tab2_2.navigation(0).virtual_url()); |
| 2053 EXPECT_EQ(bar2.spec(), tab2_2.navigation(1).virtual_url()); | 2053 EXPECT_EQ(bar2.spec(), tab2_2.navigation(1).virtual_url()); |
| 2054 |
| 2055 // Verify tab delegates have Sync ids. |
| 2056 std::set<const SyncedWindowDelegate*> window_delegates = |
| 2057 get_synced_window_getter()->GetSyncedWindowDelegates(); |
| 2058 // Sync ids are in reverse order because tabs are inserted at the beginning |
| 2059 // of the tab list. |
| 2060 EXPECT_EQ(1, (*window_delegates.begin())->GetTabAt(0)->GetSyncId()); |
| 2061 EXPECT_EQ(0, (*window_delegates.begin())->GetTabAt(1)->GetSyncId()); |
| 2054 } | 2062 } |
| 2055 | 2063 |
| 2056 // Check that if a tab becomes uninteresting (for example no syncable URLs), | 2064 // Check that if a tab becomes uninteresting (for example no syncable URLs), |
| 2057 // we correctly remove it from the header node. | 2065 // we correctly remove it from the header node. |
| 2058 TEST_F(SessionsSyncManagerTest, TabBecomesUninteresting) { | 2066 TEST_F(SessionsSyncManagerTest, TabBecomesUninteresting) { |
| 2059 syncer::SyncChangeList out; | 2067 syncer::SyncChangeList out; |
| 2060 // Init with no local data, relies on MergeLocalSessionNoTabs. | 2068 // Init with no local data, relies on MergeLocalSessionNoTabs. |
| 2061 InitWithSyncDataTakeOutput(syncer::SyncDataList(), &out); | 2069 InitWithSyncDataTakeOutput(syncer::SyncDataList(), &out); |
| 2062 ASSERT_FALSE(manager()->current_machine_tag().empty()); | 2070 ASSERT_FALSE(manager()->current_machine_tag().empty()); |
| 2063 ASSERT_EQ(2U, out.size()); | 2071 ASSERT_EQ(2U, out.size()); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2154 EXPECT_TRUE(out[3].IsValid()); | 2162 EXPECT_TRUE(out[3].IsValid()); |
| 2155 EXPECT_EQ(SyncChange::ACTION_UPDATE, out[3].change_type()); | 2163 EXPECT_EQ(SyncChange::ACTION_UPDATE, out[3].change_type()); |
| 2156 const SyncData data_2(out[3].sync_data()); | 2164 const SyncData data_2(out[3].sync_data()); |
| 2157 EXPECT_EQ(manager()->current_machine_tag(), | 2165 EXPECT_EQ(manager()->current_machine_tag(), |
| 2158 syncer::SyncDataLocal(data_2).GetTag()); | 2166 syncer::SyncDataLocal(data_2).GetTag()); |
| 2159 const sync_pb::SessionSpecifics& specifics2(data_2.GetSpecifics().session()); | 2167 const sync_pb::SessionSpecifics& specifics2(data_2.GetSpecifics().session()); |
| 2160 EXPECT_EQ(manager()->current_machine_tag(), specifics2.session_tag()); | 2168 EXPECT_EQ(manager()->current_machine_tag(), specifics2.session_tag()); |
| 2161 EXPECT_TRUE(specifics2.has_header()); | 2169 EXPECT_TRUE(specifics2.has_header()); |
| 2162 const sync_pb::SessionHeader& header_s2 = specifics2.header(); | 2170 const sync_pb::SessionHeader& header_s2 = specifics2.header(); |
| 2163 EXPECT_EQ(1, header_s2.window_size()); | 2171 EXPECT_EQ(1, header_s2.window_size()); |
| 2172 |
| 2173 // Verify tab delegates have Sync ids. |
| 2174 std::set<const SyncedWindowDelegate*> window_delegates = |
| 2175 get_synced_window_getter()->GetSyncedWindowDelegates(); |
| 2176 // Sync ids are in same order as tabs because the association happens after |
| 2177 // the tabs are opened (and therefore iterates through same order). |
| 2178 EXPECT_EQ(0, (*window_delegates.begin())->GetTabAt(0)->GetSyncId()); |
| 2179 EXPECT_EQ(1, (*window_delegates.begin())->GetTabAt(1)->GetSyncId()); |
| 2164 } | 2180 } |
| 2165 | 2181 |
| 2166 TEST_F(SessionsSyncManagerTest, ForeignSessionModifiedTime) { | 2182 TEST_F(SessionsSyncManagerTest, ForeignSessionModifiedTime) { |
| 2167 syncer::SyncDataList foreign_data; | 2183 syncer::SyncDataList foreign_data; |
| 2168 base::Time newest_time = base::Time::Now() - base::TimeDelta::FromDays(1); | 2184 base::Time newest_time = base::Time::Now() - base::TimeDelta::FromDays(1); |
| 2169 base::Time middle_time = base::Time::Now() - base::TimeDelta::FromDays(2); | 2185 base::Time middle_time = base::Time::Now() - base::TimeDelta::FromDays(2); |
| 2170 base::Time oldest_time = base::Time::Now() - base::TimeDelta::FromDays(3); | 2186 base::Time oldest_time = base::Time::Now() - base::TimeDelta::FromDays(3); |
| 2171 | 2187 |
| 2172 { | 2188 { |
| 2173 std::string session_tag = "tag1"; | 2189 std::string session_tag = "tag1"; |
| (...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2691 base::Time last_time; | 2707 base::Time last_time; |
| 2692 for (size_t i = 0; i < tabs.size(); ++i) { | 2708 for (size_t i = 0; i < tabs.size(); ++i) { |
| 2693 base::Time this_time = tabs[i]->timestamp; | 2709 base::Time this_time = tabs[i]->timestamp; |
| 2694 if (i > 0) | 2710 if (i > 0) |
| 2695 ASSERT_GE(last_time, this_time); | 2711 ASSERT_GE(last_time, this_time); |
| 2696 last_time = tabs[i]->timestamp; | 2712 last_time = tabs[i]->timestamp; |
| 2697 } | 2713 } |
| 2698 } | 2714 } |
| 2699 | 2715 |
| 2700 } // namespace sync_sessions | 2716 } // namespace sync_sessions |
| OLD | NEW |