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

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: ... lose the casts, make LifeCycleObject more private. 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..e9b609add0e1d6ac076a89de07ff459e3ffc9867 100644
--- a/base/memory/scoped_vector_unittest.cc
+++ b/base/memory/scoped_vector_unittest.cc
@@ -14,6 +14,13 @@ namespace {
// The LifeCycleObject notifies its Observer upon construction & destruction.
class LifeCycleObject {
public:
+ ~LifeCycleObject() {
+ observer_->OnLifeCycleDestroy(this);
+ }
+
+ private:
+ friend class LifeCycleWatcher;
+
class Observer {
public:
virtual void OnLifeCycleConstruct(LifeCycleObject* o) = 0;
@@ -28,11 +35,6 @@ class LifeCycleObject {
observer_->OnLifeCycleConstruct(this);
}
- ~LifeCycleObject() {
- observer_->OnLifeCycleDestroy(this);
- }
-
- private:
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());
gavinp 2012/11/24 14:27:18 And actually, no need for any cast at all here.
}
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