Section 5

Let's work on our bugs. Click on the first failing unit test and open up the debugger.

We're testing a point at 20@10 for a CellClickRegionInside and expected to see CellClickRegionPushWest as the answer but instead received CellClickRegionPushSouth. This could just be a bug in the unit test.

When we tested our inside click region logic earlier in our design we used a table like this to check results. The version of the table below is how it looks after we corrected errors we found long ago in our test design.

Label Point Push
A 10@10 East
B 20@10 West
C 15@15 North
D 10@20 North
E 20@20 North
F 11@13 East
G 14@16 North
H 19@17 West
I 15@1 South

The trouble is of course that our cells are bigger now. We now have a cell that's 40 x 40 instead of 30 x 30. With an "inside" region that's 10 pixels from the edges, the new table dimensions should be as follows.

Label Point Push
A 10@10 East
B 30@10 West
C 20@20 North
D 10@30 North
E 30@30 North
F 11@13 East
G 19@21 North
H 29@27 West
I 20@1 South

Change the unit test accordingly and re-run.

testClicksInPushRegions
     | pt regionClass pushRegion testTable cls |
     pt := 11@11.
     regionClass := CellClickRegion clickRegionForPoint: pt.
     self should: [regionClass = CellClickRegionInside].
     testTable := {
         10@10->CellClickRegionPushEast.
         30@10->CellClickRegionPushWest.
         20@20->CellClickRegionPushNorth.
         10@30->CellClickRegionPushNorth.
         30@30->CellClickRegionPushNorth.
         11@13->CellClickRegionPushEast.
         19@21->CellClickRegionPushNorth.
         29@27->CellClickRegionPushWest.
         20@1->CellClickRegionPushSouth
         }.
     testTable do: [:assoc |
         pt := assoc key.
         cls := assoc value.
         pushRegion := regionClass pushRegionForPoint: pt.
         self should: [pushRegion = cls]]

Index Page Next Page

Copyright © 2007, 2008, 2009, 2010 Stephan B Wessels    stevewessels@me.com