summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryihongg <yihongg@chromium.org>2015-06-25 13:36:11 -0700
committerCommit bot <commit-bot@chromium.org>2015-06-25 20:36:52 +0000
commitff8f65132ae7ed35ed7733ef930a0b1d1784645e (patch)
tree435b2f0d192be6ea7a340e7c974e69ffb52172e9
parenta2a59a7d6c561a59beb84966e94be78fa7707d6c (diff)
downloadchromium_src-ff8f65132ae7ed35ed7733ef930a0b1d1784645e.zip
chromium_src-ff8f65132ae7ed35ed7733ef930a0b1d1784645e.tar.gz
chromium_src-ff8f65132ae7ed35ed7733ef930a0b1d1784645e.tar.bz2
Enable session sync test cases SingleClientChanged and AllChanged to run
as KitchenSync E2E test. Since in the KitchenSync mode, tests coule be run against the same real server and the same account again and again. We cannot call CheckInitialState() since it assumes there are no session data at the beginning. CheckForeignSessionsAgainst() needs to be changed as well to consider session data from the previous test runs. BUG=500105 R=pvalenzuela@chromium.org TEST=Run SingleClientChanged and Allchanged in both KitchenSync and FakeServer mode. Run EncryptedAndChanged in FakeServer mode. Review URL: https://codereview.chromium.org/1204583002 Cr-Commit-Position: refs/heads/master@{#336246}
-rw-r--r--chrome/browser/sync/test/integration/multiple_client_sessions_sync_test.cc19
-rw-r--r--chrome/browser/sync/test/integration/sessions_helper.cc46
-rw-r--r--chrome/browser/sync/test/integration/two_client_sessions_sync_test.cc33
3 files changed, 59 insertions, 39 deletions
diff --git a/chrome/browser/sync/test/integration/multiple_client_sessions_sync_test.cc b/chrome/browser/sync/test/integration/multiple_client_sessions_sync_test.cc
index fde348a..013b0c5 100644
--- a/chrome/browser/sync/test/integration/multiple_client_sessions_sync_test.cc
+++ b/chrome/browser/sync/test/integration/multiple_client_sessions_sync_test.cc
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/guid.h"
#include "base/memory/scoped_vector.h"
#include "base/strings/stringprintf.h"
#include "chrome/browser/sessions/session_service.h"
@@ -27,26 +28,24 @@ class MultipleClientSessionsSyncTest : public SyncTest {
// Timeout on Windows, see http://crbug.com/99819
#if defined(OS_WIN)
-#define MAYBE_AllChanged DISABLED_AllChanged
+#define MAYBE_E2ETest_AllChanged DISABLED_E2ETest_AllChanged
#define MAYBE_EncryptedAndChanged DISABLED_EncryptedAndChanged
#else
-#define MAYBE_AllChanged AllChanged
+#define MAYBE_E2ETest_AllChanged E2ETest_AllChanged
#define MAYBE_EncryptedAndChanged EncryptedAndChanged
#endif
-IN_PROC_BROWSER_TEST_F(MultipleClientSessionsSyncTest, MAYBE_AllChanged) {
+IN_PROC_BROWSER_TEST_F(MultipleClientSessionsSyncTest,
+ MAYBE_E2ETest_AllChanged) {
ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
- std::vector<ScopedWindowMap> client_windows(num_clients());
-
- for (int i = 0; i < num_clients(); ++i) {
- ASSERT_TRUE(CheckInitialState(i));
- }
// Open tabs on all clients and retain window information.
+ std::vector<ScopedWindowMap> client_windows(num_clients());
for (int i = 0; i < num_clients(); ++i) {
SessionWindowMap windows;
- ASSERT_TRUE(OpenTabAndGetLocalWindows(
- i, GURL(base::StringPrintf("http://127.0.0.1/bubba%i", i)), &windows));
+ std::string url = base::StringPrintf("http://127.0.0.1/bubba%s",
+ base::GenerateGUID().c_str());
+ ASSERT_TRUE(OpenTabAndGetLocalWindows(i, GURL(url), &windows));
client_windows[i].Reset(&windows);
}
diff --git a/chrome/browser/sync/test/integration/sessions_helper.cc b/chrome/browser/sync/test/integration/sessions_helper.cc
index 2ee1507..606154d 100644
--- a/chrome/browser/sync/test/integration/sessions_helper.cc
+++ b/chrome/browser/sync/test/integration/sessions_helper.cc
@@ -318,15 +318,27 @@ bool WindowsMatch(const SessionWindowMap& win1,
const SessionWindowMap& win2) {
sessions::SessionTab* client0_tab;
sessions::SessionTab* client1_tab;
- if (win1.size() != win2.size())
+ if (win1.size() != win2.size()) {
+ LOG(ERROR) << "Win size doesn't match, win1 size: "
+ << win1.size()
+ << ", win2 size: "
+ << win2.size();
return false;
+ }
for (SessionWindowMap::const_iterator i = win1.begin();
i != win1.end(); ++i) {
SessionWindowMap::const_iterator j = win2.find(i->first);
- if (j == win2.end())
+ if (j == win2.end()) {
+ LOG(ERROR) << "Session doesn't match";
return false;
- if (i->second->tabs.size() != j->second->tabs.size())
+ }
+ if (i->second->tabs.size() != j->second->tabs.size()) {
+ LOG(ERROR) << "Tab size doesn't match, tab1 size: "
+ << i->second->tabs.size()
+ << ", tab2 size: "
+ << j->second->tabs.size();
return false;
+ }
for (size_t t = 0; t < i->second->tabs.size(); ++t) {
client0_tab = i->second->tabs[t];
client1_tab = j->second->tabs[t];
@@ -346,18 +358,28 @@ bool CheckForeignSessionsAgainst(
int index,
const std::vector<ScopedWindowMap>& windows) {
SyncedSessionVector sessions;
- if (!GetSessionData(index, &sessions))
- return false;
- if ((size_t)(test()->num_clients()-1) != sessions.size())
+
+ if (!GetSessionData(index, &sessions)) {
+ LOG(ERROR) << "Cannot get session data";
return false;
+ }
- int window_index = 0;
- for (size_t j = 0; j < sessions.size(); ++j, ++window_index) {
- if (window_index == index)
- window_index++; // Skip self.
- if (!WindowsMatch(sessions[j]->windows,
- *(windows[window_index].Get())))
+ for (size_t w_index = 0; w_index < windows.size(); ++w_index) {
+ // Skip the client's local window
+ if (static_cast<int>(w_index) == index)
+ continue;
+
+ size_t s_index = 0;
+
+ for (; s_index < sessions.size(); ++s_index) {
+ if (WindowsMatch(sessions[s_index]->windows, *(windows[w_index].Get())))
+ break;
+ }
+
+ if (s_index == sessions.size()) {
+ LOG(ERROR) << "Cannot find window #" << w_index;
return false;
+ }
}
return true;
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 72db7fe..5a913bb 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
@@ -2,7 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/guid.h"
#include "base/memory/scoped_vector.h"
+#include "base/strings/stringprintf.h"
#include "chrome/browser/sessions/session_service.h"
#include "chrome/browser/sync/test/integration/passwords_helper.h"
#include "chrome/browser/sync/test/integration/profile_sync_service_harness.h"
@@ -18,6 +20,7 @@ using sessions_helper::GetLocalWindows;
using sessions_helper::GetSessionData;
using sessions_helper::OpenTabAndGetLocalWindows;
using sessions_helper::ScopedWindowMap;
+using sessions_helper::SessionWindowMap;
using sessions_helper::SyncedSessionVector;
using sessions_helper::WindowsMatch;
@@ -39,36 +42,32 @@ static const char* kURL2 = "http://127.0.0.1/bubba2";
// Fails on Win, see http://crbug.com/232313
#if defined(OS_WIN)
-#define MAYBE_SingleClientChanged DISABLED_SingleClientChanged
+#define MAYBE_E2ETest_SingleClientChanged DISABLED_E2ETest_SingleClientChanged
#define MAYBE_BothChanged DISABLED_BothChanged
#define MAYBE_DeleteIdleSession DISABLED_DeleteIdleSession
#else
-#define MAYBE_SingleClientChanged SingleClientChanged
+#define MAYBE_E2ETest_SingleClientChanged E2ETest_SingleClientChanged
#define MAYBE_BothChanged BothChanged
#define MAYBE_DeleteIdleSession DeleteIdleSession
#endif
IN_PROC_BROWSER_TEST_F(TwoClientSessionsSyncTest,
- MAYBE_SingleClientChanged) {
+ MAYBE_E2ETest_SingleClientChanged) {
ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
- ASSERT_TRUE(CheckInitialState(0));
- ASSERT_TRUE(CheckInitialState(1));
-
- ScopedWindowMap client0_windows;
- ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(kURL1),
- client0_windows.GetMutable()));
-
- ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
+ // Open tab and access a url on client 0
+ SessionWindowMap client0_windows;
+ std::string url = base::StringPrintf("http://127.0.0.1/bubba%s",
+ base::GenerateGUID().c_str());
+ ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(url), &client0_windows));
- // Get foreign session data from client 1.
- SyncedSessionVector sessions1;
- ASSERT_TRUE(GetSessionData(1, &sessions1));
+ // Retain the window information on client 0
+ std::vector<ScopedWindowMap> expected_windows(1);
+ expected_windows[0].Reset(&client0_windows);
- // Verify client 1's foreign session matches client 0 current window.
- ASSERT_EQ(1U, sessions1.size());
- ASSERT_TRUE(WindowsMatch(sessions1[0]->windows, *client0_windows.Get()));
+ // Check the foreign windows on client 1
+ ASSERT_TRUE(AwaitCheckForeignSessionsAgainst(1, expected_windows));
}
IN_PROC_BROWSER_TEST_F(TwoClientSessionsSyncTest,