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

Unified Diff: Source/platform/graphics/ListContainerTest.cpp

Issue 1193433004: Blink-side contiguous allocation of display items. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Minor tweaks to make reviewing easier Created 5 years, 6 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
Index: Source/platform/graphics/ListContainerTest.cpp
diff --git a/Source/platform/graphics/ListContainerTest.cpp b/Source/platform/graphics/ListContainerTest.cpp
index b92b588bcb977fdb77a9bd1e13ba78e1e440cbbd..c6011c1b788493f7d395bde82ed570a3e5435657 100644
--- a/Source/platform/graphics/ListContainerTest.cpp
+++ b/Source/platform/graphics/ListContainerTest.cpp
@@ -853,6 +853,42 @@ TEST(ListContainerTest, AppendByMovingDoesNotDestruct)
EXPECT_CALL(*mde1, Destruct());
}
+TEST(ListContainerTest, AllocateWithoutConstructionDoesNotConstruct)
+{
+ static int constructorCount = 0;
+ class ConstructCounter : public SimpleDerivedElementConstructMagicNumberOne {
+ public:
+ ConstructCounter() : SimpleDerivedElementConstructMagicNumberOne()
+ {
+ constructorCount++;
+ }
+ };
+
+ ListContainer<ConstructCounter> list(kCurrentLargestDerivedElementSize);
+
+ ConstructCounter* constructCounter1 = list.allocateWithoutConstruction<ConstructCounter>();
+ EXPECT_EQ(0, constructorCount);
+ EXPECT_EQ(1u, list.size());
+ new (constructCounter1) ConstructCounter;
+ EXPECT_EQ(1, constructorCount);
+ list.allocateAndConstruct<ConstructCounter>();
+ EXPECT_EQ(2, constructorCount);
+ EXPECT_EQ(2u, list.size());
+}
+
+TEST(ListContainerTest, AppendByMovingReturnsMovedPointer)
+{
+ ListContainer<SimpleDerivedElement> list1(kCurrentLargestDerivedElementSize);
+ ListContainer<SimpleDerivedElement> list2(kCurrentLargestDerivedElementSize);
+ SimpleDerivedElement* simpleElement = list1.allocateAndConstruct<SimpleDerivedElementConstructMagicNumberOne>();
+
+ SimpleDerivedElement* movedElement1 = list2.appendByMoving(simpleElement);
+ EXPECT_EQ(list2.back(), movedElement1);
+
+ SimpleDerivedElement* movedElement2 = list1.appendByMoving(movedElement1);
+ EXPECT_EQ(list1.back(), movedElement2);
chrishtr 2015/06/29 17:19:16 Assert the pointers are not equal.
pdr. 2015/06/29 22:20:03 Done.
+}
+
TEST(ListContainerTest, AppendByMovingReplacesSourceWithNewDerivedElement)
{
ListContainer<SimpleDerivedElementConstructMagicNumberOne> list1(kCurrentLargestDerivedElementSize);

Powered by Google App Engine
This is Rietveld 408576698