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

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

Issue 2725813003: reland of [sync] Add Sessions integration tests (Closed)
Patch Set: Switch back to WaitForURLOnServer, make everything a constant Created 3 years, 9 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> 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 |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
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
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
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 // 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
98 // indefinitely. Use a data uri or the embedded_test_server to ensure that this
99 // doesn't happen.
100 bool NavigateTab(int index, const GURL& url);
101
102 // Navigate the active tab for browser in position |index| back by one;
103 // if this isn't possible, does nothing
104 void NavigateTabBack(int index);
105
106 // Navigate the active tab for browser in position |index| forward by
107 // one; if this isn't possible, does nothing
108 void NavigateTabForward(int index);
109
95 // Open multiple tabs and block until the session model associator is aware 110 // Open multiple tabs and block until the session model associator is aware
96 // of all of them. Returns true on success, false on failure. 111 // of all of them. Returns true on success, false on failure.
97 bool OpenMultipleTabs(int index, const std::vector<GURL>& urls); 112 bool OpenMultipleTabs(int index, const std::vector<GURL>& urls);
98 113
99 // Wait for a session change to propagate to the model associator. Will not 114 // Wait for a session change to propagate to the model associator. Will not
100 // return until each url in |urls| has been found. 115 // return until each url in |urls| has been found.
101 bool WaitForTabsToLoad(int index, const std::vector<GURL>& urls); 116 bool WaitForTabsToLoad(int index, const std::vector<GURL>& urls);
102 117
103 // Check if the session model associator's knows that the current open tab 118 // Check if the session model associator's knows that the current open tab
104 // has this url. 119 // has this url.
(...skipping 22 matching lines...) Expand all
127 // StatusChangeChecker implementation. 142 // StatusChangeChecker implementation.
128 bool IsExitConditionSatisfied() override; 143 bool IsExitConditionSatisfied() override;
129 std::string GetDebugMessage() const override; 144 std::string GetDebugMessage() const override;
130 145
131 private: 146 private:
132 int index_; 147 int index_;
133 const std::vector<sessions_helper::ScopedWindowMap>& windows_; 148 const std::vector<sessions_helper::ScopedWindowMap>& windows_;
134 }; 149 };
135 150
136 #endif // CHROME_BROWSER_SYNC_TEST_INTEGRATION_SESSIONS_HELPER_H_ 151 #endif // CHROME_BROWSER_SYNC_TEST_INTEGRATION_SESSIONS_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698