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

Side by Side Diff: chrome/test/live_sync/live_extensions_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: Fix indents 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_extensions_sync_test.h"
6
7 #include <cstring>
8
9 #include "base/logging.h"
10 #include "base/string_number_conversions.h"
11 #include "base/string_util.h"
12 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/common/extensions/extension.h"
14
15 const char extension_name_prefix[] = "fakeextension";
16
17 LiveExtensionsSyncTest::LiveExtensionsSyncTest(TestType test_type)
18 : LiveSyncTest(test_type) {}
19
20 LiveExtensionsSyncTest::~LiveExtensionsSyncTest() {}
21
22 bool LiveExtensionsSyncTest::SetupClients() {
23 if (!LiveSyncTest::SetupClients())
24 return false;
25
26 extension_helper_.Setup(this);
27 return true;
28 }
29
30 bool LiveExtensionsSyncTest::HasSameExtensionsAsVerifier(int index) {
31 return extension_helper_.ExtensionStatesMatch(GetProfile(index), verifier());
32 }
33
34 bool LiveExtensionsSyncTest::AllProfilesHaveSameExtensionsAsVerifier() {
35 for (int i = 0; i < num_clients(); ++i) {
36 if (!HasSameExtensionsAsVerifier(i)) {
37 LOG(ERROR) << "Profile " << i << " doesn't have the same extensions as"
38 " the verifier profile.";
39 return false;
40 }
41 }
42 return true;
43 }
44
45 bool LiveExtensionsSyncTest::AllProfilesHaveSameExtensions() {
46 for (int i = 1; i < num_clients(); ++i) {
47 if (!extension_helper_.ExtensionStatesMatch(GetProfile(0),
48 GetProfile(i))) {
49 LOG(ERROR) << "Profile " << i << " doesnt have the same extensions as"
50 " profile 0.";
51 return false;
52 }
53 }
54 return true;
55 }
56
57
58 void LiveExtensionsSyncTest::InstallExtension(Profile* profile, int index) {
59 return extension_helper_.InstallExtension(profile,
60 CreateFakeExtensionName(index),
61 Extension::TYPE_EXTENSION);
62 }
63
64 void LiveExtensionsSyncTest::UninstallExtension(Profile* profile, int index) {
65 return extension_helper_.UninstallExtension(profile,
66 CreateFakeExtensionName(index));
67 }
68
69 std::vector<int> LiveExtensionsSyncTest::GetInstalledExtensions(
70 Profile* profile) {
71 std::vector<int> indices;
72 std::vector<std::string> names =
73 extension_helper_.GetInstalledExtensionNames(profile);
74 for (std::vector<std::string>::const_iterator it = names.begin();
75 it != names.end(); ++it) {
76 int index;
77 if (ExtensionNameToIndex(*it, &index)) {
78 indices.push_back(index);
79 }
80 }
81 return indices;
82 }
83
84 void LiveExtensionsSyncTest::EnableExtension(Profile* profile, int index) {
85 return extension_helper_.EnableExtension(profile,
86 CreateFakeExtensionName(index));
87 }
88
89 void LiveExtensionsSyncTest::DisableExtension(Profile* profile, int index) {
90 return extension_helper_.DisableExtension(profile,
91 CreateFakeExtensionName(index));
92 }
93
94 bool LiveExtensionsSyncTest::IsExtensionEnabled(Profile* profile, int index) {
95 return extension_helper_.IsExtensionEnabled(profile,
96 CreateFakeExtensionName(index));
97 }
98
99 void LiveExtensionsSyncTest::IncognitoEnableExtension(Profile* profile,
100 int index) {
101 return extension_helper_.IncognitoEnableExtension(
102 profile, CreateFakeExtensionName(index));
103 }
104
105 void LiveExtensionsSyncTest::IncognitoDisableExtension(Profile* profile,
106 int index) {
107 return extension_helper_.IncognitoDisableExtension(
108 profile, CreateFakeExtensionName(index));
109 }
110
111 bool LiveExtensionsSyncTest::IsIncognitoEnabled(Profile* profile, int index) {
112 return extension_helper_.IsIncognitoEnabled(profile,
113 CreateFakeExtensionName(index));
114 }
115
116 void LiveExtensionsSyncTest::InstallExtensionsPendingForSync(
117 Profile* profile) {
118 extension_helper_.InstallExtensionsPendingForSync(
119 profile, Extension::TYPE_EXTENSION);
120 }
121
122 std::string LiveExtensionsSyncTest::CreateFakeExtensionName(int index) {
123 return extension_name_prefix + base::IntToString(index);
124 }
125
126 bool LiveExtensionsSyncTest::ExtensionNameToIndex(const std::string& name,
127 int* index) {
128 if (!StartsWithASCII(name, extension_name_prefix, true) ||
129 !base::StringToInt(name.substr(strlen(extension_name_prefix)), index)) {
130 LOG(WARNING) << "Unable to convert extension name \"" << name
131 << "\" to index";
132 return false;
133 }
134 return true;
135 }
OLDNEW
« no previous file with comments | « chrome/test/live_sync/live_extensions_sync_test.h ('k') | chrome/test/live_sync/live_sync_extension_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698