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

Side by Side Diff: chrome/browser/sync/test/integration/two_client_sessions_sync_test.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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 <string> 5 #include <string>
6 6
7 #include "base/guid.h" 7 #include "base/guid.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/run_loop.h"
9 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
10 #include "build/build_config.h" 11 #include "build/build_config.h"
12 #include "chrome/browser/chrome_notification_types.h"
11 #include "chrome/browser/sessions/session_service.h" 13 #include "chrome/browser/sessions/session_service.h"
12 #include "chrome/browser/sync/test/integration/passwords_helper.h" 14 #include "chrome/browser/sync/test/integration/passwords_helper.h"
13 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h" 15 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h"
14 #include "chrome/browser/sync/test/integration/sessions_helper.h" 16 #include "chrome/browser/sync/test/integration/sessions_helper.h"
15 #include "chrome/browser/sync/test/integration/sync_test.h" 17 #include "chrome/browser/sync/test/integration/sync_test.h"
18 #include "chrome/browser/sync/test/integration/updated_progress_marker_checker.h "
16 #include "components/sync/engine/cycle/sync_cycle_snapshot.h" 19 #include "components/sync/engine/cycle/sync_cycle_snapshot.h"
20 #include "content/public/browser/notification_service.h"
21 #include "content/public/test/test_utils.h"
17 22
18 using sessions_helper::CheckInitialState; 23 using sessions_helper::CheckInitialState;
19 using sessions_helper::DeleteForeignSession; 24 using sessions_helper::DeleteForeignSession;
20 using sessions_helper::GetLocalWindows; 25 using sessions_helper::GetLocalWindows;
21 using sessions_helper::GetSessionData; 26 using sessions_helper::GetSessionData;
22 using sessions_helper::NavigateTab; 27 using sessions_helper::NavigateTab;
23 using sessions_helper::OpenTab; 28 using sessions_helper::OpenTab;
24 using sessions_helper::OpenTabAtIndex; 29 using sessions_helper::OpenTabAtIndex;
25 using sessions_helper::ScopedWindowMap; 30 using sessions_helper::ScopedWindowMap;
26 using sessions_helper::SessionWindowMap; 31 using sessions_helper::SessionWindowMap;
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 EXPECT_TRUE(OpenTab(0, GURL(kURL1))); 214 EXPECT_TRUE(OpenTab(0, GURL(kURL1)));
210 EXPECT_TRUE(OpenTabAtIndex(0, 1, GURL(kURL2))); 215 EXPECT_TRUE(OpenTabAtIndex(0, 1, GURL(kURL2)));
211 216
212 // Add a second browser for profile 0. This browser ends up in index 2. 217 // Add a second browser for profile 0. This browser ends up in index 2.
213 AddBrowser(0); 218 AddBrowser(0);
214 EXPECT_TRUE(OpenTab(2, GURL(kURL3))); 219 EXPECT_TRUE(OpenTab(2, GURL(kURL3)));
215 EXPECT_TRUE(OpenTabAtIndex(2, 2, GURL(kURL4))); 220 EXPECT_TRUE(OpenTabAtIndex(2, 2, GURL(kURL4)));
216 221
217 WaitForForeignSessionsToSync(0, 1); 222 WaitForForeignSessionsToSync(0, 1);
218 } 223 }
224
225 IN_PROC_BROWSER_TEST_F(TwoClientSessionsSyncTest,
226 E2E_ENABLED(DoNotSyncTabsOnBrowserClose)) {
227 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
228
229 ASSERT_TRUE(CheckInitialState(0));
230 ASSERT_TRUE(CheckInitialState(1));
231
232 std::vector<GURL> urls;
233 urls.push_back(GURL(kURL1));
234 urls.push_back(GURL(kURL2));
235 ASSERT_TRUE(sessions_helper::OpenMultipleTabs(0, urls));
236
237 // Retain the window information on client 0.
238 ScopedWindowMap client0_windows;
239 ASSERT_TRUE(GetLocalWindows(0, &client0_windows));
240 std::vector<ScopedWindowMap> expected_windows(1);
241 expected_windows[0] = std::move(client0_windows);
242
243 // Check the foreign windows on client 1.
244 ASSERT_TRUE(ForeignSessionsMatchChecker(1, expected_windows).Wait());
245
246 // Close browser window on client 0.
247 CloseBrowserWindowAtIndex(0);
248 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
249
250 // Foreign windows on client 1 shouldn't be changed.
251 ASSERT_TRUE(ForeignSessionsMatchChecker(1, expected_windows).Wait());
252 }
OLDNEW
« no previous file with comments | « chrome/browser/sync/test/integration/sync_test.cc ('k') | components/sync_sessions/local_session_event_router.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698