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