This source file includes following definitions.
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
#include "base/memory/scoped_vector.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"
#include "chrome/browser/sync/test/integration/sessions_helper.h"
#include "chrome/browser/sync/test/integration/sync_test.h"
#include "sync/internal_api/public/sessions/sync_session_snapshot.h"
using passwords_helper::SetDecryptionPassphrase;
using passwords_helper::SetEncryptionPassphrase;
using sessions_helper::CheckInitialState;
using sessions_helper::DeleteForeignSession;
using sessions_helper::GetLocalWindows;
using sessions_helper::GetSessionData;
using sessions_helper::OpenTabAndGetLocalWindows;
using sessions_helper::ScopedWindowMap;
using sessions_helper::SyncedSessionVector;
using sessions_helper::WindowsMatch;
class TwoClientSessionsSyncTest : public SyncTest {
public:
TwoClientSessionsSyncTest() : SyncTest(TWO_CLIENT) {}
virtual ~TwoClientSessionsSyncTest() {}
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";
#if defined(OS_WIN)
#define MAYBE_SingleClientChanged DISABLED_SingleClientChanged
#define MAYBE_SingleClientEnabledEncryptionAndChanged DISABLED_SingleClientEnabledEncryptionAndChanged
#define MAYBE_BothChanged DISABLED_BothChanged
#define MAYBE_DeleteIdleSession DISABLED_DeleteIdleSession
#else
#define MAYBE_SingleClientChanged SingleClientChanged
#define MAYBE_SingleClientEnabledEncryptionAndChanged SingleClientEnabledEncryptionAndChanged
#define MAYBE_BothChanged BothChanged
#define MAYBE_DeleteIdleSession DeleteIdleSession
#endif
IN_PROC_BROWSER_TEST_F(TwoClientSessionsSyncTest,
MAYBE_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)));
SyncedSessionVector sessions1;
ASSERT_TRUE(GetSessionData(1, &sessions1));
ASSERT_EQ(1U, sessions1.size());
ASSERT_TRUE(WindowsMatch(sessions1[0]->windows, *client0_windows.Get()));
}
IN_PROC_BROWSER_TEST_F(TwoClientSessionsSyncTest,
SingleClientEnabledEncryption) {
ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
ASSERT_TRUE(CheckInitialState(0));
ASSERT_TRUE(CheckInitialState(1));
ASSERT_TRUE(EnableEncryption(0));
ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
ASSERT_TRUE(IsEncryptionComplete(0));
ASSERT_TRUE(IsEncryptionComplete(1));
}
IN_PROC_BROWSER_TEST_F(TwoClientSessionsSyncTest,
MAYBE_SingleClientEnabledEncryptionAndChanged) {
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(EnableEncryption(0));
ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
ASSERT_TRUE(IsEncryptionComplete(1));
SyncedSessionVector sessions1;
ASSERT_TRUE(GetSessionData(1, &sessions1));
ASSERT_EQ(1U, sessions1.size());
ASSERT_TRUE(WindowsMatch(sessions1[0]->windows, *client0_windows.Get()));
}
IN_PROC_BROWSER_TEST_F(TwoClientSessionsSyncTest,
BothClientsEnabledEncryption) {
ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
ASSERT_TRUE(CheckInitialState(0));
ASSERT_TRUE(CheckInitialState(1));
ASSERT_TRUE(EnableEncryption(0));
ASSERT_TRUE(EnableEncryption(1));
ASSERT_TRUE(AwaitQuiescence());
ASSERT_TRUE(IsEncryptionComplete(0));
ASSERT_TRUE(IsEncryptionComplete(1));
}
IN_PROC_BROWSER_TEST_F(TwoClientSessionsSyncTest, MAYBE_BothChanged) {
ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
ASSERT_TRUE(CheckInitialState(0));
ASSERT_TRUE(CheckInitialState(1));
ScopedWindowMap client0_windows;
ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(kURL2),
client0_windows.GetMutable()));
ScopedWindowMap client1_windows;
ASSERT_TRUE(OpenTabAndGetLocalWindows(1, GURL(kURL1),
client1_windows.GetMutable()));
ASSERT_TRUE(AwaitQuiescence());
SyncedSessionVector sessions0;
SyncedSessionVector sessions1;
ASSERT_TRUE(GetSessionData(0, &sessions0));
ASSERT_TRUE(GetSessionData(1, &sessions1));
ASSERT_EQ(1U, sessions0.size());
ASSERT_EQ(1U, sessions1.size());
ASSERT_TRUE(WindowsMatch(sessions1[0]->windows, *client0_windows.Get()));
ASSERT_TRUE(WindowsMatch(sessions0[0]->windows, *client1_windows.Get()));
}
IN_PROC_BROWSER_TEST_F(TwoClientSessionsSyncTest, MAYBE_DeleteIdleSession) {
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)));
SyncedSessionVector sessions1;
ASSERT_TRUE(GetSessionData(1, &sessions1));
ASSERT_EQ(1U, sessions1.size());
ASSERT_TRUE(WindowsMatch(sessions1[0]->windows, *client0_windows.Get()));
DeleteForeignSession(1, sessions1[0]->session_tag);
ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0)));
ASSERT_FALSE(GetSessionData(1, &sessions1));
}
IN_PROC_BROWSER_TEST_F(TwoClientSessionsSyncTest,
DISABLED_DeleteActiveSession) {
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)));
SyncedSessionVector sessions1;
ASSERT_TRUE(GetSessionData(1, &sessions1));
ASSERT_EQ(1U, sessions1.size());
ASSERT_TRUE(WindowsMatch(sessions1[0]->windows, *client0_windows.Get()));
DeleteForeignSession(1, sessions1[0]->session_tag);
ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0)));
ASSERT_FALSE(GetSessionData(1, &sessions1));
ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(kURL2),
client0_windows.GetMutable()));
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.Get()));
}