- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / browser / sync / test / integration / typed_urls_helper.h
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 "chrome/browser/history/history_types.h"
11 #include "content/public/common/page_transition_types.h"
12
13 namespace base {
14 class Time;
15 }
16
17 namespace typed_urls_helper {
18
19 // Gets the typed URLs from a specific sync profile.
20 history::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.
24 bool GetUrlFromClient(int index, const GURL& url, history::URLRow* row);
25
26 // Gets the visits for a URL from a specific sync profile.
27 history::VisitVector GetVisitsFromClient(int index, history::URLID id);
28
29 // Removes the passed |visits| from a specific sync profile.
30 void 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.
34 void 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.
38 void AddUrlToHistoryWithTransition(int index,
39                                    const GURL& url,
40                                    content::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.
46 void AddUrlToHistoryWithTimestamp(int index,
47                                   const GURL& url,
48                                   content::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.
53 void DeleteUrlFromHistory(int index, const GURL& url);
54
55 // Deletes a list of URLs from the history DB for a specific sync
56 // profile.
57 void DeleteUrlsFromHistory(int index, const std::vector<GURL>& urls);
58
59 // Returns true if all clients match the verifier profile.
60 void AssertAllProfilesHaveSameURLsAsVerifier();
61
62 // Checks that the two vectors contain the same set of URLRows (possibly in
63 // a different order).
64 void AssertURLRowVectorsAreEqual(const history::URLRows& left,
65                                  const history::URLRows& right);
66
67 // Checks that the passed URLRows are equivalent.
68 void AssertURLRowsAreEqual(const history::URLRow& left,
69                            const history::URLRow& right);
70
71 // Returns true if two sets of visits are equivalent.
72 bool AreVisitsEqual(const history::VisitVector& visit1,
73                     const history::VisitVector& visit2);
74
75 // Returns true if there are no duplicate visit times.
76 bool AreVisitsUnique(const history::VisitVector& visits);
77
78 // Returns a unique timestamp to use when generating page visits
79 // (HistoryService does not like having identical timestamps and will modify
80 // the timestamps behind the scenes if it encounters them, which leads to
81 // spurious test failures when the resulting timestamps aren't what we
82 // expect).
83 base::Time GetTimestamp();
84
85 }  // namespace typed_urls_helper
86
87 #endif  // CHROME_BROWSER_SYNC_TEST_INTEGRATION_TYPED_URLS_HELPER_H_