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

Side by Side Diff: chrome/browser/sync/test/integration/sessions_helper.h

Issue 2379433002: [Sync] Refactoring of sync integration test checkers to remove boilerplate await methods. (Closed)
Patch Set: Fixing another ChromeOS test. 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 #ifndef CHROME_BROWSER_SYNC_TEST_INTEGRATION_SESSIONS_HELPER_H_ 5 #ifndef CHROME_BROWSER_SYNC_TEST_INTEGRATION_SESSIONS_HELPER_H_
6 #define CHROME_BROWSER_SYNC_TEST_INTEGRATION_SESSIONS_HELPER_H_ 6 #define CHROME_BROWSER_SYNC_TEST_INTEGRATION_SESSIONS_HELPER_H_
7 7
8 #include <algorithm> 8 #include <algorithm>
9 #include <map>
10 #include <memory>
9 #include <string> 11 #include <string>
10 #include <vector> 12 #include <vector>
11 13
12 #include "base/compiler_specific.h" 14 #include "base/compiler_specific.h"
15 #include "chrome/browser/sync/test/integration/multi_client_status_change_checke r.h"
13 #include "chrome/browser/sync/test/integration/sync_test.h" 16 #include "chrome/browser/sync/test/integration/sync_test.h"
14 #include "components/sessions/core/session_types.h" 17 #include "components/sessions/core/session_types.h"
15 #include "components/sync/syncable/nigori_util.h" 18 #include "components/sync/syncable/nigori_util.h"
16 #include "components/sync_sessions/synced_session.h" 19 #include "components/sync_sessions/synced_session.h"
17 20
18 class GURL; 21 class GURL;
19 22
20 namespace sessions_helper { 23 namespace sessions_helper {
21 24
22 using SyncedSessionVector = std::vector<const sync_sessions::SyncedSession*>; 25 using SyncedSessionVector = std::vector<const sync_sessions::SyncedSession*>;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 bool WindowsMatch(const SessionWindowMap& win1, const ScopedWindowMap& win2); 77 bool WindowsMatch(const SessionWindowMap& win1, const ScopedWindowMap& win2);
75 78
76 // Retrieves the foreign sessions for a particular profile and compares them 79 // Retrieves the foreign sessions for a particular profile and compares them
77 // with a reference SessionWindow list. 80 // with a reference SessionWindow list.
78 // Returns true if the session windows of the foreign session matches the 81 // Returns true if the session windows of the foreign session matches the
79 // reference. 82 // reference.
80 bool CheckForeignSessionsAgainst( 83 bool CheckForeignSessionsAgainst(
81 int index, 84 int index,
82 const std::vector<ScopedWindowMap>& windows); 85 const std::vector<ScopedWindowMap>& windows);
83 86
84 // Retrieves the foreign sessions for a particular profile and compares them
85 // to the reference windows using CheckForeignSessionsAgains. Returns true if
86 // they match and doesn't time out.
87 bool AwaitCheckForeignSessionsAgainst(
88 int index, const std::vector<ScopedWindowMap>& windows);
89
90 // Open a single tab and block until the session model associator is aware 87 // Open a single tab and block until the session model associator is aware
91 // of it. Returns true upon success, false otherwise. 88 // of it. Returns true upon success, false otherwise.
92 bool OpenTab(int index, const GURL& url); 89 bool OpenTab(int index, const GURL& url);
93 90
94 // Open multiple tabs and block until the session model associator is aware 91 // Open multiple tabs and block until the session model associator is aware
95 // of all of them. Returns true on success, false on failure. 92 // of all of them. Returns true on success, false on failure.
96 bool OpenMultipleTabs(int index, const std::vector<GURL>& urls); 93 bool OpenMultipleTabs(int index, const std::vector<GURL>& urls);
97 94
98 // Wait for a session change to propagate to the model associator. Will not 95 // Wait for a session change to propagate to the model associator. Will not
99 // return until each url in |urls| has been found. 96 // return until each url in |urls| has been found.
100 bool WaitForTabsToLoad(int index, const std::vector<GURL>& urls); 97 bool WaitForTabsToLoad(int index, const std::vector<GURL>& urls);
101 98
102 // Check if the session model associator's knows that the current open tab 99 // Check if the session model associator's knows that the current open tab
103 // has this url. 100 // has this url.
104 bool ModelAssociatorHasTabWithUrl(int index, const GURL& url); 101 bool ModelAssociatorHasTabWithUrl(int index, const GURL& url);
105 102
106 // Stores a pointer to the local session for a given profile in |session|. 103 // Stores a pointer to the local session for a given profile in |session|.
107 // Returns true on success, false on failure. 104 // Returns true on success, false on failure.
108 bool GetLocalSession(int index, const sync_sessions::SyncedSession** session); 105 bool GetLocalSession(int index, const sync_sessions::SyncedSession** session);
109 106
110 // Deletes the foreign session with tag |session_tag| from the profile specified 107 // Deletes the foreign session with tag |session_tag| from the profile specified
111 // by |index|. This will affect all synced clients. 108 // by |index|. This will affect all synced clients.
112 // Note: We pass the session_tag in by value to ensure it's not a reference 109 // Note: We pass the session_tag in by value to ensure it's not a reference
113 // to the session tag within the SyncedSession we plan to delete. 110 // to the session tag within the SyncedSession we plan to delete.
114 void DeleteForeignSession(int index, std::string session_tag); 111 void DeleteForeignSession(int index, std::string session_tag);
115 112
116 } // namespace sessions_helper 113 } // namespace sessions_helper
117 114
115 // Checker to block until the foreign sessions for a particular profile matches
116 // the reference windows.
117 class CheckForeignSessionsChecker : public MultiClientStatusChangeChecker {
maxbogue 2016/09/30 16:27:55 Shouldn't this be ForeignSessionsMatchChecker to f
skym 2016/09/30 17:43:21 Done.
118 public:
119 CheckForeignSessionsChecker(
120 int index,
121 const std::vector<sessions_helper::ScopedWindowMap>& windows);
122
123 // StatusChangeChecker implementation.
124 bool IsExitConditionSatisfied() override;
125 std::string GetDebugMessage() const override;
126
127 private:
128 int index_;
129 const std::vector<sessions_helper::ScopedWindowMap>& windows_;
130 };
131
118 #endif // CHROME_BROWSER_SYNC_TEST_INTEGRATION_SESSIONS_HELPER_H_ 132 #endif // CHROME_BROWSER_SYNC_TEST_INTEGRATION_SESSIONS_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698