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

Unified Diff: cc/base/scoped_ptr_vector_unittest.cc

Issue 15435003: cc: Add CopyAsBitmapRequest class to hold the readback callback. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nolint Created 7 years, 7 months 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 | « cc/base/scoped_ptr_vector.h ('k') | cc/cc.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/base/scoped_ptr_vector_unittest.cc
diff --git a/cc/base/scoped_ptr_vector_unittest.cc b/cc/base/scoped_ptr_vector_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..4e450b9c82380e1d0c77317307b35b9fbdc57f60
--- /dev/null
+++ b/cc/base/scoped_ptr_vector_unittest.cc
@@ -0,0 +1,72 @@
+// Copyright 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "cc/base/scoped_ptr_vector.h"
+#include "testing/gmock/include/gmock/gmock.h"
+
+namespace cc {
+namespace {
+
+class Data {
+ public:
+ static scoped_ptr<Data> Create(int i) { return make_scoped_ptr(new Data(i)); }
+ int data() const { return data_; }
+ private:
+ explicit Data(int i) : data_(i) {}
+ int data_;
+};
+
+TEST(ScopedPtrVectorTest, PushBack) {
+ ScopedPtrVector<Data> v;
+
+ // Insert 5 things into the vector.
+ v.push_back(Data::Create(1));
+ v.push_back(Data::Create(2));
+ v.push_back(Data::Create(3));
+ v.push_back(Data::Create(4));
+ v.push_back(Data::Create(5));
+
+ EXPECT_EQ(5u, v.size());
+ EXPECT_EQ(1, v[0]->data());
+ EXPECT_EQ(2, v[1]->data());
+ EXPECT_EQ(3, v[2]->data());
+ EXPECT_EQ(4, v[3]->data());
+ EXPECT_EQ(5, v[4]->data());
+}
+
+TEST(ScopedPtrVectorTest, InsertAndTake) {
+ // Insert 3 things into each vector.
+ ScopedPtrVector<Data> v;
+ v.push_back(Data::Create(1));
+ v.push_back(Data::Create(2));
+ v.push_back(Data::Create(6));
+
+ ScopedPtrVector<Data> v2;
+ v2.push_back(Data::Create(3));
+ v2.push_back(Data::Create(4));
+ v2.push_back(Data::Create(5));
+
+ ScopedPtrVector<Data>::iterator it = v.begin();
+ ++it;
+ ++it;
+ EXPECT_EQ(6, (*it)->data());
+
+ v.insert_and_take(it, v2);
+
+ EXPECT_EQ(6u, v.size());
+ EXPECT_EQ(1, v[0]->data());
+ EXPECT_EQ(2, v[1]->data());
+ EXPECT_EQ(3, v[2]->data());
+ EXPECT_EQ(4, v[3]->data());
+ EXPECT_EQ(5, v[4]->data());
+ EXPECT_EQ(6, v[5]->data());
+
+ EXPECT_EQ(3u, v2.size());
+ EXPECT_EQ(NULL, v2[0]);
+ EXPECT_EQ(NULL, v2[1]);
+ EXPECT_EQ(NULL, v2[2]);
+}
+
+} // namespace
+} // namespace cc
« no previous file with comments | « cc/base/scoped_ptr_vector.h ('k') | cc/cc.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698