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_SEARCH_ENGINES_HELPER_H_
6#define CHROME_BROWSER_SYNC_TEST_INTEGRATION_SEARCH_ENGINES_HELPER_H_
7
8#include <map>
9#include <string>
10
11#include "base/strings/string16.h"
12
13class Profile;
14class TemplateURL;
15class TemplateURLService;
16
17typedef std::map<std::string, const TemplateURL*> GUIDToTURLMap;
18
19namespace search_engines_helper {
20
21// Used to access the search engines within a particular sync profile.
22TemplateURLService* GetServiceForBrowserContext(int profile_index);
23
24// Used to access the search engines within the verifier sync profile.
25TemplateURLService* GetVerifierService();
26
27// Compared a single TemplateURLService for a given profile to the verifier.
28// Retrns true iff their user-visible fields match.
29bool ServiceMatchesVerifier(int profile_index);
30
31// Returns true iff all TemplateURLServices match with the verifier.
32bool AllServicesMatch();
33
34// Create a TemplateURL with some test values based on |seed|. The caller owns
35// the returned TemplateURL*.
36TemplateURL* CreateTestTemplateURL(Profile* profile,
37                                   int seed,
38                                   const base::string16& keyword,
39                                   const std::string& sync_guid);
40TemplateURL* CreateTestTemplateURL(Profile* profile,
41                                   int seed,
42                                   const base::string16& keyword,
43                                   const std::string& url,
44                                   const std::string& sync_guid);
45
46// Add a search engine based on a seed to the service at index |profile_index|
47// and the verifier if it is used.
48void AddSearchEngine(int profile_index, int seed);
49
50// Retrieves a search engine from the service at index |profile_index| with
51// original keyword |keyword| and changes its user-visible fields. Does the same
52// to the verifier, if it is used.
53void EditSearchEngine(int profile_index,
54                      const base::string16& keyword,
55                      const base::string16& short_name,
56                      const base::string16& new_keyword,
57                      const std::string& url);
58
59// Deletes a search engine from the service at index |profile_index| which was
60// generated by seed |seed|.
61void DeleteSearchEngineBySeed(int profile_index, int seed);
62
63// Change the search engine generated with |seed| in service at index
64// |profile_index| to be the new default. Does the same to the verifier, if it
65// is used.
66void ChangeDefaultSearchProvider(int profile_index, int seed);
67
68}  // namespace search_engines_helper
69
70#endif  // CHROME_BROWSER_SYNC_TEST_INTEGRATION_SEARCH_ENGINES_HELPER_H_
71