Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / browser / sync / test / integration / search_engines_helper.h
blobfc35109b392194e0fae6522e4e7c47b5c340fa64
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.
5 #ifndef CHROME_BROWSER_SYNC_TEST_INTEGRATION_SEARCH_ENGINES_HELPER_H_
6 #define CHROME_BROWSER_SYNC_TEST_INTEGRATION_SEARCH_ENGINES_HELPER_H_
8 #include <map>
9 #include <string>
11 #include "base/strings/string16.h"
13 class Profile;
14 class TemplateURL;
15 class TemplateURLService;
17 typedef std::map<std::string, const TemplateURL*> GUIDToTURLMap;
19 namespace search_engines_helper {
21 // Used to access the search engines within a particular sync profile.
22 TemplateURLService* GetServiceForBrowserContext(int profile_index);
24 // Used to access the search engines within the verifier sync profile.
25 TemplateURLService* GetVerifierService();
27 // Compared a single TemplateURLService for a given profile to the verifier.
28 // Retrns true iff their user-visible fields match.
29 bool ServiceMatchesVerifier(int profile_index);
31 // Blocks until either AllServicesMatch returns true or a timeout occurs.
32 // Returns true if AllServicesMatch succeeded, false if timeout.
33 bool AwaitAllServicesMatch();
35 // Returns true iff all TemplateURLServices match with the verifier.
36 bool AllServicesMatch();
38 // Create a TemplateURL with some test values based on |seed|. The caller owns
39 // the returned TemplateURL*.
40 TemplateURL* CreateTestTemplateURL(Profile* profile,
41 int seed,
42 const base::string16& keyword,
43 const std::string& sync_guid);
44 TemplateURL* CreateTestTemplateURL(Profile* profile,
45 int seed,
46 const base::string16& keyword,
47 const std::string& url,
48 const std::string& sync_guid);
50 // Add a search engine based on a seed to the service at index |profile_index|
51 // and the verifier if it is used.
52 void AddSearchEngine(int profile_index, int seed);
54 // Retrieves a search engine from the service at index |profile_index| with
55 // original keyword |keyword| and changes its user-visible fields. Does the same
56 // to the verifier, if it is used.
57 void EditSearchEngine(int profile_index,
58 const base::string16& keyword,
59 const base::string16& short_name,
60 const base::string16& new_keyword,
61 const std::string& url);
63 // Deletes a search engine from the service at index |profile_index| which was
64 // generated by seed |seed|.
65 void DeleteSearchEngineBySeed(int profile_index, int seed);
67 // Change the search engine generated with |seed| in service at index
68 // |profile_index| to be the new default. Does the same to the verifier, if it
69 // is used.
70 void ChangeDefaultSearchProvider(int profile_index, int seed);
72 // Returns true if the profile at |profile_index| has a search engine matching
73 // the search engine generated with |seed|.
74 bool HasSearchEngine(int profile_index, int seed);
76 } // namespace search_engines_helper
78 #endif // CHROME_BROWSER_SYNC_TEST_INTEGRATION_SEARCH_ENGINES_HELPER_H_