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