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