typed_urls_helper.h revision 5821806d5e7f356e8fa4b058a389a808ea183019
190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved.
290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// found in the LICENSE file.
490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#ifndef CHROME_BROWSER_SYNC_TEST_INTEGRATION_TYPED_URLS_HELPER_H_
690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#define CHROME_BROWSER_SYNC_TEST_INTEGRATION_TYPED_URLS_HELPER_H_
7116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch
890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include <vector>
990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
1090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include "chrome/browser/history/history_types.h"
1190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include "content/public/common/page_transition_types.h"
1290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
1390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)namespace base {
1490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)class Time;
1590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)}
1690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
1790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)namespace typed_urls_helper {
1890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
1990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// Gets the typed URLs from a specific sync profile.
2090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)history::URLRows GetTypedUrlsFromClient(int index);
2190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
2290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// Gets a specific url from a specific sync profile. Returns false if the URL
2390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// was not found in the history DB.
2490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)bool GetUrlFromClient(int index, const GURL& url, history::URLRow* row);
2590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
2690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// Gets the visits for a URL from a specific sync profile.
2790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)history::VisitVector GetVisitsFromClient(int index, history::URLID id);
2890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
2990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// Removes the passed |visits| from a specific sync profile.
3090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)void RemoveVisitsFromClient(int index, const history::VisitVector& visits);
3190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
3290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// Adds a URL to the history DB for a specific sync profile (just registers a
3390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// new visit if the URL already exists) using a TYPED PageTransition.
347d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)void AddUrlToHistory(int index, const GURL& url);
3590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
3690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// Adds a URL to the history DB for a specific sync profile (just registers a
3790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// new visit if the URL already exists), using the passed PageTransition.
3890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)void AddUrlToHistoryWithTransition(int index,
3990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                   const GURL& url,
405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                                   content::PageTransition transition,
4190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                   history::VisitSource source);
4290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
4390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// Adds a URL to the history DB for a specific sync profile (just registers a
4490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// new visit if the URL already exists), using the passed PageTransition and
4590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// timestamp.
4690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)void AddUrlToHistoryWithTimestamp(int index,
4790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                  const GURL& url,
4890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                  content::PageTransition transition,
4990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                  history::VisitSource source,
5090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                  const base::Time& timestamp);
5190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
5290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// Deletes a URL from the history DB for a specific sync profile.
5390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)void DeleteUrlFromHistory(int index, const GURL& url);
5490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
5590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// Deletes a list of URLs from the history DB for a specific sync
5690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// profile.
5790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)void DeleteUrlsFromHistory(int index, const std::vector<GURL>& urls);
5890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
5990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// Returns true if all clients match the verifier profile.
6090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)void AssertAllProfilesHaveSameURLsAsVerifier();
6190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
6290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// Checks that the two vectors contain the same set of URLRows (possibly in
6390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// a different order).
6490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)void AssertURLRowVectorsAreEqual(const history::URLRows& left,
6590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                 const history::URLRows& right);
6690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
6790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// Checks that the passed URLRows are equivalent.
6890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)void AssertURLRowsAreEqual(const history::URLRow& left,
6990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                           const history::URLRow& right);
7090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
7190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// Returns true if two sets of visits are equivalent.
7290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)bool AreVisitsEqual(const history::VisitVector& visit1,
7390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                    const history::VisitVector& visit2);
7490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
7590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// Returns true if there are no duplicate visit times.
7690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)bool AreVisitsUnique(const history::VisitVector& visits);
7790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
7890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// Returns a unique timestamp to use when generating page visits
7990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// (HistoryService does not like having identical timestamps and will modify
8090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// the timestamps behind the scenes if it encounters them, which leads to
8190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// spurious test failures when the resulting timestamps aren't what we
8290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// expect).
8390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)base::Time GetTimestamp();
84
85}  // namespace typed_urls_helper
86
87#endif  // CHROME_BROWSER_SYNC_TEST_INTEGRATION_TYPED_URLS_HELPER_H_
88