Chromium Code Reviews| 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 #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> | 9 #include <map> | 
| 10 #include <memory> | 10 #include <memory> | 
| 11 #include <string> | 11 #include <string> | 
| 12 #include <vector> | 12 #include <vector> | 
| 13 | 13 | 
| 14 #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" | 15 #include "chrome/browser/sync/test/integration/multi_client_status_change_checke r.h" | 
| 16 #include "chrome/browser/sync/test/integration/sync_test.h" | 16 #include "chrome/browser/sync/test/integration/sync_test.h" | 
| 17 #include "components/sessions/core/session_types.h" | 17 #include "components/sessions/core/session_types.h" | 
| 18 #include "components/sync/syncable/nigori_util.h" | 18 #include "components/sync/syncable/nigori_util.h" | 
| 19 #include "components/sync_sessions/synced_session.h" | 19 #include "components/sync_sessions/synced_session.h" | 
| 20 | 20 | 
| 21 class GURL; | 21 class GURL; | 
| 22 | 22 | 
| 23 namespace sessions_helper { | 23 namespace sessions_helper { | 
| 24 | 24 | 
| 25 using SyncedSessionVector = std::vector<const sync_sessions::SyncedSession*>; | 25 using SyncedSessionVector = std::vector<const sync_sessions::SyncedSession*>; | 
| 26 using SessionWindowMap = std::map<SessionID::id_type, sessions::SessionWindow*>; | 26 using SessionWindowMap = std::map<SessionID::id_type, sessions::SessionWindow*>; | 
| 27 using ScopedWindowMap = | 27 using ScopedWindowMap = | 
| 28 std::map<SessionID::id_type, std::unique_ptr<sessions::SessionWindow>>; | 28 std::map<SessionID::id_type, std::unique_ptr<sessions::SessionWindow>>; | 
| 29 | 29 | 
| 30 // Copies the local session windows of profile |index| to |local_windows|. | 30 // Copies the local session windows of profile at |index| to | 
| 31 // Returns true if successful. | 31 // |local_windows|. Returns true if successful. | 
| 
 
skym
2017/02/27 19:42:50
This now wraps too early.
 
Patrick Noland
2017/02/27 23:37:07
Done.
 
 | |
| 32 bool GetLocalWindows(int index, ScopedWindowMap* local_windows); | 32 bool GetLocalWindows(int index, ScopedWindowMap* local_windows); | 
| 33 | 33 | 
| 34 // Creates and verifies the creation of a new window for profile |index| with | |
| 35 // one tab displaying |url|. Copies the SessionWindow associated with the new | |
| 36 // window to |local_windows|. Returns true if successful. This call results in | |
| 37 // multiple sessions changes, and performs synchronous blocking. It is rare, but | |
| 38 // possible, that multiple sync cycle commits occur as a result of this call. | |
| 39 // Test cases should be written to handle this possibility, otherwise they may | |
| 40 // flake. | |
| 41 bool OpenTabAndGetLocalWindows(int index, | |
| 42 const GURL& url, | |
| 43 ScopedWindowMap* local_windows); | |
| 44 | |
| 45 // Checks that window count and foreign session count are 0. | 34 // Checks that window count and foreign session count are 0. | 
| 46 bool CheckInitialState(int index); | 35 bool CheckInitialState(int index); | 
| 47 | 36 | 
| 48 // Returns number of open windows for a profile. | 37 // Returns number of open windows for a profile. | 
| 49 int GetNumWindows(int index); | 38 int GetNumWindows(int index); | 
| 50 | 39 | 
| 51 // Returns number of foreign sessions for a profile. | 40 // Returns number of foreign sessions for a profile. | 
| 52 int GetNumForeignSessions(int index); | 41 int GetNumForeignSessions(int index); | 
| 53 | 42 | 
| 54 // Fills the sessions vector with the model associator's foreign session data. | 43 // Fills the sessions vector with the model associator's foreign session data. | 
| (...skipping 22 matching lines...) Expand all Loading... | |
| 77 // 3. number of tab navigations per tab, | 66 // 3. number of tab navigations per tab, | 
| 78 // 4. actual tab navigations contents | 67 // 4. actual tab navigations contents | 
| 79 // - false otherwise. | 68 // - false otherwise. | 
| 80 bool WindowsMatch(const ScopedWindowMap& win1, const ScopedWindowMap& win2); | 69 bool WindowsMatch(const ScopedWindowMap& win1, const ScopedWindowMap& win2); | 
| 81 bool WindowsMatch(const SessionWindowMap& win1, const ScopedWindowMap& win2); | 70 bool WindowsMatch(const SessionWindowMap& win1, const ScopedWindowMap& win2); | 
| 82 | 71 | 
| 83 // Retrieves the foreign sessions for a particular profile and compares them | 72 // Retrieves the foreign sessions for a particular profile and compares them | 
| 84 // with a reference SessionWindow list. | 73 // with a reference SessionWindow list. | 
| 85 // Returns true if the session windows of the foreign session matches the | 74 // Returns true if the session windows of the foreign session matches the | 
| 86 // reference. | 75 // reference. | 
| 87 bool CheckForeignSessionsAgainst( | 76 bool CheckForeignSessionsAgainst(int index, | 
| 88 int index, | 77 const std::vector<ScopedWindowMap>& windows); | 
| 89 const std::vector<ScopedWindowMap>& windows); | |
| 90 | 78 | 
| 91 // Open a single tab and block until the session model associator is aware | 79 // Open a single tab in the browser at |index| and block until the | 
| 92 // of it. Returns true upon success, false otherwise. | 80 // session model associator is aware of it. Returns true upon success, false | 
| 81 // otherwise. | |
| 93 bool OpenTab(int index, const GURL& url); | 82 bool OpenTab(int index, const GURL& url); | 
| 94 | 83 | 
| 84 // See OpenTab, except that the tab is opened in position |tab_index|. | |
| 85 // If |tab_index| is -1 or greater than the number of tabs, the tab will be | |
| 
 
skym
2017/02/27 19:42:50
Do we need to supposed -1 or greater? Can we just
 
Patrick Noland
2017/02/27 23:37:07
We don't use it but I wanted to honestly document
 
 | |
| 86 // appended to the end of the strip. i.e. if tab_index is 3 for a tab strip of | |
| 87 // size 1, the new tab will be in position 1. | |
| 88 bool OpenTabAtIndex(int index, int tab_index, const GURL& url); | |
| 89 | |
| 90 // Moves the tab in position |tab_index| in the TabStrip for browser at | |
| 91 // |from_index| to the TabStrip for browser at |to_index|. | |
| 92 void MoveTab(int from_index, int to_index, int tab_index); | |
| 
 
skym
2017/02/27 19:42:50
Do all these navigate methods block?
 
Patrick Noland
2017/02/27 23:37:07
No, of the Navigate* functions, only NavigateTab b
 
 | |
| 93 | |
| 94 // Navigate the active tab for browser in position |index| to the given | |
| 95 // url. | |
| 96 bool NavigateTab(int index, const GURL& url); | |
| 97 | |
| 98 // Navigate the active tab for browser in position |index| back by one; | |
| 99 // if this isn't possible, does nothing | |
| 100 void NavigateTabBack(int index); | |
| 101 | |
| 102 // Navigate the active tab for browser in position |index| forward by | |
| 103 // one; if this isn't possible, does nothing | |
| 104 void NavigateTabForward(int index); | |
| 105 | |
| 95 // Open multiple tabs and block until the session model associator is aware | 106 // Open multiple tabs and block until the session model associator is aware | 
| 96 // of all of them. Returns true on success, false on failure. | 107 // of all of them. Returns true on success, false on failure. | 
| 97 bool OpenMultipleTabs(int index, const std::vector<GURL>& urls); | 108 bool OpenMultipleTabs(int index, const std::vector<GURL>& urls); | 
| 98 | 109 | 
| 99 // Wait for a session change to propagate to the model associator. Will not | 110 // Wait for a session change to propagate to the model associator. Will not | 
| 100 // return until each url in |urls| has been found. | 111 // return until each url in |urls| has been found. | 
| 101 bool WaitForTabsToLoad(int index, const std::vector<GURL>& urls); | 112 bool WaitForTabsToLoad(int index, const std::vector<GURL>& urls); | 
| 102 | 113 | 
| 103 // Check if the session model associator's knows that the current open tab | 114 // Check if the session model associator's knows that the current open tab | 
| 104 // has this url. | 115 // has this url. | 
| (...skipping 22 matching lines...) Expand all Loading... | |
| 127 // StatusChangeChecker implementation. | 138 // StatusChangeChecker implementation. | 
| 128 bool IsExitConditionSatisfied() override; | 139 bool IsExitConditionSatisfied() override; | 
| 129 std::string GetDebugMessage() const override; | 140 std::string GetDebugMessage() const override; | 
| 130 | 141 | 
| 131 private: | 142 private: | 
| 132 int index_; | 143 int index_; | 
| 133 const std::vector<sessions_helper::ScopedWindowMap>& windows_; | 144 const std::vector<sessions_helper::ScopedWindowMap>& windows_; | 
| 134 }; | 145 }; | 
| 135 | 146 | 
| 136 #endif // CHROME_BROWSER_SYNC_TEST_INTEGRATION_SESSIONS_HELPER_H_ | 147 #endif // CHROME_BROWSER_SYNC_TEST_INTEGRATION_SESSIONS_HELPER_H_ | 
| OLD | NEW |