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 "chrome/browser/sessions/session_service.h" | 5 #include "chrome/browser/sessions/session_service.h" |
6 #include "chrome/browser/sync/profile_sync_service_harness.h" | 6 #include "chrome/browser/sync/profile_sync_service_harness.h" |
7 #include "chrome/test/live_sync/live_sessions_sync_test.h" | 7 #include "chrome/test/live_sync/live_sessions_sync_test.h" |
8 | 8 |
9 // @TODO(zea): Test each individual session command we care about separately. | 9 // TODO(zea): Test each individual session command we care about separately. |
10 // (as well as multi-window). We're currently only checking basic single-window/ | 10 // (as well as multi-window). We're currently only checking basic single-window/ |
11 // single-tab functionality. | 11 // single-tab functionality. |
12 | 12 |
13 IN_PROC_BROWSER_TEST_F(TwoClientLiveSessionsSyncTest, SingleClientChanged) { | 13 IN_PROC_BROWSER_TEST_F(TwoClientLiveSessionsSyncTest, SingleClientChanged) { |
14 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 14 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
15 | 15 |
16 ASSERT_TRUE(CheckInitialState(0)); | 16 ASSERT_TRUE(CheckInitialState(0)); |
17 ASSERT_TRUE(CheckInitialState(1)); | 17 ASSERT_TRUE(CheckInitialState(1)); |
18 | 18 |
19 std::vector<SessionWindow*>* client0_windows = | 19 std::vector<SessionWindow*>* client0_windows = |
20 InitializeNewWindowWithTab(0, GURL("about:bubba")); | 20 InitializeNewWindowWithTab(0, GURL("about:bubba")); |
21 ASSERT_TRUE(client0_windows); | 21 ASSERT_TRUE(client0_windows); |
22 | 22 |
23 GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)); | 23 GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)); |
24 | 24 |
25 // Get foreign session data from client 1. | 25 // Get foreign session data from client 1. |
26 std::vector<const ForeignSession*> sessions1; | 26 std::vector<const ForeignSession*> sessions1; |
27 ASSERT_TRUE(GetSessionData(1, &sessions1)); | 27 ASSERT_TRUE(GetSessionData(1, &sessions1)); |
28 | 28 |
29 // Verify client 1's foreign session matches client 0 current window. | 29 // Verify client 1's foreign session matches client 0 current window. |
30 ASSERT_EQ(1U, sessions1.size()); | 30 ASSERT_EQ(1U, sessions1.size()); |
31 ASSERT_TRUE(WindowsMatch(sessions1[0]->windows, *client0_windows)); | 31 ASSERT_TRUE(WindowsMatch(sessions1[0]->windows, *client0_windows)); |
32 } | 32 } |
33 | 33 |
| 34 IN_PROC_BROWSER_TEST_F(TwoClientLiveSessionsSyncTest, |
| 35 SingleClientEnabledEncryption) { |
| 36 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 37 |
| 38 ASSERT_TRUE(CheckInitialState(0)); |
| 39 ASSERT_TRUE(CheckInitialState(1)); |
| 40 |
| 41 ASSERT_TRUE(EnableEncryption(0)); |
| 42 GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)); |
| 43 ASSERT_TRUE(IsEncrypted(0)); |
| 44 ASSERT_TRUE(IsEncrypted(1)); |
| 45 } |
| 46 |
| 47 IN_PROC_BROWSER_TEST_F(TwoClientLiveSessionsSyncTest, |
| 48 SingleClientEnabledEncryptionAndChanged) { |
| 49 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 50 |
| 51 ASSERT_TRUE(CheckInitialState(0)); |
| 52 ASSERT_TRUE(CheckInitialState(1)); |
| 53 |
| 54 std::vector<SessionWindow*>* client0_windows = |
| 55 InitializeNewWindowWithTab(0, GURL("about:bubba")); |
| 56 ASSERT_TRUE(client0_windows); |
| 57 ASSERT_TRUE(EnableEncryption(0)); |
| 58 GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)); |
| 59 |
| 60 // Get foreign session data from client 1. |
| 61 ASSERT_TRUE(IsEncrypted(1)); |
| 62 std::vector<const ForeignSession*> sessions1; |
| 63 ASSERT_TRUE(GetSessionData(1, &sessions1)); |
| 64 |
| 65 // Verify client 1's foreign session matches client 0 current window. |
| 66 ASSERT_EQ(1U, sessions1.size()); |
| 67 ASSERT_TRUE(WindowsMatch(sessions1[0]->windows, *client0_windows)); |
| 68 } |
| 69 |
| 70 IN_PROC_BROWSER_TEST_F(TwoClientLiveSessionsSyncTest, |
| 71 BothClientsEnabledEncryption) { |
| 72 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 73 |
| 74 ASSERT_TRUE(CheckInitialState(0)); |
| 75 ASSERT_TRUE(CheckInitialState(1)); |
| 76 |
| 77 ASSERT_TRUE(EnableEncryption(0)); |
| 78 ASSERT_TRUE(EnableEncryption(1)); |
| 79 GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)); |
| 80 ASSERT_TRUE(IsEncrypted(0)); |
| 81 ASSERT_TRUE(IsEncrypted(1)); |
| 82 } |
| 83 |
34 IN_PROC_BROWSER_TEST_F(TwoClientLiveSessionsSyncTest, BothChanged) { | 84 IN_PROC_BROWSER_TEST_F(TwoClientLiveSessionsSyncTest, BothChanged) { |
35 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 85 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
36 | 86 |
37 ASSERT_TRUE(CheckInitialState(0)); | 87 ASSERT_TRUE(CheckInitialState(0)); |
38 ASSERT_TRUE(CheckInitialState(1)); | 88 ASSERT_TRUE(CheckInitialState(1)); |
39 | 89 |
40 // Open tabs on both clients and retain window information. | 90 // Open tabs on both clients and retain window information. |
41 std::vector<SessionWindow*>* client0_windows = | 91 std::vector<SessionWindow*>* client0_windows = |
42 InitializeNewWindowWithTab(0, GURL("about:bubba0")); | 92 InitializeNewWindowWithTab(0, GURL("about:bubba0")); |
43 ASSERT_TRUE(client0_windows); | 93 ASSERT_TRUE(client0_windows); |
(...skipping 10 matching lines...) Expand all Loading... |
54 ASSERT_TRUE(GetSessionData(0, &sessions0)); | 104 ASSERT_TRUE(GetSessionData(0, &sessions0)); |
55 ASSERT_TRUE(GetSessionData(1, &sessions1)); | 105 ASSERT_TRUE(GetSessionData(1, &sessions1)); |
56 | 106 |
57 // Verify client 1's foreign session matches client 0's current window and | 107 // Verify client 1's foreign session matches client 0's current window and |
58 // vice versa. | 108 // vice versa. |
59 ASSERT_EQ(1U, sessions0.size()); | 109 ASSERT_EQ(1U, sessions0.size()); |
60 ASSERT_EQ(1U, sessions1.size()); | 110 ASSERT_EQ(1U, sessions1.size()); |
61 ASSERT_TRUE(WindowsMatch(sessions1[0]->windows, *client0_windows)); | 111 ASSERT_TRUE(WindowsMatch(sessions1[0]->windows, *client0_windows)); |
62 ASSERT_TRUE(WindowsMatch(sessions0[0]->windows, *client1_windows)); | 112 ASSERT_TRUE(WindowsMatch(sessions0[0]->windows, *client1_windows)); |
63 } | 113 } |
OLD | NEW |