Chromium Code Reviews| Index: chrome/browser/sync/test/integration/sessions_helper.h |
| diff --git a/chrome/browser/sync/test/integration/sessions_helper.h b/chrome/browser/sync/test/integration/sessions_helper.h |
| index 365bc091c121cce1178e8f8c9b133fce46b2e284..205204acec7504c2f132f33c1cb8d97b1383eab8 100644 |
| --- a/chrome/browser/sync/test/integration/sessions_helper.h |
| +++ b/chrome/browser/sync/test/integration/sessions_helper.h |
| @@ -13,13 +13,22 @@ |
| #include "base/compiler_specific.h" |
| #include "chrome/browser/sync/test/integration/multi_client_status_change_checker.h" |
| +#include "chrome/browser/sync/test/integration/single_client_status_change_checker.h" |
| #include "chrome/browser/sync/test/integration/sync_test.h" |
| #include "components/sessions/core/session_types.h" |
| #include "components/sync/syncable/nigori_util.h" |
| +#include "components/sync/test/fake_server/fake_server_verifier.h" |
| +#include "components/sync/test/fake_server/sessions_hierarchy.h" |
| #include "components/sync_sessions/synced_session.h" |
| class GURL; |
| +namespace fake_server { |
| +class SessionsHierarchy; |
| +class FakeServer; |
| +class FakeServerVerifier; |
| +} |
| + |
| namespace sessions_helper { |
| using SyncedSessionVector = std::vector<const sync_sessions::SyncedSession*>; |
| @@ -27,34 +36,35 @@ using SessionWindowMap = std::map<SessionID::id_type, sessions::SessionWindow*>; |
| using ScopedWindowMap = |
| std::map<SessionID::id_type, std::unique_ptr<sessions::SessionWindow>>; |
| -// Copies the local session windows of profile |index| to |local_windows|. |
| -// Returns true if successful. |
| -bool GetLocalWindows(int index, ScopedWindowMap* local_windows); |
| +// Copies the local session windows of profileat |profile_index| to |
|
Nicolas Zea
2017/02/24 20:25:30
nit: profileat
Patrick Noland
2017/02/27 18:53:25
Done.
|
| +// |local_windows|. Returns true if successful. |
| +bool GetLocalWindows(int profile_index, ScopedWindowMap* local_windows); |
| -// Creates and verifies the creation of a new window for profile |index| with |
| +// Creates and verifies the creation of a new window for profile |profile_index| |
| +// with |
| // one tab displaying |url|. Copies the SessionWindow associated with the new |
| // window to |local_windows|. Returns true if successful. This call results in |
| // multiple sessions changes, and performs synchronous blocking. It is rare, but |
| // possible, that multiple sync cycle commits occur as a result of this call. |
| // Test cases should be written to handle this possibility, otherwise they may |
| // flake. |
| -bool OpenTabAndGetLocalWindows(int index, |
| +bool OpenTabAndGetLocalWindows(int profile_index, |
| const GURL& url, |
| ScopedWindowMap* local_windows); |
| // Checks that window count and foreign session count are 0. |
| -bool CheckInitialState(int index); |
| +bool CheckInitialState(int profile_index); |
| // Returns number of open windows for a profile. |
| -int GetNumWindows(int index); |
| +int GetNumWindows(int profile_index); |
| // Returns number of foreign sessions for a profile. |
| -int GetNumForeignSessions(int index); |
| +int GetNumForeignSessions(int profile_index); |
| // Fills the sessions vector with the model associator's foreign session data. |
| // Caller owns |sessions|, but not SyncedSessions objects within. |
| // Returns true if foreign sessions were found, false otherwise. |
| -bool GetSessionData(int index, SyncedSessionVector* sessions); |
| +bool GetSessionData(int profile_index, SyncedSessionVector* sessions); |
| // Compares a foreign session based on the first session window. |
| // Returns true based on the comparison of the session windows. |
| @@ -84,35 +94,55 @@ bool WindowsMatch(const SessionWindowMap& win1, const ScopedWindowMap& win2); |
| // with a reference SessionWindow list. |
| // Returns true if the session windows of the foreign session matches the |
| // reference. |
| -bool CheckForeignSessionsAgainst( |
| - int index, |
| - const std::vector<ScopedWindowMap>& windows); |
| +bool CheckForeignSessionsAgainst(int profile_index, |
| + const std::vector<ScopedWindowMap>& windows); |
| + |
| +// Open a single tab in the browser at |browser_index| and block until the |
| +// session model associator is aware of it. Returns true upon success, false |
| +// otherwise. |
| +bool OpenTab(int browser_index, const GURL& url); |
|
Nicolas Zea
2017/02/24 20:25:29
I think window_index might be clearer than browser
Patrick Noland
2017/02/27 18:53:25
After discussing with sky, we think just "index" i
|
| + |
| +// See OpenTab, except that the tab is opened in position |tab_index|. |
|
Nicolas Zea
2017/02/24 20:25:30
Comment about behavior if tab_index is greater tha
Patrick Noland
2017/02/27 18:53:25
Done.
|
| +bool OpenTabAtIndex(int browser_index, int tab_index, const GURL& url); |
| + |
| +// Moves the tab in position |tab_index| in the TabStrip for browser at |
| +// |from_browser_index| to the TabStrip for browser at |to_browser_index|. |
| +void MoveTab(int from_browser_index, int to_browser_index, int tab_index); |
| -// Open a single tab and block until the session model associator is aware |
| -// of it. Returns true upon success, false otherwise. |
| -bool OpenTab(int index, const GURL& url); |
| +// Navigate the active tab for browser in position |browser_index| to the given |
| +// url. |
| +bool NavigateTab(int browser_index, const GURL& url); |
| + |
| +// Navigate the active tab for browser in position |browser_index| back by one; |
| +// if this isn't possible, does nothing |
| +void NavigateTabBack(int browser_index); |
| + |
| +// Navigate the active tab for browser in position |browser_index| forward by |
| +// one; if this isn't possible, does nothing |
| +void NavigateTabForward(int browser_index); |
| // Open multiple tabs and block until the session model associator is aware |
| // of all of them. Returns true on success, false on failure. |
| -bool OpenMultipleTabs(int index, const std::vector<GURL>& urls); |
| +bool OpenMultipleTabs(int profile_index, const std::vector<GURL>& urls); |
| // Wait for a session change to propagate to the model associator. Will not |
| // return until each url in |urls| has been found. |
| -bool WaitForTabsToLoad(int index, const std::vector<GURL>& urls); |
| +bool WaitForTabsToLoad(int profile_index, const std::vector<GURL>& urls); |
| // Check if the session model associator's knows that the current open tab |
| // has this url. |
| -bool ModelAssociatorHasTabWithUrl(int index, const GURL& url); |
| +bool ModelAssociatorHasTabWithUrl(int profile_index, const GURL& url); |
| // Stores a pointer to the local session for a given profile in |session|. |
| // Returns true on success, false on failure. |
| -bool GetLocalSession(int index, const sync_sessions::SyncedSession** session); |
| +bool GetLocalSession(int profile_index, |
| + const sync_sessions::SyncedSession** session); |
| // Deletes the foreign session with tag |session_tag| from the profile specified |
| // by |index|. This will affect all synced clients. |
| // Note: We pass the session_tag in by value to ensure it's not a reference |
| // to the session tag within the SyncedSession we plan to delete. |
| -void DeleteForeignSession(int index, std::string session_tag); |
| +void DeleteForeignSession(int profile_index, std::string session_tag); |
| } // namespace sessions_helper |
| @@ -121,7 +151,7 @@ void DeleteForeignSession(int index, std::string session_tag); |
| class ForeignSessionsMatchChecker : public MultiClientStatusChangeChecker { |
| public: |
| ForeignSessionsMatchChecker( |
| - int index, |
| + int profile_index, |
| const std::vector<sessions_helper::ScopedWindowMap>& windows); |
| // StatusChangeChecker implementation. |
| @@ -129,8 +159,26 @@ class ForeignSessionsMatchChecker : public MultiClientStatusChangeChecker { |
| std::string GetDebugMessage() const override; |
| private: |
| - int index_; |
| + int profile_index_; |
| const std::vector<sessions_helper::ScopedWindowMap>& windows_; |
| }; |
| +// Checker to block until the FakeServer records a SessionsHierarchy identical |
| +// to the SessionsHierarchy specified in the constructor. |
| +class SessionHierarchyMatchChecker : public SingleClientStatusChangeChecker { |
|
Nicolas Zea
2017/02/24 20:25:30
nit: prefer having this in its own file. It's conf
Patrick Noland
2017/02/27 18:53:26
Done.
|
| + public: |
| + SessionHierarchyMatchChecker( |
| + browser_sync::ProfileSyncService* service, |
| + const fake_server::SessionsHierarchy& sessions_hierarchy, |
|
Nicolas Zea
2017/02/24 20:25:30
nit: prefer having const inputs at start, and muta
Patrick Noland
2017/02/27 18:53:25
Done.
|
| + fake_server::FakeServer* fake_server); |
| + |
| + // StatusChangeChecker implementation. |
| + bool IsExitConditionSatisfied() override; |
| + std::string GetDebugMessage() const override; |
| + |
| + private: |
| + const fake_server::SessionsHierarchy& sessions_hierarchy_; |
|
Nicolas Zea
2017/02/24 20:25:29
Is sessions_hierarchy_ guaranteed to outlive this
Patrick Noland
2017/02/27 18:53:25
Done, although this requires an out of line copy c
|
| + fake_server::FakeServerVerifier verifier_; |
| +}; |
| + |
| #endif // CHROME_BROWSER_SYNC_TEST_INTEGRATION_SESSIONS_HELPER_H_ |