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

Side by Side Diff: Source/core/layout/MultiColumnFragmentainerGroupTest.cpp

Issue 883293004: [New Multicolumn] Preparatory work for nested multicol support. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Place the new files in ../layout/ , since that's where they'll end up soon anyway. Created 5 years, 10 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "config.h"
6
7 #include "core/layout/MultiColumnFragmentainerGroup.h"
8
9 #include "core/rendering/RenderMultiColumnFlowThread.h"
10 #include "core/rendering/RenderMultiColumnSet.h"
11 #include "core/rendering/RenderingTestHelper.h"
12
13 #include <gtest/gtest.h>
14
15 namespace blink {
16
17 namespace {
18
19 class MultiColumnFragmentainerGroupTest : public RenderingTest {
20 public:
21 MultiColumnFragmentainerGroupTest() : m_flowThread(0), m_columnSet(0) { }
22
23 protected:
24 virtual void SetUp() override;
25 virtual void TearDown() override;
26
27 RenderMultiColumnSet& columnSet() { return *m_columnSet; }
28
29 static int groupCount(const MultiColumnFragmentainerGroupList&);
30
31 private:
32 RenderMultiColumnFlowThread* m_flowThread;
33 RenderMultiColumnSet* m_columnSet;
34 };
35
36 void MultiColumnFragmentainerGroupTest::SetUp()
37 {
38 RenderingTest::SetUp();
39 RefPtr<LayoutStyle> style = LayoutStyle::create();
40 m_flowThread = RenderMultiColumnFlowThread::createAnonymous(document(), *sty le.get());
41 m_columnSet = RenderMultiColumnSet::createAnonymous(*m_flowThread, *m_flowTh read->style());
42 }
43
44 void MultiColumnFragmentainerGroupTest::TearDown()
45 {
46 m_columnSet->destroy();
47 m_flowThread->destroy();
48 RenderingTest::TearDown();
49 }
50
51 int MultiColumnFragmentainerGroupTest::groupCount(const MultiColumnFragmentainer GroupList& groupList)
52 {
53 int count = 0;
54 for (const auto& dummyGroup : groupList) {
55 (void) dummyGroup;
56 count++;
57 }
58 return count;
59 }
60
61 TEST_F(MultiColumnFragmentainerGroupTest, Create)
62 {
63 MultiColumnFragmentainerGroupList groupList(columnSet());
64 EXPECT_EQ(groupCount(groupList), 1);
65 }
66
67 TEST_F(MultiColumnFragmentainerGroupTest, DeleteExtra)
68 {
69 MultiColumnFragmentainerGroupList groupList(columnSet());
70 EXPECT_EQ(groupCount(groupList), 1);
71 groupList.deleteExtraGroups();
72 EXPECT_EQ(groupCount(groupList), 1);
73 }
74
75 TEST_F(MultiColumnFragmentainerGroupTest, AddThenDeleteExtra)
76 {
77 MultiColumnFragmentainerGroupList groupList(columnSet());
78 EXPECT_EQ(groupCount(groupList), 1);
79 groupList.addExtraGroup();
80 EXPECT_EQ(groupCount(groupList), 2);
81 groupList.deleteExtraGroups();
82 EXPECT_EQ(groupCount(groupList), 1);
83 }
84
85 TEST_F(MultiColumnFragmentainerGroupTest, AddTwoThenDeleteExtraThenAddThreeThenD eleteExtra)
86 {
87 MultiColumnFragmentainerGroupList groupList(columnSet());
88 EXPECT_EQ(groupCount(groupList), 1);
89 groupList.addExtraGroup();
90 EXPECT_EQ(groupCount(groupList), 2);
91 groupList.addExtraGroup();
92 EXPECT_EQ(groupCount(groupList), 3);
93 groupList.deleteExtraGroups();
94 EXPECT_EQ(groupCount(groupList), 1);
95 groupList.addExtraGroup();
96 EXPECT_EQ(groupCount(groupList), 2);
97 groupList.addExtraGroup();
98 EXPECT_EQ(groupCount(groupList), 3);
99 groupList.addExtraGroup();
100 EXPECT_EQ(groupCount(groupList), 4);
101 groupList.deleteExtraGroups();
102 EXPECT_EQ(groupCount(groupList), 1);
103 }
104
105 } // anonymous namespace
106
107 } // blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698