| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_SYNC_TEST_LIVE_SYNC_SESSIONS_HELPER_H_ | |
| 6 #define CHROME_BROWSER_SYNC_TEST_LIVE_SYNC_SESSIONS_HELPER_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include <algorithm> | |
| 10 #include <vector> | |
| 11 | |
| 12 #include "base/compiler_specific.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" | |
| 16 #include "chrome/browser/sync/test/live_sync/live_sync_test.h" | |
| 17 | |
| 18 class GURL; | |
| 19 | |
| 20 typedef std::vector<const browser_sync::SyncedSession*> SyncedSessionVector; | |
| 21 typedef std::vector<SessionWindow*> SessionWindowVector; | |
| 22 | |
| 23 namespace sessions_helper { | |
| 24 | |
| 25 // Copies the local session windows of profile |index| to |local_windows|. | |
| 26 // Returns true if successful. | |
| 27 bool GetLocalWindows(int index, SessionWindowVector& local_windows); | |
| 28 | |
| 29 // 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 | |
| 31 // window to |local_windows|. Returns true if successful. | |
| 32 bool OpenTabAndGetLocalWindows(int index, | |
| 33 const GURL& url, | |
| 34 SessionWindowVector& local_windows); | |
| 35 | |
| 36 // Checks that window count and foreign session count are 0. | |
| 37 bool CheckInitialState(int index); | |
| 38 | |
| 39 // Returns number of open windows for a profile. | |
| 40 int GetNumWindows(int index); | |
| 41 | |
| 42 // Returns number of foreign sessions for a profile. | |
| 43 int GetNumForeignSessions(int index); | |
| 44 | |
| 45 // Fills the sessions vector with the model associator's foreign session data. | |
| 46 // Caller owns |sessions|, but not SyncedSessions objects within. | |
| 47 bool GetSessionData(int index, SyncedSessionVector* sessions); | |
| 48 | |
| 49 // Compare session windows based on their first tab's url. | |
| 50 // Returns true if the virtual url of the lhs is < the rhs. | |
| 51 bool CompareSessionWindows(SessionWindow* lhs, SessionWindow* rhs); | |
| 52 | |
| 53 // Sort session windows using our custom comparator (first tab url | |
| 54 // comparison). | |
| 55 void SortSessionWindows(SessionWindowVector& windows); | |
| 56 | |
| 57 // Compares a foreign session based on the first session window. | |
| 58 // Returns true based on the comparison of the session windows. | |
| 59 bool CompareSyncedSessions(const browser_sync::SyncedSession* lhs, | |
| 60 const browser_sync::SyncedSession* rhs); | |
| 61 | |
| 62 // Sort a SyncedSession vector using our custom SyncedSession comparator. | |
| 63 void SortSyncedSessions(SyncedSessionVector* sessions); | |
| 64 | |
| 65 // Compares two tab navigations base on the parameters we sync. | |
| 66 // (Namely, we don't sync state or type mask) | |
| 67 bool NavigationEquals(const TabNavigation& expected, | |
| 68 const TabNavigation& actual); | |
| 69 | |
| 70 // Verifies that two SessionWindows match. | |
| 71 // Returns: | |
| 72 // - true if all the following match: | |
| 73 // 1. number of SessionWindows, | |
| 74 // 2. number of tabs per SessionWindow, | |
| 75 // 3. number of tab navigations per tab, | |
| 76 // 4. actual tab navigations contents | |
| 77 // - false otherwise. | |
| 78 bool WindowsMatch(const SessionWindowVector& win1, | |
| 79 const SessionWindowVector& win2); | |
| 80 | |
| 81 // Retrieves the foreign sessions for a particular profile and compares them | |
| 82 // with a reference SessionWindow list. | |
| 83 // Returns true if the session windows of the foreign session matches the | |
| 84 // reference. | |
| 85 bool CheckForeignSessionsAgainst( | |
| 86 int index, | |
| 87 const std::vector<SessionWindowVector*>& windows); | |
| 88 | |
| 89 // Open a single tab and block until the session model associator is aware | |
| 90 // of it. Returns true upon success, false otherwise. | |
| 91 bool OpenTab(int index, const GURL& url); | |
| 92 | |
| 93 // Open multiple tabs and block until the session model associator is aware | |
| 94 // of all of them. Returns true on success, false on failure. | |
| 95 bool OpenMultipleTabs(int index, const std::vector<GURL>& urls); | |
| 96 | |
| 97 // Wait for a session change to propagate to the model associator. Will not | |
| 98 // return until each url in |urls| has been found. | |
| 99 bool WaitForTabsToLoad(int index, const std::vector<GURL>& urls); | |
| 100 | |
| 101 // Check if the session model associator's knows that the current open tab | |
| 102 // has this url. | |
| 103 bool ModelAssociatorHasTabWithUrl(int index, const GURL& url); | |
| 104 | |
| 105 // Stores a pointer to the local session for a given profile in |session|. | |
| 106 // Returns true on success, false on failure. | |
| 107 bool GetLocalSession(int index, const browser_sync::SyncedSession** session); | |
| 108 | |
| 109 } // namespace sessions_helper | |
| 110 | |
| 111 #endif // CHROME_BROWSER_SYNC_TEST_LIVE_SYNC_SESSIONS_HELPER_H_ | |
| OLD | NEW |