| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/memory/scoped_vector.h" | 5 #include "base/memory/scoped_vector.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/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 | 105 |
| 106 TEST(ScopedVectorTest, LifeCycleWatcher) { | 106 TEST(ScopedVectorTest, LifeCycleWatcher) { |
| 107 LifeCycleWatcher watcher; | 107 LifeCycleWatcher watcher; |
| 108 EXPECT_EQ(LC_INITIAL, watcher.life_cycle_state()); | 108 EXPECT_EQ(LC_INITIAL, watcher.life_cycle_state()); |
| 109 LifeCycleObject* object = watcher.NewLifeCycleObject(); | 109 LifeCycleObject* object = watcher.NewLifeCycleObject(); |
| 110 EXPECT_EQ(LC_CONSTRUCTED, watcher.life_cycle_state()); | 110 EXPECT_EQ(LC_CONSTRUCTED, watcher.life_cycle_state()); |
| 111 delete object; | 111 delete object; |
| 112 EXPECT_EQ(LC_DESTROYED, watcher.life_cycle_state()); | 112 EXPECT_EQ(LC_DESTROYED, watcher.life_cycle_state()); |
| 113 } | 113 } |
| 114 | 114 |
| 115 TEST(ScopedVectorTest, PopBack) { |
| 116 LifeCycleWatcher watcher; |
| 117 EXPECT_EQ(LC_INITIAL, watcher.life_cycle_state()); |
| 118 ScopedVector<LifeCycleObject> scoped_vector; |
| 119 scoped_vector.push_back(watcher.NewLifeCycleObject()); |
| 120 EXPECT_EQ(LC_CONSTRUCTED, watcher.life_cycle_state()); |
| 121 EXPECT_TRUE(watcher.IsWatching(scoped_vector.back())); |
| 122 scoped_vector.pop_back(); |
| 123 EXPECT_EQ(LC_DESTROYED, watcher.life_cycle_state()); |
| 124 EXPECT_TRUE(scoped_vector.empty()); |
| 125 } |
| 126 |
| 115 TEST(ScopedVectorTest, Clear) { | 127 TEST(ScopedVectorTest, Clear) { |
| 116 LifeCycleWatcher watcher; | 128 LifeCycleWatcher watcher; |
| 117 EXPECT_EQ(LC_INITIAL, watcher.life_cycle_state()); | 129 EXPECT_EQ(LC_INITIAL, watcher.life_cycle_state()); |
| 118 ScopedVector<LifeCycleObject> scoped_vector; | 130 ScopedVector<LifeCycleObject> scoped_vector; |
| 119 scoped_vector.push_back(watcher.NewLifeCycleObject()); | 131 scoped_vector.push_back(watcher.NewLifeCycleObject()); |
| 120 EXPECT_EQ(LC_CONSTRUCTED, watcher.life_cycle_state()); | 132 EXPECT_EQ(LC_CONSTRUCTED, watcher.life_cycle_state()); |
| 121 EXPECT_TRUE(watcher.IsWatching(scoped_vector.back())); | 133 EXPECT_TRUE(watcher.IsWatching(scoped_vector.back())); |
| 122 scoped_vector.clear(); | 134 scoped_vector.clear(); |
| 123 EXPECT_EQ(LC_DESTROYED, watcher.life_cycle_state()); | 135 EXPECT_EQ(LC_DESTROYED, watcher.life_cycle_state()); |
| 124 EXPECT_TRUE(scoped_vector.empty()); | 136 EXPECT_TRUE(scoped_vector.empty()); |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 for(LifeCycleWatcher* it = watchers; it != watchers + 1; ++it) | 302 for(LifeCycleWatcher* it = watchers; it != watchers + 1; ++it) |
| 291 EXPECT_EQ(LC_CONSTRUCTED, it->life_cycle_state()); | 303 EXPECT_EQ(LC_CONSTRUCTED, it->life_cycle_state()); |
| 292 for(LifeCycleWatcher* it = watchers + 1; it != watchers + 3; ++it) | 304 for(LifeCycleWatcher* it = watchers + 1; it != watchers + 3; ++it) |
| 293 EXPECT_EQ(LC_DESTROYED, it->life_cycle_state()); | 305 EXPECT_EQ(LC_DESTROYED, it->life_cycle_state()); |
| 294 for(LifeCycleWatcher* it = watchers + 3; it != watchers + arraysize(watchers); | 306 for(LifeCycleWatcher* it = watchers + 3; it != watchers + arraysize(watchers); |
| 295 ++it) | 307 ++it) |
| 296 EXPECT_EQ(LC_CONSTRUCTED, it->life_cycle_state()); | 308 EXPECT_EQ(LC_CONSTRUCTED, it->life_cycle_state()); |
| 297 } | 309 } |
| 298 | 310 |
| 299 } // namespace | 311 } // namespace |
| OLD | NEW |