OLD | NEW |
---|---|
(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 "base/memory/scoped_ptr.h" | |
10 #include "base/memory/ref_counted.h" | |
11 #include "chrome/browser/extensions/extension_event_router.h" | |
12 #include "chrome/browser/extensions/extension_service.h" | |
13 #include "chrome/browser/extensions/test_extension_service.h" | |
14 #include "chrome/test/base/testing_profile.h" | |
15 | |
16 class Extension; | |
17 | |
18 // Utilities for extension settings API tests. | |
19 namespace extension_settings_test_util { | |
20 | |
21 // Synchronously gets the storage area for an extension from |frontend|. | |
22 ExtensionSettingsStorage* GetStorage( | |
23 const std::string& extension_id, ExtensionSettingsFrontend* frontend); | |
akalin
2011/10/28 06:04:54
#include <string>
akalin
2011/10/28 06:04:54
forward-declare Frontend?
not at google - send to devlin
2011/10/31 00:02:23
Done, but, why?
not at google - send to devlin
2011/10/31 00:02:23
Done.
akalin
2011/10/31 20:20:57
You use it as a parameter. It's probably pulled i
| |
24 | |
25 // An ExtensionService which allows extensions to be hand-added to be returned | |
26 // by GetExtensionById. | |
27 class MockExtensionService : public TestExtensionService { | |
28 public: | |
29 MockExtensionService(); | |
30 virtual ~MockExtensionService(); | |
31 | |
32 // Adds an extension with id |id| to be returned by GetExtensionById. | |
33 void AddExtension(const std::string& id, bool is_app); | |
akalin
2011/10/28 06:04:54
I think using Extension::Type (not sure what it's
not at google - send to devlin
2011/10/31 00:02:23
Done.
| |
34 | |
35 virtual const Extension* GetExtensionById( | |
36 const std::string& id, bool include_disabled) const OVERRIDE; | |
37 | |
38 private: | |
39 std::map<std::string, scoped_refptr<Extension> > extensions_; | |
40 }; | |
41 | |
42 // A Profile which returns ExtensionService and ExtensionEventRouters with | |
43 // enough functionality for the tests. | |
44 class MockProfile : public TestingProfile { | |
45 public: | |
46 explicit MockProfile(const FilePath& file_path); | |
47 virtual ~MockProfile(); | |
48 | |
49 // Returns the same object as GetExtensionService, but not coaxed into an | |
50 // ExtensionService; use this method from tests. | |
51 MockExtensionService* GetMockExtensionService(); | |
52 | |
53 virtual ExtensionService* GetExtensionService() OVERRIDE; | |
54 virtual ExtensionEventRouter* GetExtensionEventRouter() OVERRIDE; | |
55 | |
56 private: | |
57 MockExtensionService extension_service_; | |
58 scoped_ptr<ExtensionEventRouter> event_router_; | |
59 }; | |
60 | |
61 } // namespace extension_settings_test_util | |
62 | |
63 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SETTINGS_TEST_UTIL_H_ | |
OLD | NEW |