Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1129)

Side by Side Diff: chrome/browser/sync/test/integration/two_client_sessions_sync_test.cc

Issue 2379433002: [Sync] Refactoring of sync integration test checkers to remove boilerplate await methods. (Closed)
Patch Set: Rebase Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 #include "chrome/browser/sessions/session_service.h" 11 #include "chrome/browser/sessions/session_service.h"
12 #include "chrome/browser/sync/test/integration/passwords_helper.h" 12 #include "chrome/browser/sync/test/integration/passwords_helper.h"
13 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h" 13 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h"
14 #include "chrome/browser/sync/test/integration/sessions_helper.h" 14 #include "chrome/browser/sync/test/integration/sessions_helper.h"
15 #include "chrome/browser/sync/test/integration/sync_test.h" 15 #include "chrome/browser/sync/test/integration/sync_test.h"
16 #include "components/sync/engine/cycle/sync_cycle_snapshot.h" 16 #include "components/sync/engine/cycle/sync_cycle_snapshot.h"
17 17
18 using sessions_helper::AwaitCheckForeignSessionsAgainst;
19 using sessions_helper::CheckInitialState; 18 using sessions_helper::CheckInitialState;
20 using sessions_helper::DeleteForeignSession; 19 using sessions_helper::DeleteForeignSession;
21 using sessions_helper::GetLocalWindows; 20 using sessions_helper::GetLocalWindows;
22 using sessions_helper::GetSessionData; 21 using sessions_helper::GetSessionData;
23 using sessions_helper::OpenTabAndGetLocalWindows; 22 using sessions_helper::OpenTabAndGetLocalWindows;
24 using sessions_helper::ScopedWindowMap; 23 using sessions_helper::ScopedWindowMap;
25 using sessions_helper::SessionWindowMap; 24 using sessions_helper::SessionWindowMap;
26 using sessions_helper::SyncedSessionVector; 25 using sessions_helper::SyncedSessionVector;
27 using sessions_helper::WindowsMatch; 26 using sessions_helper::WindowsMatch;
28 27
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 ScopedWindowMap client0_windows; 63 ScopedWindowMap client0_windows;
65 std::string url = base::StringPrintf("http://127.0.0.1/bubba%s", 64 std::string url = base::StringPrintf("http://127.0.0.1/bubba%s",
66 base::GenerateGUID().c_str()); 65 base::GenerateGUID().c_str());
67 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(url), &client0_windows)); 66 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(url), &client0_windows));
68 67
69 // Retain the window information on client 0 68 // Retain the window information on client 0
70 std::vector<ScopedWindowMap> expected_windows(1); 69 std::vector<ScopedWindowMap> expected_windows(1);
71 expected_windows[0] = std::move(client0_windows); 70 expected_windows[0] = std::move(client0_windows);
72 71
73 // Check the foreign windows on client 1 72 // Check the foreign windows on client 1
74 ASSERT_TRUE(AwaitCheckForeignSessionsAgainst(1, expected_windows)); 73 ASSERT_TRUE(ForeignSessionsMatchChecker(1, expected_windows).Wait());
75 } 74 }
76 75
77 IN_PROC_BROWSER_TEST_F(TwoClientSessionsSyncTest, 76 IN_PROC_BROWSER_TEST_F(TwoClientSessionsSyncTest,
78 E2E_ENABLED(MAYBE_AllChanged)) { 77 E2E_ENABLED(MAYBE_AllChanged)) {
79 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 78 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
80 79
81 // Open tabs on all clients and retain window information. 80 // Open tabs on all clients and retain window information.
82 std::vector<ScopedWindowMap> client_windows(num_clients()); 81 std::vector<ScopedWindowMap> client_windows(num_clients());
83 for (int i = 0; i < num_clients(); ++i) { 82 for (int i = 0; i < num_clients(); ++i) {
84 ScopedWindowMap windows; 83 ScopedWindowMap windows;
85 std::string url = base::StringPrintf("http://127.0.0.1/bubba%s", 84 std::string url = base::StringPrintf("http://127.0.0.1/bubba%s",
86 base::GenerateGUID().c_str()); 85 base::GenerateGUID().c_str());
87 ASSERT_TRUE(OpenTabAndGetLocalWindows(i, GURL(url), &windows)); 86 ASSERT_TRUE(OpenTabAndGetLocalWindows(i, GURL(url), &windows));
88 client_windows[i] = std::move(windows); 87 client_windows[i] = std::move(windows);
89 } 88 }
90 89
91 // Get foreign session data from all clients and check it against all 90 // Get foreign session data from all clients and check it against all
92 // client_windows. 91 // client_windows.
93 for (int i = 0; i < num_clients(); ++i) { 92 for (int i = 0; i < num_clients(); ++i) {
94 ASSERT_TRUE(AwaitCheckForeignSessionsAgainst(i, client_windows)); 93 ASSERT_TRUE(ForeignSessionsMatchChecker(i, client_windows).Wait());
95 } 94 }
96 } 95 }
97 96
98 IN_PROC_BROWSER_TEST_F(TwoClientSessionsSyncTest, 97 IN_PROC_BROWSER_TEST_F(TwoClientSessionsSyncTest,
99 SingleClientEnabledEncryption) { 98 SingleClientEnabledEncryption) {
100 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 99 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
101 100
102 ASSERT_TRUE(CheckInitialState(0)); 101 ASSERT_TRUE(CheckInitialState(0));
103 ASSERT_TRUE(CheckInitialState(1)); 102 ASSERT_TRUE(CheckInitialState(1));
104 103
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0))); 224 ASSERT_TRUE(GetClient(1)->AwaitMutualSyncCycleCompletion(GetClient(0)));
226 ASSERT_FALSE(GetSessionData(1, &sessions1)); 225 ASSERT_FALSE(GetSessionData(1, &sessions1));
227 226
228 // Client 0 becomes active again with a new tab. 227 // Client 0 becomes active again with a new tab.
229 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(kURL2), &client0_windows)); 228 ASSERT_TRUE(OpenTabAndGetLocalWindows(0, GURL(kURL2), &client0_windows));
230 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1))); 229 ASSERT_TRUE(GetClient(0)->AwaitMutualSyncCycleCompletion(GetClient(1)));
231 ASSERT_TRUE(GetSessionData(1, &sessions1)); 230 ASSERT_TRUE(GetSessionData(1, &sessions1));
232 ASSERT_EQ(1U, sessions1.size()); 231 ASSERT_EQ(1U, sessions1.size());
233 ASSERT_TRUE(WindowsMatch(sessions1[0]->windows, client0_windows)); 232 ASSERT_TRUE(WindowsMatch(sessions1[0]->windows, client0_windows));
234 } 233 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698