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

Unified Diff: base/memory/scoped_vector_unittest.cc

Issue 11416166: Clean up ScopedVectorTest's LifeCycleObject. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ... ok, private and friendship is confusing with respect to base classes Created 8 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/memory/scoped_vector_unittest.cc
diff --git a/base/memory/scoped_vector_unittest.cc b/base/memory/scoped_vector_unittest.cc
index 03774c52a6c2039ed4f580ad4df486a4bb2c14db..5616fd4aab67e0ebf763cc20378ad994ef9f5959 100644
--- a/base/memory/scoped_vector_unittest.cc
+++ b/base/memory/scoped_vector_unittest.cc
@@ -23,16 +23,18 @@ class LifeCycleObject {
virtual ~Observer() {}
};
- explicit LifeCycleObject(Observer* observer)
- : observer_(observer) {
- observer_->OnLifeCycleConstruct(this);
- }
-
~LifeCycleObject() {
observer_->OnLifeCycleDestroy(this);
}
private:
+ friend class LifeCycleWatcher;
+
+ explicit LifeCycleObject(Observer* observer)
+ : observer_(observer) {
+ observer_->OnLifeCycleConstruct(this);
+ }
+
Observer* observer_;
DISALLOW_COPY_AND_ASSIGN(LifeCycleObject);
@@ -115,19 +117,18 @@ TEST(ScopedVectorTest, Clear) {
EXPECT_EQ(LC_CONSTRUCTED, watcher.life_cycle_state());
scoped_vector.clear();
EXPECT_EQ(LC_DESTROYED, watcher.life_cycle_state());
- EXPECT_EQ(static_cast<size_t>(0), scoped_vector.size());
+ EXPECT_TRUE(scoped_vector.empty());
}
TEST(ScopedVectorTest, WeakClear) {
LifeCycleWatcher watcher;
EXPECT_EQ(LC_INITIAL, watcher.life_cycle_state());
ScopedVector<LifeCycleObject> scoped_vector;
- scoped_ptr<LifeCycleObject> object(watcher.NewLifeCycleObject());
- scoped_vector.push_back(object.get());
+ scoped_vector.push_back(watcher.NewLifeCycleObject());
EXPECT_EQ(LC_CONSTRUCTED, watcher.life_cycle_state());
scoped_vector.weak_clear();
EXPECT_EQ(LC_CONSTRUCTED, watcher.life_cycle_state());
- EXPECT_EQ(static_cast<size_t>(0), scoped_vector.size());
+ EXPECT_TRUE(scoped_vector.empty());
}
TEST(ScopedVectorTest, Scope) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698