OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_TEST_LIVE_SYNC_SESSIONS_HELPER_H_ | 5 #ifndef CHROME_TEST_LIVE_SYNC_SESSIONS_HELPER_H_ |
6 #define CHROME_TEST_LIVE_SYNC_SESSIONS_HELPER_H_ | 6 #define CHROME_TEST_LIVE_SYNC_SESSIONS_HELPER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "chrome/browser/sessions/session_types.h" | 13 #include "chrome/browser/sessions/session_types.h" |
14 #include "chrome/browser/sync/glue/synced_session.h" | |
15 #include "chrome/browser/sync/engine/nigori_util.h" | 14 #include "chrome/browser/sync/engine/nigori_util.h" |
16 #include "chrome/test/live_sync/live_sync_test.h" | 15 #include "chrome/test/live_sync/live_sync_test.h" |
17 | 16 |
18 class GURL; | 17 class GURL; |
19 | 18 |
20 typedef std::vector<const browser_sync::SyncedSession*> SyncedSessionVector; | 19 typedef std::vector<const SyncedSession*> SyncedSessionVector; |
21 typedef std::vector<SessionWindow*> SessionWindowVector; | 20 typedef std::vector<SessionWindow*> SessionWindowVector; |
22 | 21 |
23 namespace sessions_helper { | 22 namespace sessions_helper { |
24 | 23 |
25 // Copies the local session windows of profile |index| to |local_windows|. | 24 // Copies the local session windows of profile |index| to |local_windows|. |
26 // Returns true if successful. | 25 // Returns true if successful. |
27 bool GetLocalWindows(int index, SessionWindowVector& local_windows); | 26 bool GetLocalWindows(int index, SessionWindowVector& local_windows); |
28 | 27 |
29 // Creates and verifies the creation of a new window for profile |index| with | 28 // Creates and verifies the creation of a new window for profile |index| with |
30 // one tab displaying |url|. Copies the SessionWindow associated with the new | 29 // one tab displaying |url|. Copies the SessionWindow associated with the new |
(...skipping 18 matching lines...) Expand all Loading... |
49 // Compare session windows based on their first tab's url. | 48 // Compare session windows based on their first tab's url. |
50 // Returns true if the virtual url of the lhs is < the rhs. | 49 // Returns true if the virtual url of the lhs is < the rhs. |
51 bool CompareSessionWindows(SessionWindow* lhs, SessionWindow* rhs); | 50 bool CompareSessionWindows(SessionWindow* lhs, SessionWindow* rhs); |
52 | 51 |
53 // Sort session windows using our custom comparator (first tab url | 52 // Sort session windows using our custom comparator (first tab url |
54 // comparison). | 53 // comparison). |
55 void SortSessionWindows(SessionWindowVector& windows); | 54 void SortSessionWindows(SessionWindowVector& windows); |
56 | 55 |
57 // Compares a foreign session based on the first session window. | 56 // Compares a foreign session based on the first session window. |
58 // Returns true based on the comparison of the session windows. | 57 // Returns true based on the comparison of the session windows. |
59 bool CompareSyncedSessions(const browser_sync::SyncedSession* lhs, | 58 bool CompareSyncedSessions(const SyncedSession* lhs, const SyncedSession* rhs); |
60 const browser_sync::SyncedSession* rhs); | |
61 | 59 |
62 // Sort a SyncedSession vector using our custom SyncedSession comparator. | 60 // Sort a SyncedSession vector using our custom SyncedSession comparator. |
63 void SortSyncedSessions(SyncedSessionVector* sessions); | 61 void SortSyncedSessions(SyncedSessionVector* sessions); |
64 | 62 |
65 // Compares two tab navigations base on the parameters we sync. | 63 // Compares two tab navigations base on the parameters we sync. |
66 // (Namely, we don't sync state or type mask) | 64 // (Namely, we don't sync state or type mask) |
67 bool NavigationEquals(const TabNavigation& expected, | 65 bool NavigationEquals(const TabNavigation& expected, |
68 const TabNavigation& actual); | 66 const TabNavigation& actual); |
69 | 67 |
70 // Verifies that two SessionWindows match. | 68 // Verifies that two SessionWindows match. |
(...skipping 26 matching lines...) Expand all Loading... |
97 // Wait for a session change to propagate to the model associator. Will not | 95 // Wait for a session change to propagate to the model associator. Will not |
98 // return until each url in |urls| has been found. | 96 // return until each url in |urls| has been found. |
99 bool WaitForTabsToLoad(int index, const std::vector<GURL>& urls); | 97 bool WaitForTabsToLoad(int index, const std::vector<GURL>& urls); |
100 | 98 |
101 // Check if the session model associator's knows that the current open tab | 99 // Check if the session model associator's knows that the current open tab |
102 // has this url. | 100 // has this url. |
103 bool ModelAssociatorHasTabWithUrl(int index, const GURL& url); | 101 bool ModelAssociatorHasTabWithUrl(int index, const GURL& url); |
104 | 102 |
105 // Stores a pointer to the local session for a given profile in |session|. | 103 // Stores a pointer to the local session for a given profile in |session|. |
106 // Returns true on success, false on failure. | 104 // Returns true on success, false on failure. |
107 bool GetLocalSession(int index, const browser_sync::SyncedSession** session); | 105 bool GetLocalSession(int index, const SyncedSession** session); |
108 | 106 |
109 } // namespace sessions_helper | 107 } // namespace sessions_helper |
110 | 108 |
111 #endif // CHROME_TEST_LIVE_SYNC_SESSIONS_HELPER_H_ | 109 #endif // CHROME_TEST_LIVE_SYNC_SESSIONS_HELPER_H_ |
OLD | NEW |