| 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 "chrome/common/extensions/extension_unittest.h" | 10 #include "chrome/common/extensions/extension_unittest.h" |
| 11 #include "content/public/test/test_browser_thread.h" | 11 #include "content/public/test/test_browser_thread.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 13 | 13 |
| 14 class PrefRegistrySyncable; | |
| 15 | |
| 16 namespace base { | 14 namespace base { |
| 17 class Value; | 15 class Value; |
| 18 } | 16 } |
| 19 | 17 |
| 18 namespace user_prefs { |
| 19 class PrefRegistrySyncable; |
| 20 } |
| 21 |
| 20 namespace extensions { | 22 namespace extensions { |
| 21 class Extension; | 23 class Extension; |
| 22 | 24 |
| 23 // Base class for extension preference-related unit tests. | 25 // Base class for extension preference-related unit tests. |
| 24 class ExtensionPrefsTest : public ExtensionTest { | 26 class ExtensionPrefsTest : public ExtensionTest { |
| 25 public: | 27 public: |
| 26 ExtensionPrefsTest(); | 28 ExtensionPrefsTest(); |
| 27 virtual ~ExtensionPrefsTest(); | 29 virtual ~ExtensionPrefsTest(); |
| 28 | 30 |
| 29 // This function will get called once, and is the right place to do operations | 31 // This function will get called once, and is the right place to do operations |
| 30 // on ExtensionPrefs that write data. | 32 // on ExtensionPrefs that write data. |
| 31 virtual void Initialize() = 0; | 33 virtual void Initialize() = 0; |
| 32 | 34 |
| 33 // This function will be called twice - once while the original ExtensionPrefs | 35 // This function will be called twice - once while the original ExtensionPrefs |
| 34 // object is still alive, and once after recreation. Thus, it tests that | 36 // object is still alive, and once after recreation. Thus, it tests that |
| 35 // things don't break after any ExtensionPrefs startup work. | 37 // things don't break after any ExtensionPrefs startup work. |
| 36 virtual void Verify() = 0; | 38 virtual void Verify() = 0; |
| 37 | 39 |
| 38 // This function is called to Register preference default values. | 40 // This function is called to Register preference default values. |
| 39 virtual void RegisterPreferences(PrefRegistrySyncable* registry); | 41 virtual void RegisterPreferences(user_prefs::PrefRegistrySyncable* registry); |
| 40 | 42 |
| 41 virtual void SetUp() OVERRIDE; | 43 virtual void SetUp() OVERRIDE; |
| 42 | 44 |
| 43 virtual void TearDown() OVERRIDE; | 45 virtual void TearDown() OVERRIDE; |
| 44 | 46 |
| 45 protected: | 47 protected: |
| 46 ExtensionPrefs* prefs() { return prefs_.prefs(); } | 48 ExtensionPrefs* prefs() { return prefs_.prefs(); } |
| 47 | 49 |
| 48 MessageLoop message_loop_; | 50 MessageLoop message_loop_; |
| 49 content::TestBrowserThread ui_thread_; | 51 content::TestBrowserThread ui_thread_; |
| 50 | 52 |
| 51 TestExtensionPrefs prefs_; | 53 TestExtensionPrefs prefs_; |
| 52 | 54 |
| 53 private: | 55 private: |
| 54 DISALLOW_COPY_AND_ASSIGN(ExtensionPrefsTest); | 56 DISALLOW_COPY_AND_ASSIGN(ExtensionPrefsTest); |
| 55 }; | 57 }; |
| 56 | 58 |
| 57 class ExtensionPrefsPrepopulatedTest : public ExtensionPrefsTest { | 59 class ExtensionPrefsPrepopulatedTest : public ExtensionPrefsTest { |
| 58 public: | 60 public: |
| 59 ExtensionPrefsPrepopulatedTest(); | 61 ExtensionPrefsPrepopulatedTest(); |
| 60 virtual ~ExtensionPrefsPrepopulatedTest(); | 62 virtual ~ExtensionPrefsPrepopulatedTest(); |
| 61 | 63 |
| 62 virtual void RegisterPreferences(PrefRegistrySyncable* registry) OVERRIDE; | 64 virtual void RegisterPreferences( |
| 65 user_prefs::PrefRegistrySyncable* registry) OVERRIDE; |
| 63 | 66 |
| 64 void InstallExtControlledPref(Extension* ext, | 67 void InstallExtControlledPref(Extension* ext, |
| 65 const std::string& key, | 68 const std::string& key, |
| 66 base::Value* val); | 69 base::Value* val); |
| 67 | 70 |
| 68 void InstallExtControlledPrefIncognito(Extension* ext, | 71 void InstallExtControlledPrefIncognito(Extension* ext, |
| 69 const std::string& key, | 72 const std::string& key, |
| 70 base::Value* val); | 73 base::Value* val); |
| 71 | 74 |
| 72 void InstallExtControlledPrefIncognitoSessionOnly( | 75 void InstallExtControlledPrefIncognitoSessionOnly( |
| (...skipping 21 matching lines...) Expand all Loading... |
| 94 | 97 |
| 95 scoped_refptr<Extension> ext1_scoped_; | 98 scoped_refptr<Extension> ext1_scoped_; |
| 96 scoped_refptr<Extension> ext2_scoped_; | 99 scoped_refptr<Extension> ext2_scoped_; |
| 97 scoped_refptr<Extension> ext3_scoped_; | 100 scoped_refptr<Extension> ext3_scoped_; |
| 98 scoped_refptr<Extension> ext4_scoped_; | 101 scoped_refptr<Extension> ext4_scoped_; |
| 99 }; | 102 }; |
| 100 | 103 |
| 101 } // namespace extensions | 104 } // namespace extensions |
| 102 | 105 |
| 103 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PREFS_UNITTEST_H_ | 106 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PREFS_UNITTEST_H_ |
| OLD | NEW |