RegressionTests__GraphicDrawingTest.st
author Claus Gittinger <cg@exept.de>
Thu, 14 Apr 2016 19:08:20 +0200
changeset 1393 50384f233a0f
parent 222 9f4633a520da
child 1447 2351db93aa5b
child 1499 26a16a04219b
permissions -rw-r--r--
#DOCUMENTATION by cg class: RegressionTests::Win32OLETests changed: #test00_loadOLE

"{ Package: 'exept:regression' }"

"{ NameSpace: RegressionTests }"

TestCase subclass:#GraphicDrawingTest
	instanceVariableNames:''
	classVariableNames:''
	poolDictionaries:''
	category:'tests-Regression'
!


!GraphicDrawingTest methodsFor:'tests'!

_testDraw:drawBlock thenCheck:checkBlock
    |form|

    form := Form width:30 height:30 depth:(Display depth) onDevice:Display.
    form clear.
    drawBlock value:form.

    checkBlock value:form.
!

test_01_Clear
    self 
        _testDraw:[:form | ] 
        thenCheck:[:form | 
            |blackPixel whitePixel pix|

            blackPixel := (Color black onDevice:Display) colorId.
            whitePixel := (Color white onDevice:Display) colorId.

            0 to:form height-1 do:[:y |
                0 to:form width-1 do:[:x |
                    pix := form atX:x y:y.
                    self assert:( pix == blackPixel )
                ]
            ]
        ]

    "
     self new test_01_Clear
    "
!

test_02_DrawHLine
    self 
        _testDraw:[:form | 
            form paint:Color white.
            form displayLineFromX:1 y:0 toX:form width-1-1 y:0.
        ] 
        thenCheck:[:form | 
            |blackPixel whitePixel pix|

            blackPixel := (Color black onDevice:Display) colorId.
            whitePixel := (Color white onDevice:Display) colorId.

            1 to:form height-1 do:[:y |
                0 to:form width-1 do:[:x |
                    pix := form atX:x y:y.
                    self assert:( pix == blackPixel )
                ]
            ].

            pix := form atX:0 y:0.
            self assert:( pix == blackPixel ).
            pix := form atX:(form width-1) y:0.
            self assert:( pix == blackPixel ).

            1 to:form width-2 do:[:x |
                pix := form atX:x y:0.
                self assert:( pix == whitePixel )
            ]
        ]

    "
     self new test_02_DrawHLine
    "
!

test_03_DrawRectangle
    self 
        _testDraw:[:form | 
            form paint:Color white.
            form displayRectangleX:1 y:1 width:(form width-1-1) height:(form height-1-1).
        ] 
        thenCheck:[:form | 
            |blackPixel whitePixel pix|

            blackPixel := (Color black onDevice:Display) colorId.
            whitePixel := (Color white onDevice:Display) colorId.

            2 to:form height-1-1-1 do:[:y |
                2 to:form width-1-1-1 do:[:x |
                    pix := form atX:x y:y.
                    self assert:( pix == blackPixel )
                ]
            ].

            0 to:form width-1 do:[:x |
                pix := form atX:x y:0.
                self assert:( pix == blackPixel )
            ].
            0 to:form width-1 do:[:x |
                pix := form atX:x y:(form height-1).
                self assert:( pix == blackPixel )
            ].
            0 to:form height-1 do:[:y |
                pix := form atX:0 y:y.
                self assert:( pix == blackPixel )
            ].
            0 to:form height-1 do:[:y |
                pix := form atX:(form width-1) y:y.
                self assert:( pix == blackPixel )
            ].

            1 to:form width-1-1 do:[:x |
                pix := form atX:x y:1.
                self assert:( pix == whitePixel )
            ].
            1 to:form width-1-1 do:[:x |
                pix := form atX:x y:(form height-2).
                self assert:( pix == whitePixel )
            ].

        ]

    "
     self new test_03_DrawRectangle
    "
!

test_03_DrawVLine
    self 
        _testDraw:[:form | 
            form paint:Color white.
            form displayLineFromX:0 y:1 toX:0 y:form height-1-1.
        ] 
        thenCheck:[:form | 
            |blackPixel whitePixel pix|

            blackPixel := (Color black onDevice:Display) colorId.
            whitePixel := (Color white onDevice:Display) colorId.

            0 to:form height-1 do:[:y |
                1 to:form width-1 do:[:x |
                    pix := form atX:x y:y.
                    self assert:( pix == blackPixel )
                ]
            ].

            pix := form atX:0 y:0.
            self assert:( pix == blackPixel ).
            pix := form atX:0 y:(form height-1).
            self assert:( pix == blackPixel ).

            1 to:form height-2 do:[:y |
                pix := form atX:0 y:y.
                self assert:( pix == whitePixel )
            ]
        ]

    "
     self new test_03_DrawVLine
    "
! !

!GraphicDrawingTest class methodsFor:'documentation'!

version
    ^ '$Header$'
! !