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

Side by Side Diff: content/browser/cache_storage/cache_storage_scheduler_unittest.cc

Issue 2947753002: CacheStorage: Migrate to BindOnce/OnceCallback/OnceClosure (Closed)
Patch Set: Untangle Batch logic (relies on AdaptCallbackForRepeating) Created 3 years, 6 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "content/browser/cache_storage/cache_storage_scheduler.h" 5 #include "content/browser/cache_storage/cache_storage_scheduler.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "content/public/test/test_browser_thread_bundle.h" 10 #include "content/public/test/test_browser_thread_bundle.h"
(...skipping 29 matching lines...) Expand all
40 task2_(TestTask(&scheduler_)) {} 40 task2_(TestTask(&scheduler_)) {}
41 41
42 TestBrowserThreadBundle browser_thread_bundle_; 42 TestBrowserThreadBundle browser_thread_bundle_;
43 CacheStorageScheduler scheduler_; 43 CacheStorageScheduler scheduler_;
44 TestTask task1_; 44 TestTask task1_;
45 TestTask task2_; 45 TestTask task2_;
46 }; 46 };
47 47
48 TEST_F(CacheStorageSchedulerTest, ScheduleOne) { 48 TEST_F(CacheStorageSchedulerTest, ScheduleOne) {
49 scheduler_.ScheduleOperation( 49 scheduler_.ScheduleOperation(
50 base::Bind(&TestTask::Run, base::Unretained(&task1_))); 50 base::BindOnce(&TestTask::Run, base::Unretained(&task1_)));
51 base::RunLoop().RunUntilIdle(); 51 base::RunLoop().RunUntilIdle();
52 EXPECT_EQ(1, task1_.callback_count()); 52 EXPECT_EQ(1, task1_.callback_count());
53 } 53 }
54 54
55 TEST_F(CacheStorageSchedulerTest, ScheduleTwo) { 55 TEST_F(CacheStorageSchedulerTest, ScheduleTwo) {
56 scheduler_.ScheduleOperation( 56 scheduler_.ScheduleOperation(
57 base::Bind(&TestTask::Run, base::Unretained(&task1_))); 57 base::BindOnce(&TestTask::Run, base::Unretained(&task1_)));
58 scheduler_.ScheduleOperation( 58 scheduler_.ScheduleOperation(
59 base::Bind(&TestTask::Run, base::Unretained(&task2_))); 59 base::BindOnce(&TestTask::Run, base::Unretained(&task2_)));
60 base::RunLoop().RunUntilIdle(); 60 base::RunLoop().RunUntilIdle();
61 EXPECT_EQ(1, task1_.callback_count()); 61 EXPECT_EQ(1, task1_.callback_count());
62 EXPECT_EQ(0, task2_.callback_count()); 62 EXPECT_EQ(0, task2_.callback_count());
63 63
64 task1_.Done(); 64 task1_.Done();
65 EXPECT_TRUE(scheduler_.ScheduledOperations()); 65 EXPECT_TRUE(scheduler_.ScheduledOperations());
66 base::RunLoop().RunUntilIdle(); 66 base::RunLoop().RunUntilIdle();
67 EXPECT_EQ(1, task1_.callback_count()); 67 EXPECT_EQ(1, task1_.callback_count());
68 EXPECT_EQ(1, task2_.callback_count()); 68 EXPECT_EQ(1, task2_.callback_count());
69 } 69 }
70 70
71 TEST_F(CacheStorageSchedulerTest, ScheduledOperations) { 71 TEST_F(CacheStorageSchedulerTest, ScheduledOperations) {
72 scheduler_.ScheduleOperation( 72 scheduler_.ScheduleOperation(
73 base::Bind(&TestTask::Run, base::Unretained(&task1_))); 73 base::BindOnce(&TestTask::Run, base::Unretained(&task1_)));
74 EXPECT_TRUE(scheduler_.ScheduledOperations()); 74 EXPECT_TRUE(scheduler_.ScheduledOperations());
75 base::RunLoop().RunUntilIdle(); 75 base::RunLoop().RunUntilIdle();
76 EXPECT_EQ(1, task1_.callback_count()); 76 EXPECT_EQ(1, task1_.callback_count());
77 EXPECT_TRUE(scheduler_.ScheduledOperations()); 77 EXPECT_TRUE(scheduler_.ScheduledOperations());
78 task1_.Done(); 78 task1_.Done();
79 EXPECT_FALSE(scheduler_.ScheduledOperations()); 79 EXPECT_FALSE(scheduler_.ScheduledOperations());
80 } 80 }
81 81
82 } // namespace content 82 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698