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

Unified Diff: ui/base/models/list_model_unittest.cc

Issue 22339004: Make an AddAll in ListModel. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rework, add early return Created 7 years, 4 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 | « ui/base/models/list_model.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/base/models/list_model_unittest.cc
diff --git a/ui/base/models/list_model_unittest.cc b/ui/base/models/list_model_unittest.cc
index 56661671547e80687e72689c8703ec67043eab13..eab2bf05773b81123ac0ed89e40bfd2d32f974ad 100644
--- a/ui/base/models/list_model_unittest.cc
+++ b/ui/base/models/list_model_unittest.cc
@@ -7,6 +7,7 @@
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
+#include "base/memory/scoped_vector.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace ui {
@@ -94,6 +95,34 @@ TEST_F(ListModelTest, Add) {
EXPECT_EQ(1, model.GetItemAt(2)->id());
}
+TEST_F(ListModelTest, AddAll) {
+ ListModel<FooItem> model;
+ model.AddObserver(this);
+
+ // Append FooItem(0)
+ model.Add(new FooItem(0));
+ ExpectCountsEqual(1, 0, 0, 0);
+
+ ScopedVector<FooItem> items;
+ items.push_back(new FooItem(1));
+ items.push_back(new FooItem(2));
+
+ // Append FooItem(1), FooItem(2)
+ model.AddAll(items.Pass());
+ ExpectCountsEqual(3, 0, 0, 0);
+
+ // Onwership of FooItems transferred.
+ EXPECT_TRUE(items.empty());
+
+ // Total 3 items in model.
+ EXPECT_EQ(3U, model.item_count());
+
+ // First one should be FooItem(0), followed by FooItem(1) and FooItem(2)
+ EXPECT_EQ(0, model.GetItemAt(0)->id());
+ EXPECT_EQ(1, model.GetItemAt(1)->id());
+ EXPECT_EQ(2, model.GetItemAt(2)->id());
+}
+
TEST_F(ListModelTest, Remove) {
ListModel<FooItem> model;
model.AddObserver(this);
« no previous file with comments | « ui/base/models/list_model.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698