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

Unified Diff: chrome/test/live_sync/sync_extension_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
« no previous file with comments | « chrome/test/live_sync/sync_extension_helper.h ('k') | chrome/test/live_sync/themes_helper.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/live_sync/sync_extension_helper.cc
diff --git a/chrome/test/live_sync/live_sync_extension_helper.cc b/chrome/test/live_sync/sync_extension_helper.cc
similarity index 86%
rename from chrome/test/live_sync/live_sync_extension_helper.cc
rename to chrome/test/live_sync/sync_extension_helper.cc
index c58251b3dcfd4dbea5bb095a36df630bcbc27342..02b471ba010a4e7ab312720b1e080fe19dcfdb3b 100644
--- a/chrome/test/live_sync/live_sync_extension_helper.cc
+++ b/chrome/test/live_sync/sync_extension_helper.cc
@@ -2,7 +2,7 @@
// 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/live_sync_extension_helper.h"
+#include "chrome/test/live_sync/sync_extension_helper.h"
#include "base/file_path.h"
#include "base/file_util.h"
@@ -14,38 +14,51 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/extensions/extension_constants.h"
#include "chrome/test/live_sync/live_sync_test.h"
+#include "chrome/test/live_sync/sync_datatype_helper.h"
#include "testing/gtest/include/gtest/gtest.h"
-LiveSyncExtensionHelper::ExtensionState::ExtensionState()
+SyncExtensionHelper::ExtensionState::ExtensionState()
: enabled_state(ENABLED), incognito_enabled(false) {}
-LiveSyncExtensionHelper::ExtensionState::~ExtensionState() {}
+SyncExtensionHelper::ExtensionState::~ExtensionState() {}
-bool LiveSyncExtensionHelper::ExtensionState::Equals(
- const LiveSyncExtensionHelper::ExtensionState &other) const {
+bool SyncExtensionHelper::ExtensionState::Equals(
+ const SyncExtensionHelper::ExtensionState &other) const {
return ((enabled_state == other.enabled_state) &&
(incognito_enabled == other.incognito_enabled));
}
-LiveSyncExtensionHelper::LiveSyncExtensionHelper() {}
+// static
+SyncExtensionHelper* SyncExtensionHelper::GetInstance() {
+ SyncExtensionHelper* instance = Singleton<SyncExtensionHelper>::get();
+ instance->SetupIfNecessary(sync_datatype_helper::test());
+ return instance;
+}
+
+SyncExtensionHelper::SyncExtensionHelper() : setup_completed_(false) {}
-LiveSyncExtensionHelper::~LiveSyncExtensionHelper() {}
+SyncExtensionHelper::~SyncExtensionHelper() {}
// static
-std::string LiveSyncExtensionHelper::NameToId(const std::string& name) {
+std::string SyncExtensionHelper::NameToId(const std::string& name) {
std::string id;
EXPECT_TRUE(Extension::GenerateId(name, &id));
return id;
}
-void LiveSyncExtensionHelper::Setup(LiveSyncTest* test) {
+void SyncExtensionHelper::SetupIfNecessary(LiveSyncTest* test) {
+ if (setup_completed_)
+ return;
+
for (int i = 0; i < test->num_clients(); ++i) {
SetupProfile(test->GetProfile(i));
}
SetupProfile(test->verifier());
+
+ setup_completed_ = true;
}
-void LiveSyncExtensionHelper::InstallExtension(
+void SyncExtensionHelper::InstallExtension(
Profile* profile, const std::string& name, Extension::Type type) {
scoped_refptr<Extension> extension = GetExtension(profile, name, type);
ASSERT_TRUE(extension.get()) << "Could not get extension " << name
@@ -54,13 +67,13 @@ void LiveSyncExtensionHelper::InstallExtension(
extension, extension->UpdatesFromGallery());
}
-void LiveSyncExtensionHelper::UninstallExtension(
+void SyncExtensionHelper::UninstallExtension(
Profile* profile, const std::string& name) {
ExtensionService::UninstallExtensionHelper(profile->GetExtensionService(),
NameToId(name));
}
-std::vector<std::string> LiveSyncExtensionHelper::GetInstalledExtensionNames(
+std::vector<std::string> SyncExtensionHelper::GetInstalledExtensionNames(
Profile* profile) const {
std::vector<std::string> names;
ExtensionService* extension_service = profile->GetExtensionService();
@@ -88,38 +101,38 @@ std::vector<std::string> LiveSyncExtensionHelper::GetInstalledExtensionNames(
return names;
}
-void LiveSyncExtensionHelper::EnableExtension(Profile* profile,
+void SyncExtensionHelper::EnableExtension(Profile* profile,
const std::string& name) {
akalin 2011/08/11 00:08:08 indent
Raghu Simha 2011/08/11 00:30:50 Good catch. Done.
profile->GetExtensionService()->EnableExtension(NameToId(name));
}
-void LiveSyncExtensionHelper::DisableExtension(Profile* profile,
+void SyncExtensionHelper::DisableExtension(Profile* profile,
const std::string& name) {
akalin 2011/08/11 00:08:08 indent
Raghu Simha 2011/08/11 00:30:50 Good catch. Done.
profile->GetExtensionService()->DisableExtension(NameToId(name));
}
-bool LiveSyncExtensionHelper::IsExtensionEnabled(
+bool SyncExtensionHelper::IsExtensionEnabled(
Profile* profile, const std::string& name) const {
return profile->GetExtensionService()->IsExtensionEnabled(NameToId(name));
}
-void LiveSyncExtensionHelper::IncognitoEnableExtension(
+void SyncExtensionHelper::IncognitoEnableExtension(
Profile* profile, const std::string& name) {
profile->GetExtensionService()->SetIsIncognitoEnabled(NameToId(name), true);
}
-void LiveSyncExtensionHelper::IncognitoDisableExtension(
+void SyncExtensionHelper::IncognitoDisableExtension(
Profile* profile, const std::string& name) {
profile->GetExtensionService()->SetIsIncognitoEnabled(NameToId(name), false);
}
-bool LiveSyncExtensionHelper::IsIncognitoEnabled(
+bool SyncExtensionHelper::IsIncognitoEnabled(
Profile* profile, const std::string& name) const {
return profile->GetExtensionService()->IsIncognitoEnabled(NameToId(name));
}
-bool LiveSyncExtensionHelper::IsExtensionPendingInstallForSync(
+bool SyncExtensionHelper::IsExtensionPendingInstallForSync(
Profile* profile, const std::string& id) const {
const PendingExtensionManager* pending_extension_manager =
profile->GetExtensionService()->pending_extension_manager();
@@ -130,7 +143,7 @@ bool LiveSyncExtensionHelper::IsExtensionPendingInstallForSync(
return info.is_from_sync();
}
-void LiveSyncExtensionHelper::InstallExtensionsPendingForSync(
+void SyncExtensionHelper::InstallExtensionsPendingForSync(
Profile* profile, Extension::Type type) {
// TODO(akalin): Mock out the servers that the extensions auto-update
// mechanism talk to so as to more closely match what actually happens.
@@ -159,8 +172,8 @@ void LiveSyncExtensionHelper::InstallExtensionsPendingForSync(
}
}
-LiveSyncExtensionHelper::ExtensionStateMap
- LiveSyncExtensionHelper::GetExtensionStates(Profile* profile) {
+SyncExtensionHelper::ExtensionStateMap
+ SyncExtensionHelper::GetExtensionStates(Profile* profile) {
const std::string& profile_debug_name = profile->GetDebugName();
ExtensionStateMap extension_state_map;
@@ -206,7 +219,7 @@ LiveSyncExtensionHelper::ExtensionStateMap
return extension_state_map;
}
-bool LiveSyncExtensionHelper::ExtensionStatesMatch(
+bool SyncExtensionHelper::ExtensionStatesMatch(
Profile* profile1, Profile* profile2) {
const ExtensionStateMap& state_map1 = GetExtensionStates(profile1);
const ExtensionStateMap& state_map2 = GetExtensionStates(profile2);
@@ -234,7 +247,7 @@ bool LiveSyncExtensionHelper::ExtensionStatesMatch(
return true;
}
-void LiveSyncExtensionHelper::SetupProfile(Profile* profile) {
+void SyncExtensionHelper::SetupProfile(Profile* profile) {
profile->InitExtensions(true);
profile_extensions_.insert(make_pair(profile, ExtensionNameMap()));
}
@@ -311,7 +324,7 @@ scoped_refptr<Extension> CreateExtension(
} // namespace
-scoped_refptr<Extension> LiveSyncExtensionHelper::GetExtension(
+scoped_refptr<Extension> SyncExtensionHelper::GetExtension(
Profile* profile, const std::string& name,
Extension::Type type) {
if (name.empty()) {
« no previous file with comments | « chrome/test/live_sync/sync_extension_helper.h ('k') | chrome/test/live_sync/themes_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698