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/memory/scoped_vector.h"
7 #include "base/strings/stringprintf.h"
8 #include "chrome/browser/sessions/session_service.h"
9 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h"
10 #include "chrome/browser/sync/test/integration/sessions_helper.h"
11 #include "chrome/browser/sync/test/integration/sync_test.h"
13 using sessions_helper::AwaitCheckForeignSessionsAgainst
;
14 using sessions_helper::CheckInitialState
;
15 using sessions_helper::OpenTabAndGetLocalWindows
;
16 using sessions_helper::ScopedWindowMap
;
17 using sessions_helper::SessionWindowMap
;
18 using sessions_helper::SyncedSessionVector
;
20 class MultipleClientSessionsSyncTest
: public SyncTest
{
22 MultipleClientSessionsSyncTest() : SyncTest(MULTIPLE_CLIENT
) {}
23 ~MultipleClientSessionsSyncTest() override
{}
26 DISALLOW_COPY_AND_ASSIGN(MultipleClientSessionsSyncTest
);
29 // Timeout on Windows, see http://crbug.com/99819
31 #define MAYBE_E2ETest_AllChanged DISABLED_E2ETest_AllChanged
32 #define MAYBE_EncryptedAndChanged DISABLED_EncryptedAndChanged
34 #define MAYBE_E2ETest_AllChanged E2ETest_AllChanged
35 #define MAYBE_EncryptedAndChanged EncryptedAndChanged
38 IN_PROC_BROWSER_TEST_F(MultipleClientSessionsSyncTest
,
39 MAYBE_E2ETest_AllChanged
) {
40 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
42 // Open tabs on all clients and retain window information.
43 std::vector
<ScopedWindowMap
> client_windows(num_clients());
44 for (int i
= 0; i
< num_clients(); ++i
) {
45 SessionWindowMap windows
;
46 std::string url
= base::StringPrintf("http://127.0.0.1/bubba%s",
47 base::GenerateGUID().c_str());
48 ASSERT_TRUE(OpenTabAndGetLocalWindows(i
, GURL(url
), &windows
));
49 client_windows
[i
].Reset(&windows
);
52 // Get foreign session data from all clients and check it against all
54 for (int i
= 0; i
< num_clients(); ++i
) {
55 ASSERT_TRUE(AwaitCheckForeignSessionsAgainst(i
, client_windows
));
59 IN_PROC_BROWSER_TEST_F(MultipleClientSessionsSyncTest
,
60 MAYBE_EncryptedAndChanged
) {
61 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
62 std::vector
<ScopedWindowMap
> client_windows(num_clients());
64 for (int i
= 0; i
< num_clients(); ++i
) {
65 ASSERT_TRUE(CheckInitialState(i
));
68 // Enable encryption on client 0, should propagate to all other clients.
69 ASSERT_TRUE(EnableEncryption(0));
72 // TODO(zea): Fix sync completion detection so we don't need this. For now,
73 // the profile sync service harness detects completion before all encryption
74 // changes are propagated.
75 ASSERT_TRUE(GetClient(0)->AwaitGroupSyncCycleCompletion(clients()));
77 // Open tabs on all clients and retain window information.
78 for (int i
= 0; i
< num_clients(); ++i
) {
79 SessionWindowMap windows
;
80 ASSERT_TRUE(OpenTabAndGetLocalWindows(
81 i
, GURL(base::StringPrintf("http://127.0.0.1/bubba%i", i
)), &windows
));
82 client_windows
[i
].Reset(&windows
);
85 // Get foreign session data from all clients and check it against all
87 for (int i
= 0; i
< num_clients(); ++i
) {
88 ASSERT_TRUE(AwaitCheckForeignSessionsAgainst(i
, client_windows
));
89 ASSERT_TRUE(IsEncryptionComplete(i
));