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

Side by Side Diff: base/memory/scoped_vector_unittest.cc

Issue 25293002: Add DiscardableMemoryAllocator to work around FD limit issue. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address William's comments Created 7 years 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 | Annotate | Revision Log
« base/memory/scoped_vector.h ('K') | « base/memory/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 // 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
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
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
OLDNEW
« base/memory/scoped_vector.h ('K') | « base/memory/scoped_vector.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698