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 3// found in the LICENSE file. 4 5#ifndef CHROME_BROWSER_SYNC_TEST_INTEGRATION_TYPED_URLS_HELPER_H_ 6#define CHROME_BROWSER_SYNC_TEST_INTEGRATION_TYPED_URLS_HELPER_H_ 7 8#include <vector> 9 10#include "components/history/core/browser/history_types.h" 11#include "ui/base/page_transition_types.h" 12 13namespace base { 14class Time; 15} 16 17namespace typed_urls_helper { 18 19// Gets the typed URLs from a specific sync profile. 20history::URLRows GetTypedUrlsFromClient(int index); 21 22// Gets a specific url from a specific sync profile. Returns false if the URL 23// was not found in the history DB. 24bool GetUrlFromClient(int index, const GURL& url, history::URLRow* row); 25 26// Gets the visits for a URL from a specific sync profile. 27history::VisitVector GetVisitsFromClient(int index, history::URLID id); 28 29// Removes the passed |visits| from a specific sync profile. 30void RemoveVisitsFromClient(int index, const history::VisitVector& visits); 31 32// Adds a URL to the history DB for a specific sync profile (just registers a 33// new visit if the URL already exists) using a TYPED PageTransition. 34void AddUrlToHistory(int index, const GURL& url); 35 36// Adds a URL to the history DB for a specific sync profile (just registers a 37// new visit if the URL already exists), using the passed PageTransition. 38void AddUrlToHistoryWithTransition(int index, 39 const GURL& url, 40 ui::PageTransition transition, 41 history::VisitSource source); 42 43// Adds a URL to the history DB for a specific sync profile (just registers a 44// new visit if the URL already exists), using the passed PageTransition and 45// timestamp. 46void AddUrlToHistoryWithTimestamp(int index, 47 const GURL& url, 48 ui::PageTransition transition, 49 history::VisitSource source, 50 const base::Time& timestamp); 51 52// Deletes a URL from the history DB for a specific sync profile. 53void DeleteUrlFromHistory(int index, const GURL& url); 54 55// Deletes a list of URLs from the history DB for a specific sync 56// profile. 57void DeleteUrlsFromHistory(int index, const std::vector<GURL>& urls); 58 59// Returns true if all clients match the verifier profile. 60bool CheckAllProfilesHaveSameURLsAsVerifier(); 61 62// Returns true if all clients match the verifier profile and if the 63// verification doesn't time out. 64bool AwaitCheckAllProfilesHaveSameURLsAsVerifier(); 65 66// Checks that the two vectors contain the same set of URLRows (possibly in 67// a different order). 68bool CheckURLRowVectorsAreEqual(const history::URLRows& left, 69 const history::URLRows& right); 70 71// Checks that the passed URLRows are equivalent. 72bool CheckURLRowsAreEqual(const history::URLRow& left, 73 const history::URLRow& right); 74 75// Returns true if two sets of visits are equivalent. 76bool AreVisitsEqual(const history::VisitVector& visit1, 77 const history::VisitVector& visit2); 78 79// Returns true if there are no duplicate visit times. 80bool AreVisitsUnique(const history::VisitVector& visits); 81 82// Returns a unique timestamp to use when generating page visits 83// (HistoryService does not like having identical timestamps and will modify 84// the timestamps behind the scenes if it encounters them, which leads to 85// spurious test failures when the resulting timestamps aren't what we 86// expect). 87base::Time GetTimestamp(); 88 89} // namespace typed_urls_helper 90 91#endif // CHROME_BROWSER_SYNC_TEST_INTEGRATION_TYPED_URLS_HELPER_H_ 92