app_shell: Add version number in user agent
[chromium-blink-merge.git] / chrome / browser / search_engines / template_url_service_test_util.h
blob4833a9acdaa3330fbc130e2e9f715758e7adc765
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_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_TEST_UTIL_H_
6 #define CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_TEST_UTIL_H_
8 #include <string>
10 #include "base/basictypes.h"
11 #include "base/files/scoped_temp_dir.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/strings/string16.h"
14 #include "components/search_engines/template_url_service_observer.h"
15 #include "content/public/test/test_browser_thread_bundle.h"
17 class GURL;
18 class TemplateURLService;
19 class TestingProfile;
20 class TestingSearchTermsData;
21 class TestingTemplateURLService;
23 class TemplateURLServiceTestUtil : public TemplateURLServiceObserver {
24 public:
25 TemplateURLServiceTestUtil();
26 virtual ~TemplateURLServiceTestUtil();
28 // TemplateURLServiceObserver implemementation.
29 virtual void OnTemplateURLServiceChanged() OVERRIDE;
31 // Gets the observer count.
32 int GetObserverCount();
34 // Sets the observer count to 0.
35 void ResetObserverCount();
37 // Makes sure the load was successful and sent the correct notification.
38 void VerifyLoad();
40 // Makes the model believe it has been loaded (without actually doing the
41 // load). Since this avoids setting the built-in keyword version, the next
42 // load will do a merge from prepopulated data.
43 void ChangeModelToLoadState();
45 // Deletes the current model (and doesn't create a new one).
46 void ClearModel();
48 // Creates a new TemplateURLService.
49 void ResetModel(bool verify_load);
51 // Returns the search term from the last invocation of
52 // TemplateURLService::SetKeywordSearchTermsForURL and clears the search term.
53 base::string16 GetAndClearSearchTerm();
55 // Set the google base url. |base_url| must be valid.
56 void SetGoogleBaseURL(const GURL& base_url);
58 // Set the managed preferences for the default search provider and trigger
59 // notification. If |alternate_url| is empty, uses an empty list of alternate
60 // URLs, otherwise use a list containing a single entry.
61 void SetManagedDefaultSearchPreferences(
62 bool enabled,
63 const std::string& name,
64 const std::string& keyword,
65 const std::string& search_url,
66 const std::string& suggest_url,
67 const std::string& icon_url,
68 const std::string& encodings,
69 const std::string& alternate_url,
70 const std::string& search_terms_replacement_key);
72 // Remove all the managed preferences for the default search provider and
73 // trigger notification.
74 void RemoveManagedDefaultSearchPreferences();
76 // Returns the TemplateURLService.
77 TemplateURLService* model();
79 // Returns the TestingProfile.
80 TestingProfile* profile() { return profile_.get(); }
82 private:
83 content::TestBrowserThreadBundle thread_bundle_;
84 scoped_ptr<TestingProfile> profile_;
85 base::ScopedTempDir temp_dir_;
86 int changed_count_;
87 TestingSearchTermsData* search_terms_data_;
88 scoped_ptr<TestingTemplateURLService> model_;
90 DISALLOW_COPY_AND_ASSIGN(TemplateURLServiceTestUtil);
93 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_TEST_UTIL_H_