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.
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::AwaitCheckForeignSessionsAgainst
;
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
{
21 MultipleClientSessionsSyncTest() : SyncTest(MULTIPLE_CLIENT
) {}
22 ~MultipleClientSessionsSyncTest() override
{}
25 DISALLOW_COPY_AND_ASSIGN(MultipleClientSessionsSyncTest
);
28 // Timeout on Windows, see http://crbug.com/99819
30 #define MAYBE_E2ETest_AllChanged DISABLED_E2ETest_AllChanged
31 #define MAYBE_EncryptedAndChanged DISABLED_EncryptedAndChanged
33 #define MAYBE_E2ETest_AllChanged E2ETest_AllChanged
34 #define MAYBE_EncryptedAndChanged EncryptedAndChanged
37 IN_PROC_BROWSER_TEST_F(MultipleClientSessionsSyncTest
,
38 MAYBE_E2ETest_AllChanged
) {
39 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
41 // Open tabs on all clients and retain window information.
42 std::vector
<ScopedWindowMap
> client_windows(num_clients());
43 for (int i
= 0; i
< num_clients(); ++i
) {
44 SessionWindowMap windows
;
45 std::string url
= base::StringPrintf("http://127.0.0.1/bubba%s",
46 base::GenerateGUID().c_str());
47 ASSERT_TRUE(OpenTabAndGetLocalWindows(i
, GURL(url
), &windows
));
48 client_windows
[i
].Reset(&windows
);
51 // Get foreign session data from all clients and check it against all
53 for (int i
= 0; i
< num_clients(); ++i
) {
54 ASSERT_TRUE(AwaitCheckForeignSessionsAgainst(i
, client_windows
));
58 IN_PROC_BROWSER_TEST_F(MultipleClientSessionsSyncTest
,
59 MAYBE_EncryptedAndChanged
) {
60 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
61 std::vector
<ScopedWindowMap
> client_windows(num_clients());
63 for (int i
= 0; i
< num_clients(); ++i
) {
64 ASSERT_TRUE(CheckInitialState(i
));
67 // Enable encryption on client 0, should propagate to all other clients.
68 ASSERT_TRUE(EnableEncryption(0));
71 // TODO(zea): Fix sync completion detection so we don't need this. For now,
72 // the profile sync service harness detects completion before all encryption
73 // changes are propagated.
74 ASSERT_TRUE(GetClient(0)->AwaitGroupSyncCycleCompletion(clients()));
76 // Open tabs on all clients and retain window information.
77 for (int i
= 0; i
< num_clients(); ++i
) {
78 SessionWindowMap windows
;
79 ASSERT_TRUE(OpenTabAndGetLocalWindows(
80 i
, GURL(base::StringPrintf("http://127.0.0.1/bubba%i", i
)), &windows
));
81 client_windows
[i
].Reset(&windows
);
84 // Get foreign session data from all clients and check it against all
86 for (int i
= 0; i
< num_clients(); ++i
) {
87 ASSERT_TRUE(AwaitCheckForeignSessionsAgainst(i
, client_windows
));
88 ASSERT_TRUE(IsEncryptionComplete(i
));