Section 5

The CellRendererTestCase class has an instance method that has similar dependencies we must correct. Here's the existing method.

testCellOffsetCalculations
    | grid form cellLoc cell renderer offset |
    grid := GridFactory demoGrid.
    form := Form extent: (LaserGame boardExtentFor: grid) depth: Display depth.
    form fillColor: (Color r: 0.820 g: 0.820 b: 0.820).

    cellLoc := 1@1.
    cell := grid at: cellLoc.
    renderer := CellRenderer rendererFor: cell grid: grid form: form.
    offset := renderer offsetWithinGridForm.
    self should: [offset = (0@0)].

    cellLoc := 2@1.
    cell := grid at: cellLoc.
    renderer := CellRenderer rendererFor: cell grid: grid form: form.
    offset := renderer offsetWithinGridForm.
    self should: [offset = (40@0)].

    cellLoc := 1@2.
    cell := grid at: cellLoc.
    renderer := CellRenderer rendererFor: cell grid: grid form: form.
    offset := renderer offsetWithinGridForm.
    self should: [offset = (0@40)].

    cellLoc := 2@2.
    cell := grid at: cellLoc.
    renderer := CellRenderer rendererFor: cell grid: grid form: form.
    offset := renderer offsetWithinGridForm.
    self should: [offset = (40@40)].

And here is the "corrected" method.

testCellOffsetCalculations
    | grid form cellLoc cell renderer offset |
    grid := GridFactory demoGrid.
    form := Form extent: (LaserGame boardExtentFor: grid) depth: Display depth.
    form fillColor: (Color r: 0.820 g: 0.820 b: 0.820).

    cellLoc := 1@1.
    cell := grid at: cellLoc.
    renderer := CellRenderer rendererFor: cell grid: grid form: form.
    offset := renderer offsetWithinGridForm.
    self should: [offset = (0@0)].

    cellLoc := 2@1.
    cell := grid at: cellLoc.
    renderer := CellRenderer rendererFor: cell grid: grid form: form.
    offset := renderer offsetWithinGridForm.
    self should: [offset = ((CellRenderer cellExtent x)@0)].

    cellLoc := 1@2.
    cell := grid at: cellLoc.
    renderer := CellRenderer rendererFor: cell grid: grid form: form.
    offset := renderer offsetWithinGridForm.
    self should: [offset = (0@(CellRenderer cellExtent y))].

    cellLoc := 2@2.
    cell := grid at: cellLoc.
    renderer := CellRenderer rendererFor: cell grid: grid form: form.
    offset := renderer offsetWithinGridForm.
    self should: [offset = (CellRenderer cellExtent)].

The unit tests continue to pass when we run them.

Index Page Next Page

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