| OLD | NEW |
| 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 Loading... |
| 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(scoped_vector.Pass()); | 224 ScopedVector<LifeCycleObject> scoped_vector_copy( |
| 225 scoped_vector.DEPRECATED_Pass()); |
| 225 EXPECT_TRUE(scoped_vector.empty()); | 226 EXPECT_TRUE(scoped_vector.empty()); |
| 226 EXPECT_FALSE(scoped_vector_copy.empty()); | 227 EXPECT_FALSE(scoped_vector_copy.empty()); |
| 227 EXPECT_TRUE(watcher.IsWatching(scoped_vector_copy.back())); | 228 EXPECT_TRUE(watcher.IsWatching(scoped_vector_copy.back())); |
| 228 | 229 |
| 229 EXPECT_EQ(LC_CONSTRUCTED, watcher.life_cycle_state()); | 230 EXPECT_EQ(LC_CONSTRUCTED, watcher.life_cycle_state()); |
| 230 } | 231 } |
| 231 EXPECT_EQ(LC_DESTROYED, watcher.life_cycle_state()); | 232 EXPECT_EQ(LC_DESTROYED, watcher.life_cycle_state()); |
| 232 } | 233 } |
| 233 | 234 |
| 234 TEST(ScopedVectorTest, MoveAssign) { | 235 TEST(ScopedVectorTest, MoveAssign) { |
| 235 LifeCycleWatcher watcher; | 236 LifeCycleWatcher watcher; |
| 236 EXPECT_EQ(LC_INITIAL, watcher.life_cycle_state()); | 237 EXPECT_EQ(LC_INITIAL, watcher.life_cycle_state()); |
| 237 { | 238 { |
| 238 ScopedVector<LifeCycleObject> scoped_vector; | 239 ScopedVector<LifeCycleObject> scoped_vector; |
| 239 scoped_vector.push_back(watcher.NewLifeCycleObject()); | 240 scoped_vector.push_back(watcher.NewLifeCycleObject()); |
| 240 ScopedVector<LifeCycleObject> scoped_vector_assign; | 241 ScopedVector<LifeCycleObject> scoped_vector_assign; |
| 241 EXPECT_FALSE(scoped_vector.empty()); | 242 EXPECT_FALSE(scoped_vector.empty()); |
| 242 EXPECT_TRUE(watcher.IsWatching(scoped_vector.back())); | 243 EXPECT_TRUE(watcher.IsWatching(scoped_vector.back())); |
| 243 | 244 |
| 244 scoped_vector_assign = scoped_vector.Pass(); | 245 scoped_vector_assign = scoped_vector.DEPRECATED_Pass(); |
| 245 EXPECT_TRUE(scoped_vector.empty()); | 246 EXPECT_TRUE(scoped_vector.empty()); |
| 246 EXPECT_FALSE(scoped_vector_assign.empty()); | 247 EXPECT_FALSE(scoped_vector_assign.empty()); |
| 247 EXPECT_TRUE(watcher.IsWatching(scoped_vector_assign.back())); | 248 EXPECT_TRUE(watcher.IsWatching(scoped_vector_assign.back())); |
| 248 | 249 |
| 249 EXPECT_EQ(LC_CONSTRUCTED, watcher.life_cycle_state()); | 250 EXPECT_EQ(LC_CONSTRUCTED, watcher.life_cycle_state()); |
| 250 } | 251 } |
| 251 EXPECT_EQ(LC_DESTROYED, watcher.life_cycle_state()); | 252 EXPECT_EQ(LC_DESTROYED, watcher.life_cycle_state()); |
| 252 } | 253 } |
| 253 | 254 |
| 254 class DeleteCounter { | 255 class DeleteCounter { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 266 private: | 267 private: |
| 267 int* const deletes_; | 268 int* const deletes_; |
| 268 | 269 |
| 269 RTC_DISALLOW_COPY_AND_ASSIGN(DeleteCounter); | 270 RTC_DISALLOW_COPY_AND_ASSIGN(DeleteCounter); |
| 270 }; | 271 }; |
| 271 | 272 |
| 272 // This class is used in place of Chromium's base::Callback. | 273 // This class is used in place of Chromium's base::Callback. |
| 273 template <typename T> | 274 template <typename T> |
| 274 class PassThru { | 275 class PassThru { |
| 275 public: | 276 public: |
| 276 explicit PassThru(ScopedVector<T> scoper) : scoper_(scoper.Pass()) {} | 277 explicit PassThru(ScopedVector<T> scoper) |
| 278 : scoper_(scoper.DEPRECATED_Pass()) {} |
| 277 | 279 |
| 278 ScopedVector<T> Run() { | 280 ScopedVector<T> Run() { |
| 279 return scoper_.Pass(); | 281 return scoper_.DEPRECATED_Pass(); |
| 280 } | 282 } |
| 281 | 283 |
| 282 private: | 284 private: |
| 283 ScopedVector<T> scoper_; | 285 ScopedVector<T> scoper_; |
| 284 }; | 286 }; |
| 285 | 287 |
| 286 TEST(ScopedVectorTest, Passed) { | 288 TEST(ScopedVectorTest, Passed) { |
| 287 int deletes = 0; | 289 int deletes = 0; |
| 288 ScopedVector<DeleteCounter> deleter_vector; | 290 ScopedVector<DeleteCounter> deleter_vector; |
| 289 deleter_vector.push_back(new DeleteCounter(&deletes)); | 291 deleter_vector.push_back(new DeleteCounter(&deletes)); |
| 290 EXPECT_EQ(0, deletes); | 292 EXPECT_EQ(0, deletes); |
| 291 PassThru<DeleteCounter> pass_thru(deleter_vector.Pass()); | 293 PassThru<DeleteCounter> pass_thru(deleter_vector.DEPRECATED_Pass()); |
| 292 EXPECT_EQ(0, deletes); | 294 EXPECT_EQ(0, deletes); |
| 293 ScopedVector<DeleteCounter> result = pass_thru.Run(); | 295 ScopedVector<DeleteCounter> result = pass_thru.Run(); |
| 294 EXPECT_EQ(0, deletes); | 296 EXPECT_EQ(0, deletes); |
| 295 result.clear(); | 297 result.clear(); |
| 296 EXPECT_EQ(1, deletes); | 298 EXPECT_EQ(1, deletes); |
| 297 }; | 299 }; |
| 298 | 300 |
| 299 TEST(ScopedVectorTest, InsertRange) { | 301 TEST(ScopedVectorTest, InsertRange) { |
| 300 LifeCycleWatcher watchers[5]; | 302 LifeCycleWatcher watchers[5]; |
| 301 size_t watchers_size = sizeof(watchers) / sizeof(*watchers); | 303 size_t watchers_size = sizeof(watchers) / sizeof(*watchers); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 319 EXPECT_EQ(LC_CONSTRUCTED, it->life_cycle_state()); | 321 EXPECT_EQ(LC_CONSTRUCTED, it->life_cycle_state()); |
| 320 for (LifeCycleWatcher* it = watchers + 1; it != watchers + 3; ++it) | 322 for (LifeCycleWatcher* it = watchers + 1; it != watchers + 3; ++it) |
| 321 EXPECT_EQ(LC_DESTROYED, it->life_cycle_state()); | 323 EXPECT_EQ(LC_DESTROYED, it->life_cycle_state()); |
| 322 for (LifeCycleWatcher* it = watchers + 3; it != watchers + watchers_size; | 324 for (LifeCycleWatcher* it = watchers + 3; it != watchers + watchers_size; |
| 323 ++it) | 325 ++it) |
| 324 EXPECT_EQ(LC_CONSTRUCTED, it->life_cycle_state()); | 326 EXPECT_EQ(LC_CONSTRUCTED, it->life_cycle_state()); |
| 325 } | 327 } |
| 326 | 328 |
| 327 } // namespace | 329 } // namespace |
| 328 } // namespace webrtc | 330 } // namespace webrtc |
| OLD | NEW |