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

Unified Diff: chrome/browser/sync/test/integration/two_client_sessions_sync_test.cc

Issue 2713913002: [sync] Add Sessions integration tests (Closed)
Patch Set: Update commit message Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/sync/test/integration/two_client_sessions_sync_test.cc
diff --git a/chrome/browser/sync/test/integration/two_client_sessions_sync_test.cc b/chrome/browser/sync/test/integration/two_client_sessions_sync_test.cc
index da1f810df7a63d3c650b7f075a315d86e4dc50b8..a103d6ac651e1a42a5aed891b8f8c237d838dd17 100644
--- a/chrome/browser/sync/test/integration/two_client_sessions_sync_test.cc
+++ b/chrome/browser/sync/test/integration/two_client_sessions_sync_test.cc
@@ -19,7 +19,10 @@ using sessions_helper::CheckInitialState;
using sessions_helper::DeleteForeignSession;
using sessions_helper::GetLocalWindows;
using sessions_helper::GetSessionData;
+using sessions_helper::NavigateTab;
using sessions_helper::OpenTabAndGetLocalWindows;
+using sessions_helper::OpenTab;
+using sessions_helper::OpenTabAtIndex;
using sessions_helper::ScopedWindowMap;
using sessions_helper::SessionWindowMap;
using sessions_helper::SyncedSessionVector;
@@ -30,12 +33,22 @@ class TwoClientSessionsSyncTest : public SyncTest {
TwoClientSessionsSyncTest() : SyncTest(TWO_CLIENT) {}
~TwoClientSessionsSyncTest() override {}
+ void WaitForWindowsInForeignSession(int profile_index,
+ ScopedWindowMap windows) {
+ std::vector<ScopedWindowMap> expected_windows(1);
skym 2017/02/24 00:14:09 Wow, you really seem to like reserving space. What
Patrick Noland 2017/02/27 18:53:26 I actually tried this. You can't (trivially) put u
skym 2017/02/27 19:12:27 Why?
skym 2017/02/27 19:42:49 Okay, you're right, and things get confusing reall
Patrick Noland 2017/02/27 19:44:50 initializer lists don't work with move only types.
+ expected_windows[0] = std::move(windows);
+ ASSERT_TRUE(
skym 2017/02/24 00:14:09 EXPECT_TRUE?
Patrick Noland 2017/02/27 18:53:26 Done.
+ ForeignSessionsMatchChecker(profile_index, expected_windows).Wait());
+ }
+
private:
DISALLOW_COPY_AND_ASSIGN(TwoClientSessionsSyncTest);
};
static const char* kURL1 = "http://127.0.0.1/bubba1";
static const char* kURL2 = "http://127.0.0.1/bubba2";
+static const char* kURL3 = "http://127.0.0.1/foobar";
+static const char* kURL4 = "http://127.0.0.1/barbaz";
// TODO(zea): Test each individual session command we care about separately.
// (as well as multi-window). We're currently only checking basic single-window/
@@ -145,21 +158,13 @@ IN_PROC_BROWSER_TEST_F(TwoClientSessionsSyncTest, BothChanged) {
ScopedWindowMap client1_windows;
ASSERT_TRUE(OpenTabAndGetLocalWindows(1, GURL(kURL1), &client1_windows));
- // Wait for sync.
- ASSERT_TRUE(AwaitQuiescence());
-
- // Get foreign session data from client 0 and 1.
- SyncedSessionVector sessions0;
- SyncedSessionVector sessions1;
- ASSERT_TRUE(GetSessionData(0, &sessions0));
- ASSERT_TRUE(GetSessionData(1, &sessions1));
+ WaitForWindowsInForeignSession(1, std::move(client0_windows));
+ WaitForWindowsInForeignSession(0, std::move(client0_windows));
skym 2017/02/24 00:14:09 You're moving client0_windows twice.
Patrick Noland 2017/02/27 18:53:26 Done.
- // Verify client 1's foreign session matches client 0's current window and
- // vice versa.
- ASSERT_EQ(1U, sessions0.size());
- ASSERT_EQ(1U, sessions1.size());
- ASSERT_TRUE(WindowsMatch(sessions1[0]->windows, client0_windows));
- ASSERT_TRUE(WindowsMatch(sessions0[0]->windows, client1_windows));
+ // Check that a navigation is reflected on the other client.
+ NavigateTab(0, GURL(kURL3));
+ ASSERT_TRUE(GetLocalWindows(0, &client0_windows));
+ WaitForWindowsInForeignSession(1, std::move(client0_windows));
}
IN_PROC_BROWSER_TEST_F(TwoClientSessionsSyncTest, DeleteIdleSession) {
@@ -172,16 +177,12 @@ IN_PROC_BROWSER_TEST_F(TwoClientSessionsSyncTest, DeleteIdleSession) {
ScopedWindowMap client0_windows;
ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(kURL1), &client0_windows));
- ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
+ WaitForWindowsInForeignSession(1, std::move(client0_windows));
// Get foreign session data from client 1.
SyncedSessionVector sessions1;
ASSERT_TRUE(GetSessionData(1, &sessions1));
- // Verify client 1's foreign session matches client 0 current window.
- ASSERT_EQ(1U, sessions1.size());
- ASSERT_TRUE(WindowsMatch(sessions1[0]->windows, client0_windows));
-
// Client 1 now deletes client 0's tabs. This frees the memory of sessions1.
DeleteForeignSession(1, sessions1[0]->session_tag);
ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0)));
@@ -200,11 +201,11 @@ IN_PROC_BROWSER_TEST_F(TwoClientSessionsSyncTest,
ScopedWindowMap client0_windows;
ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(kURL1), &client0_windows));
- ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
+ WaitForWindowsInForeignSession(1, std::move(client0_windows));
+
SyncedSessionVector sessions1;
ASSERT_TRUE(GetSessionData(1, &sessions1));
ASSERT_EQ(1U, sessions1.size());
- ASSERT_TRUE(WindowsMatch(sessions1[0]->windows, client0_windows));
// Client 1 now deletes client 0's tabs. This frees the memory of sessions1.
DeleteForeignSession(1, sessions1[0]->session_tag);
@@ -213,8 +214,26 @@ IN_PROC_BROWSER_TEST_F(TwoClientSessionsSyncTest,
// Client 0 becomes active again with a new tab.
ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(kURL2), &client0_windows));
- ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
- ASSERT_TRUE(GetSessionData(1, &sessions1));
- ASSERT_EQ(1U, sessions1.size());
- ASSERT_TRUE(WindowsMatch(sessions1[0]->windows, client0_windows));
+ WaitForWindowsInForeignSession(1, std::move(client0_windows));
+}
+
+IN_PROC_BROWSER_TEST_F(TwoClientSessionsSyncTest, MultipleWindowsMultipleTabs) {
+ ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
+
+ ASSERT_TRUE(CheckInitialState(0));
+ ASSERT_TRUE(CheckInitialState(1));
+
+ ASSERT_TRUE(OpenTab(0, GURL(kURL1)));
+ ASSERT_TRUE(OpenTabAtIndex(0, 1, GURL(kURL2)));
+
+ // Add a second browser for profile 0. This browser ends up in index 2.
+ AddBrowser(0);
+ ASSERT_TRUE(OpenTab(2, GURL(kURL3)));
+ ASSERT_TRUE(OpenTabAtIndex(2, 2, GURL(kURL4)));
+
+ ScopedWindowMap client0_windows;
+ ASSERT_TRUE(GetLocalWindows(2, &client0_windows));
+ EXPECT_EQ(client0_windows.size(), 2u);
skym 2017/02/24 00:14:09 https://github.com/google/googletest/blob/master/g
+
+ WaitForWindowsInForeignSession(1, std::move(client0_windows));
}

Powered by Google App Engine
This is Rietveld 408576698