OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/memory/scoped_vector.h" | 5 #include "base/memory/scoped_vector.h" |
6 #include "base/stringprintf.h" | 6 #include "base/stringprintf.h" |
7 #include "chrome/browser/sessions/session_service.h" | 7 #include "chrome/browser/sessions/session_service.h" |
8 #include "chrome/browser/sync/profile_sync_service_harness.h" | 8 #include "chrome/browser/sync/profile_sync_service_harness.h" |
9 #include "chrome/browser/sync/test/integration/sync_test.h" | 9 #include "chrome/browser/sync/test/integration/sync_test.h" |
10 #include "chrome/browser/sync/test/integration/sessions_helper.h" | 10 #include "chrome/browser/sync/test/integration/sessions_helper.h" |
11 | 11 |
12 using sessions_helper::CheckForeignSessionsAgainst; | 12 using sessions_helper::CheckForeignSessionsAgainst; |
13 using sessions_helper::CheckInitialState; | 13 using sessions_helper::CheckInitialState; |
14 using sessions_helper::OpenTabAndGetLocalWindows; | 14 using sessions_helper::OpenTabAndGetLocalWindows; |
| 15 using sessions_helper::ScopedWindowMap; |
| 16 using sessions_helper::SessionWindowMap; |
| 17 using sessions_helper::SyncedSessionVector; |
15 | 18 |
16 class MultipleClientSessionsSyncTest : public SyncTest { | 19 class MultipleClientSessionsSyncTest : public SyncTest { |
17 public: | 20 public: |
18 MultipleClientSessionsSyncTest() : SyncTest(MULTIPLE_CLIENT) {} | 21 MultipleClientSessionsSyncTest() : SyncTest(MULTIPLE_CLIENT) {} |
19 virtual ~MultipleClientSessionsSyncTest() {} | 22 virtual ~MultipleClientSessionsSyncTest() {} |
20 | 23 |
21 private: | 24 private: |
22 DISALLOW_COPY_AND_ASSIGN(MultipleClientSessionsSyncTest); | 25 DISALLOW_COPY_AND_ASSIGN(MultipleClientSessionsSyncTest); |
23 }; | 26 }; |
24 | 27 |
25 IN_PROC_BROWSER_TEST_F(MultipleClientSessionsSyncTest, AllChanged) { | 28 IN_PROC_BROWSER_TEST_F(MultipleClientSessionsSyncTest, AllChanged) { |
26 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 29 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
27 ScopedVector<SessionWindowVector> client_windows; | 30 std::vector<ScopedWindowMap> client_windows(num_clients()); |
28 | 31 |
29 for (int i = 0; i < num_clients(); ++i) { | 32 for (int i = 0; i < num_clients(); ++i) { |
30 ASSERT_TRUE(CheckInitialState(i)); | 33 ASSERT_TRUE(CheckInitialState(i)); |
31 } | 34 } |
32 | 35 |
33 // Open tabs on all clients and retain window information. | 36 // Open tabs on all clients and retain window information. |
34 for (int i = 0; i < num_clients(); ++i) { | 37 for (int i = 0; i < num_clients(); ++i) { |
35 SessionWindowVector* windows = new SessionWindowVector(); | 38 SessionWindowMap windows; |
36 ASSERT_TRUE(OpenTabAndGetLocalWindows( | 39 ASSERT_TRUE(OpenTabAndGetLocalWindows( |
37 i, GURL(StringPrintf("about:bubba%i", i)), *windows)); | 40 i, GURL(StringPrintf("about:bubba%i", i)), &windows)); |
38 client_windows.push_back(windows); | 41 client_windows[i].set(&windows); |
39 } | 42 } |
40 | 43 |
41 // Wait for sync. | 44 // Wait for sync. |
42 ASSERT_TRUE(AwaitQuiescence()); | 45 ASSERT_TRUE(AwaitQuiescence()); |
43 | 46 |
44 // Get foreign session data from all clients and check it against all | 47 // Get foreign session data from all clients and check it against all |
45 // client_windows. | 48 // client_windows. |
46 for (int i = 0; i < num_clients(); ++i) { | 49 for (int i = 0; i < num_clients(); ++i) { |
47 ASSERT_TRUE(CheckForeignSessionsAgainst(i, client_windows.get())); | 50 ASSERT_TRUE(CheckForeignSessionsAgainst(i, client_windows)); |
48 } | 51 } |
49 } | 52 } |
50 | 53 |
51 IN_PROC_BROWSER_TEST_F(MultipleClientSessionsSyncTest, | 54 IN_PROC_BROWSER_TEST_F(MultipleClientSessionsSyncTest, |
52 EncryptedAndChanged) { | 55 EncryptedAndChanged) { |
53 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 56 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
54 ScopedVector<SessionWindowVector> client_windows; | 57 std::vector<ScopedWindowMap> client_windows(num_clients()); |
55 | 58 |
56 for (int i = 0; i < num_clients(); ++i) { | 59 for (int i = 0; i < num_clients(); ++i) { |
57 ASSERT_TRUE(CheckInitialState(i)); | 60 ASSERT_TRUE(CheckInitialState(i)); |
58 } | 61 } |
59 | 62 |
60 // Enable encryption on client 0, should propagate to all other clients. | 63 // Enable encryption on client 0, should propagate to all other clients. |
61 ASSERT_TRUE(EnableEncryption(0, syncable::SESSIONS)); | 64 ASSERT_TRUE(EnableEncryption(0, syncable::SESSIONS)); |
62 | 65 |
63 // Wait for sync. | 66 // Wait for sync. |
64 // TODO(zea): Fix sync completion detection so we don't need this. For now, | 67 // TODO(zea): Fix sync completion detection so we don't need this. For now, |
65 // the profile sync service harness detects completion before all encryption | 68 // the profile sync service harness detects completion before all encryption |
66 // changes are propagated. | 69 // changes are propagated. |
67 ASSERT_TRUE(GetClient(0)->AwaitGroupSyncCycleCompletion(clients())); | 70 ASSERT_TRUE(GetClient(0)->AwaitGroupSyncCycleCompletion(clients())); |
68 | 71 |
69 // Open tabs on all clients and retain window information. | 72 // Open tabs on all clients and retain window information. |
70 for (int i = 0; i < num_clients(); ++i) { | 73 for (int i = 0; i < num_clients(); ++i) { |
71 SessionWindowVector* windows = new SessionWindowVector(); | 74 SessionWindowMap windows; |
72 ASSERT_TRUE(OpenTabAndGetLocalWindows( | 75 ASSERT_TRUE(OpenTabAndGetLocalWindows( |
73 i, GURL(StringPrintf("about:bubba%i", i)), *windows)); | 76 i, GURL(StringPrintf("about:bubba%i", i)), &windows)); |
74 client_windows.push_back(windows); | 77 client_windows[i].set(&windows); |
75 } | 78 } |
76 | 79 |
77 // Wait for sync. | 80 // Wait for sync. |
78 ASSERT_TRUE(AwaitQuiescence()); | 81 ASSERT_TRUE(AwaitQuiescence()); |
79 | 82 |
80 // Get foreign session data from all clients and check it against all | 83 // Get foreign session data from all clients and check it against all |
81 // client_windows. | 84 // client_windows. |
82 for (int i = 0; i < num_clients(); ++i) { | 85 for (int i = 0; i < num_clients(); ++i) { |
83 ASSERT_TRUE(IsEncrypted(i, syncable::SESSIONS)); | 86 ASSERT_TRUE(IsEncrypted(i, syncable::SESSIONS)); |
84 ASSERT_TRUE(CheckForeignSessionsAgainst(i, client_windows.get())); | 87 ASSERT_TRUE(CheckForeignSessionsAgainst(i, client_windows)); |
85 } | 88 } |
86 } | 89 } |
OLD | NEW |