| 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 f3fc775e575f2c5800cc59c936756f6626006821..da1f810df7a63d3c650b7f075a315d86e4dc50b8 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,9 +19,7 @@
|
| using sessions_helper::DeleteForeignSession;
|
| using sessions_helper::GetLocalWindows;
|
| using sessions_helper::GetSessionData;
|
| -using sessions_helper::NavigateTab;
|
| -using sessions_helper::OpenTab;
|
| -using sessions_helper::OpenTabAtIndex;
|
| +using sessions_helper::OpenTabAndGetLocalWindows;
|
| using sessions_helper::ScopedWindowMap;
|
| using sessions_helper::SessionWindowMap;
|
| using sessions_helper::SyncedSessionVector;
|
| @@ -32,26 +30,12 @@
|
| TwoClientSessionsSyncTest() : SyncTest(TWO_CLIENT) {}
|
| ~TwoClientSessionsSyncTest() override {}
|
|
|
| - void WaitForWindowsInForeignSession(int index, ScopedWindowMap windows) {
|
| - std::vector<ScopedWindowMap> expected_windows;
|
| - expected_windows.push_back(std::move(windows));
|
| - EXPECT_TRUE(ForeignSessionsMatchChecker(index, expected_windows).Wait());
|
| - }
|
| -
|
| - void WaitForForeignSessionsToSync(int local_index, int non_local_index) {
|
| - ScopedWindowMap client_windows;
|
| - ASSERT_TRUE(GetLocalWindows(local_index, &client_windows));
|
| - WaitForWindowsInForeignSession(non_local_index, std::move(client_windows));
|
| - }
|
| -
|
| 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/
|
| @@ -66,9 +50,14 @@
|
| ScopedWindowMap client0_windows;
|
| std::string url = base::StringPrintf("http://127.0.0.1/bubba%s",
|
| base::GenerateGUID().c_str());
|
| -
|
| - ASSERT_TRUE(OpenTab(0, GURL(url)));
|
| - WaitForForeignSessionsToSync(0, 1);
|
| + ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(url), &client0_windows));
|
| +
|
| + // Retain the window information on client 0
|
| + std::vector<ScopedWindowMap> expected_windows(1);
|
| + expected_windows[0] = std::move(client0_windows);
|
| +
|
| + // Check the foreign windows on client 1
|
| + ASSERT_TRUE(ForeignSessionsMatchChecker(1, expected_windows).Wait());
|
| }
|
|
|
| IN_PROC_BROWSER_TEST_F(TwoClientSessionsSyncTest,
|
| @@ -81,8 +70,7 @@
|
| ScopedWindowMap windows;
|
| std::string url = base::StringPrintf("http://127.0.0.1/bubba%s",
|
| base::GenerateGUID().c_str());
|
| - ASSERT_TRUE(OpenTab(i, GURL(url)));
|
| - ASSERT_TRUE(GetLocalWindows(i, &windows));
|
| + ASSERT_TRUE(OpenTabAndGetLocalWindows(i, GURL(url), &windows));
|
| client_windows[i] = std::move(windows);
|
| }
|
|
|
| @@ -116,9 +104,19 @@
|
| ASSERT_TRUE(CheckInitialState(0));
|
| ASSERT_TRUE(CheckInitialState(1));
|
|
|
| - ASSERT_TRUE(OpenTab(0, GURL(kURL1)));
|
| + ScopedWindowMap client0_windows;
|
| + ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(kURL1), &client0_windows));
|
| ASSERT_TRUE(EnableEncryption(0));
|
| - WaitForForeignSessionsToSync(0, 1);
|
| + ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
|
| +
|
| + // Get foreign session data from client 1.
|
| + ASSERT_TRUE(IsEncryptionComplete(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));
|
| }
|
|
|
| IN_PROC_BROWSER_TEST_F(TwoClientSessionsSyncTest,
|
| @@ -141,15 +139,27 @@
|
| ASSERT_TRUE(CheckInitialState(0));
|
| ASSERT_TRUE(CheckInitialState(1));
|
|
|
| - ASSERT_TRUE(OpenTab(0, GURL(kURL1)));
|
| - ASSERT_TRUE(OpenTab(1, GURL(kURL2)));
|
| -
|
| - WaitForForeignSessionsToSync(0, 1);
|
| - WaitForForeignSessionsToSync(1, 0);
|
| -
|
| - // Check that a navigation in client 0 is reflected on client 1.
|
| - NavigateTab(0, GURL(kURL3));
|
| - WaitForForeignSessionsToSync(0, 1);
|
| + // Open tabs on both clients and retain window information.
|
| + ScopedWindowMap client0_windows;
|
| + ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(kURL2), &client0_windows));
|
| + 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));
|
| +
|
| + // 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));
|
| }
|
|
|
| IN_PROC_BROWSER_TEST_F(TwoClientSessionsSyncTest, DeleteIdleSession) {
|
| @@ -159,12 +169,18 @@
|
| ASSERT_TRUE(CheckInitialState(1));
|
|
|
| // Client 0 opened some tabs then went idle.
|
| - ASSERT_TRUE(OpenTab(0, GURL(kURL1)));
|
| - WaitForForeignSessionsToSync(0, 1);
|
| + ScopedWindowMap client0_windows;
|
| + ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(kURL1), &client0_windows));
|
| +
|
| + ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
|
|
|
| // 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);
|
| @@ -181,12 +197,14 @@
|
| ASSERT_TRUE(CheckInitialState(1));
|
|
|
| // Client 0 opened some tabs then went idle.
|
| - ASSERT_TRUE(OpenTab(0, GURL(kURL1)));
|
| - WaitForForeignSessionsToSync(0, 1);
|
| -
|
| - SyncedSessionVector sessions1;
|
| - ASSERT_TRUE(GetSessionData(1, &sessions1));
|
| - ASSERT_EQ(1U, sessions1.size());
|
| + ScopedWindowMap client0_windows;
|
| + ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(kURL1), &client0_windows));
|
| +
|
| + ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
|
| + 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);
|
| @@ -194,23 +212,9 @@
|
| ASSERT_FALSE(GetSessionData(1, &sessions1));
|
|
|
| // Client 0 becomes active again with a new tab.
|
| - ASSERT_TRUE(OpenTab(0, GURL(kURL2)));
|
| - WaitForForeignSessionsToSync(0, 1);
|
| -}
|
| -
|
| -IN_PROC_BROWSER_TEST_F(TwoClientSessionsSyncTest, MultipleWindowsMultipleTabs) {
|
| - ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
|
| -
|
| - ASSERT_TRUE(CheckInitialState(0));
|
| - ASSERT_TRUE(CheckInitialState(1));
|
| -
|
| - EXPECT_TRUE(OpenTab(0, GURL(kURL1)));
|
| - EXPECT_TRUE(OpenTabAtIndex(0, 1, GURL(kURL2)));
|
| -
|
| - // Add a second browser for profile 0. This browser ends up in index 2.
|
| - AddBrowser(0);
|
| - EXPECT_TRUE(OpenTab(2, GURL(kURL3)));
|
| - EXPECT_TRUE(OpenTabAtIndex(2, 2, GURL(kURL4)));
|
| -
|
| - WaitForForeignSessionsToSync(0, 1);
|
| -}
|
| + 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));
|
| +}
|
|
|