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

Unified Diff: chrome/test/live_sync/themes_helper.cc

Issue 7599019: Allow sync integration tests to operate on multiple datatypes: Apps, Extensions, Themes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: CR feedback Created 9 years, 4 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/test/live_sync/themes_helper.cc
diff --git a/chrome/test/live_sync/themes_helper.cc b/chrome/test/live_sync/themes_helper.cc
new file mode 100644
index 0000000000000000000000000000000000000000..d9e78ec48424a855fd5edf07e39dfaa21100a99f
--- /dev/null
+++ b/chrome/test/live_sync/themes_helper.cc
@@ -0,0 +1,75 @@
+// Copyright (c) 2011 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/test/live_sync/themes_helper.h"
+
+#include "base/logging.h"
+#include "base/string_number_conversions.h"
+#include "chrome/browser/themes/theme_service.h"
+#include "chrome/browser/themes/theme_service_factory.h"
+#include "chrome/common/extensions/extension.h"
+#include "chrome/test/live_sync/sync_datatype_helper.h"
+#include "chrome/test/live_sync/sync_extension_helper.h"
+
+using sync_datatype_helper::test;
+
+namespace {
+
+// Make a name to pass to an extension helper.
+std::string MakeName(int index) {
+ return "faketheme" + base::IntToString(index);
+}
+
+ThemeService* GetThemeService(Profile* profile) {
+ return ThemeServiceFactory::GetForProfile(profile);
+}
+
+} // namespace
+
+namespace themes_helper {
+
+std::string GetCustomTheme(int index) {
+ return SyncExtensionHelper::GetInstance()->NameToId(MakeName(index));
+}
+
+std::string GetThemeID(Profile* profile) {
+ return GetThemeService(profile)->GetThemeID();
+}
+
+bool UsingCustomTheme(Profile* profile) {
+ return GetThemeID(profile) != ThemeService::kDefaultThemeID;
+}
+
+bool UsingDefaultTheme(Profile* profile) {
+ return GetThemeService(profile)->UsingDefaultTheme();
+}
+
+bool UsingNativeTheme(Profile* profile) {
+ return GetThemeService(profile)->UsingNativeTheme();
+}
+
+bool ThemeIsPendingInstall(Profile* profile, const std::string& id) {
+ return SyncExtensionHelper::GetInstance()->
+ IsExtensionPendingInstallForSync(profile, id);
+}
+
+bool HasOrWillHaveCustomTheme(Profile* profile, const std::string& id) {
+ return (GetThemeID(profile) == id) || ThemeIsPendingInstall(profile, id);
+}
+
+void UseCustomTheme(Profile* profile, int index) {
+ SyncExtensionHelper::GetInstance()->InstallExtension(
+ profile, MakeName(index), Extension::TYPE_THEME);
+}
+
+void UseDefaultTheme(Profile* profile) {
+ GetThemeService(profile)->UseDefaultTheme();
+}
+
+void UseNativeTheme(Profile* profile) {
+ // TODO(akalin): Fix this inconsistent naming in the theme service.
+ GetThemeService(profile)->SetNativeTheme();
+}
+
+} // namespace themes_helper

Powered by Google App Engine
This is Rietveld 408576698