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

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: Add ListContainer::AllocateAndConstructWithArguments and a TODO in DisplayItemList::findMatchingIte… 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
« no previous file with comments | « Source/platform/graphics/ListContainer.h ('k') | Source/platform/graphics/paint/CachedDisplayItem.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/graphics/ListContainerTest.cpp
diff --git a/Source/platform/graphics/ListContainerTest.cpp b/Source/platform/graphics/ListContainerTest.cpp
index b92b588bcb977fdb77a9bd1e13ba78e1e440cbbd..3d2546b8fe95efa136707b5278b826dfa49ccafe 100644
--- a/Source/platform/graphics/ListContainerTest.cpp
+++ b/Source/platform/graphics/ListContainerTest.cpp
@@ -153,6 +153,27 @@ TEST(ListContainerTest, ConstructorCalledInAllocateAndConstruct)
EXPECT_EQ(kMagicNumberToUseForSimpleDerivedElementTwo, derivedElement2->getValue());
}
+TEST(ListContainerTest, AllocateAndConstructWithArguments)
+{
+ // Create a new OwnPtr<SimpleDerivedElement> by passing in a new SimpleDerivedElement.
+ ListContainer<OwnPtr<SimpleDerivedElement>> list1(kCurrentLargestDerivedElementSize);
+ auto* sdeOwnPtr1 = list1.allocateAndConstruct<OwnPtr<SimpleDerivedElement>>(adoptPtr(new SimpleDerivedElementConstructMagicNumberOne()));
+ EXPECT_EQ(1u, list1.size());
+ EXPECT_EQ(sdeOwnPtr1, list1.back());
+ EXPECT_EQ(kMagicNumberToUseForSimpleDerivedElementOne, (*sdeOwnPtr1)->getValue());
+ (*sdeOwnPtr1)->setValue(kMagicNumberToUseForSimpleDerivedElementTwo);
+
+ // Transfer an OwnPtr<SimpleDerivedElement> to another list.
+ ListContainer<OwnPtr<SimpleDerivedElement>> list2(kCurrentLargestDerivedElementSize);
+ auto* sdeOwnPtr2 = list2.allocateAndConstruct<OwnPtr<SimpleDerivedElement>>(sdeOwnPtr1->release());
+ EXPECT_EQ(1u, list2.size());
+ EXPECT_EQ(sdeOwnPtr2, list2.back());
+ EXPECT_EQ(kMagicNumberToUseForSimpleDerivedElementTwo, (*sdeOwnPtr2)->getValue());
+
+ // Verify the first OwnPtr is null after moving.
+ EXPECT_EQ(nullptr, list1.back()->get());
+}
+
TEST(ListContainerTest, DestructorCalled)
{
ListContainer<DerivedElement> list(kCurrentLargestDerivedElementSize);
@@ -853,6 +874,20 @@ TEST(ListContainerTest, AppendByMovingDoesNotDestruct)
EXPECT_CALL(*mde1, Destruct());
}
+TEST(ListContainerTest, AppendByMovingReturnsMovedPointer)
+{
+ ListContainer<SimpleDerivedElement> list1(kCurrentLargestDerivedElementSize);
+ ListContainer<SimpleDerivedElement> list2(kCurrentLargestDerivedElementSize);
+ SimpleDerivedElement* simpleElement = list1.allocateAndConstruct<SimpleDerivedElement>();
+
+ SimpleDerivedElement* movedElement1 = list2.appendByMoving(simpleElement);
+ EXPECT_EQ(list2.back(), movedElement1);
+
+ SimpleDerivedElement* movedElement2 = list1.appendByMoving(movedElement1);
+ EXPECT_EQ(list1.back(), movedElement2);
+ EXPECT_NE(movedElement1, movedElement2);
+}
+
TEST(ListContainerTest, AppendByMovingReplacesSourceWithNewDerivedElement)
{
ListContainer<SimpleDerivedElementConstructMagicNumberOne> list1(kCurrentLargestDerivedElementSize);
« no previous file with comments | « Source/platform/graphics/ListContainer.h ('k') | Source/platform/graphics/paint/CachedDisplayItem.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698