We can now apply the same technique to the other test case. Here are our previous notes for CellClickOutsideRegionRotateTestCase.
|
|
The existing method.
testClicksInRotateRegions
| pt regionClass testTable cls rotateRegion |
pt := 5@5.
regionClass := CellClickRegion clickRegionForPoint: pt.
self should: [regionClass = CellClickRegionOutside].
testTable := {
10@10->CellClickRegionRotateClockwise.
30@10->CellClickRegionRotateClockwise.
10@20->CellClickRegionRotateClockwise.
30@20->CellClickRegionRotateClockwise.
10@30->CellClickRegionRotateCounterClockwise.
30@30->CellClickRegionRotateCounterClockwise.
4@4->CellClickRegionRotateClockwise.
36@4->CellClickRegionRotateClockwise.
4@20->CellClickRegionRotateClockwise.
36@20->CellClickRegionRotateClockwise.
4@36->CellClickRegionRotateCounterClockwise.
36@36->CellClickRegionRotateCounterClockwise.
6@10->CellClickRegionRotateClockwise.
32@18->CellClickRegionRotateClockwise.
12@32->CellClickRegionRotateCounterClockwise.
}.
testTable do: [:assoc |
pt := assoc key.
cls := assoc value.
rotateRegion := regionClass rotateRegionForPoint: pt.
self should: [rotateRegion = cls]]
We'll do the same thing we did for the "inside" region. One big difference however is that we will need both the inside and outside region rectangles. I'll call them "outRect" and "inRect".
|
|
The "M" test point was the only tricky one in the table. Again, it's easy to understand the test when the points are described this way. Let's modify the method.
testClicksInRotateRegions
| pt regionClass testTable cls rotateRegion inRect outRect |
inRect := CellClickRegionInside regionRectangle.
outRect := CellClickRegionOutside regionRectangle.
pt := outRect topLeft + (1@1).
regionClass := CellClickRegion clickRegionForPoint: pt.
self should: [regionClass = CellClickRegionOutside].
testTable := {
inRect topLeft ->CellClickRegionRotateClockwise.
inRect topRight ->CellClickRegionRotateClockwise.
inRect leftCenter ->CellClickRegionRotateClockwise.
inRect rightCenter ->CellClickRegionRotateClockwise.
inRect bottomLeft ->CellClickRegionRotateCounterClockwise.
inRect bottomRight ->CellClickRegionRotateCounterClockwise.
outRect topLeft ->CellClickRegionRotateClockwise.
outRect topRight ->CellClickRegionRotateClockwise.
outRect leftCenter ->CellClickRegionRotateClockwise.
outRect rightCenter ->CellClickRegionRotateClockwise.
outRect bottomCenter ->CellClickRegionRotateCounterClockwise.
outRect bottomRight ->CellClickRegionRotateCounterClockwise.
(outRect topLeft x + 2)@(inRect topLeft y) ->CellClickRegionRotateClockwise.
inRect rightCenter + (2@-2) ->CellClickRegionRotateClockwise.
inRect bottomLeft + (2@2) ->CellClickRegionRotateCounterClockwise.
}.
testTable do: [:assoc |
pt := assoc key.
cls := assoc value.
rotateRegion := regionClass rotateRegionForPoint: pt.
self should: [rotateRegion = cls]]
Once again when we run the unit tests they still pass. This change works fine.