| 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 "base/memory/scoped_ptr.h" |
| 8 #include "base/prefs/testing_pref_service.h" | 9 #include "base/prefs/testing_pref_service.h" |
| 9 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 10 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
| 10 #include "components/user_prefs/user_prefs.h" | 11 #include "components/user_prefs/user_prefs.h" |
| 11 #include "content/public/browser/notification_service.h" | 12 #include "content/public/browser/notification_service.h" |
| 12 #include "content/public/test/test_browser_context.h" | 13 #include "content/public/test/test_browser_context.h" |
| 13 #include "extensions/browser/extension_registry.h" | 14 #include "extensions/browser/extension_registry.h" |
| 14 #include "extensions/browser/extension_registry_factory.h" | 15 #include "extensions/browser/extension_registry_factory.h" |
| 15 #include "extensions/browser/extensions_test.h" | 16 #include "extensions/browser/extensions_test.h" |
| 16 #include "extensions/browser/process_manager.h" | 17 #include "extensions/browser/process_manager.h" |
| 17 #include "extensions/browser/process_manager_factory.h" | 18 #include "extensions/browser/process_manager_factory.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 45 create_count_++; | 46 create_count_++; |
| 46 return false; | 47 return false; |
| 47 } | 48 } |
| 48 | 49 |
| 49 private: | 50 private: |
| 50 int create_count_; | 51 int create_count_; |
| 51 | 52 |
| 52 DISALLOW_COPY_AND_ASSIGN(TestProcessManager); | 53 DISALLOW_COPY_AND_ASSIGN(TestProcessManager); |
| 53 }; | 54 }; |
| 54 | 55 |
| 55 KeyedService* CreateTestProcessManager(BrowserContext* context) { | 56 scoped_ptr<KeyedService> CreateTestProcessManager(BrowserContext* context) { |
| 56 return new TestProcessManager(context); | 57 return make_scoped_ptr(new TestProcessManager(context)); |
| 57 } | 58 } |
| 58 | 59 |
| 59 } // namespace | 60 } // namespace |
| 60 | 61 |
| 61 // Derives from ExtensionsTest to provide content module and keyed service | 62 // Derives from ExtensionsTest to provide content module and keyed service |
| 62 // initialization. | 63 // initialization. |
| 63 class LazyBackgroundTaskQueueTest : public ExtensionsTest { | 64 class LazyBackgroundTaskQueueTest : public ExtensionsTest { |
| 64 public: | 65 public: |
| 65 LazyBackgroundTaskQueueTest() | 66 LazyBackgroundTaskQueueTest() |
| 66 : notification_service_(content::NotificationService::Create()), | 67 : notification_service_(content::NotificationService::Create()), |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 EXPECT_EQ(1u, queue.extensions_with_pending_tasks()); | 205 EXPECT_EQ(1u, queue.extensions_with_pending_tasks()); |
| 205 | 206 |
| 206 // Processing tasks when there is one pending runs the task and removes the | 207 // Processing tasks when there is one pending runs the task and removes the |
| 207 // extension from the list of extensions with pending tasks. | 208 // extension from the list of extensions with pending tasks. |
| 208 queue.ProcessPendingTasks(NULL, browser_context(), extension.get()); | 209 queue.ProcessPendingTasks(NULL, browser_context(), extension.get()); |
| 209 EXPECT_EQ(1, task_run_count()); | 210 EXPECT_EQ(1, task_run_count()); |
| 210 EXPECT_EQ(0u, queue.extensions_with_pending_tasks()); | 211 EXPECT_EQ(0u, queue.extensions_with_pending_tasks()); |
| 211 } | 212 } |
| 212 | 213 |
| 213 } // namespace extensions | 214 } // namespace extensions |
| OLD | NEW |