Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(361)

Side by Side Diff: extensions/browser/lazy_background_task_queue_unittest.cc

Issue 503873002: Remove implicit conversions from scoped_refptr to T* in extensions/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « extensions/browser/info_map.h ('k') | extensions/browser/process_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 // The task ran immediately because the creation failed. 188 // The task ran immediately because the creation failed.
189 EXPECT_EQ(1, task_run_count()); 189 EXPECT_EQ(1, task_run_count());
190 } 190 }
191 191
192 // Tests that pending tasks are actually run. 192 // Tests that pending tasks are actually run.
193 TEST_F(LazyBackgroundTaskQueueTest, ProcessPendingTasks) { 193 TEST_F(LazyBackgroundTaskQueueTest, ProcessPendingTasks) {
194 LazyBackgroundTaskQueue queue(browser_context()); 194 LazyBackgroundTaskQueue queue(browser_context());
195 195
196 // ProcessPendingTasks is a no-op if there are no tasks. 196 // ProcessPendingTasks is a no-op if there are no tasks.
197 scoped_refptr<Extension> extension = CreateSimpleExtension(); 197 scoped_refptr<Extension> extension = CreateSimpleExtension();
198 queue.ProcessPendingTasks(NULL, browser_context(), extension); 198 queue.ProcessPendingTasks(NULL, browser_context(), extension.get());
199 EXPECT_EQ(0, task_run_count()); 199 EXPECT_EQ(0, task_run_count());
200 200
201 // Schedule a task to run. 201 // Schedule a task to run.
202 queue.AddPendingTask(browser_context(), 202 queue.AddPendingTask(browser_context(),
203 extension->id(), 203 extension->id(),
204 base::Bind(&LazyBackgroundTaskQueueTest::RunPendingTask, 204 base::Bind(&LazyBackgroundTaskQueueTest::RunPendingTask,
205 base::Unretained(this))); 205 base::Unretained(this)));
206 EXPECT_EQ(0, task_run_count()); 206 EXPECT_EQ(0, task_run_count());
207 EXPECT_EQ(1u, queue.extensions_with_pending_tasks()); 207 EXPECT_EQ(1u, queue.extensions_with_pending_tasks());
208 208
209 // Trying to run tasks for an unrelated BrowserContext should do nothing. 209 // Trying to run tasks for an unrelated BrowserContext should do nothing.
210 content::TestBrowserContext unrelated_context; 210 content::TestBrowserContext unrelated_context;
211 queue.ProcessPendingTasks(NULL, &unrelated_context, extension); 211 queue.ProcessPendingTasks(NULL, &unrelated_context, extension.get());
212 EXPECT_EQ(0, task_run_count()); 212 EXPECT_EQ(0, task_run_count());
213 EXPECT_EQ(1u, queue.extensions_with_pending_tasks()); 213 EXPECT_EQ(1u, queue.extensions_with_pending_tasks());
214 214
215 // Processing tasks when there is one pending runs the task and removes the 215 // Processing tasks when there is one pending runs the task and removes the
216 // extension from the list of extensions with pending tasks. 216 // extension from the list of extensions with pending tasks.
217 queue.ProcessPendingTasks(NULL, browser_context(), extension); 217 queue.ProcessPendingTasks(NULL, browser_context(), extension.get());
218 EXPECT_EQ(1, task_run_count()); 218 EXPECT_EQ(1, task_run_count());
219 EXPECT_EQ(0u, queue.extensions_with_pending_tasks()); 219 EXPECT_EQ(0u, queue.extensions_with_pending_tasks());
220 } 220 }
221 221
222 } // namespace extensions 222 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/info_map.h ('k') | extensions/browser/process_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698