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