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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/ContiguousContainerTest.cpp

Issue 2967013002: Be explicit about namespace testing to not mix it with blink::testing (Closed)
Patch Set: Dropped mojo parts that need another review. Created 3 years, 5 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
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 "platform/graphics/ContiguousContainer.h" 5 #include "platform/graphics/ContiguousContainer.h"
6 6
7 #include "platform/wtf/TypeTraits.h" 7 #include "platform/wtf/TypeTraits.h"
8 #include "testing/gmock/include/gmock/gmock.h" 8 #include "testing/gmock/include/gmock/gmock.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 auto& destructible = list.AllocateAndConstruct<MockDestructible>(); 73 auto& destructible = list.AllocateAndConstruct<MockDestructible>();
74 EXPECT_EQ(&destructible, &list.First()); 74 EXPECT_EQ(&destructible, &list.First());
75 EXPECT_CALL(destructible, Destruct()); 75 EXPECT_CALL(destructible, Destruct());
76 } 76 }
77 77
78 TEST(ContiguousContainerTest, DestructorCalledOnceWhenClear) { 78 TEST(ContiguousContainerTest, DestructorCalledOnceWhenClear) {
79 ContiguousContainer<MockDestructible> list(sizeof(MockDestructible)); 79 ContiguousContainer<MockDestructible> list(sizeof(MockDestructible));
80 auto& destructible = list.AllocateAndConstruct<MockDestructible>(); 80 auto& destructible = list.AllocateAndConstruct<MockDestructible>();
81 EXPECT_EQ(&destructible, &list.First()); 81 EXPECT_EQ(&destructible, &list.First());
82 82
83 testing::MockFunction<void()> separator; 83 ::testing::MockFunction<void()> separator;
84 { 84 {
85 testing::InSequence s; 85 ::testing::InSequence s;
86 EXPECT_CALL(destructible, Destruct()); 86 EXPECT_CALL(destructible, Destruct());
87 EXPECT_CALL(separator, Call()); 87 EXPECT_CALL(separator, Call());
88 EXPECT_CALL(destructible, Destruct()).Times(0); 88 EXPECT_CALL(destructible, Destruct()).Times(0);
89 } 89 }
90 90
91 list.Clear(); 91 list.Clear();
92 separator.Call(); 92 separator.Call();
93 } 93 }
94 94
95 TEST(ContiguousContainerTest, DestructorCalledOnceWhenRemoveLast) { 95 TEST(ContiguousContainerTest, DestructorCalledOnceWhenRemoveLast) {
96 ContiguousContainer<MockDestructible> list(sizeof(MockDestructible)); 96 ContiguousContainer<MockDestructible> list(sizeof(MockDestructible));
97 auto& destructible = list.AllocateAndConstruct<MockDestructible>(); 97 auto& destructible = list.AllocateAndConstruct<MockDestructible>();
98 EXPECT_EQ(&destructible, &list.First()); 98 EXPECT_EQ(&destructible, &list.First());
99 99
100 testing::MockFunction<void()> separator; 100 ::testing::MockFunction<void()> separator;
101 { 101 {
102 testing::InSequence s; 102 ::testing::InSequence s;
103 EXPECT_CALL(destructible, Destruct()); 103 EXPECT_CALL(destructible, Destruct());
104 EXPECT_CALL(separator, Call()); 104 EXPECT_CALL(separator, Call());
105 EXPECT_CALL(destructible, Destruct()).Times(0); 105 EXPECT_CALL(destructible, Destruct()).Times(0);
106 } 106 }
107 107
108 list.RemoveLast(); 108 list.RemoveLast();
109 separator.Call(); 109 separator.Call();
110 } 110 }
111 111
112 TEST(ContiguousContainerTest, DestructorCalledWithMultipleRemoveLastCalls) { 112 TEST(ContiguousContainerTest, DestructorCalledWithMultipleRemoveLastCalls) {
113 // This container only requests space for one, but the implementation is 113 // This container only requests space for one, but the implementation is
114 // free to use more space if the allocator provides it. 114 // free to use more space if the allocator provides it.
115 ContiguousContainer<MockDestructible> list(sizeof(MockDestructible), 115 ContiguousContainer<MockDestructible> list(sizeof(MockDestructible),
116 1 * sizeof(MockDestructible)); 116 1 * sizeof(MockDestructible));
117 testing::MockFunction<void()> separator; 117 ::testing::MockFunction<void()> separator;
118 118
119 // We should be okay to allocate and remove a single one, like before. 119 // We should be okay to allocate and remove a single one, like before.
120 list.AllocateAndConstruct<MockDestructible>(); 120 list.AllocateAndConstruct<MockDestructible>();
121 EXPECT_EQ(1u, list.size()); 121 EXPECT_EQ(1u, list.size());
122 { 122 {
123 testing::InSequence s; 123 ::testing::InSequence s;
124 EXPECT_CALL(list[0], Destruct()); 124 EXPECT_CALL(list[0], Destruct());
125 EXPECT_CALL(separator, Call()); 125 EXPECT_CALL(separator, Call());
126 EXPECT_CALL(list[0], Destruct()).Times(0); 126 EXPECT_CALL(list[0], Destruct()).Times(0);
127 } 127 }
128 list.RemoveLast(); 128 list.RemoveLast();
129 separator.Call(); 129 separator.Call();
130 EXPECT_EQ(0u, list.size()); 130 EXPECT_EQ(0u, list.size());
131 131
132 testing::Mock::VerifyAndClearExpectations(&separator); 132 ::testing::Mock::VerifyAndClearExpectations(&separator);
133 133
134 // We should also be okay to allocate and remove multiple. 134 // We should also be okay to allocate and remove multiple.
135 list.AllocateAndConstruct<MockDestructible>(); 135 list.AllocateAndConstruct<MockDestructible>();
136 list.AllocateAndConstruct<MockDestructible>(); 136 list.AllocateAndConstruct<MockDestructible>();
137 list.AllocateAndConstruct<MockDestructible>(); 137 list.AllocateAndConstruct<MockDestructible>();
138 list.AllocateAndConstruct<MockDestructible>(); 138 list.AllocateAndConstruct<MockDestructible>();
139 list.AllocateAndConstruct<MockDestructible>(); 139 list.AllocateAndConstruct<MockDestructible>();
140 list.AllocateAndConstruct<MockDestructible>(); 140 list.AllocateAndConstruct<MockDestructible>();
141 EXPECT_EQ(6u, list.size()); 141 EXPECT_EQ(6u, list.size());
142 { 142 {
143 // The last three should be destroyed by removeLast. 143 // The last three should be destroyed by removeLast.
144 testing::InSequence s; 144 ::testing::InSequence s;
145 EXPECT_CALL(list[5], Destruct()); 145 EXPECT_CALL(list[5], Destruct());
146 EXPECT_CALL(separator, Call()); 146 EXPECT_CALL(separator, Call());
147 EXPECT_CALL(list[5], Destruct()).Times(0); 147 EXPECT_CALL(list[5], Destruct()).Times(0);
148 EXPECT_CALL(list[4], Destruct()); 148 EXPECT_CALL(list[4], Destruct());
149 EXPECT_CALL(separator, Call()); 149 EXPECT_CALL(separator, Call());
150 EXPECT_CALL(list[4], Destruct()).Times(0); 150 EXPECT_CALL(list[4], Destruct()).Times(0);
151 EXPECT_CALL(list[3], Destruct()); 151 EXPECT_CALL(list[3], Destruct());
152 EXPECT_CALL(separator, Call()); 152 EXPECT_CALL(separator, Call());
153 EXPECT_CALL(list[3], Destruct()).Times(0); 153 EXPECT_CALL(list[3], Destruct()).Times(0);
154 } 154 }
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 list.AppendByMoving(list[2], sizeof(Point3D)); 533 list.AppendByMoving(list[2], sizeof(Point3D));
534 EXPECT_EQ(0u, reinterpret_cast<intptr_t>(&list.Last()) & (kMaxAlign - 1)); 534 EXPECT_EQ(0u, reinterpret_cast<intptr_t>(&list.Last()) & (kMaxAlign - 1));
535 list.AppendByMoving(list[3], sizeof(Point3D)); 535 list.AppendByMoving(list[3], sizeof(Point3D));
536 EXPECT_EQ(0u, reinterpret_cast<intptr_t>(&list.Last()) & (kMaxAlign - 1)); 536 EXPECT_EQ(0u, reinterpret_cast<intptr_t>(&list.Last()) & (kMaxAlign - 1));
537 list.AppendByMoving(list[4], sizeof(Point2D)); 537 list.AppendByMoving(list[4], sizeof(Point2D));
538 EXPECT_EQ(0u, reinterpret_cast<intptr_t>(&list.Last()) & (kMaxAlign - 1)); 538 EXPECT_EQ(0u, reinterpret_cast<intptr_t>(&list.Last()) & (kMaxAlign - 1));
539 } 539 }
540 540
541 } // namespace 541 } // namespace
542 } // namespace blink 542 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698