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> |
(...skipping 22 matching lines...) Expand all Loading... |
33 | 33 |
34 // Checks that window count and foreign session count are 0. | 34 // Checks that window count and foreign session count are 0. |
35 bool CheckInitialState(int index); | 35 bool CheckInitialState(int index); |
36 | 36 |
37 // Returns number of open windows for a profile. | 37 // Returns number of open windows for a profile. |
38 int GetNumWindows(int index); | 38 int GetNumWindows(int index); |
39 | 39 |
40 // Returns number of foreign sessions for a profile. | 40 // Returns number of foreign sessions for a profile. |
41 int GetNumForeignSessions(int index); | 41 int GetNumForeignSessions(int index); |
42 | 42 |
43 // Fills the sessions vector with the model associator's foreign session data. | 43 // Fills the sessions vector with the SyncableService's foreign session data. |
44 // Caller owns |sessions|, but not SyncedSessions objects within. | 44 // Caller owns |sessions|, but not SyncedSessions objects within. |
45 // Returns true if foreign sessions were found, false otherwise. | 45 // Returns true if foreign sessions were found, false otherwise. |
46 bool GetSessionData(int index, SyncedSessionVector* sessions); | 46 bool GetSessionData(int index, SyncedSessionVector* sessions); |
47 | 47 |
48 // Compares a foreign session based on the first session window. | 48 // Compares a foreign session based on the first session window. |
49 // Returns true based on the comparison of the session windows. | 49 // Returns true based on the comparison of the session windows. |
50 bool CompareSyncedSessions(const sync_sessions::SyncedSession* lhs, | 50 bool CompareSyncedSessions(const sync_sessions::SyncedSession* lhs, |
51 const sync_sessions::SyncedSession* rhs); | 51 const sync_sessions::SyncedSession* rhs); |
52 | 52 |
53 // Sort a SyncedSession vector using our custom SyncedSession comparator. | 53 // Sort a SyncedSession vector using our custom SyncedSession comparator. |
(...skipping 16 matching lines...) Expand all Loading... |
70 bool WindowsMatch(const SessionWindowMap& win1, const ScopedWindowMap& win2); | 70 bool WindowsMatch(const SessionWindowMap& win1, const ScopedWindowMap& win2); |
71 | 71 |
72 // Retrieves the foreign sessions for a particular profile and compares them | 72 // Retrieves the foreign sessions for a particular profile and compares them |
73 // with a reference SessionWindow list. | 73 // with a reference SessionWindow list. |
74 // 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 |
75 // reference. | 75 // reference. |
76 bool CheckForeignSessionsAgainst(int index, | 76 bool CheckForeignSessionsAgainst(int index, |
77 const std::vector<ScopedWindowMap>& windows); | 77 const std::vector<ScopedWindowMap>& windows); |
78 | 78 |
79 // Open a single tab in the browser at |index| and block until the | 79 // Open a single tab in the browser at |index| and block until the |
80 // session model associator is aware of it. Returns true upon success, false | 80 // session SyncableService is aware of it. Returns true upon success, false |
81 // otherwise. | 81 // otherwise. |
82 bool OpenTab(int index, const GURL& url); | 82 bool OpenTab(int index, const GURL& url); |
83 | 83 |
84 // See OpenTab, except that the tab is opened in position |tab_index|. | 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 | 85 // If |tab_index| is -1 or greater than the number of tabs, the tab will be |
86 // appended to the end of the strip. i.e. if tab_index is 3 for a tab strip of | 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. | 87 // size 1, the new tab will be in position 1. |
88 bool OpenTabAtIndex(int index, int tab_index, const GURL& url); | 88 bool OpenTabAtIndex(int index, int tab_index, const GURL& url); |
89 | 89 |
| 90 // Like OpenTab, but opens |url| from the tab at |index_of_source_tab| using |
| 91 // |disposition|. |
| 92 bool OpenTabFromSourceIndex(int index, |
| 93 int index_of_source_tab, |
| 94 const GURL& url, |
| 95 WindowOpenDisposition disposition); |
| 96 |
| 97 // Open multiple tabs and block until the session SyncableService is aware |
| 98 // of all of them. Returns true on success, false on failure. |
| 99 bool OpenMultipleTabs(int index, const std::vector<GURL>& urls); |
| 100 |
90 // Moves the tab in position |tab_index| in the TabStrip for browser at | 101 // Moves the tab in position |tab_index| in the TabStrip for browser at |
91 // |from_index| to the TabStrip for browser at |to_index|. | 102 // |from_index| to the TabStrip for browser at |to_index|. |
92 void MoveTab(int from_index, int to_index, int tab_index); | 103 void MoveTab(int from_index, int to_index, int tab_index); |
93 | 104 |
94 // Navigate the active tab for browser in position |index| to the given | 105 // Navigate the active tab for browser in position |index| to the given |
95 // url, and blocks until the session model associator is aware of it. | 106 // url, and blocks until the session SyncableService is aware of it. |
96 // WARNING: it's dangerous to assume this will return for any arbitrary URL. | 107 // WARNING: it's dangerous to assume this will return for any arbitrary URL. |
97 // For URLs that don't resolve to a valid server response, this can block | 108 // For URLs that don't resolve to a valid server response, this can block |
98 // indefinitely. Use a data uri or the embedded_test_server to ensure that this | 109 // indefinitely. Use a data uri or the embedded_test_server to ensure that this |
99 // doesn't happen. | 110 // doesn't happen. |
100 bool NavigateTab(int index, const GURL& url); | 111 bool NavigateTab(int index, const GURL& url); |
101 | 112 |
102 // Navigate the active tab for browser in position |index| back by one; | 113 // Navigate the active tab for browser in position |index| back by one; |
103 // if this isn't possible, does nothing | 114 // if this isn't possible, does nothing |
104 void NavigateTabBack(int index); | 115 void NavigateTabBack(int index); |
105 | 116 |
106 // Navigate the active tab for browser in position |index| forward by | 117 // Navigate the active tab for browser in position |index| forward by |
107 // one; if this isn't possible, does nothing | 118 // one; if this isn't possible, does nothing |
108 void NavigateTabForward(int index); | 119 void NavigateTabForward(int index); |
109 | 120 |
110 // Open multiple tabs and block until the session model associator is aware | 121 // Wait for a session change to |web_contents| to propagate to the model |
111 // of all of them. Returns true on success, false on failure. | 122 // associator. Will return true once |url| has been found, or false if it times |
112 bool OpenMultipleTabs(int index, const std::vector<GURL>& urls); | 123 // out while waiting. |
| 124 bool WaitForTabToLoad(int index, |
| 125 const GURL& url, |
| 126 content::WebContents* web_contents); |
113 | 127 |
114 // Wait for a session change to propagate to the model associator. Will not | 128 // Wait for each url in |urls| to load. The ordering of |urls| is assumed to |
115 // return until each url in |urls| has been found. | 129 // match the ordering of the corresponding tabs. |
116 bool WaitForTabsToLoad(int index, const std::vector<GURL>& urls); | 130 bool WaitForTabsToLoad(int index, const std::vector<GURL>& urls); |
117 | 131 |
118 // Check if the session model associator's knows that the current open tab | 132 // Check if the session SyncableService knows that the current open tab |
119 // has this url. | 133 // has this url. |
120 bool ModelAssociatorHasTabWithUrl(int index, const GURL& url); | 134 bool SessionsSyncManagerHasTabWithURL(int index, const GURL& url); |
121 | 135 |
122 // Stores a pointer to the local session for a given profile in |session|. | 136 // Stores a pointer to the local session for a given profile in |session|. |
123 // Returns true on success, false on failure. | 137 // Returns true on success, false on failure. |
124 bool GetLocalSession(int index, const sync_sessions::SyncedSession** session); | 138 bool GetLocalSession(int index, const sync_sessions::SyncedSession** session); |
125 | 139 |
126 // Deletes the foreign session with tag |session_tag| from the profile specified | 140 // Deletes the foreign session with tag |session_tag| from the profile specified |
127 // by |index|. This will affect all synced clients. | 141 // by |index|. This will affect all synced clients. |
128 // Note: We pass the session_tag in by value to ensure it's not a reference | 142 // Note: We pass the session_tag in by value to ensure it's not a reference |
129 // to the session tag within the SyncedSession we plan to delete. | 143 // to the session tag within the SyncedSession we plan to delete. |
130 void DeleteForeignSession(int index, std::string session_tag); | 144 void DeleteForeignSession(int index, std::string session_tag); |
(...skipping 11 matching lines...) Expand all Loading... |
142 // StatusChangeChecker implementation. | 156 // StatusChangeChecker implementation. |
143 bool IsExitConditionSatisfied() override; | 157 bool IsExitConditionSatisfied() override; |
144 std::string GetDebugMessage() const override; | 158 std::string GetDebugMessage() const override; |
145 | 159 |
146 private: | 160 private: |
147 int index_; | 161 int index_; |
148 const std::vector<sessions_helper::ScopedWindowMap>& windows_; | 162 const std::vector<sessions_helper::ScopedWindowMap>& windows_; |
149 }; | 163 }; |
150 | 164 |
151 #endif // CHROME_BROWSER_SYNC_TEST_INTEGRATION_SESSIONS_HELPER_H_ | 165 #endif // CHROME_BROWSER_SYNC_TEST_INTEGRATION_SESSIONS_HELPER_H_ |
OLD | NEW |