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 at |index| to |local_windows|. | 30 // Copies the local session windows of profile |index| to |local_windows|. |
31 // Returns true if successful. | 31 // Returns true if successful. |
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 |
34 // Checks that window count and foreign session count are 0. | 45 // Checks that window count and foreign session count are 0. |
35 bool CheckInitialState(int index); | 46 bool CheckInitialState(int index); |
36 | 47 |
37 // Returns number of open windows for a profile. | 48 // Returns number of open windows for a profile. |
38 int GetNumWindows(int index); | 49 int GetNumWindows(int index); |
39 | 50 |
40 // Returns number of foreign sessions for a profile. | 51 // Returns number of foreign sessions for a profile. |
41 int GetNumForeignSessions(int index); | 52 int GetNumForeignSessions(int index); |
42 | 53 |
43 // Fills the sessions vector with the model associator's foreign session data. | 54 // Fills the sessions vector with the model associator's foreign session data. |
(...skipping 22 matching lines...) Expand all Loading... |
66 // 3. number of tab navigations per tab, | 77 // 3. number of tab navigations per tab, |
67 // 4. actual tab navigations contents | 78 // 4. actual tab navigations contents |
68 // - false otherwise. | 79 // - false otherwise. |
69 bool WindowsMatch(const ScopedWindowMap& win1, const ScopedWindowMap& win2); | 80 bool WindowsMatch(const ScopedWindowMap& win1, const ScopedWindowMap& win2); |
70 bool WindowsMatch(const SessionWindowMap& win1, const ScopedWindowMap& win2); | 81 bool WindowsMatch(const SessionWindowMap& win1, const ScopedWindowMap& win2); |
71 | 82 |
72 // Retrieves the foreign sessions for a particular profile and compares them | 83 // Retrieves the foreign sessions for a particular profile and compares them |
73 // with a reference SessionWindow list. | 84 // with a reference SessionWindow list. |
74 // Returns true if the session windows of the foreign session matches the | 85 // Returns true if the session windows of the foreign session matches the |
75 // reference. | 86 // reference. |
76 bool CheckForeignSessionsAgainst(int index, | 87 bool CheckForeignSessionsAgainst( |
77 const std::vector<ScopedWindowMap>& windows); | 88 int index, |
| 89 const std::vector<ScopedWindowMap>& windows); |
78 | 90 |
79 // Open a single tab in the browser at |index| and block until the | 91 // Open a single tab and block until the session model associator is aware |
80 // session model associator is aware of it. Returns true upon success, false | 92 // of it. Returns true upon success, false otherwise. |
81 // otherwise. | |
82 bool OpenTab(int index, const GURL& url); | 93 bool OpenTab(int index, const GURL& url); |
83 | 94 |
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 | |
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); | |
93 | |
94 // 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. | |
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 | |
106 // Open multiple tabs and block until the session model associator is aware | 95 // Open multiple tabs and block until the session model associator is aware |
107 // of all of them. Returns true on success, false on failure. | 96 // of all of them. Returns true on success, false on failure. |
108 bool OpenMultipleTabs(int index, const std::vector<GURL>& urls); | 97 bool OpenMultipleTabs(int index, const std::vector<GURL>& urls); |
109 | 98 |
110 // Wait for a session change to propagate to the model associator. Will not | 99 // Wait for a session change to propagate to the model associator. Will not |
111 // return until each url in |urls| has been found. | 100 // return until each url in |urls| has been found. |
112 bool WaitForTabsToLoad(int index, const std::vector<GURL>& urls); | 101 bool WaitForTabsToLoad(int index, const std::vector<GURL>& urls); |
113 | 102 |
114 // Check if the session model associator's knows that the current open tab | 103 // Check if the session model associator's knows that the current open tab |
115 // has this url. | 104 // has this url. |
(...skipping 22 matching lines...) Expand all Loading... |
138 // StatusChangeChecker implementation. | 127 // StatusChangeChecker implementation. |
139 bool IsExitConditionSatisfied() override; | 128 bool IsExitConditionSatisfied() override; |
140 std::string GetDebugMessage() const override; | 129 std::string GetDebugMessage() const override; |
141 | 130 |
142 private: | 131 private: |
143 int index_; | 132 int index_; |
144 const std::vector<sessions_helper::ScopedWindowMap>& windows_; | 133 const std::vector<sessions_helper::ScopedWindowMap>& windows_; |
145 }; | 134 }; |
146 | 135 |
147 #endif // CHROME_BROWSER_SYNC_TEST_INTEGRATION_SESSIONS_HELPER_H_ | 136 #endif // CHROME_BROWSER_SYNC_TEST_INTEGRATION_SESSIONS_HELPER_H_ |
OLD | NEW |