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

Side by Side Diff: Source/platform/graphics/ListContainerTest.cpp

Issue 1207773003: Add ListContainer::swap (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « Source/platform/graphics/ListContainer.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "platform/graphics/ListContainer.h" 6 #include "platform/graphics/ListContainer.h"
7 7
8 #include "wtf/OwnPtr.h" 8 #include "wtf/OwnPtr.h"
9 #include "wtf/PassOwnPtr.h" 9 #include "wtf/PassOwnPtr.h"
10 #include "wtf/RefPtr.h" 10 #include "wtf/RefPtr.h"
(...skipping 921 matching lines...) Expand 10 before | Expand all | Expand 10 after
932 list.appendByMoving(list.front()); 932 list.appendByMoving(list.front());
933 EXPECT_TRUE(static_cast<LongSimpleDerivedElement*>(list.back())->areAllValue sEqualTo(kMagicNumberToUseForLongSimpleDerivedElement)); 933 EXPECT_TRUE(static_cast<LongSimpleDerivedElement*>(list.back())->areAllValue sEqualTo(kMagicNumberToUseForLongSimpleDerivedElement));
934 EXPECT_EQ(kMagicNumberToUseForSimpleDerivedElementOne, simpleElement->getVal ue()); 934 EXPECT_EQ(kMagicNumberToUseForSimpleDerivedElementOne, simpleElement->getVal ue());
935 935
936 LongSimpleDerivedElement* longElement = static_cast<LongSimpleDerivedElement *>(list.back()); 936 LongSimpleDerivedElement* longElement = static_cast<LongSimpleDerivedElement *>(list.back());
937 list.appendByMoving(simpleElement); 937 list.appendByMoving(simpleElement);
938 EXPECT_TRUE(longElement->areAllValuesEqualTo(kMagicNumberToUseForLongSimpleD erivedElement)); 938 EXPECT_TRUE(longElement->areAllValuesEqualTo(kMagicNumberToUseForLongSimpleD erivedElement));
939 EXPECT_EQ(kMagicNumberToUseForSimpleDerivedElementOne, list.back()->getValue ()); 939 EXPECT_EQ(kMagicNumberToUseForSimpleDerivedElementOne, list.back()->getValue ());
940 } 940 }
941 941
942 TEST(ListContainerTest, Swap)
943 {
944 ListContainer<SimpleDerivedElement> list1(kCurrentLargestDerivedElementSize) ;
945 list1.allocateAndConstruct<SimpleDerivedElementConstructMagicNumberOne>();
946 ListContainer<SimpleDerivedElement> list2(kCurrentLargestDerivedElementSize) ;
947 list2.allocateAndConstruct<SimpleDerivedElementConstructMagicNumberTwo>();
948 list2.allocateAndConstruct<SimpleDerivedElementConstructMagicNumberTwo>();
949
950 SimpleDerivedElement* preSwapList1Front = list1.front();
951
952 EXPECT_EQ(kMagicNumberToUseForSimpleDerivedElementOne, list1.front()->getVal ue());
953 EXPECT_EQ(kMagicNumberToUseForSimpleDerivedElementTwo, list2.front()->getVal ue());
chrishtr 2015/06/24 18:12:28 same comment
954 EXPECT_EQ(kMagicNumberToUseForSimpleDerivedElementTwo, list2.back()->getValu e());
955 EXPECT_EQ(1u, list1.size());
956 EXPECT_EQ(2u, list2.size());
957
958 list2.swap(list1);
959
960 EXPECT_EQ(kMagicNumberToUseForSimpleDerivedElementTwo, list1.front()->getVal ue());
961 EXPECT_EQ(kMagicNumberToUseForSimpleDerivedElementTwo, list1.back()->getValu e());
962 EXPECT_EQ(kMagicNumberToUseForSimpleDerivedElementOne, list2.front()->getVal ue());
963 EXPECT_EQ(2u, list1.size());
964 EXPECT_EQ(1u, list2.size());
965
966 // Ensure pointers are still valid after swapping.
967 EXPECT_EQ(preSwapList1Front, list2.front());
968 }
969
942 } // namespace 970 } // namespace
943 } // namespace blink 971 } // namespace blink
OLDNEW
« no previous file with comments | « Source/platform/graphics/ListContainer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698