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

Side by Side Diff: chrome/test/live_sync/live_extensions_sync_test.cc

Issue 4732005: [Sync] Added some basic extension sync integration tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed whitespace Created 10 years, 1 month 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) 2010 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 <map>
8 #include <string>
9
10 #include "base/logging.h"
11 #include "base/ref_counted.h"
12 #include "chrome/browser/extensions/extensions_service.h"
13 #include "chrome/browser/profile.h"
14 #include "chrome/browser/themes/browser_theme_provider.h"
15 #include "chrome/common/extensions/extension.h"
16
17 LiveExtensionsSyncTest::LiveExtensionsSyncTest(TestType test_type)
18 : LiveExtensionsSyncTestBase(test_type) {}
19
20 LiveExtensionsSyncTest::~LiveExtensionsSyncTest() {}
21
22 namespace {
23
24 enum ExtensionState { DISABLED, PENDING, ENABLED };
25
26 typedef std::map<std::string, ExtensionState> ExtensionStateMap;
27
28 ExtensionStateMap GetExtensionStates(ExtensionsService* extensions_service) {
29 ExtensionStateMap extension_states;
30
31 const ExtensionList* extensions = extensions_service->extensions();
32 for (ExtensionList::const_iterator it = extensions->begin();
33 it != extensions->end(); ++it) {
34 extension_states[(*it)->id()] = ENABLED;
35 }
36
37 const ExtensionList* disabled_extensions =
38 extensions_service->disabled_extensions();
39 for (ExtensionList::const_iterator it = disabled_extensions->begin();
40 it != disabled_extensions->end(); ++it) {
41 extension_states[(*it)->id()] = DISABLED;
42 }
43
44 const PendingExtensionMap& pending_extensions =
45 extensions_service->pending_extensions();
46 for (PendingExtensionMap::const_iterator it = pending_extensions.begin();
47 it != pending_extensions.end(); ++it) {
48 extension_states[it->first] = PENDING;
49 }
50
51 return extension_states;
52 }
53
54 } // namespace
55
56 bool LiveExtensionsSyncTest::HasSameExtensions(
57 Profile* profile1, Profile* profile2) {
58 ExtensionStateMap extension_states1(
59 GetExtensionStates(profile1->GetExtensionsService()));
60 ExtensionStateMap extension_states2(
61 GetExtensionStates(profile2->GetExtensionsService()));
62 return extension_states1 == extension_states2;
63 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698