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

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

Issue 7104072: Adding new extension sync integration tests. Also modified the way that profile (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: More review changes Created 9 years, 6 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/live_sync_extension_helper.cc
diff --git a/chrome/test/live_sync/live_sync_extension_helper.cc b/chrome/test/live_sync/live_sync_extension_helper.cc
index dc260adee85c1b8a4bc97746b3f49397f2f7850a..145cac694f8a42ede661031d917b6f220e4d52e2 100644
--- a/chrome/test/live_sync/live_sync_extension_helper.cc
+++ b/chrome/test/live_sync/live_sync_extension_helper.cc
@@ -16,6 +16,17 @@
#include "chrome/test/live_sync/live_sync_test.h"
#include "testing/gtest/include/gtest/gtest.h"
+LiveSyncExtensionHelper::ExtensionState::ExtensionState()
+ : enabled_state(ENABLED), incognito_enabled(false) {}
+
+LiveSyncExtensionHelper::ExtensionState::~ExtensionState() {}
+
+bool LiveSyncExtensionHelper::ExtensionState::Equals(
+ const LiveSyncExtensionHelper::ExtensionState &other) const {
+ return ((enabled_state == other.enabled_state) &&
+ (incognito_enabled == other.incognito_enabled));
+}
+
LiveSyncExtensionHelper::LiveSyncExtensionHelper() {}
LiveSyncExtensionHelper::~LiveSyncExtensionHelper() {}
@@ -48,6 +59,26 @@ void LiveSyncExtensionHelper::UninstallExtension(
NameToId(name));
}
+void LiveSyncExtensionHelper::EnableExtension(Profile* profile,
+ const std::string& name) {
+ profile->GetExtensionService()->EnableExtension(NameToId(name));
+}
+
+void LiveSyncExtensionHelper::DisableExtension(Profile* profile,
+ const std::string& name) {
+ profile->GetExtensionService()->DisableExtension(NameToId(name));
+}
+
+void LiveSyncExtensionHelper::IncognitoEnableExtension(
+ Profile* profile, const std::string& name) {
+ profile->GetExtensionService()->SetIsIncognitoEnabled(NameToId(name), true);
+}
+
+void LiveSyncExtensionHelper::IncognitoDisableExtension(
+ Profile* profile, const std::string& name) {
+ profile->GetExtensionService()->SetIsIncognitoEnabled(NameToId(name), false);
+}
+
bool LiveSyncExtensionHelper::IsExtensionPendingInstallForSync(
Profile* profile, const std::string& id) const {
const PendingExtensionManager* pending_extension_manager =
@@ -89,8 +120,7 @@ void LiveSyncExtensionHelper::InstallExtensionsPendingForSync(
}
LiveSyncExtensionHelper::ExtensionStateMap
- LiveSyncExtensionHelper::GetExtensionStates(
- Profile* profile) const {
+ LiveSyncExtensionHelper::GetExtensionStates(Profile* profile) {
const std::string& profile_debug_name = profile->GetDebugName();
ExtensionStateMap extension_state_map;
@@ -100,7 +130,10 @@ LiveSyncExtensionHelper::ExtensionStateMap
const ExtensionList* extensions = extension_service->extensions();
for (ExtensionList::const_iterator it = extensions->begin();
it != extensions->end(); ++it) {
- extension_state_map[(*it)->id()] = ENABLED;
+ const std::string& id = (*it)->id();
+ extension_state_map[id].enabled_state = ExtensionState::ENABLED;
+ extension_state_map[id].incognito_enabled =
+ extension_service->IsIncognitoEnabled(id);
VLOG(2) << "Extension " << (*it)->id() << " in profile "
<< profile_debug_name << " is enabled";
}
@@ -109,7 +142,10 @@ LiveSyncExtensionHelper::ExtensionStateMap
extension_service->disabled_extensions();
for (ExtensionList::const_iterator it = disabled_extensions->begin();
it != disabled_extensions->end(); ++it) {
- extension_state_map[(*it)->id()] = DISABLED;
+ const std::string& id = (*it)->id();
+ extension_state_map[id].enabled_state = ExtensionState::DISABLED;
+ extension_state_map[id].incognito_enabled =
+ extension_service->IsIncognitoEnabled(id);
VLOG(2) << "Extension " << (*it)->id() << " in profile "
<< profile_debug_name << " is disabled";
}
@@ -119,7 +155,10 @@ LiveSyncExtensionHelper::ExtensionStateMap
PendingExtensionManager::const_iterator it;
for (it = pending_extension_manager->begin();
it != pending_extension_manager->end(); ++it) {
- extension_state_map[it->first] = PENDING;
+ const std::string& id = it->first;
+ extension_state_map[id].enabled_state = ExtensionState::PENDING;
+ extension_state_map[id].incognito_enabled =
+ extension_service->IsIncognitoEnabled(id);
VLOG(2) << "Extension " << it->first << " in profile "
<< profile_debug_name << " is pending";
}
@@ -127,6 +166,34 @@ LiveSyncExtensionHelper::ExtensionStateMap
return extension_state_map;
}
+bool LiveSyncExtensionHelper::ExtensionStatesMatch(
+ Profile* profile1, Profile* profile2) {
+ const ExtensionStateMap& state_map1 = GetExtensionStates(profile1);
+ const ExtensionStateMap& state_map2 = GetExtensionStates(profile2);
+ if (state_map1.size() != state_map2.size()) {
+ VLOG(1) << "Number of extensions for profile " << profile1->GetDebugName()
+ << " does not match profile " << profile2->GetDebugName();
+ return false;
+ }
+
+ ExtensionStateMap::const_iterator it1 = state_map1.begin();
+ ExtensionStateMap::const_iterator it2 = state_map2.begin();
+ while (it1 != state_map1.end()) {
+ if (it1->first != it2->first) {
+ VLOG(1) << "Extensions for profile " << profile1->GetDebugName()
+ << " do not match profile " << profile2->GetDebugName();
+ return false;
+ } else if (!it1->second.Equals(it2->second)) {
+ VLOG(1) << "Extension states for profile " << profile1->GetDebugName()
+ << " do not match profile " << profile2->GetDebugName();
+ return false;
+ }
+ ++it1;
+ ++it2;
+ }
+ return true;
+}
+
void LiveSyncExtensionHelper::SetupProfile(Profile* profile) {
profile->InitExtensions(true);
profile_extensions_.insert(make_pair(profile, ExtensionNameMap()));
« no previous file with comments | « chrome/test/live_sync/live_sync_extension_helper.h ('k') | chrome/test/live_sync/two_client_live_apps_sync_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698