Section 5

We're not done yet. The CellClickRegionTestCase class has the following instance method.

testClicksInIgnoreRegion
    | pt regionClass |
    pt := 1@1.
    regionClass := CellClickRegion clickRegionForPoint: pt.
    self should: [regionClass = CellClickRegionIgnore].
    pt := 39@39.
    regionClass := CellClickRegion clickRegionForPoint: pt.
    self should: [regionClass = CellClickRegionIgnore].
    pt := 3@3.
    regionClass := CellClickRegion clickRegionForPoint: pt.
    self should: [regionClass = CellClickRegionIgnore].
    pt := 10@10.
    regionClass := CellClickRegion clickRegionForPoint: pt.
    self shouldnt: [regionClass = CellClickRegionIgnore].

This has the same brittleness. Here's the re-coded method.

testClicksInIgnoreRegion
    | pt regionClass |
    pt := 1@1.
    regionClass := CellClickRegion clickRegionForPoint: pt.
    self should: [regionClass = CellClickRegionIgnore].
    pt := CellRenderer cellExtent - (1@1).
    regionClass := CellClickRegion clickRegionForPoint: pt.
    self should: [regionClass = CellClickRegionIgnore].
    pt := CellRenderer ignoreRegionOffset - (1@1).
    regionClass := CellClickRegion clickRegionForPoint: pt.
    self should: [regionClass = CellClickRegionIgnore].
    pt := CellClickRegionOutside regionRectangle topLeft.
    regionClass := CellClickRegion clickRegionForPoint: pt.
    self shouldnt: [regionClass = CellClickRegionIgnore].
    pt := CellClickRegionInside regionRectangle topLeft.
    regionClass := CellClickRegion clickRegionForPoint: pt.
    self shouldnt: [regionClass = CellClickRegionIgnore].

I also added another check to the test. When we run the unit tests everything continues to pass.

Index Page Next Page

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