| 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 namespace base { | 13 namespace base { |
| 14 class SequencedWorkerPool; |
| 14 class Value; | 15 class Value; |
| 15 } | 16 } |
| 16 | 17 |
| 17 namespace extensions { | 18 namespace extensions { |
| 18 class Extension; | 19 class Extension; |
| 19 | 20 |
| 20 // Base class for extension preference-related unit tests. | 21 // Base class for extension preference-related unit tests. |
| 21 class ExtensionPrefsTest : public testing::Test { | 22 class ExtensionPrefsTest : public testing::Test { |
| 22 public: | 23 public: |
| 23 ExtensionPrefsTest(); | 24 ExtensionPrefsTest(); |
| 24 virtual ~ExtensionPrefsTest(); | 25 virtual ~ExtensionPrefsTest(); |
| 25 | 26 |
| 26 // 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 |
| 27 // on ExtensionPrefs that write data. | 28 // on ExtensionPrefs that write data. |
| 28 virtual void Initialize() = 0; | 29 virtual void Initialize() = 0; |
| 29 | 30 |
| 30 // This function will be called twice - once while the original ExtensionPrefs | 31 // This function will be called twice - once while the original ExtensionPrefs |
| 31 // object is still alive, and once after recreation. Thus, it tests that | 32 // object is still alive, and once after recreation. Thus, it tests that |
| 32 // things don't break after any ExtensionPrefs startup work. | 33 // things don't break after any ExtensionPrefs startup work. |
| 33 virtual void Verify() = 0; | 34 virtual void Verify() = 0; |
| 34 | 35 |
| 35 // This function is called to Register preference default values. | 36 // This function is called to Register preference default values. |
| 36 virtual void RegisterPreferences(); | 37 virtual void RegisterPreferences(); |
| 37 | 38 |
| 38 virtual void SetUp() OVERRIDE; | 39 virtual void SetUp() OVERRIDE; |
| 39 | 40 |
| 40 virtual void TearDown() OVERRIDE; | 41 virtual void TearDown() OVERRIDE; |
| 41 | 42 |
| 42 protected: | 43 protected: |
| 43 ExtensionPrefs* prefs() { return prefs_.prefs(); } | 44 ExtensionPrefs* prefs() { return prefs_->prefs(); } |
| 44 | 45 |
| 45 MessageLoop message_loop_; | 46 MessageLoop message_loop_; |
| 46 content::TestBrowserThread ui_thread_; | 47 content::TestBrowserThread ui_thread_; |
| 47 content::TestBrowserThread file_thread_; | 48 content::TestBrowserThread file_thread_; |
| 48 | 49 |
| 49 TestExtensionPrefs prefs_; | 50 scoped_ptr<TestExtensionPrefs> prefs_; |
| 51 // A blocking pool that we can use for file operations. |
| 52 scoped_refptr<base::SequencedWorkerPool> blocking_pool_; |
| 50 | 53 |
| 51 private: | 54 private: |
| 52 DISALLOW_COPY_AND_ASSIGN(ExtensionPrefsTest); | 55 DISALLOW_COPY_AND_ASSIGN(ExtensionPrefsTest); |
| 53 }; | 56 }; |
| 54 | 57 |
| 55 class ExtensionPrefsPrepopulatedTest : public ExtensionPrefsTest { | 58 class ExtensionPrefsPrepopulatedTest : public ExtensionPrefsTest { |
| 56 public: | 59 public: |
| 57 ExtensionPrefsPrepopulatedTest(); | 60 ExtensionPrefsPrepopulatedTest(); |
| 58 virtual ~ExtensionPrefsPrepopulatedTest(); | 61 virtual ~ExtensionPrefsPrepopulatedTest(); |
| 59 | 62 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 | 95 |
| 93 scoped_refptr<Extension> ext1_scoped_; | 96 scoped_refptr<Extension> ext1_scoped_; |
| 94 scoped_refptr<Extension> ext2_scoped_; | 97 scoped_refptr<Extension> ext2_scoped_; |
| 95 scoped_refptr<Extension> ext3_scoped_; | 98 scoped_refptr<Extension> ext3_scoped_; |
| 96 scoped_refptr<Extension> ext4_scoped_; | 99 scoped_refptr<Extension> ext4_scoped_; |
| 97 }; | 100 }; |
| 98 | 101 |
| 99 } // namespace extensions | 102 } // namespace extensions |
| 100 | 103 |
| 101 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PREFS_UNITTEST_H_ | 104 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PREFS_UNITTEST_H_ |
| OLD | NEW |