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

Side by Side Diff: webrtc/system_wrappers/source/scoped_vector_unittest.cc

Issue 1778243006: Remove the (previosly deprecated) Pass methods (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 9 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 | « webrtc/system_wrappers/include/scoped_vector.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 214
215 TEST(ScopedVectorTest, MoveConstruct) { 215 TEST(ScopedVectorTest, MoveConstruct) {
216 LifeCycleWatcher watcher; 216 LifeCycleWatcher watcher;
217 EXPECT_EQ(LC_INITIAL, watcher.life_cycle_state()); 217 EXPECT_EQ(LC_INITIAL, watcher.life_cycle_state());
218 { 218 {
219 ScopedVector<LifeCycleObject> scoped_vector; 219 ScopedVector<LifeCycleObject> scoped_vector;
220 scoped_vector.push_back(watcher.NewLifeCycleObject()); 220 scoped_vector.push_back(watcher.NewLifeCycleObject());
221 EXPECT_FALSE(scoped_vector.empty()); 221 EXPECT_FALSE(scoped_vector.empty());
222 EXPECT_TRUE(watcher.IsWatching(scoped_vector.back())); 222 EXPECT_TRUE(watcher.IsWatching(scoped_vector.back()));
223 223
224 ScopedVector<LifeCycleObject> scoped_vector_copy( 224 ScopedVector<LifeCycleObject> scoped_vector_copy(std::move(scoped_vector));
225 scoped_vector.DEPRECATED_Pass());
226 EXPECT_TRUE(scoped_vector.empty()); 225 EXPECT_TRUE(scoped_vector.empty());
227 EXPECT_FALSE(scoped_vector_copy.empty()); 226 EXPECT_FALSE(scoped_vector_copy.empty());
228 EXPECT_TRUE(watcher.IsWatching(scoped_vector_copy.back())); 227 EXPECT_TRUE(watcher.IsWatching(scoped_vector_copy.back()));
229 228
230 EXPECT_EQ(LC_CONSTRUCTED, watcher.life_cycle_state()); 229 EXPECT_EQ(LC_CONSTRUCTED, watcher.life_cycle_state());
231 } 230 }
232 EXPECT_EQ(LC_DESTROYED, watcher.life_cycle_state()); 231 EXPECT_EQ(LC_DESTROYED, watcher.life_cycle_state());
233 } 232 }
234 233
235 TEST(ScopedVectorTest, MoveAssign) { 234 TEST(ScopedVectorTest, MoveAssign) {
236 LifeCycleWatcher watcher; 235 LifeCycleWatcher watcher;
237 EXPECT_EQ(LC_INITIAL, watcher.life_cycle_state()); 236 EXPECT_EQ(LC_INITIAL, watcher.life_cycle_state());
238 { 237 {
239 ScopedVector<LifeCycleObject> scoped_vector; 238 ScopedVector<LifeCycleObject> scoped_vector;
240 scoped_vector.push_back(watcher.NewLifeCycleObject()); 239 scoped_vector.push_back(watcher.NewLifeCycleObject());
241 ScopedVector<LifeCycleObject> scoped_vector_assign; 240 ScopedVector<LifeCycleObject> scoped_vector_assign;
242 EXPECT_FALSE(scoped_vector.empty()); 241 EXPECT_FALSE(scoped_vector.empty());
243 EXPECT_TRUE(watcher.IsWatching(scoped_vector.back())); 242 EXPECT_TRUE(watcher.IsWatching(scoped_vector.back()));
244 243
245 scoped_vector_assign = scoped_vector.DEPRECATED_Pass(); 244 scoped_vector_assign = std::move(scoped_vector);
246 EXPECT_TRUE(scoped_vector.empty()); 245 EXPECT_TRUE(scoped_vector.empty());
247 EXPECT_FALSE(scoped_vector_assign.empty()); 246 EXPECT_FALSE(scoped_vector_assign.empty());
248 EXPECT_TRUE(watcher.IsWatching(scoped_vector_assign.back())); 247 EXPECT_TRUE(watcher.IsWatching(scoped_vector_assign.back()));
249 248
250 EXPECT_EQ(LC_CONSTRUCTED, watcher.life_cycle_state()); 249 EXPECT_EQ(LC_CONSTRUCTED, watcher.life_cycle_state());
251 } 250 }
252 EXPECT_EQ(LC_DESTROYED, watcher.life_cycle_state()); 251 EXPECT_EQ(LC_DESTROYED, watcher.life_cycle_state());
253 } 252 }
254 253
255 class DeleteCounter { 254 class DeleteCounter {
(...skipping 11 matching lines...) Expand all
267 private: 266 private:
268 int* const deletes_; 267 int* const deletes_;
269 268
270 RTC_DISALLOW_COPY_AND_ASSIGN(DeleteCounter); 269 RTC_DISALLOW_COPY_AND_ASSIGN(DeleteCounter);
271 }; 270 };
272 271
273 // This class is used in place of Chromium's base::Callback. 272 // This class is used in place of Chromium's base::Callback.
274 template <typename T> 273 template <typename T>
275 class PassThru { 274 class PassThru {
276 public: 275 public:
277 explicit PassThru(ScopedVector<T> scoper) 276 explicit PassThru(ScopedVector<T> scoper) : scoper_(std::move(scoper)) {}
278 : scoper_(scoper.DEPRECATED_Pass()) {} 277 ScopedVector<T> Run() { return std::move(scoper_); }
279
280 ScopedVector<T> Run() {
281 return scoper_.DEPRECATED_Pass();
282 }
283 278
284 private: 279 private:
285 ScopedVector<T> scoper_; 280 ScopedVector<T> scoper_;
286 }; 281 };
287 282
288 TEST(ScopedVectorTest, Passed) { 283 TEST(ScopedVectorTest, Passed) {
289 int deletes = 0; 284 int deletes = 0;
290 ScopedVector<DeleteCounter> deleter_vector; 285 ScopedVector<DeleteCounter> deleter_vector;
291 deleter_vector.push_back(new DeleteCounter(&deletes)); 286 deleter_vector.push_back(new DeleteCounter(&deletes));
292 EXPECT_EQ(0, deletes); 287 EXPECT_EQ(0, deletes);
293 PassThru<DeleteCounter> pass_thru(deleter_vector.DEPRECATED_Pass()); 288 PassThru<DeleteCounter> pass_thru(std::move(deleter_vector));
294 EXPECT_EQ(0, deletes); 289 EXPECT_EQ(0, deletes);
295 ScopedVector<DeleteCounter> result = pass_thru.Run(); 290 ScopedVector<DeleteCounter> result = pass_thru.Run();
296 EXPECT_EQ(0, deletes); 291 EXPECT_EQ(0, deletes);
297 result.clear(); 292 result.clear();
298 EXPECT_EQ(1, deletes); 293 EXPECT_EQ(1, deletes);
299 }; 294 };
300 295
301 TEST(ScopedVectorTest, InsertRange) { 296 TEST(ScopedVectorTest, InsertRange) {
302 LifeCycleWatcher watchers[5]; 297 LifeCycleWatcher watchers[5];
303 size_t watchers_size = sizeof(watchers) / sizeof(*watchers); 298 size_t watchers_size = sizeof(watchers) / sizeof(*watchers);
(...skipping 17 matching lines...) Expand all
321 EXPECT_EQ(LC_CONSTRUCTED, it->life_cycle_state()); 316 EXPECT_EQ(LC_CONSTRUCTED, it->life_cycle_state());
322 for (LifeCycleWatcher* it = watchers + 1; it != watchers + 3; ++it) 317 for (LifeCycleWatcher* it = watchers + 1; it != watchers + 3; ++it)
323 EXPECT_EQ(LC_DESTROYED, it->life_cycle_state()); 318 EXPECT_EQ(LC_DESTROYED, it->life_cycle_state());
324 for (LifeCycleWatcher* it = watchers + 3; it != watchers + watchers_size; 319 for (LifeCycleWatcher* it = watchers + 3; it != watchers + watchers_size;
325 ++it) 320 ++it)
326 EXPECT_EQ(LC_CONSTRUCTED, it->life_cycle_state()); 321 EXPECT_EQ(LC_CONSTRUCTED, it->life_cycle_state());
327 } 322 }
328 323
329 } // namespace 324 } // namespace
330 } // namespace webrtc 325 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/system_wrappers/include/scoped_vector.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698