quixote
quixote copied to clipboard
Quixote assertion API improvements, part 2: Rectangles
Quixote's new assertion API was described in issue #47. Some of the assertions were released in v1.0. This issue describes the next batch of improvements.
Rectangles
Introduce a new type of descriptor, tentatively called Rectangle
or perhaps RectangleDescriptor
. QElement
, QPage
, QViewport
, and ElementRendered
will be retrofitted to extend this descriptor.
Properties
Rectangles have these properties, same as now:
-
top
,bottom
,left
,right
-
width
,height
-
center
,middle
Assertions
We'll add these assertions.
Fill
Determine if one rectangle is inside another. "Fill" means all four edges match the expectation. "FillTopOf" means all edges except the bottom match the expectation. And so forth.
-
should.fill(rectangle)
-
should.fillTopOf(rectangle)
-
should.fillBottomOf(rectangle)
-
should.fillLeftOf(rectangle)
-
should.fillRightOf(rectangle)
Alignment
Determine if one rectangle is aligned with another. "Vertically aligned" means the left and right edges are the same.
Single-variable alignment (center, left, etc.) could be added, but we'll wait to see how the first batch of assertions works out.
-
should.alignVerticallyWith(rectangle)
-
should.alignHorizontallyWith(rectangle)
Others
Additional assertions are possible, but we'll wait and see how this batch works out first.
-
should.notOverlap(rectangle)
-
should.overlapTopOf(rectangle, optionalSizeToOverlap)
etc. -
should.abutTopOf(rectangle)
etc. -
should.beAbove(rectangle)
etc.
Methods
Only one method, for now. It creates a new rectangle, similar to PositionDescriptor.to()
. There may be a better way to do this.
-
rectangle.to(otherRectangle)
(need a better name?)