Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2138)

Unified Diff: chrome/browser/search_engines/template_url_service_factory_test_util.cc

Issue 376413002: Stop using TemplateURLServiceTestUtil to initialize TemplateURLServiceFactory (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add DefaultSearchPrefTestUtil Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/search_engines/template_url_service_factory_test_util.cc
diff --git a/chrome/browser/search_engines/template_url_service_factory_test_util.cc b/chrome/browser/search_engines/template_url_service_factory_test_util.cc
new file mode 100644
index 0000000000000000000000000000000000000000..b4bba853c120c3906ff8aaabd5e08577d35eac6c
--- /dev/null
+++ b/chrome/browser/search_engines/template_url_service_factory_test_util.cc
@@ -0,0 +1,57 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/search_engines/template_url_service_factory_test_util.h"
+
+#include "base/run_loop.h"
+#include "chrome/browser/search_engines/template_url_service_factory.h"
+#include "chrome/test/base/testing_pref_service_syncable.h"
+#include "chrome/test/base/testing_profile.h"
+#include "components/search_engines/default_search_pref_test_util.h"
+#include "components/search_engines/template_url_service.h"
+
+TemplateURLServiceFactoryTestUtil::TemplateURLServiceFactoryTestUtil(
+ TestingProfile* profile)
+ : profile_(profile) {
+ profile_->CreateWebDataService();
+
+ TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse(
+ profile_, TemplateURLServiceFactory::BuildInstanceFor);
+}
+
+TemplateURLServiceFactoryTestUtil::~TemplateURLServiceFactoryTestUtil() {
+ // Flush the message loop to make application verifiers happy.
+ base::RunLoop().RunUntilIdle();
+}
+
+void TemplateURLServiceFactoryTestUtil::VerifyLoad() {
+ model()->Load();
+ base::RunLoop().RunUntilIdle();
+}
+
+void TemplateURLServiceFactoryTestUtil::SetManagedDefaultSearchPreferences(
+ bool enabled,
+ const std::string& name,
+ const std::string& keyword,
+ const std::string& search_url,
+ const std::string& suggest_url,
+ const std::string& icon_url,
+ const std::string& encodings,
+ const std::string& alternate_url,
+ const std::string& search_terms_replacement_key) {
+ DefaultSearchPrefTestUtil::SetManagedPref(
+ profile_->GetTestingPrefService(),
+ enabled, name, keyword, search_url, suggest_url, icon_url, encodings,
+ alternate_url, search_terms_replacement_key);
+}
+
+void
+TemplateURLServiceFactoryTestUtil::RemoveManagedDefaultSearchPreferences() {
+ DefaultSearchPrefTestUtil::RemoveManagedPref(
+ profile_->GetTestingPrefService());
+}
+
+TemplateURLService* TemplateURLServiceFactoryTestUtil::model() const {
+ return TemplateURLServiceFactory::GetForProfile(profile_);
+}

Powered by Google App Engine
This is Rietveld 408576698