Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / sync / test / integration / multiple_client_sessions_sync_test.cc
blobee5f9f42544753551f483ada07bb68f80cb536af
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "base/memory/scoped_vector.h"
6 #include "base/strings/stringprintf.h"
7 #include "chrome/browser/sessions/session_service.h"
8 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h"
9 #include "chrome/browser/sync/test/integration/sessions_helper.h"
10 #include "chrome/browser/sync/test/integration/sync_test.h"
12 using sessions_helper::CheckForeignSessionsAgainst;
13 using sessions_helper::CheckInitialState;
14 using sessions_helper::OpenTabAndGetLocalWindows;
15 using sessions_helper::ScopedWindowMap;
16 using sessions_helper::SessionWindowMap;
17 using sessions_helper::SyncedSessionVector;
19 class MultipleClientSessionsSyncTest : public SyncTest {
20 public:
21 MultipleClientSessionsSyncTest() : SyncTest(MULTIPLE_CLIENT) {}
22 virtual ~MultipleClientSessionsSyncTest() {}
24 private:
25 DISALLOW_COPY_AND_ASSIGN(MultipleClientSessionsSyncTest);
28 // Timeout on Windows, see http://crbug.com/99819
29 #if defined(OS_WIN)
30 #define MAYBE_AllChanged DISABLED_AllChanged
31 #define MAYBE_EncryptedAndChanged DISABLED_EncryptedAndChanged
32 #else
33 #define MAYBE_AllChanged AllChanged
34 #define MAYBE_EncryptedAndChanged EncryptedAndChanged
35 #endif
37 IN_PROC_BROWSER_TEST_F(MultipleClientSessionsSyncTest, MAYBE_AllChanged) {
38 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
39 std::vector<ScopedWindowMap> client_windows(num_clients());
41 for (int i = 0; i < num_clients(); ++i) {
42 ASSERT_TRUE(CheckInitialState(i));
45 // Open tabs on all clients and retain window information.
46 for (int i = 0; i < num_clients(); ++i) {
47 SessionWindowMap windows;
48 ASSERT_TRUE(OpenTabAndGetLocalWindows(
49 i, GURL(base::StringPrintf("http://127.0.0.1/bubba%i", i)), &windows));
50 client_windows[i].Reset(&windows);
53 // Wait for sync.
54 ASSERT_TRUE(AwaitQuiescence());
56 // Get foreign session data from all clients and check it against all
57 // client_windows.
58 for (int i = 0; i < num_clients(); ++i) {
59 ASSERT_TRUE(CheckForeignSessionsAgainst(i, client_windows));
63 IN_PROC_BROWSER_TEST_F(MultipleClientSessionsSyncTest,
64 MAYBE_EncryptedAndChanged) {
65 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
66 std::vector<ScopedWindowMap> client_windows(num_clients());
68 for (int i = 0; i < num_clients(); ++i) {
69 ASSERT_TRUE(CheckInitialState(i));
72 // Enable encryption on client 0, should propagate to all other clients.
73 ASSERT_TRUE(EnableEncryption(0));
75 // Wait for sync.
76 // TODO(zea): Fix sync completion detection so we don't need this. For now,
77 // the profile sync service harness detects completion before all encryption
78 // changes are propagated.
79 ASSERT_TRUE(GetClient(0)->AwaitGroupSyncCycleCompletion(clients()));
81 // Open tabs on all clients and retain window information.
82 for (int i = 0; i < num_clients(); ++i) {
83 SessionWindowMap windows;
84 ASSERT_TRUE(OpenTabAndGetLocalWindows(
85 i, GURL(base::StringPrintf("http://127.0.0.1/bubba%i", i)), &windows));
86 client_windows[i].Reset(&windows);
89 // Wait for sync.
90 ASSERT_TRUE(AwaitQuiescence());
92 // Get foreign session data from all clients and check it against all
93 // client_windows.
94 for (int i = 0; i < num_clients(); ++i) {
95 ASSERT_TRUE(IsEncryptionComplete(i));
96 ASSERT_TRUE(CheckForeignSessionsAgainst(i, client_windows));