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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 8 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
9 #include "content/public/browser/notification_service.h" | 9 #include "content/public/browser/notification_service.h" |
10 #include "content/public/test/test_browser_context.h" | 10 #include "content/public/test/test_browser_context.h" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 // Derives from ExtensionsTest to provide content module and keyed service | 70 // Derives from ExtensionsTest to provide content module and keyed service |
71 // initialization. | 71 // initialization. |
72 class LazyBackgroundTaskQueueTest : public ExtensionsTest { | 72 class LazyBackgroundTaskQueueTest : public ExtensionsTest { |
73 public: | 73 public: |
74 LazyBackgroundTaskQueueTest() | 74 LazyBackgroundTaskQueueTest() |
75 : notification_service_(content::NotificationService::Create()), | 75 : notification_service_(content::NotificationService::Create()), |
76 task_run_count_(0) { | 76 task_run_count_(0) { |
77 extensions_browser_client()->set_extension_system_factory( | 77 extensions_browser_client()->set_extension_system_factory( |
78 &extension_system_factory_); | 78 &extension_system_factory_); |
79 } | 79 } |
80 virtual ~LazyBackgroundTaskQueueTest() {} | 80 ~LazyBackgroundTaskQueueTest() override {} |
81 | 81 |
82 int task_run_count() { return task_run_count_; } | 82 int task_run_count() { return task_run_count_; } |
83 | 83 |
84 // A simple callback for AddPendingTask. | 84 // A simple callback for AddPendingTask. |
85 void RunPendingTask(ExtensionHost* host) { | 85 void RunPendingTask(ExtensionHost* host) { |
86 task_run_count_++; | 86 task_run_count_++; |
87 } | 87 } |
88 | 88 |
89 // Creates and registers an extension without a background page. | 89 // Creates and registers an extension without a background page. |
90 scoped_refptr<Extension> CreateSimpleExtension() { | 90 scoped_refptr<Extension> CreateSimpleExtension() { |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 EXPECT_EQ(1u, queue.extensions_with_pending_tasks()); | 211 EXPECT_EQ(1u, queue.extensions_with_pending_tasks()); |
212 | 212 |
213 // Processing tasks when there is one pending runs the task and removes the | 213 // Processing tasks when there is one pending runs the task and removes the |
214 // extension from the list of extensions with pending tasks. | 214 // extension from the list of extensions with pending tasks. |
215 queue.ProcessPendingTasks(NULL, browser_context(), extension.get()); | 215 queue.ProcessPendingTasks(NULL, browser_context(), extension.get()); |
216 EXPECT_EQ(1, task_run_count()); | 216 EXPECT_EQ(1, task_run_count()); |
217 EXPECT_EQ(0u, queue.extensions_with_pending_tasks()); | 217 EXPECT_EQ(0u, queue.extensions_with_pending_tasks()); |
218 } | 218 } |
219 | 219 |
220 } // namespace extensions | 220 } // namespace extensions |
OLD | NEW |