OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "extensions/browser/lazy_background_task_queue.h" | 5 #include "extensions/browser/lazy_background_task_queue.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
12 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 12 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
13 #include "components/pref_registry/testing_pref_service_syncable.h" | |
14 #include "components/prefs/testing_pref_service.h" | 13 #include "components/prefs/testing_pref_service.h" |
| 14 #include "components/sync_preferences/testing_pref_service_syncable.h" |
15 #include "components/user_prefs/user_prefs.h" | 15 #include "components/user_prefs/user_prefs.h" |
16 #include "content/public/test/test_browser_context.h" | 16 #include "content/public/test/test_browser_context.h" |
17 #include "extensions/browser/extension_registry.h" | 17 #include "extensions/browser/extension_registry.h" |
18 #include "extensions/browser/extension_registry_factory.h" | 18 #include "extensions/browser/extension_registry_factory.h" |
19 #include "extensions/browser/extensions_test.h" | 19 #include "extensions/browser/extensions_test.h" |
20 #include "extensions/browser/process_manager.h" | 20 #include "extensions/browser/process_manager.h" |
21 #include "extensions/browser/process_manager_factory.h" | 21 #include "extensions/browser/process_manager_factory.h" |
22 #include "extensions/browser/test_extensions_browser_client.h" | 22 #include "extensions/browser/test_extensions_browser_client.h" |
23 #include "extensions/common/extension.h" | 23 #include "extensions/common/extension.h" |
24 #include "extensions/common/extension_builder.h" | 24 #include "extensions/common/extension_builder.h" |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 ExtensionRegistry::Get(browser_context())->AddEnabled(extension); | 111 ExtensionRegistry::Get(browser_context())->AddEnabled(extension); |
112 return extension; | 112 return extension; |
113 } | 113 } |
114 | 114 |
115 protected: | 115 protected: |
116 void SetUp() override { | 116 void SetUp() override { |
117 user_prefs::UserPrefs::Set(browser_context(), &testing_pref_service_); | 117 user_prefs::UserPrefs::Set(browser_context(), &testing_pref_service_); |
118 } | 118 } |
119 | 119 |
120 private: | 120 private: |
121 user_prefs::TestingPrefServiceSyncable testing_pref_service_; | 121 sync_preferences::TestingPrefServiceSyncable testing_pref_service_; |
122 | 122 |
123 // The total number of pending tasks that have been executed. | 123 // The total number of pending tasks that have been executed. |
124 int task_run_count_; | 124 int task_run_count_; |
125 | 125 |
126 DISALLOW_COPY_AND_ASSIGN(LazyBackgroundTaskQueueTest); | 126 DISALLOW_COPY_AND_ASSIGN(LazyBackgroundTaskQueueTest); |
127 }; | 127 }; |
128 | 128 |
129 // Tests that only extensions with background pages should have tasks queued. | 129 // Tests that only extensions with background pages should have tasks queued. |
130 TEST_F(LazyBackgroundTaskQueueTest, ShouldEnqueueTask) { | 130 TEST_F(LazyBackgroundTaskQueueTest, ShouldEnqueueTask) { |
131 LazyBackgroundTaskQueue queue(browser_context()); | 131 LazyBackgroundTaskQueue queue(browser_context()); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 EXPECT_EQ(1u, queue.extensions_with_pending_tasks()); | 209 EXPECT_EQ(1u, queue.extensions_with_pending_tasks()); |
210 | 210 |
211 // Processing tasks when there is one pending runs the task and removes the | 211 // Processing tasks when there is one pending runs the task and removes the |
212 // extension from the list of extensions with pending tasks. | 212 // extension from the list of extensions with pending tasks. |
213 queue.ProcessPendingTasks(NULL, browser_context(), extension.get()); | 213 queue.ProcessPendingTasks(NULL, browser_context(), extension.get()); |
214 EXPECT_EQ(1, task_run_count()); | 214 EXPECT_EQ(1, task_run_count()); |
215 EXPECT_EQ(0u, queue.extensions_with_pending_tasks()); | 215 EXPECT_EQ(0u, queue.extensions_with_pending_tasks()); |
216 } | 216 } |
217 | 217 |
218 } // namespace extensions | 218 } // namespace extensions |
OLD | NEW |