OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/safe_browsing/incident_reporting/delayed_callback_runne
r.h" | 5 #include "chrome/browser/safe_browsing/incident_reporting/delayed_callback_runne
r.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 } | 122 } |
123 | 123 |
124 // Tests that a callback registered after Start() is called is also run and | 124 // Tests that a callback registered after Start() is called is also run and |
125 // deleted. | 125 // deleted. |
126 TEST_F(DelayedCallbackRunnerTest, AddWhileRunningRun) { | 126 TEST_F(DelayedCallbackRunnerTest, AddWhileRunningRun) { |
127 const std::string name("one"); | 127 const std::string name("one"); |
128 const std::string name2("two"); | 128 const std::string name2("two"); |
129 | 129 |
130 // Post a task to register a new callback after Start() is called. | 130 // Post a task to register a new callback after Start() is called. |
131 base::ThreadTaskRunnerHandle::Get()->PostTask( | 131 base::ThreadTaskRunnerHandle::Get()->PostTask( |
132 FROM_HERE, base::Bind(&DelayedCallbackRunnerTest::RegisterTestCallback, | 132 FROM_HERE, |
133 base::Unretained(this), name2)); | 133 base::BindOnce(&DelayedCallbackRunnerTest::RegisterTestCallback, |
| 134 base::Unretained(this), name2)); |
134 | 135 |
135 RegisterTestCallback(name); | 136 RegisterTestCallback(name); |
136 instance_->Start(); | 137 instance_->Start(); |
137 base::RunLoop().RunUntilIdle(); | 138 base::RunLoop().RunUntilIdle(); |
138 EXPECT_TRUE(CallbackWasRun(name)); | 139 EXPECT_TRUE(CallbackWasRun(name)); |
139 EXPECT_TRUE(CallbackWasDeleted(name)); | 140 EXPECT_TRUE(CallbackWasDeleted(name)); |
140 EXPECT_TRUE(CallbackWasRun(name2)); | 141 EXPECT_TRUE(CallbackWasRun(name2)); |
141 EXPECT_TRUE(CallbackWasDeleted(name2)); | 142 EXPECT_TRUE(CallbackWasDeleted(name2)); |
142 } | 143 } |
143 | 144 |
144 TEST_F(DelayedCallbackRunnerTest, MultipleRuns) { | 145 TEST_F(DelayedCallbackRunnerTest, MultipleRuns) { |
145 const std::string name("one"); | 146 const std::string name("one"); |
146 const std::string name2("two"); | 147 const std::string name2("two"); |
147 | 148 |
148 RegisterTestCallback(name); | 149 RegisterTestCallback(name); |
149 instance_->Start(); | 150 instance_->Start(); |
150 base::RunLoop().RunUntilIdle(); | 151 base::RunLoop().RunUntilIdle(); |
151 EXPECT_TRUE(CallbackWasRun(name)); | 152 EXPECT_TRUE(CallbackWasRun(name)); |
152 EXPECT_TRUE(CallbackWasDeleted(name)); | 153 EXPECT_TRUE(CallbackWasDeleted(name)); |
153 | 154 |
154 RegisterTestCallback(name2); | 155 RegisterTestCallback(name2); |
155 instance_->Start(); | 156 instance_->Start(); |
156 base::RunLoop().RunUntilIdle(); | 157 base::RunLoop().RunUntilIdle(); |
157 EXPECT_TRUE(CallbackWasRun(name2)); | 158 EXPECT_TRUE(CallbackWasRun(name2)); |
158 EXPECT_TRUE(CallbackWasDeleted(name2)); | 159 EXPECT_TRUE(CallbackWasDeleted(name2)); |
159 } | 160 } |
OLD | NEW |