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

Side by Side Diff: chrome/browser/extensions/extension_settings_test_util.h

Issue 8375047: Separate the syncing of extension settings and app settings into separate data (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 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) 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 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_SETTINGS_TEST_UTIL_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_SETTINGS_TEST_UTIL_H_
7 #pragma once
8
9 #include <string>
10
11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/ref_counted.h"
13 #include "chrome/browser/extensions/extension_event_router.h"
14 #include "chrome/browser/extensions/extension_service.h"
15 #include "chrome/browser/extensions/test_extension_service.h"
16 #include "chrome/common/extensions/extension.h"
17 #include "chrome/test/base/testing_profile.h"
18
19 class ExtensionSettingsFrontend;
20
21 // Utilities for extension settings API tests.
22 namespace extension_settings_test_util {
23
24 // Synchronously gets the storage area for an extension from |frontend|.
25 ExtensionSettingsStorage* GetStorage(
26 const std::string& extension_id, ExtensionSettingsFrontend* frontend);
27
28 // An ExtensionService which allows extensions to be hand-added to be returned
29 // by GetExtensionById.
30 class MockExtensionService : public TestExtensionService {
31 public:
32 MockExtensionService();
33 virtual ~MockExtensionService();
34
35 // Adds an extension with id |id| to be returned by GetExtensionById.
36 void AddExtension(const std::string& id, Extension::Type type);
37
38 virtual const Extension* GetExtensionById(
39 const std::string& id, bool include_disabled) const OVERRIDE;
40
41 private:
42 std::map<std::string, scoped_refptr<Extension> > extensions_;
43 };
44
45 // A Profile which returns ExtensionService and ExtensionEventRouters with
46 // enough functionality for the tests.
47 class MockProfile : public TestingProfile {
48 public:
49 explicit MockProfile(const FilePath& file_path);
50 virtual ~MockProfile();
51
52 // Returns the same object as GetExtensionService, but not coaxed into an
53 // ExtensionService; use this method from tests.
54 MockExtensionService* GetMockExtensionService();
55
56 virtual ExtensionService* GetExtensionService() OVERRIDE;
57 virtual ExtensionEventRouter* GetExtensionEventRouter() OVERRIDE;
58
59 private:
60 MockExtensionService extension_service_;
61 scoped_ptr<ExtensionEventRouter> event_router_;
62 };
63
64 } // namespace extension_settings_test_util
65
66 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SETTINGS_TEST_UTIL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698