| 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "chrome/browser/extensions/test_extension_prefs.h" | 10 #include "chrome/browser/extensions/test_extension_prefs.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 namespace base { | 14 namespace base { |
| 15 class Value; | 15 class Value; |
| 16 } | 16 } |
| 17 | 17 |
| 18 namespace extensions { | 18 namespace extensions { |
| 19 class Extension; | 19 class Extension; |
| 20 } | |
| 21 | 20 |
| 22 // Base class for extension preference-related unit tests. | 21 // Base class for extension preference-related unit tests. |
| 23 class ExtensionPrefsTest : public testing::Test { | 22 class ExtensionPrefsTest : public testing::Test { |
| 24 public: | 23 public: |
| 25 ExtensionPrefsTest(); | 24 ExtensionPrefsTest(); |
| 26 virtual ~ExtensionPrefsTest(); | 25 virtual ~ExtensionPrefsTest(); |
| 27 | 26 |
| 28 // This function will get called once, and is the right place to do operations | 27 // This function will get called once, and is the right place to do operations |
| 29 // on ExtensionPrefs that write data. | 28 // on ExtensionPrefs that write data. |
| 30 virtual void Initialize() = 0; | 29 virtual void Initialize() = 0; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 54 DISALLOW_COPY_AND_ASSIGN(ExtensionPrefsTest); | 53 DISALLOW_COPY_AND_ASSIGN(ExtensionPrefsTest); |
| 55 }; | 54 }; |
| 56 | 55 |
| 57 class ExtensionPrefsPrepopulatedTest : public ExtensionPrefsTest { | 56 class ExtensionPrefsPrepopulatedTest : public ExtensionPrefsTest { |
| 58 public: | 57 public: |
| 59 ExtensionPrefsPrepopulatedTest(); | 58 ExtensionPrefsPrepopulatedTest(); |
| 60 virtual ~ExtensionPrefsPrepopulatedTest(); | 59 virtual ~ExtensionPrefsPrepopulatedTest(); |
| 61 | 60 |
| 62 virtual void RegisterPreferences() OVERRIDE; | 61 virtual void RegisterPreferences() OVERRIDE; |
| 63 | 62 |
| 64 void InstallExtControlledPref(extensions::Extension* ext, | 63 void InstallExtControlledPref(Extension* ext, |
| 65 const std::string& key, | 64 const std::string& key, |
| 66 base::Value* val); | 65 base::Value* val); |
| 67 | 66 |
| 68 void InstallExtControlledPrefIncognito(extensions::Extension* ext, | 67 void InstallExtControlledPrefIncognito(Extension* ext, |
| 69 const std::string& key, | 68 const std::string& key, |
| 70 base::Value* val); | 69 base::Value* val); |
| 71 | 70 |
| 72 void InstallExtControlledPrefIncognitoSessionOnly( | 71 void InstallExtControlledPrefIncognitoSessionOnly( |
| 73 extensions::Extension* ext, | 72 Extension* ext, |
| 74 const std::string& key, | 73 const std::string& key, |
| 75 base::Value* val); | 74 base::Value* val); |
| 76 | 75 |
| 77 void InstallExtension(extensions::Extension* ext); | 76 void InstallExtension(Extension* ext); |
| 78 | 77 |
| 79 void UninstallExtension(const std::string& extension_id); | 78 void UninstallExtension(const std::string& extension_id); |
| 80 | 79 |
| 81 // Weak references, for convenience. | 80 // Weak references, for convenience. |
| 82 extensions::Extension* ext1_; | 81 Extension* ext1_; |
| 83 extensions::Extension* ext2_; | 82 Extension* ext2_; |
| 84 extensions::Extension* ext3_; | 83 Extension* ext3_; |
| 85 extensions::Extension* ext4_; | 84 Extension* ext4_; |
| 86 | 85 |
| 87 // Flags indicating whether each of the extensions has been installed, yet. | 86 // Flags indicating whether each of the extensions has been installed, yet. |
| 88 bool installed[4]; | 87 bool installed[4]; |
| 89 | 88 |
| 90 private: | 89 private: |
| 91 void EnsureExtensionInstalled(extensions::Extension *ext); | 90 void EnsureExtensionInstalled(Extension *ext); |
| 92 | 91 |
| 93 void EnsureExtensionUninstalled(const std::string& extension_id); | 92 void EnsureExtensionUninstalled(const std::string& extension_id); |
| 94 | 93 |
| 95 scoped_refptr<extensions::Extension> ext1_scoped_; | 94 scoped_refptr<Extension> ext1_scoped_; |
| 96 scoped_refptr<extensions::Extension> ext2_scoped_; | 95 scoped_refptr<Extension> ext2_scoped_; |
| 97 scoped_refptr<extensions::Extension> ext3_scoped_; | 96 scoped_refptr<Extension> ext3_scoped_; |
| 98 scoped_refptr<extensions::Extension> ext4_scoped_; | 97 scoped_refptr<Extension> ext4_scoped_; |
| 99 }; | 98 }; |
| 100 | 99 |
| 100 } // namespace extensions |
| 101 | 101 |
| 102 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PREFS_UNITTEST_H_ | 102 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PREFS_UNITTEST_H_ |
| OLD | NEW |