Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chrome / browser / sync / test / integration / multiple_client_sessions_sync_test.cc
blob013b0c51d95bc71f687a879b3ed45e2c8ebff155
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/guid.h"
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 {
21 public:
22 MultipleClientSessionsSyncTest() : SyncTest(MULTIPLE_CLIENT) {}
23 ~MultipleClientSessionsSyncTest() override {}
25 private:
26 DISALLOW_COPY_AND_ASSIGN(MultipleClientSessionsSyncTest);
29 // Timeout on Windows, see http://crbug.com/99819
30 #if defined(OS_WIN)
31 #define MAYBE_E2ETest_AllChanged DISABLED_E2ETest_AllChanged
32 #define MAYBE_EncryptedAndChanged DISABLED_EncryptedAndChanged
33 #else
34 #define MAYBE_E2ETest_AllChanged E2ETest_AllChanged
35 #define MAYBE_EncryptedAndChanged EncryptedAndChanged
36 #endif
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
53 // client_windows.
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));
71 // Wait for sync.
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
86 // client_windows.
87 for (int i = 0; i < num_clients(); ++i) {
88 ASSERT_TRUE(AwaitCheckForeignSessionsAgainst(i, client_windows));
89 ASSERT_TRUE(IsEncryptionComplete(i));