Fire an error if a pref used in the UI is missing once all prefs are fetched.
[chromium-blink-merge.git] / chrome / browser / sync / test / integration / multiple_client_sessions_sync_test.cc
blobfde348a89f23b2ff7d6f4bbb43d849c4583006a7
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::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 {
20 public:
21 MultipleClientSessionsSyncTest() : SyncTest(MULTIPLE_CLIENT) {}
22 ~MultipleClientSessionsSyncTest() override {}
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 // Get foreign session data from all clients and check it against all
54 // client_windows.
55 for (int i = 0; i < num_clients(); ++i) {
56 ASSERT_TRUE(AwaitCheckForeignSessionsAgainst(i, client_windows));
60 IN_PROC_BROWSER_TEST_F(MultipleClientSessionsSyncTest,
61 MAYBE_EncryptedAndChanged) {
62 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
63 std::vector<ScopedWindowMap> client_windows(num_clients());
65 for (int i = 0; i < num_clients(); ++i) {
66 ASSERT_TRUE(CheckInitialState(i));
69 // Enable encryption on client 0, should propagate to all other clients.
70 ASSERT_TRUE(EnableEncryption(0));
72 // Wait for sync.
73 // TODO(zea): Fix sync completion detection so we don't need this. For now,
74 // the profile sync service harness detects completion before all encryption
75 // changes are propagated.
76 ASSERT_TRUE(GetClient(0)->AwaitGroupSyncCycleCompletion(clients()));
78 // Open tabs on all clients and retain window information.
79 for (int i = 0; i < num_clients(); ++i) {
80 SessionWindowMap windows;
81 ASSERT_TRUE(OpenTabAndGetLocalWindows(
82 i, GURL(base::StringPrintf("http://127.0.0.1/bubba%i", i)), &windows));
83 client_windows[i].Reset(&windows);
86 // Get foreign session data from all clients and check it against all
87 // client_windows.
88 for (int i = 0; i < num_clients(); ++i) {
89 ASSERT_TRUE(AwaitCheckForeignSessionsAgainst(i, client_windows));
90 ASSERT_TRUE(IsEncryptionComplete(i));