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

Side by Side Diff: chrome/test/live_sync/live_themes_sync_test.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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2011 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 #include "chrome/test/live_sync/live_themes_sync_test.h"
6
7 #include "base/logging.h"
8 #include "base/string_number_conversions.h"
9 #include "chrome/browser/themes/theme_service.h"
10 #include "chrome/browser/themes/theme_service_factory.h"
11 #include "chrome/common/extensions/extension.h"
12
13 namespace {
14
15 // Make a name to pass to an extension helper.
16 std::string MakeName(int index) {
17 return "faketheme" + base::IntToString(index);
18 }
19
20 ThemeService* GetThemeService(Profile* profile) {
21 return ThemeServiceFactory::GetForProfile(profile);
22 }
23
24 } // namespace
25
26 LiveThemesSyncTest::LiveThemesSyncTest(TestType test_type)
27 : LiveSyncTest(test_type) {}
28
29 LiveThemesSyncTest::~LiveThemesSyncTest() {}
30
31 bool LiveThemesSyncTest::SetupClients() {
32 if (!LiveSyncTest::SetupClients())
33 return false;
34
35 extension_helper_.Setup(this);
36 return true;
37 }
38
39 std::string LiveThemesSyncTest::GetCustomTheme(int index) const {
40 return extension_helper_.NameToId(MakeName(index));
41 }
42
43 std::string LiveThemesSyncTest::GetThemeID(Profile* profile) const {
44 return GetThemeService(profile)->GetThemeID();
45 }
46
47 bool LiveThemesSyncTest::UsingCustomTheme(Profile* profile) const {
48 return GetThemeID(profile) != ThemeService::kDefaultThemeID;
49 }
50
51 bool LiveThemesSyncTest::UsingDefaultTheme(Profile* profile) const {
52 return GetThemeService(profile)->UsingDefaultTheme();
53 }
54
55 bool LiveThemesSyncTest::UsingNativeTheme(Profile* profile) const {
56 return GetThemeService(profile)->UsingNativeTheme();
57 }
58
59 bool LiveThemesSyncTest::ThemeIsPendingInstall(
60 Profile* profile, const std::string& id) const {
61 return extension_helper_.IsExtensionPendingInstallForSync(profile, id);
62 }
63
64 bool LiveThemesSyncTest::HasOrWillHaveCustomTheme(
65 Profile* profile, const std::string& id) const {
66 return (GetThemeID(profile) == id) || ThemeIsPendingInstall(profile, id);
67 }
68
69 void LiveThemesSyncTest::UseCustomTheme(Profile* profile, int index) {
70 extension_helper_.InstallExtension(
71 profile, MakeName(index), Extension::TYPE_THEME);
72 }
73
74 void LiveThemesSyncTest::UseDefaultTheme(Profile* profile) {
75 GetThemeService(profile)->UseDefaultTheme();
76 }
77
78 void LiveThemesSyncTest::UseNativeTheme(Profile* profile) {
79 // TODO(akalin): Fix this inconsistent naming in the theme service.
80 GetThemeService(profile)->SetNativeTheme();
81 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698