OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_PREFS_UNITTEST_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_PREFS_UNITTEST_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_PREFS_UNITTEST_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_PREFS_UNITTEST_H_ |
7 | 7 |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "chrome/browser/extensions/test_extension_prefs.h" | 9 #include "chrome/browser/extensions/test_extension_prefs.h" |
10 #include "content/public/test/test_browser_thread.h" | 10 #include "content/public/test/test_browser_thread.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
12 | 12 |
| 13 class PrefRegistrySyncable; |
| 14 |
13 namespace base { | 15 namespace base { |
14 class Value; | 16 class Value; |
15 } | 17 } |
16 | 18 |
17 namespace extensions { | 19 namespace extensions { |
18 class Extension; | 20 class Extension; |
19 | 21 |
20 // Base class for extension preference-related unit tests. | 22 // Base class for extension preference-related unit tests. |
21 class ExtensionPrefsTest : public testing::Test { | 23 class ExtensionPrefsTest : public testing::Test { |
22 public: | 24 public: |
23 ExtensionPrefsTest(); | 25 ExtensionPrefsTest(); |
24 virtual ~ExtensionPrefsTest(); | 26 virtual ~ExtensionPrefsTest(); |
25 | 27 |
26 // This function will get called once, and is the right place to do operations | 28 // This function will get called once, and is the right place to do operations |
27 // on ExtensionPrefs that write data. | 29 // on ExtensionPrefs that write data. |
28 virtual void Initialize() = 0; | 30 virtual void Initialize() = 0; |
29 | 31 |
30 // This function will be called twice - once while the original ExtensionPrefs | 32 // This function will be called twice - once while the original ExtensionPrefs |
31 // object is still alive, and once after recreation. Thus, it tests that | 33 // object is still alive, and once after recreation. Thus, it tests that |
32 // things don't break after any ExtensionPrefs startup work. | 34 // things don't break after any ExtensionPrefs startup work. |
33 virtual void Verify() = 0; | 35 virtual void Verify() = 0; |
34 | 36 |
35 // This function is called to Register preference default values. | 37 // This function is called to Register preference default values. |
36 virtual void RegisterPreferences(); | 38 virtual void RegisterPreferences(PrefRegistrySyncable* registry); |
37 | 39 |
38 virtual void SetUp() OVERRIDE; | 40 virtual void SetUp() OVERRIDE; |
39 | 41 |
40 virtual void TearDown() OVERRIDE; | 42 virtual void TearDown() OVERRIDE; |
41 | 43 |
42 protected: | 44 protected: |
43 ExtensionPrefs* prefs() { return prefs_.prefs(); } | 45 ExtensionPrefs* prefs() { return prefs_.prefs(); } |
44 | 46 |
45 MessageLoop message_loop_; | 47 MessageLoop message_loop_; |
46 content::TestBrowserThread ui_thread_; | 48 content::TestBrowserThread ui_thread_; |
47 | 49 |
48 TestExtensionPrefs prefs_; | 50 TestExtensionPrefs prefs_; |
49 | 51 |
50 private: | 52 private: |
51 DISALLOW_COPY_AND_ASSIGN(ExtensionPrefsTest); | 53 DISALLOW_COPY_AND_ASSIGN(ExtensionPrefsTest); |
52 }; | 54 }; |
53 | 55 |
54 class ExtensionPrefsPrepopulatedTest : public ExtensionPrefsTest { | 56 class ExtensionPrefsPrepopulatedTest : public ExtensionPrefsTest { |
55 public: | 57 public: |
56 ExtensionPrefsPrepopulatedTest(); | 58 ExtensionPrefsPrepopulatedTest(); |
57 virtual ~ExtensionPrefsPrepopulatedTest(); | 59 virtual ~ExtensionPrefsPrepopulatedTest(); |
58 | 60 |
59 virtual void RegisterPreferences() OVERRIDE; | 61 virtual void RegisterPreferences(PrefRegistrySyncable* registry) OVERRIDE; |
60 | 62 |
61 void InstallExtControlledPref(Extension* ext, | 63 void InstallExtControlledPref(Extension* ext, |
62 const std::string& key, | 64 const std::string& key, |
63 base::Value* val); | 65 base::Value* val); |
64 | 66 |
65 void InstallExtControlledPrefIncognito(Extension* ext, | 67 void InstallExtControlledPrefIncognito(Extension* ext, |
66 const std::string& key, | 68 const std::string& key, |
67 base::Value* val); | 69 base::Value* val); |
68 | 70 |
69 void InstallExtControlledPrefIncognitoSessionOnly( | 71 void InstallExtControlledPrefIncognitoSessionOnly( |
(...skipping 21 matching lines...) Expand all Loading... |
91 | 93 |
92 scoped_refptr<Extension> ext1_scoped_; | 94 scoped_refptr<Extension> ext1_scoped_; |
93 scoped_refptr<Extension> ext2_scoped_; | 95 scoped_refptr<Extension> ext2_scoped_; |
94 scoped_refptr<Extension> ext3_scoped_; | 96 scoped_refptr<Extension> ext3_scoped_; |
95 scoped_refptr<Extension> ext4_scoped_; | 97 scoped_refptr<Extension> ext4_scoped_; |
96 }; | 98 }; |
97 | 99 |
98 } // namespace extensions | 100 } // namespace extensions |
99 | 101 |
100 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PREFS_UNITTEST_H_ | 102 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PREFS_UNITTEST_H_ |
OLD | NEW |