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

Side by Side Diff: chrome/browser/sync/test/integration/single_client_sessions_sync_test.cc

Issue 2499023004: [Sync] Introduce SyncedSessionWindow type. (Closed)
Patch Set: Address comments Created 3 years, 8 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
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 "base/macros.h" 5 #include "base/macros.h"
6 #include "base/run_loop.h" 6 #include "base/run_loop.h"
7 #include "base/test/histogram_tester.h" 7 #include "base/test/histogram_tester.h"
8 #include "chrome/browser/sessions/session_service.h" 8 #include "chrome/browser/sessions/session_service.h"
9 #include "chrome/browser/sessions/session_tab_helper.h" 9 #include "chrome/browser/sessions/session_tab_helper.h"
10 #include "chrome/browser/sync/sessions/sync_sessions_router_tab_helper.h" 10 #include "chrome/browser/sync/sessions/sync_sessions_router_tab_helper.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 } // namespace 70 } // namespace
71 71
72 class SingleClientSessionsSyncTest : public SyncTest { 72 class SingleClientSessionsSyncTest : public SyncTest {
73 public: 73 public:
74 SingleClientSessionsSyncTest() : SyncTest(SINGLE_CLIENT) {} 74 SingleClientSessionsSyncTest() : SyncTest(SINGLE_CLIENT) {}
75 ~SingleClientSessionsSyncTest() override {} 75 ~SingleClientSessionsSyncTest() override {}
76 76
77 void ExpectNavigationChain(const std::vector<GURL>& urls) { 77 void ExpectNavigationChain(const std::vector<GURL>& urls) {
78 ScopedWindowMap windows; 78 ScopedWindowMap windows;
79 ASSERT_TRUE(GetLocalWindows(0, &windows)); 79 ASSERT_TRUE(GetLocalWindows(0, &windows));
80 ASSERT_EQ(windows.begin()->second->tabs.size(), 1u); 80 ASSERT_EQ(windows.begin()->second->wrapped_window.tabs.size(), 1u);
81 sessions::SessionTab* tab = windows.begin()->second->tabs[0].get(); 81 sessions::SessionTab* tab =
82 windows.begin()->second->wrapped_window.tabs[0].get();
82 83
83 int index = 0; 84 int index = 0;
84 EXPECT_EQ(urls.size(), tab->navigations.size()); 85 EXPECT_EQ(urls.size(), tab->navigations.size());
85 for (auto it = tab->navigations.begin(); it != tab->navigations.end(); 86 for (auto it = tab->navigations.begin(); it != tab->navigations.end();
86 ++it, ++index) { 87 ++it, ++index) {
87 EXPECT_EQ(urls[index], it->virtual_url()); 88 EXPECT_EQ(urls[index], it->virtual_url());
88 } 89 }
89 } 90 }
90 91
91 // Block until the expected hierarchy is recorded on the FakeServer for 92 // Block until the expected hierarchy is recorded on the FakeServer for
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 ASSERT_TRUE(CheckInitialState(0)); 155 ASSERT_TRUE(CheckInitialState(0));
155 156
156 const GURL url(kURL1); 157 const GURL url(kURL1);
157 158
158 ScopedWindowMap windows; 159 ScopedWindowMap windows;
159 ASSERT_TRUE(OpenTab(0, url)); 160 ASSERT_TRUE(OpenTab(0, url));
160 ASSERT_TRUE(GetLocalWindows(0, &windows)); 161 ASSERT_TRUE(GetLocalWindows(0, &windows));
161 162
162 int found_navigations = 0; 163 int found_navigations = 0;
163 for (auto it = windows.begin(); it != windows.end(); ++it) { 164 for (auto it = windows.begin(); it != windows.end(); ++it) {
164 for (auto it2 = it->second->tabs.begin(); it2 != it->second->tabs.end(); 165 for (auto it2 = it->second->wrapped_window.tabs.begin();
165 ++it2) { 166 it2 != it->second->wrapped_window.tabs.end(); ++it2) {
166 for (auto it3 = (*it2)->navigations.begin(); 167 for (auto it3 = (*it2)->navigations.begin();
167 it3 != (*it2)->navigations.end(); ++it3) { 168 it3 != (*it2)->navigations.end(); ++it3) {
168 const base::Time timestamp = it3->timestamp(); 169 const base::Time timestamp = it3->timestamp();
169 170
170 history::URLRow virtual_row; 171 history::URLRow virtual_row;
171 ASSERT_TRUE(GetUrlFromClient(0, it3->virtual_url(), &virtual_row)); 172 ASSERT_TRUE(GetUrlFromClient(0, it3->virtual_url(), &virtual_row));
172 const base::Time history_timestamp = virtual_row.last_visit(); 173 const base::Time history_timestamp = virtual_row.last_visit();
173 174
174 ASSERT_EQ(timestamp, history_timestamp); 175 ASSERT_EQ(timestamp, history_timestamp);
175 ++found_navigations; 176 ++found_navigations;
176 } 177 }
177 } 178 }
178 } 179 }
179 ASSERT_EQ(1, found_navigations); 180 ASSERT_EQ(1, found_navigations);
180 } 181 }
181 182
182 IN_PROC_BROWSER_TEST_F(SingleClientSessionsSyncTest, ResponseCodeIsPreserved) { 183 IN_PROC_BROWSER_TEST_F(SingleClientSessionsSyncTest, ResponseCodeIsPreserved) {
183 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 184 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
184 185
185 ASSERT_TRUE(CheckInitialState(0)); 186 ASSERT_TRUE(CheckInitialState(0));
186 187
187 const GURL url(kURL1); 188 const GURL url(kURL1);
188 ScopedWindowMap windows; 189 ScopedWindowMap windows;
189 ASSERT_TRUE(OpenTab(0, url)); 190 ASSERT_TRUE(OpenTab(0, url));
190 ASSERT_TRUE(GetLocalWindows(0, &windows)); 191 ASSERT_TRUE(GetLocalWindows(0, &windows));
191 192
192 int found_navigations = 0; 193 int found_navigations = 0;
193 for (auto it = windows.begin(); it != windows.end(); ++it) { 194 for (auto it = windows.begin(); it != windows.end(); ++it) {
194 for (auto it2 = it->second->tabs.begin(); it2 != it->second->tabs.end(); 195 for (auto it2 = it->second->wrapped_window.tabs.begin();
195 ++it2) { 196 it2 != it->second->wrapped_window.tabs.end(); ++it2) {
196 for (auto it3 = (*it2)->navigations.begin(); 197 for (auto it3 = (*it2)->navigations.begin();
197 it3 != (*it2)->navigations.end(); ++it3) { 198 it3 != (*it2)->navigations.end(); ++it3) {
198 EXPECT_EQ(200, it3->http_status_code()); 199 EXPECT_EQ(200, it3->http_status_code());
199 ++found_navigations; 200 ++found_navigations;
200 } 201 }
201 } 202 }
202 } 203 }
203 ASSERT_EQ(1, found_navigations); 204 ASSERT_EQ(1, found_navigations);
204 } 205 }
205 206
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 // Verify the cookie jar mismatch bool is set to false. 423 // Verify the cookie jar mismatch bool is set to false.
423 ASSERT_TRUE(GetFakeServer()->GetLastCommitMessage(&message)); 424 ASSERT_TRUE(GetFakeServer()->GetLastCommitMessage(&message));
424 ASSERT_FALSE(message.commit().config_params().cookie_jar_mismatch()); 425 ASSERT_FALSE(message.commit().config_params().cookie_jar_mismatch());
425 426
426 // Verify the histograms were recorded properly. 427 // Verify the histograms were recorded properly.
427 ExpectUniqueSampleGE(histogram_tester, "Sync.CookieJarMatchOnNavigation", 428 ExpectUniqueSampleGE(histogram_tester, "Sync.CookieJarMatchOnNavigation",
428 true, 1); 429 true, 1);
429 histogram_tester.ExpectTotalCount("Sync.CookieJarEmptyOnMismatch", 0); 430 histogram_tester.ExpectTotalCount("Sync.CookieJarEmptyOnMismatch", 0);
430 } 431 }
431 } 432 }
OLDNEW
« no previous file with comments | « chrome/browser/sync/test/integration/sessions_helper.cc ('k') | chrome/browser/ui/webui/foreign_session_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698