| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/guid.h" | 7 #include "base/guid.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 DISALLOW_COPY_AND_ASSIGN(TwoClientSessionsSyncTest); | 37 DISALLOW_COPY_AND_ASSIGN(TwoClientSessionsSyncTest); |
| 38 }; | 38 }; |
| 39 | 39 |
| 40 static const char* kURL1 = "http://127.0.0.1/bubba1"; | 40 static const char* kURL1 = "http://127.0.0.1/bubba1"; |
| 41 static const char* kURL2 = "http://127.0.0.1/bubba2"; | 41 static const char* kURL2 = "http://127.0.0.1/bubba2"; |
| 42 | 42 |
| 43 // TODO(zea): Test each individual session command we care about separately. | 43 // TODO(zea): Test each individual session command we care about separately. |
| 44 // (as well as multi-window). We're currently only checking basic single-window/ | 44 // (as well as multi-window). We're currently only checking basic single-window/ |
| 45 // single-tab functionality. | 45 // single-tab functionality. |
| 46 | 46 |
| 47 // Fails on Win, see http://crbug.com/232313 | |
| 48 #if defined(OS_WIN) | |
| 49 #define MAYBE_SingleClientChanged DISABLED_SingleClientChanged | |
| 50 #define MAYBE_BothChanged DISABLED_BothChanged | |
| 51 #define MAYBE_DeleteIdleSession DISABLED_DeleteIdleSession | |
| 52 #define MAYBE_AllChanged DISABLED_AllChanged | |
| 53 #else | |
| 54 #define MAYBE_SingleClientChanged SingleClientChanged | |
| 55 #define MAYBE_BothChanged BothChanged | |
| 56 #define MAYBE_DeleteIdleSession DeleteIdleSession | |
| 57 #define MAYBE_AllChanged AllChanged | |
| 58 #endif | |
| 59 | |
| 60 | 47 |
| 61 IN_PROC_BROWSER_TEST_F(TwoClientSessionsSyncTest, | 48 IN_PROC_BROWSER_TEST_F(TwoClientSessionsSyncTest, |
| 62 E2E_ENABLED(MAYBE_SingleClientChanged)) { | 49 E2E_ENABLED(SingleClientChanged)) { |
| 63 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 50 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 64 | 51 |
| 65 // Open tab and access a url on client 0 | 52 // Open tab and access a url on client 0 |
| 66 ScopedWindowMap client0_windows; | 53 ScopedWindowMap client0_windows; |
| 67 std::string url = base::StringPrintf("http://127.0.0.1/bubba%s", | 54 std::string url = base::StringPrintf("http://127.0.0.1/bubba%s", |
| 68 base::GenerateGUID().c_str()); | 55 base::GenerateGUID().c_str()); |
| 69 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(url), &client0_windows)); | 56 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(url), &client0_windows)); |
| 70 | 57 |
| 71 // Retain the window information on client 0 | 58 // Retain the window information on client 0 |
| 72 std::vector<ScopedWindowMap> expected_windows(1); | 59 std::vector<ScopedWindowMap> expected_windows(1); |
| 73 expected_windows[0] = std::move(client0_windows); | 60 expected_windows[0] = std::move(client0_windows); |
| 74 | 61 |
| 75 // Check the foreign windows on client 1 | 62 // Check the foreign windows on client 1 |
| 76 ASSERT_TRUE(AwaitCheckForeignSessionsAgainst(1, expected_windows)); | 63 ASSERT_TRUE(AwaitCheckForeignSessionsAgainst(1, expected_windows)); |
| 77 } | 64 } |
| 78 | 65 |
| 79 IN_PROC_BROWSER_TEST_F(TwoClientSessionsSyncTest, | 66 IN_PROC_BROWSER_TEST_F(TwoClientSessionsSyncTest, |
| 80 E2E_ENABLED(MAYBE_AllChanged)) { | 67 E2E_ENABLED(AllChanged)) { |
| 81 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 68 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 82 | 69 |
| 83 // Open tabs on all clients and retain window information. | 70 // Open tabs on all clients and retain window information. |
| 84 std::vector<ScopedWindowMap> client_windows(num_clients()); | 71 std::vector<ScopedWindowMap> client_windows(num_clients()); |
| 85 for (int i = 0; i < num_clients(); ++i) { | 72 for (int i = 0; i < num_clients(); ++i) { |
| 86 ScopedWindowMap windows; | 73 ScopedWindowMap windows; |
| 87 std::string url = base::StringPrintf("http://127.0.0.1/bubba%s", | 74 std::string url = base::StringPrintf("http://127.0.0.1/bubba%s", |
| 88 base::GenerateGUID().c_str()); | 75 base::GenerateGUID().c_str()); |
| 89 ASSERT_TRUE(OpenTabAndGetLocalWindows(i, GURL(url), &windows)); | 76 ASSERT_TRUE(OpenTabAndGetLocalWindows(i, GURL(url), &windows)); |
| 90 client_windows[i] = std::move(windows); | 77 client_windows[i] = std::move(windows); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 ASSERT_TRUE(CheckInitialState(0)); | 129 ASSERT_TRUE(CheckInitialState(0)); |
| 143 ASSERT_TRUE(CheckInitialState(1)); | 130 ASSERT_TRUE(CheckInitialState(1)); |
| 144 | 131 |
| 145 ASSERT_TRUE(EnableEncryption(0)); | 132 ASSERT_TRUE(EnableEncryption(0)); |
| 146 ASSERT_TRUE(EnableEncryption(1)); | 133 ASSERT_TRUE(EnableEncryption(1)); |
| 147 ASSERT_TRUE(AwaitQuiescence()); | 134 ASSERT_TRUE(AwaitQuiescence()); |
| 148 ASSERT_TRUE(IsEncryptionComplete(0)); | 135 ASSERT_TRUE(IsEncryptionComplete(0)); |
| 149 ASSERT_TRUE(IsEncryptionComplete(1)); | 136 ASSERT_TRUE(IsEncryptionComplete(1)); |
| 150 } | 137 } |
| 151 | 138 |
| 152 IN_PROC_BROWSER_TEST_F(TwoClientSessionsSyncTest, MAYBE_BothChanged) { | 139 IN_PROC_BROWSER_TEST_F(TwoClientSessionsSyncTest, BothChanged) { |
| 153 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 140 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 154 | 141 |
| 155 ASSERT_TRUE(CheckInitialState(0)); | 142 ASSERT_TRUE(CheckInitialState(0)); |
| 156 ASSERT_TRUE(CheckInitialState(1)); | 143 ASSERT_TRUE(CheckInitialState(1)); |
| 157 | 144 |
| 158 // Open tabs on both clients and retain window information. | 145 // Open tabs on both clients and retain window information. |
| 159 ScopedWindowMap client0_windows; | 146 ScopedWindowMap client0_windows; |
| 160 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(kURL2), &client0_windows)); | 147 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(kURL2), &client0_windows)); |
| 161 ScopedWindowMap client1_windows; | 148 ScopedWindowMap client1_windows; |
| 162 ASSERT_TRUE(OpenTabAndGetLocalWindows(1, GURL(kURL1), &client1_windows)); | 149 ASSERT_TRUE(OpenTabAndGetLocalWindows(1, GURL(kURL1), &client1_windows)); |
| 163 | 150 |
| 164 // Wait for sync. | 151 // Wait for sync. |
| 165 ASSERT_TRUE(AwaitQuiescence()); | 152 ASSERT_TRUE(AwaitQuiescence()); |
| 166 | 153 |
| 167 // Get foreign session data from client 0 and 1. | 154 // Get foreign session data from client 0 and 1. |
| 168 SyncedSessionVector sessions0; | 155 SyncedSessionVector sessions0; |
| 169 SyncedSessionVector sessions1; | 156 SyncedSessionVector sessions1; |
| 170 ASSERT_TRUE(GetSessionData(0, &sessions0)); | 157 ASSERT_TRUE(GetSessionData(0, &sessions0)); |
| 171 ASSERT_TRUE(GetSessionData(1, &sessions1)); | 158 ASSERT_TRUE(GetSessionData(1, &sessions1)); |
| 172 | 159 |
| 173 // Verify client 1's foreign session matches client 0's current window and | 160 // Verify client 1's foreign session matches client 0's current window and |
| 174 // vice versa. | 161 // vice versa. |
| 175 ASSERT_EQ(1U, sessions0.size()); | 162 ASSERT_EQ(1U, sessions0.size()); |
| 176 ASSERT_EQ(1U, sessions1.size()); | 163 ASSERT_EQ(1U, sessions1.size()); |
| 177 ASSERT_TRUE(WindowsMatch(sessions1[0]->windows, client0_windows)); | 164 ASSERT_TRUE(WindowsMatch(sessions1[0]->windows, client0_windows)); |
| 178 ASSERT_TRUE(WindowsMatch(sessions0[0]->windows, client1_windows)); | 165 ASSERT_TRUE(WindowsMatch(sessions0[0]->windows, client1_windows)); |
| 179 } | 166 } |
| 180 | 167 |
| 181 IN_PROC_BROWSER_TEST_F(TwoClientSessionsSyncTest, MAYBE_DeleteIdleSession) { | 168 IN_PROC_BROWSER_TEST_F(TwoClientSessionsSyncTest, DeleteIdleSession) { |
| 182 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 169 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 183 | 170 |
| 184 ASSERT_TRUE(CheckInitialState(0)); | 171 ASSERT_TRUE(CheckInitialState(0)); |
| 185 ASSERT_TRUE(CheckInitialState(1)); | 172 ASSERT_TRUE(CheckInitialState(1)); |
| 186 | 173 |
| 187 // Client 0 opened some tabs then went idle. | 174 // Client 0 opened some tabs then went idle. |
| 188 ScopedWindowMap client0_windows; | 175 ScopedWindowMap client0_windows; |
| 189 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(kURL1), &client0_windows)); | 176 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(kURL1), &client0_windows)); |
| 190 | 177 |
| 191 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | 178 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); |
| 192 | 179 |
| 193 // Get foreign session data from client 1. | 180 // Get foreign session data from client 1. |
| 194 SyncedSessionVector sessions1; | 181 SyncedSessionVector sessions1; |
| 195 ASSERT_TRUE(GetSessionData(1, &sessions1)); | 182 ASSERT_TRUE(GetSessionData(1, &sessions1)); |
| 196 | 183 |
| 197 // Verify client 1's foreign session matches client 0 current window. | 184 // Verify client 1's foreign session matches client 0 current window. |
| 198 ASSERT_EQ(1U, sessions1.size()); | 185 ASSERT_EQ(1U, sessions1.size()); |
| 199 ASSERT_TRUE(WindowsMatch(sessions1[0]->windows, client0_windows)); | 186 ASSERT_TRUE(WindowsMatch(sessions1[0]->windows, client0_windows)); |
| 200 | 187 |
| 201 // Client 1 now deletes client 0's tabs. This frees the memory of sessions1. | 188 // Client 1 now deletes client 0's tabs. This frees the memory of sessions1. |
| 202 DeleteForeignSession(1, sessions1[0]->session_tag); | 189 DeleteForeignSession(1, sessions1[0]->session_tag); |
| 203 ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0))); | 190 ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0))); |
| 204 ASSERT_FALSE(GetSessionData(1, &sessions1)); | 191 ASSERT_FALSE(GetSessionData(1, &sessions1)); |
| 205 } | 192 } |
| 206 | 193 |
| 207 // Fails all release trybots. crbug.com/263369. | 194 // Fails all release trybots. crbug.com/263369. |
| 208 IN_PROC_BROWSER_TEST_F(TwoClientSessionsSyncTest, | 195 IN_PROC_BROWSER_TEST_F(TwoClientSessionsSyncTest, |
| 209 DISABLED_DeleteActiveSession) { | 196 DeleteActiveSession) { |
| 210 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; | 197 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; |
| 211 | 198 |
| 212 ASSERT_TRUE(CheckInitialState(0)); | 199 ASSERT_TRUE(CheckInitialState(0)); |
| 213 ASSERT_TRUE(CheckInitialState(1)); | 200 ASSERT_TRUE(CheckInitialState(1)); |
| 214 | 201 |
| 215 // Client 0 opened some tabs then went idle. | 202 // Client 0 opened some tabs then went idle. |
| 216 ScopedWindowMap client0_windows; | 203 ScopedWindowMap client0_windows; |
| 217 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(kURL1), &client0_windows)); | 204 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(kURL1), &client0_windows)); |
| 218 | 205 |
| 219 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | 206 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); |
| 220 SyncedSessionVector sessions1; | 207 SyncedSessionVector sessions1; |
| 221 ASSERT_TRUE(GetSessionData(1, &sessions1)); | 208 ASSERT_TRUE(GetSessionData(1, &sessions1)); |
| 222 ASSERT_EQ(1U, sessions1.size()); | 209 ASSERT_EQ(1U, sessions1.size()); |
| 223 ASSERT_TRUE(WindowsMatch(sessions1[0]->windows, client0_windows)); | 210 ASSERT_TRUE(WindowsMatch(sessions1[0]->windows, client0_windows)); |
| 224 | 211 |
| 225 // Client 1 now deletes client 0's tabs. This frees the memory of sessions1. | 212 // Client 1 now deletes client 0's tabs. This frees the memory of sessions1. |
| 226 DeleteForeignSession(1, sessions1[0]->session_tag); | 213 DeleteForeignSession(1, sessions1[0]->session_tag); |
| 227 ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0))); | 214 ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0))); |
| 228 ASSERT_FALSE(GetSessionData(1, &sessions1)); | 215 ASSERT_FALSE(GetSessionData(1, &sessions1)); |
| 229 | 216 |
| 230 // Client 0 becomes active again with a new tab. | 217 // Client 0 becomes active again with a new tab. |
| 231 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(kURL2), &client0_windows)); | 218 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(kURL2), &client0_windows)); |
| 232 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); | 219 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); |
| 233 ASSERT_TRUE(GetSessionData(1, &sessions1)); | 220 ASSERT_TRUE(GetSessionData(1, &sessions1)); |
| 234 ASSERT_EQ(1U, sessions1.size()); | 221 ASSERT_EQ(1U, sessions1.size()); |
| 235 ASSERT_TRUE(WindowsMatch(sessions1[0]->windows, client0_windows)); | 222 ASSERT_TRUE(WindowsMatch(sessions1[0]->windows, client0_windows)); |
| 236 } | 223 } |
| OLD | NEW |