summaryrefslogtreecommitdiffstats
path: root/chrome/test/live_sync
diff options
context:
space:
mode:
authorzea@chromium.org <zea@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-24 18:54:39 +0000
committerzea@chromium.org <zea@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-24 18:54:39 +0000
commit3fa964af1c44352d08fca3a4bb0cad6006b3640c (patch)
tree4e92d801c0566acfa9531ad31a2813e4f2cf71b8 /chrome/test/live_sync
parentef3facf5d7cae5977657f6ff7dfe3f14746eb08b (diff)
downloadchromium_src-3fa964af1c44352d08fca3a4bb0cad6006b3640c.zip
chromium_src-3fa964af1c44352d08fca3a4bb0cad6006b3640c.tar.gz
chromium_src-3fa964af1c44352d08fca3a4bb0cad6006b3640c.tar.bz2
[Sync] Unrevert r75287 (initial support for sync encryption of all datatypes). Fix passphrase race.
BUG=73218,59242 TEST=unit,sync_unit,sync_integration Review URL: http://codereview.chromium.org/6561001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@75920 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/live_sync')
-rw-r--r--chrome/test/live_sync/live_sessions_sync_test.h12
-rw-r--r--chrome/test/live_sync/multiple_client_live_sessions_sync_test.cc36
-rw-r--r--chrome/test/live_sync/two_client_live_sessions_sync_test.cc52
3 files changed, 99 insertions, 1 deletions
diff --git a/chrome/test/live_sync/live_sessions_sync_test.h b/chrome/test/live_sync/live_sessions_sync_test.h
index 87c3a65..11734e9 100644
--- a/chrome/test/live_sync/live_sessions_sync_test.h
+++ b/chrome/test/live_sync/live_sessions_sync_test.h
@@ -16,6 +16,8 @@
#include "chrome/browser/sessions/base_session_service.h"
#include "chrome/browser/sessions/session_service_test_helper.h"
#include "chrome/browser/sessions/session_types.h"
+#include "chrome/browser/sync/profile_sync_service_harness.h"
+#include "chrome/browser/sync/syncable/nigori_util.h"
#include "chrome/test/live_sync/live_sync_test.h"
class GURL;
@@ -97,6 +99,16 @@ class LiveSessionsSyncTest : public LiveSyncTest {
// Sets up the TestSessionService helper and the new browser windows.
virtual bool SetupClients();
+ // Encrypt sessions datatype.
+ bool EnableEncryption(int index) {
+ return GetClient(index)->EnableEncryptionForType(syncable::SESSIONS);
+ }
+
+ // Check if Sessions are encrypted.
+ bool IsEncrypted(int index) {
+ return GetClient(index)->IsTypeEncrypted(syncable::SESSIONS);
+ }
+
// Open a single tab and return the TabContents. TabContents must be checked
// to ensure the tab opened successsfully.
TabContents* OpenTab(int index, GURL url) WARN_UNUSED_RESULT;
diff --git a/chrome/test/live_sync/multiple_client_live_sessions_sync_test.cc b/chrome/test/live_sync/multiple_client_live_sessions_sync_test.cc
index 5183b0b..0604239 100644
--- a/chrome/test/live_sync/multiple_client_live_sessions_sync_test.cc
+++ b/chrome/test/live_sync/multiple_client_live_sessions_sync_test.cc
@@ -33,3 +33,39 @@ IN_PROC_BROWSER_TEST_F(MultipleClientLiveSessionsSyncTest, AllChanged) {
}
}
+IN_PROC_BROWSER_TEST_F(MultipleClientLiveSessionsSyncTest,
+ EncryptedAndChanged) {
+ ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
+ std::vector<std::vector<SessionWindow*>* > client_windows;
+
+ for (int i = 0; i < num_clients(); ++i) {
+ ASSERT_TRUE(CheckInitialState(i));
+ }
+
+ // Enable encryption on client 0, should propagate to all other clients.
+ ASSERT_TRUE(EnableEncryption(0));
+
+ // Wait for sync.
+ // TODO(zea): Fix sync completion detection so we don't need this. For now,
+ // the profile sync service harness detects completion before all encryption
+ // changes are propagated.
+ ASSERT_TRUE(GetClient(0)->AwaitGroupSyncCycleCompletion(clients()));
+
+ // Open tabs on all clients and retain window information.
+ for (int i = 0; i < num_clients(); ++i) {
+ std::vector<SessionWindow*>* new_windows =
+ InitializeNewWindowWithTab(i, GURL(StringPrintf("about:bubba%i", i)));
+ ASSERT_TRUE(new_windows);
+ client_windows.push_back(new_windows);
+ }
+
+ // Wait for sync.
+ ASSERT_TRUE(AwaitQuiescence());
+
+ // Get foreign session data from all clients and check it against all
+ // client_windows.
+ for (int i = 0; i < num_clients(); ++i) {
+ ASSERT_TRUE(IsEncrypted(i));
+ ASSERT_TRUE(CheckForeignSessionsAgainst(i, client_windows));
+ }
+}
diff --git a/chrome/test/live_sync/two_client_live_sessions_sync_test.cc b/chrome/test/live_sync/two_client_live_sessions_sync_test.cc
index 7294c07..86f97cf 100644
--- a/chrome/test/live_sync/two_client_live_sessions_sync_test.cc
+++ b/chrome/test/live_sync/two_client_live_sessions_sync_test.cc
@@ -6,7 +6,7 @@
#include "chrome/browser/sync/profile_sync_service_harness.h"
#include "chrome/test/live_sync/live_sessions_sync_test.h"
-// @TODO(zea): Test each individual session command we care about separately.
+// TODO(zea): Test each individual session command we care about separately.
// (as well as multi-window). We're currently only checking basic single-window/
// single-tab functionality.
@@ -31,6 +31,56 @@ IN_PROC_BROWSER_TEST_F(TwoClientLiveSessionsSyncTest, SingleClientChanged) {
ASSERT_TRUE(WindowsMatch(sessions1[0]->windows, *client0_windows));
}
+IN_PROC_BROWSER_TEST_F(TwoClientLiveSessionsSyncTest,
+ SingleClientEnabledEncryption) {
+ ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
+
+ ASSERT_TRUE(CheckInitialState(0));
+ ASSERT_TRUE(CheckInitialState(1));
+
+ ASSERT_TRUE(EnableEncryption(0));
+ GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1));
+ ASSERT_TRUE(IsEncrypted(0));
+ ASSERT_TRUE(IsEncrypted(1));
+}
+
+IN_PROC_BROWSER_TEST_F(TwoClientLiveSessionsSyncTest,
+ SingleClientEnabledEncryptionAndChanged) {
+ ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
+
+ ASSERT_TRUE(CheckInitialState(0));
+ ASSERT_TRUE(CheckInitialState(1));
+
+ std::vector<SessionWindow*>* client0_windows =
+ InitializeNewWindowWithTab(0, GURL("about:bubba"));
+ ASSERT_TRUE(client0_windows);
+ ASSERT_TRUE(EnableEncryption(0));
+ GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1));
+
+ // Get foreign session data from client 1.
+ ASSERT_TRUE(IsEncrypted(1));
+ std::vector<const ForeignSession*> 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(TwoClientLiveSessionsSyncTest,
+ BothClientsEnabledEncryption) {
+ ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
+
+ ASSERT_TRUE(CheckInitialState(0));
+ ASSERT_TRUE(CheckInitialState(1));
+
+ ASSERT_TRUE(EnableEncryption(0));
+ ASSERT_TRUE(EnableEncryption(1));
+ GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1));
+ ASSERT_TRUE(IsEncrypted(0));
+ ASSERT_TRUE(IsEncrypted(1));
+}
+
IN_PROC_BROWSER_TEST_F(TwoClientLiveSessionsSyncTest, BothChanged) {
ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";