@@ -111,113 +111,3 @@ void CPositioner::initElementIfNeeded(SP<IElement> el) {
111111
112112 el->impl ->positionerData = makeUnique<Hyprtoolkit::SPositionerData>();
113113}
114-
115- #ifdef HT_UNIT_TESTS
116-
117- // FIXME: These tests aren't very comprehensive.
118-
119- #include < gtest/gtest.h>
120-
121- #include < hyprtoolkit/element/Null.hpp>
122- #include < hyprtoolkit/element/RowLayout.hpp>
123- #include < hyprtoolkit/element/ColumnLayout.hpp>
124-
125- TEST (Positioner, main) {
126- auto root = CNullBuilder::begin ()->size ({CDynamicSize::HT_SIZE_ABSOLUTE, CDynamicSize::HT_SIZE_ABSOLUTE, {1000 , 1000 }})->commence ();
127- root->setMargin (4 );
128- auto rowLayoutMain = CRowLayoutBuilder::begin ()->size ({CDynamicSize::HT_SIZE_PERCENT, CDynamicSize::HT_SIZE_PERCENT, {1 , 1 }})->gap (10 )->commence ();
129- root->addChild (rowLayoutMain);
130-
131- auto columnLayoutLeft = CColumnLayoutBuilder::begin ()->size ({CDynamicSize::HT_SIZE_AUTO, CDynamicSize::HT_SIZE_PERCENT, {1 , 1 }})->gap (10 )->commence ();
132- auto childLeft = CNullBuilder::begin ()->size ({CDynamicSize::HT_SIZE_ABSOLUTE, CDynamicSize::HT_SIZE_ABSOLUTE, {100 , 200 }})->commence ();
133-
134- auto nullRight = CNullBuilder::begin ()->size ({CDynamicSize::HT_SIZE_AUTO, CDynamicSize::HT_SIZE_PERCENT, {1 , 1 }})->commence ();
135- nullRight->setGrow (true );
136-
137- auto columnLayoutRight = CColumnLayoutBuilder::begin ()->size ({CDynamicSize::HT_SIZE_AUTO, CDynamicSize::HT_SIZE_AUTO, {1 , 1 }})->gap (10 )->commence ();
138- auto childRight = CNullBuilder::begin ()->size ({CDynamicSize::HT_SIZE_ABSOLUTE, CDynamicSize::HT_SIZE_ABSOLUTE, {200 , 300 }})->commence ();
139- auto childRight2 = CNullBuilder::begin ()->size ({CDynamicSize::HT_SIZE_ABSOLUTE, CDynamicSize::HT_SIZE_ABSOLUTE, {200 , 300 }})->commence ();
140-
141- childRight->setPositionMode (IElement::HT_POSITION_ABSOLUTE);
142- childRight2->setPositionMode (IElement::HT_POSITION_ABSOLUTE);
143- columnLayoutRight->setPositionMode (IElement::HT_POSITION_ABSOLUTE);
144-
145- nullRight->addChild (columnLayoutRight);
146- rowLayoutMain->addChild (columnLayoutLeft);
147- rowLayoutMain->addChild (nullRight);
148-
149- columnLayoutLeft->addChild (childLeft);
150-
151- columnLayoutRight->addChild (childRight);
152- columnLayoutRight->addChild (childRight2);
153-
154- g_positioner->position (root, {{}, {1000 , 1000 }});
155- g_positioner->positionChildren (root);
156-
157- EXPECT_EQ (root->impl ->position , CBox (4 , 4 , 992 , 992 ));
158- EXPECT_EQ (rowLayoutMain->impl ->position , CBox (4 , 4 , 992 , 992 ));
159- EXPECT_EQ (columnLayoutLeft->impl ->position , CBox (4 , 4 , 100 , 992 ));
160- EXPECT_EQ (columnLayoutRight->impl ->position , CBox (114 , 4 , 200 , 610 ));
161- EXPECT_EQ (childRight2->impl ->position , CBox (114 , 314 , 200 , 300 ));
162- }
163-
164- TEST (Positioner, align) {
165- auto root = CNullBuilder::begin ()->size ({CDynamicSize::HT_SIZE_ABSOLUTE, CDynamicSize::HT_SIZE_ABSOLUTE, {1000 , 1000 }})->commence ();
166- auto child = CNullBuilder::begin ()->size ({CDynamicSize::HT_SIZE_ABSOLUTE, CDynamicSize::HT_SIZE_ABSOLUTE, {10 , 10 }})->commence ();
167- child->setPositionMode (IElement::HT_POSITION_ABSOLUTE);
168-
169- root->addChild (child);
170-
171- g_positioner->position (root, {{}, {1000 , 1000 }});
172- g_positioner->positionChildren (root);
173-
174- EXPECT_EQ (child->impl ->position , CBox (0 , 0 , 10 , 10 ));
175-
176- child->setPositionFlag (IElement::HT_POSITION_FLAG_VCENTER, true );
177-
178- g_positioner->position (root, {{}, {1000 , 1000 }});
179- g_positioner->positionChildren (root);
180-
181- EXPECT_EQ (child->impl ->position , CBox (0 , 495 , 10 , 10 ));
182-
183- child->setPositionFlag (IElement::HT_POSITION_FLAG_HCENTER, true );
184-
185- g_positioner->position (root, {{}, {1000 , 1000 }});
186- g_positioner->positionChildren (root);
187-
188- EXPECT_EQ (child->impl ->position , CBox (495 , 495 , 10 , 10 ));
189-
190- child->setPositionFlag (IElement::HT_POSITION_FLAG_VCENTER, false );
191- child->setPositionFlag (IElement::HT_POSITION_FLAG_TOP, true );
192-
193- g_positioner->position (root, {{}, {1000 , 1000 }});
194- g_positioner->positionChildren (root);
195-
196- EXPECT_EQ (child->impl ->position , CBox (495 , 0 , 10 , 10 ));
197-
198- child->setPositionFlag (IElement::HT_POSITION_FLAG_TOP, false );
199- child->setPositionFlag (IElement::HT_POSITION_FLAG_BOTTOM, true );
200-
201- g_positioner->position (root, {{}, {1000 , 1000 }});
202- g_positioner->positionChildren (root);
203-
204- EXPECT_EQ (child->impl ->position , CBox (495 , 990 , 10 , 10 ));
205-
206- child->setPositionFlag (IElement::HT_POSITION_FLAG_HCENTER, false );
207- child->setPositionFlag (IElement::HT_POSITION_FLAG_RIGHT, true );
208-
209- g_positioner->position (root, {{}, {1000 , 1000 }});
210- g_positioner->positionChildren (root);
211-
212- EXPECT_EQ (child->impl ->position , CBox (990 , 990 , 10 , 10 ));
213-
214- child->setPositionFlag (IElement::HT_POSITION_FLAG_RIGHT, false );
215- child->setPositionFlag (IElement::HT_POSITION_FLAG_LEFT, true );
216-
217- g_positioner->position (root, {{}, {1000 , 1000 }});
218- g_positioner->positionChildren (root);
219-
220- EXPECT_EQ (child->impl ->position , CBox (0 , 990 , 10 , 10 ));
221- }
222-
223- #endif
0 commit comments