Don't show supervised user as "already on this device" while they're being imported.
[chromium-blink-merge.git] / cc / quads / list_container_unittest.cc
blob76dd966b16a39efad8fbd735f66baecd3a7f82d9
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "cc/base/list_container.h"
7 #include <vector>
8 #include "cc/quads/draw_quad.h"
9 #include "cc/quads/largest_draw_quad.h"
10 #include "cc/quads/render_pass_draw_quad.h"
11 #include "cc/quads/shared_quad_state.h"
12 #include "cc/quads/stream_video_draw_quad.h"
13 #include "testing/gmock/include/gmock/gmock.h"
14 #include "testing/gtest/include/gtest/gtest.h"
16 // TODO(jbroman): This unit test should be made generic and moved to cc/base/.
18 namespace cc {
19 namespace {
21 int kMagicNumberToUseForDrawQuadOne = 42;
22 int kMagicNumberToUseForDrawQuadTwo = 314;
24 bool isConstSharedQuadStatePointer(const SharedQuadState* ptr) {
25 return true;
28 bool isConstSharedQuadStatePointer(SharedQuadState* ptr) {
29 return false;
32 class SimpleDrawQuad : public DrawQuad {
33 public:
34 ~SimpleDrawQuad() override {}
35 void IterateResources(const ResourceIteratorCallback& callback) override {}
37 void set_value(int val) { value = val; }
38 int get_value() { return value; }
39 void ExtendValue(base::trace_event::TracedValue* value) const override {}
41 private:
42 int value;
45 class SimpleDrawQuadConstructMagicNumberOne : public SimpleDrawQuad {
46 public:
47 SimpleDrawQuadConstructMagicNumberOne() : SimpleDrawQuad() {
48 set_value(kMagicNumberToUseForDrawQuadOne);
52 class SimpleDrawQuadConstructMagicNumberTwo : public SimpleDrawQuad {
53 public:
54 SimpleDrawQuadConstructMagicNumberTwo() : SimpleDrawQuad() {
55 set_value(kMagicNumberToUseForDrawQuadTwo);
59 class MockDrawQuad : public SimpleDrawQuadConstructMagicNumberOne {
60 public:
61 ~MockDrawQuad() override { Destruct(); }
62 MOCK_METHOD0(Destruct, void());
65 class MockDrawQuadSubclass : public MockDrawQuad {
66 public:
67 MockDrawQuadSubclass() { set_value(kMagicNumberToUseForDrawQuadTwo); }
70 const size_t kLargestQuadSize =
71 std::max(LargestDrawQuadSize(), sizeof(MockDrawQuadSubclass));
73 TEST(ListContainerTest, ConstructorCalledInAllocateAndConstruct) {
74 ListContainer<DrawQuad> list(kLargestQuadSize);
76 size_t size = 2;
77 SimpleDrawQuadConstructMagicNumberOne* dq_1 =
78 list.AllocateAndConstruct<SimpleDrawQuadConstructMagicNumberOne>();
79 SimpleDrawQuadConstructMagicNumberTwo* dq_2 =
80 list.AllocateAndConstruct<SimpleDrawQuadConstructMagicNumberTwo>();
82 EXPECT_EQ(size, list.size());
83 EXPECT_EQ(dq_1, list.front());
84 EXPECT_EQ(dq_2, list.back());
86 EXPECT_EQ(kMagicNumberToUseForDrawQuadOne, dq_1->get_value());
87 EXPECT_EQ(kMagicNumberToUseForDrawQuadTwo, dq_2->get_value());
90 TEST(ListContainerTest, DestructorCalled) {
91 ListContainer<DrawQuad> list(kLargestQuadSize);
93 size_t size = 1;
94 MockDrawQuad* dq_1 = list.AllocateAndConstruct<MockDrawQuad>();
96 EXPECT_CALL(*dq_1, Destruct());
97 EXPECT_EQ(size, list.size());
98 EXPECT_EQ(dq_1, list.front());
101 TEST(ListContainerTest, DestructorCalledOnceWhenClear) {
102 ListContainer<DrawQuad> list(kLargestQuadSize);
103 size_t size = 1;
104 MockDrawQuad* dq_1 = list.AllocateAndConstruct<MockDrawQuad>();
106 EXPECT_EQ(size, list.size());
107 EXPECT_EQ(dq_1, list.front());
109 // Make sure destructor is called once during clear, and won't be called
110 // again.
111 testing::MockFunction<void()> separator;
113 testing::InSequence s;
114 EXPECT_CALL(*dq_1, Destruct());
115 EXPECT_CALL(separator, Call());
116 EXPECT_CALL(*dq_1, Destruct()).Times(0);
119 list.clear();
120 separator.Call();
123 TEST(ListContainerTest, ReplaceExistingElement) {
124 ListContainer<DrawQuad> list(kLargestQuadSize);
125 size_t size = 1;
126 MockDrawQuad* dq_1 = list.AllocateAndConstruct<MockDrawQuad>();
128 EXPECT_EQ(size, list.size());
129 EXPECT_EQ(dq_1, list.front());
131 // Make sure destructor is called once during clear, and won't be called
132 // again.
133 testing::MockFunction<void()> separator;
135 testing::InSequence s;
136 EXPECT_CALL(*dq_1, Destruct());
137 EXPECT_CALL(separator, Call());
138 EXPECT_CALL(*dq_1, Destruct()).Times(0);
141 list.ReplaceExistingElement<MockDrawQuadSubclass>(list.begin());
142 EXPECT_EQ(kMagicNumberToUseForDrawQuadTwo, dq_1->get_value());
143 separator.Call();
145 EXPECT_CALL(*dq_1, Destruct());
146 list.clear();
149 TEST(ListContainerTest, DestructorCalledOnceWhenErase) {
150 ListContainer<DrawQuad> list(kLargestQuadSize);
151 size_t size = 1;
152 MockDrawQuad* dq_1 = list.AllocateAndConstruct<MockDrawQuad>();
154 EXPECT_EQ(size, list.size());
155 EXPECT_EQ(dq_1, list.front());
157 // Make sure destructor is called once during clear, and won't be called
158 // again.
159 testing::MockFunction<void()> separator;
161 testing::InSequence s;
162 EXPECT_CALL(*dq_1, Destruct());
163 EXPECT_CALL(separator, Call());
164 EXPECT_CALL(*dq_1, Destruct()).Times(0);
167 list.EraseAndInvalidateAllPointers(list.begin());
168 separator.Call();
171 TEST(ListContainerTest, SimpleIndexAccessSharedQuadState) {
172 ListContainer<SharedQuadState> list;
174 size_t size = 3;
175 SharedQuadState* sqs_1 = list.AllocateAndConstruct<SharedQuadState>();
176 SharedQuadState* sqs_2 = list.AllocateAndConstruct<SharedQuadState>();
177 SharedQuadState* sqs_3 = list.AllocateAndConstruct<SharedQuadState>();
179 EXPECT_EQ(size, list.size());
180 EXPECT_EQ(sqs_1, list.front());
181 EXPECT_EQ(sqs_3, list.back());
182 EXPECT_EQ(list.front(), list.ElementAt(0));
183 EXPECT_EQ(sqs_2, list.ElementAt(1));
184 EXPECT_EQ(list.back(), list.ElementAt(2));
187 TEST(ListContainerTest, SimpleInsertionSharedQuadState) {
188 ListContainer<SharedQuadState> list;
190 size_t size = 3;
191 SharedQuadState* sqs_1 = list.AllocateAndConstruct<SharedQuadState>();
192 list.AllocateAndConstruct<SharedQuadState>();
193 SharedQuadState* sqs_3 = list.AllocateAndConstruct<SharedQuadState>();
195 EXPECT_EQ(size, list.size());
196 EXPECT_EQ(sqs_1, list.front());
197 EXPECT_EQ(sqs_3, list.back());
200 TEST(ListContainerTest, SimpleInsertionAndClearSharedQuadState) {
201 ListContainer<SharedQuadState> list;
202 EXPECT_TRUE(list.empty());
203 EXPECT_EQ(0u, list.size());
205 size_t size = 3;
206 SharedQuadState* sqs_1 = list.AllocateAndConstruct<SharedQuadState>();
207 list.AllocateAndConstruct<SharedQuadState>();
208 SharedQuadState* sqs_3 = list.AllocateAndConstruct<SharedQuadState>();
210 EXPECT_EQ(size, list.size());
211 EXPECT_EQ(sqs_1, list.front());
212 EXPECT_EQ(sqs_3, list.back());
213 EXPECT_FALSE(list.empty());
215 list.clear();
216 EXPECT_TRUE(list.empty());
217 EXPECT_EQ(0u, list.size());
220 TEST(ListContainerTest, SimpleInsertionClearAndInsertAgainSharedQuadState) {
221 ListContainer<SharedQuadState> list;
222 EXPECT_TRUE(list.empty());
223 EXPECT_EQ(0u, list.size());
225 size_t size = 2;
226 SharedQuadState* sqs_front = list.AllocateAndConstruct<SharedQuadState>();
227 SharedQuadState* sqs_back = list.AllocateAndConstruct<SharedQuadState>();
229 EXPECT_EQ(size, list.size());
230 EXPECT_EQ(sqs_front, list.front());
231 EXPECT_EQ(sqs_back, list.back());
232 EXPECT_FALSE(list.empty());
234 list.clear();
235 EXPECT_TRUE(list.empty());
236 EXPECT_EQ(0u, list.size());
238 size = 3;
239 sqs_front = list.AllocateAndConstruct<SharedQuadState>();
240 list.AllocateAndConstruct<SharedQuadState>();
241 sqs_back = list.AllocateAndConstruct<SharedQuadState>();
243 EXPECT_EQ(size, list.size());
244 EXPECT_EQ(sqs_front, list.front());
245 EXPECT_EQ(sqs_back, list.back());
246 EXPECT_FALSE(list.empty());
249 // This test is used to test when there is more than one allocation needed
250 // for, ListContainer can still perform like normal vector.
251 TEST(ListContainerTest,
252 SimpleInsertionTriggerMoreThanOneAllocationSharedQuadState) {
253 ListContainer<SharedQuadState> list(sizeof(SharedQuadState), 2);
254 std::vector<SharedQuadState*> sqs_list;
255 size_t size = 10;
256 for (size_t i = 0; i < size; ++i) {
257 sqs_list.push_back(list.AllocateAndConstruct<SharedQuadState>());
259 EXPECT_EQ(size, list.size());
261 ListContainer<SharedQuadState>::Iterator iter = list.begin();
262 for (std::vector<SharedQuadState*>::const_iterator sqs_iter =
263 sqs_list.begin();
264 sqs_iter != sqs_list.end(); ++sqs_iter) {
265 EXPECT_EQ(*sqs_iter, *iter);
266 ++iter;
270 TEST(ListContainerTest,
271 CorrectAllocationSizeForMoreThanOneAllocationSharedQuadState) {
272 // Constructor sets the allocation size to 2. Every time ListContainer needs
273 // to allocate again, it doubles allocation size. In this test, 10 elements is
274 // needed, thus ListContainerShould allocate spaces 2, 4 and 8 elements.
275 ListContainer<SharedQuadState> list(sizeof(SharedQuadState), 2);
276 std::vector<SharedQuadState*> sqs_list;
277 size_t size = 10;
278 for (size_t i = 0; i < size; ++i) {
279 // Before asking for a new element, space available without another
280 // allocation follows.
281 switch (i) {
282 case 2:
283 case 6:
284 EXPECT_EQ(0u, list.AvailableSizeWithoutAnotherAllocationForTesting());
285 break;
286 case 1:
287 case 5:
288 EXPECT_EQ(1u, list.AvailableSizeWithoutAnotherAllocationForTesting());
289 break;
290 case 0:
291 case 4:
292 EXPECT_EQ(2u, list.AvailableSizeWithoutAnotherAllocationForTesting());
293 break;
294 case 3:
295 EXPECT_EQ(3u, list.AvailableSizeWithoutAnotherAllocationForTesting());
296 break;
297 case 9:
298 EXPECT_EQ(5u, list.AvailableSizeWithoutAnotherAllocationForTesting());
299 break;
300 case 8:
301 EXPECT_EQ(6u, list.AvailableSizeWithoutAnotherAllocationForTesting());
302 break;
303 case 7:
304 EXPECT_EQ(7u, list.AvailableSizeWithoutAnotherAllocationForTesting());
305 break;
306 default:
307 break;
309 sqs_list.push_back(list.AllocateAndConstruct<SharedQuadState>());
310 // After asking for a new element, space available without another
311 // allocation follows.
312 switch (i) {
313 case 1:
314 case 5:
315 EXPECT_EQ(0u, list.AvailableSizeWithoutAnotherAllocationForTesting());
316 break;
317 case 0:
318 case 4:
319 EXPECT_EQ(1u, list.AvailableSizeWithoutAnotherAllocationForTesting());
320 break;
321 case 3:
322 EXPECT_EQ(2u, list.AvailableSizeWithoutAnotherAllocationForTesting());
323 break;
324 case 2:
325 EXPECT_EQ(3u, list.AvailableSizeWithoutAnotherAllocationForTesting());
326 break;
327 case 9:
328 EXPECT_EQ(4u, list.AvailableSizeWithoutAnotherAllocationForTesting());
329 break;
330 case 8:
331 EXPECT_EQ(5u, list.AvailableSizeWithoutAnotherAllocationForTesting());
332 break;
333 case 7:
334 EXPECT_EQ(6u, list.AvailableSizeWithoutAnotherAllocationForTesting());
335 break;
336 case 6:
337 EXPECT_EQ(7u, list.AvailableSizeWithoutAnotherAllocationForTesting());
338 break;
339 default:
340 break;
343 EXPECT_EQ(size, list.size());
345 ListContainer<SharedQuadState>::Iterator iter = list.begin();
346 for (std::vector<SharedQuadState*>::const_iterator sqs_iter =
347 sqs_list.begin();
348 sqs_iter != sqs_list.end(); ++sqs_iter) {
349 EXPECT_EQ(*sqs_iter, *iter);
350 ++iter;
354 TEST(ListContainerTest, SimpleIterationSharedQuadState) {
355 ListContainer<SharedQuadState> list;
356 std::vector<SharedQuadState*> sqs_list;
357 size_t size = 10;
358 for (size_t i = 0; i < size; ++i) {
359 sqs_list.push_back(list.AllocateAndConstruct<SharedQuadState>());
361 EXPECT_EQ(size, list.size());
363 size_t num_iters_in_list = 0;
365 std::vector<SharedQuadState*>::const_iterator sqs_iter = sqs_list.begin();
366 for (ListContainer<SharedQuadState>::Iterator iter = list.begin();
367 iter != list.end(); ++iter) {
368 EXPECT_EQ(*sqs_iter, *iter);
369 ++num_iters_in_list;
370 ++sqs_iter;
374 size_t num_iters_in_vector = 0;
376 ListContainer<SharedQuadState>::Iterator iter = list.begin();
377 for (std::vector<SharedQuadState*>::const_iterator sqs_iter =
378 sqs_list.begin();
379 sqs_iter != sqs_list.end(); ++sqs_iter) {
380 EXPECT_EQ(*sqs_iter, *iter);
381 ++num_iters_in_vector;
382 ++iter;
386 EXPECT_EQ(num_iters_in_vector, num_iters_in_list);
389 TEST(ListContainerTest, SimpleConstIteratorIterationSharedQuadState) {
390 ListContainer<SharedQuadState> list;
391 std::vector<const SharedQuadState*> sqs_list;
392 size_t size = 10;
393 for (size_t i = 0; i < size; ++i) {
394 sqs_list.push_back(list.AllocateAndConstruct<SharedQuadState>());
396 EXPECT_EQ(size, list.size());
399 std::vector<const SharedQuadState*>::const_iterator sqs_iter =
400 sqs_list.begin();
401 for (ListContainer<SharedQuadState>::ConstIterator iter = list.begin();
402 iter != list.end(); ++iter) {
403 EXPECT_TRUE(isConstSharedQuadStatePointer(*iter));
404 EXPECT_EQ(*sqs_iter, *iter);
405 ++sqs_iter;
410 std::vector<const SharedQuadState*>::const_iterator sqs_iter =
411 sqs_list.begin();
412 for (ListContainer<SharedQuadState>::Iterator iter = list.begin();
413 iter != list.end(); ++iter) {
414 EXPECT_FALSE(isConstSharedQuadStatePointer(*iter));
415 EXPECT_EQ(*sqs_iter, *iter);
416 ++sqs_iter;
421 ListContainer<SharedQuadState>::ConstIterator iter = list.begin();
422 for (std::vector<const SharedQuadState*>::const_iterator sqs_iter =
423 sqs_list.begin();
424 sqs_iter != sqs_list.end(); ++sqs_iter) {
425 EXPECT_EQ(*sqs_iter, *iter);
426 ++iter;
431 TEST(ListContainerTest, SimpleReverseInsertionSharedQuadState) {
432 ListContainer<SharedQuadState> list;
433 std::vector<SharedQuadState*> sqs_list;
434 size_t size = 10;
435 for (size_t i = 0; i < size; ++i) {
436 sqs_list.push_back(list.AllocateAndConstruct<SharedQuadState>());
438 EXPECT_EQ(size, list.size());
441 std::vector<SharedQuadState*>::const_reverse_iterator sqs_iter =
442 sqs_list.rbegin();
443 for (ListContainer<SharedQuadState>::ReverseIterator iter = list.rbegin();
444 iter != list.rend(); ++iter) {
445 EXPECT_EQ(*sqs_iter, *iter);
446 ++sqs_iter;
451 ListContainer<SharedQuadState>::ReverseIterator iter = list.rbegin();
452 for (std::vector<SharedQuadState*>::reverse_iterator sqs_iter =
453 sqs_list.rbegin();
454 sqs_iter != sqs_list.rend(); ++sqs_iter) {
455 EXPECT_EQ(*sqs_iter, *iter);
456 ++iter;
461 TEST(ListContainerTest, SimpleDeletion) {
462 ListContainer<DrawQuad> list(kLargestQuadSize);
463 std::vector<SimpleDrawQuad*> sdq_list;
464 size_t size = 10;
465 for (size_t i = 0; i < size; ++i) {
466 sdq_list.push_back(list.AllocateAndConstruct<SimpleDrawQuad>());
467 sdq_list.back()->set_value(i);
469 EXPECT_EQ(size, list.size());
471 list.EraseAndInvalidateAllPointers(list.begin());
472 --size;
473 EXPECT_EQ(size, list.size());
474 int i = 1;
475 for (ListContainer<DrawQuad>::Iterator iter = list.begin();
476 iter != list.end(); ++iter) {
477 EXPECT_EQ(i, static_cast<SimpleDrawQuad*>(*iter)->get_value());
478 ++i;
482 TEST(ListContainerTest, DeletionAllInAllocation) {
483 const size_t kReserve = 10;
484 ListContainer<DrawQuad> list(kLargestQuadSize, kReserve);
485 std::vector<SimpleDrawQuad*> sdq_list;
486 // Add enough quads to cause another allocation.
487 for (size_t i = 0; i < kReserve + 1; ++i) {
488 sdq_list.push_back(list.AllocateAndConstruct<SimpleDrawQuad>());
489 sdq_list.back()->set_value(static_cast<int>(i));
491 EXPECT_EQ(kReserve + 1, list.size());
493 // Remove everything in the first allocation.
494 for (size_t i = 0; i < kReserve; ++i)
495 list.EraseAndInvalidateAllPointers(list.begin());
496 EXPECT_EQ(1u, list.size());
498 // The last quad is left.
499 SimpleDrawQuad* quad = static_cast<SimpleDrawQuad*>(*list.begin());
500 EXPECT_EQ(static_cast<int>(kReserve), quad->get_value());
502 // Remove the quad from the 2nd allocation.
503 list.EraseAndInvalidateAllPointers(list.begin());
504 EXPECT_EQ(0u, list.size());
507 TEST(ListContainerTest, DeletionAllInAllocationReversed) {
508 const size_t kReserve = 10;
509 ListContainer<DrawQuad> list(kLargestQuadSize, kReserve);
510 std::vector<SimpleDrawQuad*> sdq_list;
511 // Add enough quads to cause another allocation.
512 for (size_t i = 0; i < kReserve + 1; ++i) {
513 sdq_list.push_back(list.AllocateAndConstruct<SimpleDrawQuad>());
514 sdq_list.back()->set_value(static_cast<int>(i));
516 EXPECT_EQ(kReserve + 1, list.size());
518 // Remove everything in the 2nd allocation.
519 auto it = list.begin();
520 for (size_t i = 0; i < kReserve; ++i)
521 ++it;
522 list.EraseAndInvalidateAllPointers(it);
524 // The 2nd-last quad is next, and the rest of the quads exist.
525 size_t i = kReserve - 1;
526 for (auto it = list.rbegin(); it != list.rend(); ++it) {
527 SimpleDrawQuad* quad = static_cast<SimpleDrawQuad*>(*it);
528 EXPECT_EQ(static_cast<int>(i), quad->get_value());
529 --i;
532 // Can forward iterate too.
533 i = 0;
534 for (auto it = list.begin(); it != list.end(); ++it) {
535 SimpleDrawQuad* quad = static_cast<SimpleDrawQuad*>(*it);
536 EXPECT_EQ(static_cast<int>(i), quad->get_value());
537 ++i;
540 // Remove the last thing from the 1st allocation.
541 it = list.begin();
542 for (size_t i = 0; i < kReserve - 1; ++i)
543 ++it;
544 list.EraseAndInvalidateAllPointers(it);
546 // The 2nd-last quad is next, and the rest of the quads exist.
547 i = kReserve - 2;
548 for (auto it = list.rbegin(); it != list.rend(); ++it) {
549 SimpleDrawQuad* quad = static_cast<SimpleDrawQuad*>(*it);
550 EXPECT_EQ(static_cast<int>(i), quad->get_value());
551 --i;
554 // Can forward iterate too.
555 i = 0;
556 for (auto it = list.begin(); it != list.end(); ++it) {
557 SimpleDrawQuad* quad = static_cast<SimpleDrawQuad*>(*it);
558 EXPECT_EQ(static_cast<int>(i), quad->get_value());
559 ++i;
563 TEST(ListContainerTest, SimpleIterationAndManipulation) {
564 ListContainer<DrawQuad> list(kLargestQuadSize);
565 std::vector<SimpleDrawQuad*> sdq_list;
566 size_t size = 10;
567 for (size_t i = 0; i < size; ++i) {
568 SimpleDrawQuad* simple_dq = list.AllocateAndConstruct<SimpleDrawQuad>();
569 sdq_list.push_back(simple_dq);
571 EXPECT_EQ(size, list.size());
573 ListContainer<DrawQuad>::Iterator iter = list.begin();
574 for (int i = 0; i < 10; ++i) {
575 static_cast<SimpleDrawQuad*>(*iter)->set_value(i);
576 ++iter;
579 int i = 0;
580 for (std::vector<SimpleDrawQuad*>::const_iterator sdq_iter = sdq_list.begin();
581 sdq_iter < sdq_list.end(); ++sdq_iter) {
582 EXPECT_EQ(i, (*sdq_iter)->get_value());
583 ++i;
587 TEST(ListContainerTest, SimpleManipulationWithIndexSimpleDrawQuad) {
588 ListContainer<DrawQuad> list(kLargestQuadSize);
589 std::vector<SimpleDrawQuad*> dq_list;
590 size_t size = 10;
591 for (size_t i = 0; i < size; ++i) {
592 dq_list.push_back(list.AllocateAndConstruct<SimpleDrawQuad>());
594 EXPECT_EQ(size, list.size());
596 for (size_t i = 0; i < size; ++i) {
597 static_cast<SimpleDrawQuad*>(list.ElementAt(i))->set_value(i);
600 int i = 0;
601 for (std::vector<SimpleDrawQuad*>::const_iterator dq_iter = dq_list.begin();
602 dq_iter != dq_list.end(); ++dq_iter, ++i) {
603 EXPECT_EQ(i, (*dq_iter)->get_value());
607 TEST(ListContainerTest,
608 SimpleManipulationWithIndexMoreThanOneAllocationSimpleDrawQuad) {
609 ListContainer<DrawQuad> list(LargestDrawQuadSize(), 2);
610 std::vector<SimpleDrawQuad*> dq_list;
611 size_t size = 10;
612 for (size_t i = 0; i < size; ++i) {
613 dq_list.push_back(list.AllocateAndConstruct<SimpleDrawQuad>());
615 EXPECT_EQ(size, list.size());
617 for (size_t i = 0; i < size; ++i) {
618 static_cast<SimpleDrawQuad*>(list.ElementAt(i))->set_value(i);
621 int i = 0;
622 for (std::vector<SimpleDrawQuad*>::const_iterator dq_iter = dq_list.begin();
623 dq_iter != dq_list.end(); ++dq_iter, ++i) {
624 EXPECT_EQ(i, (*dq_iter)->get_value());
628 TEST(ListContainerTest,
629 SimpleIterationAndReverseIterationWithIndexSharedQuadState) {
630 ListContainer<SharedQuadState> list;
631 std::vector<SharedQuadState*> sqs_list;
632 size_t size = 10;
633 for (size_t i = 0; i < size; ++i) {
634 sqs_list.push_back(list.AllocateAndConstruct<SharedQuadState>());
636 EXPECT_EQ(size, list.size());
638 size_t i = 0;
639 for (ListContainer<SharedQuadState>::Iterator iter = list.begin();
640 iter != list.end(); ++iter) {
641 EXPECT_EQ(i, iter.index());
642 ++i;
645 i = 0;
646 for (ListContainer<SharedQuadState>::ReverseIterator iter = list.rbegin();
647 iter != list.rend(); ++iter) {
648 EXPECT_EQ(i, iter.index());
649 ++i;
653 } // namespace
654 } // namespace cc