1 // Copyright 2014 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_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_FACTORY_TEST_UTIL_H_ 6 #define CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_FACTORY_TEST_UTIL_H_ 7 8 #include <string> 9 10 #include "base/basictypes.h" 11 12 class TemplateURLService; 13 class TestingProfile; 14 15 // TemplateURLServiceFactoryTestUtil initializes TemplateURLServiceFactory to 16 // return a valid TemplateURLService instance for the given profile. 17 class TemplateURLServiceFactoryTestUtil { 18 public: 19 explicit TemplateURLServiceFactoryTestUtil(TestingProfile* profile); 20 virtual ~TemplateURLServiceFactoryTestUtil(); 21 22 // Makes sure the load was successful. 23 void VerifyLoad(); 24 25 // Set the managed preferences for the default search provider and trigger 26 // notification. If |alternate_url| is empty, uses an empty list of alternate 27 // URLs, otherwise use a list containing a single entry. 28 void SetManagedDefaultSearchPreferences( 29 bool enabled, 30 const std::string& name, 31 const std::string& keyword, 32 const std::string& search_url, 33 const std::string& suggest_url, 34 const std::string& icon_url, 35 const std::string& encodings, 36 const std::string& alternate_url, 37 const std::string& search_terms_replacement_key); 38 39 // Remove all the managed preferences for the default search provider and 40 // trigger notification. 41 void RemoveManagedDefaultSearchPreferences(); 42 43 // Returns the TemplateURLService. 44 TemplateURLService* model() const; 45 46 private: 47 TestingProfile* profile_; 48 49 DISALLOW_COPY_AND_ASSIGN(TemplateURLServiceFactoryTestUtil); 50 }; 51 52 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_FACTORY_TEST_UTIL_H_ 53