[Pkg] Squeak3.10bc: GraphicsTests-kph.14.mcz
squeak-dev-noreply at lists.squeakfoundation.org
squeak-dev-noreply at lists.squeakfoundation.org
Sat Dec 13 04:53:23 UTC 2008
A new version of GraphicsTests was added to project Squeak3.10bc:
http://www.squeaksource.com/310bc/GraphicsTests-kph.14.mcz
==================== Summary ====================
Name: GraphicsTests-kph.14
Author: kph
Time: 13 December 2008, 4:53:21 am
UUID: 2fb61003-8bff-4b18-97dd-22c702904772
Ancestors: GraphicsTests-edc.13
Saved from SystemVersion
==================== Snapshot ====================
SystemOrganization addCategory: #'GraphicsTests-Primitives'!
SystemOrganization addCategory: #'GraphicsTests-Text'!
SystemOrganization addCategory: #'GraphicsTests-Files'!
HashAndEqualsTestCase subclass: #TextStyleTest
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'GraphicsTests-Text'!
----- Method: TextStyleTest>>setUp (in category 'initialize-release') -----
setUp
super setUp.
prototypes add: TextStyle default !
TestCase subclass: #BMPReadWriterTest
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'GraphicsTests-Files'!
----- Method: BMPReadWriterTest>>bmpData16bit (in category 'data') -----
bmpData16bit
"Created via:
(Base64MimeConverter mimeEncode:
(FileStream readOnlyFileNamed: 'bmptest16b.bmp') binary)
contents
"
^(Base64MimeConverter mimeDecodeToBytes:
'Qk24AAAAAAAAADYAAAAoAAAACAAAAAgAAAABABAAAAAAAIIAAADDDgAAww4AAAAAAAAAAAAA
4APgA+AD4AMfAB8AHwAfAOAD4APgA+ADHwAfAB8AHwDgA+AD/3//f/9//38fAB8A4APgA/9/
/3//f/9/HwAfAAAAAAD/f/9//3//fwB8AHwAAAAA/3//f/9//38AfAB8AAAAAAAAAAAAfAB8
AHwAfAAAAAAAAAAAAHwAfAB8AHwAAA==' readStream) contents!
----- Method: BMPReadWriterTest>>bmpData24bit (in category 'data') -----
bmpData24bit
"Created via:
(Base64MimeConverter mimeEncode:
(FileStream readOnlyFileNamed: 'bmptest24.bmp') binary)
contents
"
^(Base64MimeConverter mimeDecodeToBytes:
'Qk32AAAAAAAAADYAAAAoAAAACAAAAAgAAAABABgAAAAAAAAAAADEDgAAxA4AAAAAAAAAAAAA
AP8AAP8AAP8AAP8A/wAA/wAA/wAA/wAAAP8AAP8AAP8AAP8A/wAA/wAA/wAA/wAAAP8AAP8A
/////////////////wAA/wAAAP8AAP8A/////////////////wAA/wAAAAAAAAAA////////
////////AAD/AAD/AAAAAAAA////////////////AAD/AAD/AAAAAAAAAAAAAAAAAAD/AAD/
AAD/AAD/AAAAAAAAAAAAAAAAAAD/AAD/AAD/AAD/' readStream) contents!
----- Method: BMPReadWriterTest>>bmpData32bit (in category 'data') -----
bmpData32bit
"Created via:
(Base64MimeConverter mimeEncode:
(FileStream readOnlyFileNamed: 'bmptest32b.bmp') binary)
contents
"
^(Base64MimeConverter mimeDecodeToBytes:
'Qk04AQAAAAAAADYAAAAoAAAACAAAAAgAAAABACAAAAAAAAIBAADDDgAAww4AAAAAAAAAAAAA
AP8AAAD/AAAA/wAAAP8AAP8AAAD/AAAA/wAAAP8AAAAA/wAAAP8AAAD/AAAA/wAA/wAAAP8A
AAD/AAAA/wAAAAD/AAAA/wAA////AP///wD///8A////AP8AAAD/AAAAAP8AAAD/AAD///8A
////AP///wD///8A/wAAAP8AAAAAAAAAAAAAAP///wD///8A////AP///wAAAP8AAAD/AAAA
AAAAAAAA////AP///wD///8A////AAAA/wAAAP8AAAAAAAAAAAAAAAAAAAAAAAAA/wAAAP8A
AAD/AAAA/wAAAAAAAAAAAAAAAAAAAAAAAAD/AAAA/wAAAP8AAAD/AAAA'
readStream) contents!
----- Method: BMPReadWriterTest>>bmpData4bit (in category 'data') -----
bmpData4bit
"Created via:
(Base64MimeConverter mimeEncode:
(FileStream readOnlyFileNamed: 'bmptest4.bmp') binary)
contents
"
^(Base64MimeConverter mimeDecodeToBytes:
'Qk12BAAAAAAAADYEAAAoAAAACAAAAAgAAAABAAgAAAAAAEAAAADEDg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QADAIGAAwCCAAMAgoADAIMAAwCDgAMBAAADAQCAAwEBAAMBAYADAQIAAwECgAMBAwADAQOAA
wGAAAMBgIADAYEAAwGBgAMBggADAYKAAwGDAAMBg4ADAgAAAwIAgAMCAQADAgGAAwICAAMCA
oADAgMAAwIDgAMCgAADAoCAAwKBAAMCgYADAoIAAwKCgAMCgwADAoOAAwMAAAMDAIADAwEAA
wMBgAMDAgADAwKAA8Pv/AKSgoACAgIAAAAD/AAD/AAAA//8A/wAAAP8A/wD//wAA////APr6
+vr8/Pz8+vr6+vz8/Pz6+v/////8/Pr6//////z8AAD/////+fkAAP/////5+QAAAAD5+fn5
AAAAAPn5+fk=' readStream) contents!
----- Method: BMPReadWriterTest>>bmpData8bit (in category 'data') -----
bmpData8bit
"Created via:
(Base64MimeConverter mimeEncode:
(FileStream readOnlyFileNamed: 'bmptest8.bmp') binary)
contents
"
^(Base64MimeConverter mimeDecodeToBytes:
'Qk12BAAAAAAAADYEAAAoAAAACAAAAAgAAAABAAgAAAAAAEAAAADEDgAAxA4AAAAAAAAAAAAA
AAAAAAAAgAAAgAAAAICAAIAAAACAAIAAgIAAAMDAwADA3MAA8MqmAAAgQAAAIGAAACCAAAAg
oAAAIMAAACDgAABAAAAAQCAAAEBAAABAYAAAQIAAAECgAABAwAAAQOAAAGAAAABgIAAAYEAA
AGBgAABggAAAYKAAAGDAAABg4AAAgAAAAIAgAACAQAAAgGAAAICAAACAoAAAgMAAAIDgAACg
AAAAoCAAAKBAAACgYAAAoIAAAKCgAACgwAAAoOAAAMAAAADAIAAAwEAAAMBgAADAgAAAwKAA
AMDAAADA4AAA4AAAAOAgAADgQAAA4GAAAOCAAADgoAAA4MAAAODgAEAAAABAACAAQABAAEAA
YABAAIAAQACgAEAAwABAAOAAQCAAAEAgIABAIEAAQCBgAEAggABAIKAAQCDAAEAg4ABAQAAA
QEAgAEBAQABAQGAAQECAAEBAoABAQMAAQEDgAEBgAABAYCAAQGBAAEBgYABAYIAAQGCgAEBg
wABAYOAAQIAAAECAIABAgEAAQIBgAECAgABAgKAAQIDAAECA4ABAoAAAQKAgAECgQABAoGAA
QKCAAECgoABAoMAAQKDgAEDAAABAwCAAQMBAAEDAYABAwIAAQMCgAEDAwABAwOAAQOAAAEDg
IABA4EAAQOBgAEDggABA4KAAQODAAEDg4ACAAAAAgAAgAIAAQACAAGAAgACAAIAAoACAAMAA
gADgAIAgAACAICAAgCBAAIAgYACAIIAAgCCgAIAgwACAIOAAgEAAAIBAIACAQEAAgEBgAIBA
gACAQKAAgEDAAIBA4ACAYAAAgGAgAIBgQACAYGAAgGCAAIBgoACAYMAAgGDgAICAAACAgCAA
gIBAAICAYACAgIAAgICgAICAwACAgOAAgKAAAICgIACAoEAAgKBgAICggACAoKAAgKDAAICg
4ACAwAAAgMAgAIDAQACAwGAAgMCAAIDAoACAwMAAgMDgAIDgAACA4CAAgOBAAIDgYACA4IAA
gOCgAIDgwACA4OAAwAAAAMAAIADAAEAAwABgAMAAgADAAKAAwADAAMAA4ADAIAAAwCAgAMAg
QADAIGAAwCCAAMAgoADAIMAAwCDgAMBAAADAQCAAwEBAAMBAYADAQIAAwECgAMBAwADAQOAA
wGAAAMBgIADAYEAAwGBgAMBggADAYKAAwGDAAMBg4ADAgAAAwIAgAMCAQADAgGAAwICAAMCA
oADAgMAAwIDgAMCgAADAoCAAwKBAAMCgYADAoIAAwKCgAMCgwADAoOAAwMAAAMDAIADAwEAA
wMBgAMDAgADAwKAA8Pv/AKSgoACAgIAAAAD/AAD/AAAA//8A/wAAAP8A/wD//wAA////APr6
+vr8/Pz8+vr6+vz8/Pz6+v/////8/Pr6//////z8AAD/////+fkAAP/////5+QAAAAD5+fn5
AAAAAPn5+fk=' readStream) contents!
----- Method: BMPReadWriterTest>>bmpDataR5G6B5 (in category 'data') -----
bmpDataR5G6B5
"This is a BMP file based on BitmapV4Header which is currently unsupported."
"Created via:
(Base64MimeConverter mimeEncode:
(FileStream readOnlyFileNamed: 'bmptest16-R5G6B5.bmp') binary)
contents
"
^(Base64MimeConverter mimeDecodeToBytes:
'Qk3IAAAAAAAAAEYAAAA4AAAACAAAAAgAAAABABAAAwAAAIIAAADDDgAAww4AAAAAAAAAAAAA
APgAAOAHAAAfAAAAAAAAAOAH4AfgB+AHHwAfAB8AHwDgB+AH4AfgBx8AHwAfAB8A4AfgB///
////////HwAfAOAH4Af//////////x8AHwAAAAAA//////////8A+AD4AAAAAP//////////
APgA+AAAAAAAAAAAAPgA+AD4APgAAAAAAAAAAAD4APgA+AD4AAA='
readStream) contents!
----- Method: BMPReadWriterTest>>bmpDataX4R4G4B4 (in category 'data') -----
bmpDataX4R4G4B4
"This is a BMP file based on BitmapV4Header which is currently unsupported."
"Created via:
(Base64MimeConverter mimeEncode:
(FileStream readOnlyFileNamed: 'bmptest16-X4R4G4B4.bmp') binary)
contents
"
^(Base64MimeConverter mimeDecodeToBytes:
'Qk3IAAAAAAAAAEYAAAA4AAAACAAAAAgAAAABABAAAwAAAIIAAADDDgAAww4AAAAAAAAAAAAA
AA8AAPAAAAAPAAAAAAAAAPAA8ADwAPAADwAPAA8ADwDwAPAA8ADwAA8ADwAPAA8A8ADwAP8P
/w//D/8PDwAPAPAA8AD/D/8P/w//Dw8ADwAAAAAA/w//D/8P/w8ADwAPAAAAAP8P/w//D/8P
AA8ADwAAAAAAAAAAAA8ADwAPAA8AAAAAAAAAAAAPAA8ADwAPAAA='
readStream) contents!
----- Method: BMPReadWriterTest>>bmpDataX8R8G8B8 (in category 'data') -----
bmpDataX8R8G8B8
"This is a BMP file based on BitmapV4Header which is currently unsupported."
"Created via:
(Base64MimeConverter mimeEncode:
(FileStream readOnlyFileNamed: 'bmptest32-X8R8G8B8.bmp') binary)
contents
"
^(Base64MimeConverter mimeDecodeToBytes:
'Qk1IAQAAAAAAAEYAAAA4AAAACAAAAAgAAAABACAAAwAAAAIBAADDDgAAww4AAAAAAAAAAAAA
AAAA/wAA/wAA/wAAAAAAAAAA/wAAAP8AAAD/AAAA/wAA/wAAAP8AAAD/AAAA/wAAAAD/AAAA
/wAAAP8AAAD/AAD/AAAA/wAAAP8AAAD/AAAAAP8AAAD/AAD///8A////AP///wD///8A/wAA
AP8AAAAA/wAAAP8AAP///wD///8A////AP///wD/AAAA/wAAAAAAAAAAAAAA////AP///wD/
//8A////AAAA/wAAAP8AAAAAAAAAAAD///8A////AP///wD///8AAAD/AAAA/wAAAAAAAAAA
AAAAAAAAAAAAAAD/AAAA/wAAAP8AAAD/AAAAAAAAAAAAAAAAAAAAAAAAAP8AAAD/AAAA/wAA
AP8AAA=='
readStream) contents!
----- Method: BMPReadWriterTest>>testBmp16Bit (in category 'reading') -----
testBmp16Bit
| reader form |
reader := BMPReadWriter new on: (ReadStream on: self bmpData16bit).
form := reader nextImage.
"special black here to compensate for zero-is-transparent effect"
self assert: (form colorAt: 7 at 1) = Color red.
self assert: (form colorAt: 1 at 7) = Color green.
self assert: (form colorAt: 7 at 7) = Color blue.
self assert: (form colorAt: 4 at 4) = Color white.
self assert: (form pixelValueAt: 1 at 1) = 16r8000.
!
----- Method: BMPReadWriterTest>>testBmp24Bit (in category 'reading') -----
testBmp24Bit
| reader form |
reader := BMPReadWriter new on: (ReadStream on: self bmpData24bit).
form := reader nextImage.
self assert: (form colorAt: 7 at 1) = Color red.
self assert: (form colorAt: 1 at 7) = Color green.
self assert: (form colorAt: 7 at 7) = Color blue.
self assert: (form colorAt: 4 at 4) = Color white.
self assert: (form pixelValueAt: 1 at 1) = 16rFF000000.
!
----- Method: BMPReadWriterTest>>testBmp32Bit (in category 'reading') -----
testBmp32Bit
| reader form |
reader := BMPReadWriter new on: (ReadStream on: self bmpData32bit).
form := reader nextImage.
self assert: (form colorAt: 7 at 1) = Color red.
self assert: (form colorAt: 1 at 7) = Color green.
self assert: (form colorAt: 7 at 7) = Color blue.
self assert: (form colorAt: 4 at 4) = Color white.
self assert: (form pixelValueAt: 1 at 1) = 16rFF000000.
!
----- Method: BMPReadWriterTest>>testBmp4Bit (in category 'reading') -----
testBmp4Bit
| reader form |
reader := BMPReadWriter new on: (ReadStream on: self bmpData4bit).
form := reader nextImage.
self assert: (form colorAt: 1 at 1) = Color black.
self assert: (form colorAt: 7 at 1) = Color red.
self assert: (form colorAt: 1 at 7) = Color green.
self assert: (form colorAt: 7 at 7) = Color blue.
self assert: (form colorAt: 4 at 4) = Color white.
!
----- Method: BMPReadWriterTest>>testBmp8Bit (in category 'reading') -----
testBmp8Bit
| reader form |
reader := BMPReadWriter new on: (ReadStream on: self bmpData8bit).
form := reader nextImage.
self assert: (form colorAt: 1 at 1) = Color black.
self assert: (form colorAt: 7 at 1) = Color red.
self assert: (form colorAt: 1 at 7) = Color green.
self assert: (form colorAt: 7 at 7) = Color blue.
self assert: (form colorAt: 4 at 4) = Color white.
!
TestCase subclass: #PNGReadWriterTest
instanceVariableNames: 'fileName'
classVariableNames: ''
poolDictionaries: ''
category: 'GraphicsTests-Files'!
----- Method: PNGReadWriterTest>>coloredFiles16 (in category 'tests - decoding') -----
coloredFiles16
"Created by
{Color red. Color green. Color blue. Color black} collect:[:fillC|
| ff bytes |
ff := Form extent: 32 at 32 depth: 16.
ff fillColor: fillC.
bytes := WriteStream on: ByteArray new.
PNGReadWriter putForm: ff onStream: bytes.
fillC ->
(Base64MimeConverter mimeEncode: (bytes contents readStream)) contents
].
"
^{Color red->
'iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABHNCSVQFBQUBSsjp7wAAADZJ
REFUeF7lziEBAAAMAjD6J8b9MRAT80uT65Af8AN+wA/4AT/gB/yAH/ADfsAP+AE/4AfmgQdc
z9xqBS2pdAAAAABJRU5ErkJggg=='.
Color green->
'iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABHNCSVQFBQUBSsjp7wAAADVJ
REFUeF7lziEBAAAMAjD6J77jMRAT80sunfIDfsAP+AE/4Af8gB/wA37AD/gBP+AH/MA68HyT
3Gqf2I6NAAAAAElFTkSuQmCC'.
Color blue->
'iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABHNCSVQFBQUBSsjp7wAAADVJ
REFUeF7lziEBAAAMAjD6J77jMRAT80ty3fIDfsAP+AE/4Af8gB/wA37AD/gBP+AH/MA48JxX
3GpYhihrAAAAAElFTkSuQmCC'.
Color black->
'iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABHNCSVQFBQUBSsjp7wAAADVJ
REFUeF7lziEBAAAMAjDk+xfmMRAT80ty3fIDfsAP+AE/4Af8gB/wA37AD/gBP+AH/MA48LbT
HD3MKH3GAAAAAElFTkSuQmCC'
}!
----- Method: PNGReadWriterTest>>coloredFiles32 (in category 'tests - decoding') -----
coloredFiles32
"Created by
{Color red. Color green. Color blue. Color black} collect:[:fillC|
| ff bytes |
ff := Form extent: 32 at 32 depth: 32.
ff fillColor: fillC.
bytes := WriteStream on: ByteArray new.
PNGReadWriter putForm: ff onStream: bytes.
fillC ->
(Base64MimeConverter mimeEncode: (bytes contents readStream)) contents
].
"
^{
Color red -> 'iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAANUlEQVR4XuXOIQEAAAwEoe9f
+hZjAoFnbfVo+QE/4Af8gB/wA37AD/gBP+AH/IAf8AN+4DlwVA34ajP6EEoAAAAASUVORK5C
YII='.
Color green -> 'iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAM0lEQVR4XuXOMQ0AAAACIPuX
1hgejAIkPfMDfsAP+AE/4Af8gB/wA37AD/gBP+AH/MA7MFfR+Grvv2BdAAAAAElFTkSuQmCC'.
Color blue->
'iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAANElEQVR4XuXOIQEAAAACIP+f
1hkGAp0k7Zcf8AN+wA/4AT/gB/yAH/ADfsAP+AE/4AfOgQFblfhqnnPWHAAAAABJRU5ErkJg
gg=='.
Color black -> 'iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAANUlEQVR4XuXOMQEAAAwCINc/
tIvhwcFPkuuWH/ADfsAP+AE/4Af8gB/wA37AD/gBP+AHxoEH95UAPU59TTMAAAAASUVORK5C
YII='
}!
----- Method: PNGReadWriterTest>>coloredFiles8 (in category 'tests - decoding') -----
coloredFiles8
"Created by
{Color red. Color green. Color blue. Color black} collect:[:fillC|
| ff bytes |
ff := Form extent: 32 at 32 depth: 8.
ff fillColor: fillC.
bytes := WriteStream on: ByteArray new.
PNGReadWriter putForm: ff onStream: bytes.
fillC ->
(Base64MimeConverter mimeEncode: (bytes contents readStream)) contents
].
"
^{Color red->
'iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAADAFBMVEX///8AAAD///9/f3//
AAAA/wAAAP8A/////wD/AP8fHx8/Pz9fX1+fn5+/v7/f398HBwcPDw8XFxcnJycvLy83NzdH
R0dPT09XV1dnZ2dvb293d3eHh4ePj4+Xl5enp6evr6+3t7fHx8fPz8/X19fn5+fv7+/39/cA
AAAAMgAAZQAAmAAAywAA/wAAADIAMjIAZTIAmDIAyzIA/zIAAGUAMmUAZWUAmGUAy2UA/2UA
AJgAMpgAZZgAmJgAy5gA/5gAAMsAMssAZcsAmMsAy8sA/8sAAP8AMv8AZf8AmP8Ay/8A//8y
AAAyMgAyZQAymAAyywAy/wAyADIyMjIyZTIymDIyyzIy/zIyAGUyMmUyZWUymGUyy2Uy/2Uy
AJgyMpgyZZgymJgyy5gy/5gyAMsyMssyZcsymMsyy8sy/8syAP8yMv8yZf8ymP8yy/8y//9l
AABlMgBlZQBlmABlywBl/wBlADJlMjJlZTJlmDJlyzJl/zJlAGVlMmVlZWVlmGVly2Vl/2Vl
AJhlMphlZZhlmJhly5hl/5hlAMtlMstlZctlmMtly8tl/8tlAP9lMv9lZf9lmP9ly/9l//+Y
AACYMgCYZQCYmACYywCY/wCYADKYMjKYZTKYmDKYyzKY/zKYAGWYMmWYZWWYmGWYy2WY/2WY
AJiYMpiYZZiYmJiYy5iY/5iYAMu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yAMsyMssyZcsymMsyy8sy/8syAP8yMv8yZf8ymP8yy/8y//9l
AABlMgBlZQBlmABlywBl/wBlADJlMjJlZTJlmDJlyzJl/zJlAGVlMmVlZWVlmGVly2Vl/2Vl
AJhlMphlZZhlmJhly5hl/5hlAMtlMstlZctlmMtly8tl/8tlAP9lMv9lZf9lmP9ly/9l//+Y
AACYMgCYZQCYmACYywCY/wCYADKYMjKYZTKYmDKYyzKY/zKYAGWYMmWYZWWYmGWYy2WY/2WY
AJiYMpiYZZiYmJiYy5iY/5iYAMuYMsuYZcuYmMuYy8uY/8uYAP+YMv+YZf+YmP+Yy/+Y///L
AADLMgDLZQDLmADLywDL/wDLADLLMjLLZTLLmDLLyzLL/zLLAGXLMmXLZWXLmGXLy2XL/2XL
AJjLMpjLZZjLmJjLy5jL/5jLAMvLMsvLZcvLmMvLy8vL/8vLAP/LMv/LZf/LmP/Ly//L////
AAD/MgD/ZQD/mAD/ywD//wD/ADL/MjL/ZTL/mDL/yzL//zL/AGX/MmX/ZWX/mGX/y2X//2X/
AJj/Mpj/ZZj/mJj/y5j//5j/AMv/Msv/Zcv/mMv/y8v//8v/AP//Mv//Zf//mP//y/////9E
CiHUAAAAGUlEQVR4XmNgZMQPGBhHvoKRr2DkKxihCgBEmAQBphO0cAAAAABJRU5ErkJggg=='
}!
----- Method: PNGReadWriterTest>>decodeColors:depth: (in category 'tests - decoding') -----
decodeColors: colorsAndFiles depth: requiredDepth
| color bytes form |
colorsAndFiles do:[:assoc|
color := assoc key.
bytes := Base64MimeConverter mimeDecodeToBytes: assoc value readStream.
form := PNGReadWriter formFromStream: bytes.
self assert: form depth = requiredDepth.
self assert: (form pixelValueAt: 1 at 1) = (color pixelValueForDepth: requiredDepth).
].!
----- Method: PNGReadWriterTest>>drawStuffOn: (in category 'helpers') -----
drawStuffOn: aForm
"Draw stuff on aForm. Avoid any symmetry."
| canvas |
canvas := FormCanvas on: aForm.
canvas frameAndFillRectangle: (1 at 1 corner: aForm extent - 15) fillColor: Color red borderWidth: 3 borderColor: Color green.
canvas fillOval: (aForm boundingBox topRight - (15 at -5) extent: 20 at 20) color: Color blue borderWidth: 1 borderColor: Color white.
^aForm
"(PNGReadWriterTest new drawStuffOn: (Form extent: 32 at 32 depth: 16)) display"!
----- Method: PNGReadWriterTest>>drawTransparentStuffOn: (in category 'helpers') -----
drawTransparentStuffOn: aForm
"Draw stuff on aForm. Avoid any symmetry."
| canvas |
canvas := FormCanvas on: aForm.
canvas frameAndFillRectangle: (1 at 1 corner: aForm extent - 15) fillColor: (Color red alpha: 0.25) borderWidth: 3 borderColor: (Color green alpha: 0.5).
canvas fillOval: (aForm boundingBox topRight - (15 at -5) extent: 20 at 20) color: (Color white alpha: 0.75) borderWidth: 1 borderColor: Color blue.
^aForm
"(PNGReadWriterTest new drawStuffOn: (Form extent: 32 at 32 depth: 16)) display"!
----- Method: PNGReadWriterTest>>encodeAndDecode: (in category 'helpers') -----
encodeAndDecode: original
"Make sure that the given form is encoded and decoded correctly"
| stream bytes decoded maxErr |
"encode"
stream := ByteArray new writeStream.
(PNGReadWriter on: stream) nextPutImage: original; close.
bytes := stream contents.
self writeEncoded: bytes.
"decode"
stream := self readEncoded: bytes.
decoded := (PNGReadWriter new on: stream) nextImage.
decoded display.
"compare"
self assert: original width = decoded width.
self assert: original height = decoded height.
self assert: original depth = decoded depth.
self assert: original bits = decoded bits.
self assert: original class == decoded class.
(original isColorForm) ifTrue:[
original colors with: decoded colors do:[:c1 :c2|
"we must round here due to encoding errors"
maxErr := 1. "max. error for 8bit rgb component"
self assert: ((c1 red * 255) truncated - (c2 red * 255) truncated) abs <= maxErr.
self assert: ((c1 green * 255) truncated - (c2 green * 255) truncated) abs <= maxErr.
self assert: ((c1 blue * 255) truncated - (c2 blue * 255) truncated) abs <= maxErr.
self assert: ((c1 alpha * 255) truncated - (c2 alpha * 255) truncated) abs <= maxErr.
].
].!
----- Method: PNGReadWriterTest>>encodeAndDecodeAlpha: (in category 'helpers') -----
encodeAndDecodeAlpha: original
fileName := 'testAlpha', original depth printString,'.png'.
self encodeAndDecode: original.!
----- Method: PNGReadWriterTest>>encodeAndDecodeColor:depth: (in category 'helpers') -----
encodeAndDecodeColor: aColor depth: aDepth
| aForm |
fileName := 'testColor', aColor name, aDepth printString,'.png'.
aForm := Form extent: 32 at 32 depth: aDepth.
aForm fillColor: aColor.
self encodeAndDecode: aForm.
!
----- Method: PNGReadWriterTest>>encodeAndDecodeDisplay: (in category 'helpers') -----
encodeAndDecodeDisplay: depth
| form |
fileName := 'testDisplay', depth printString,'.png'.
form := Form extent: (Display extent min: 560 at 560) depth: depth.
Smalltalk isMorphic
ifTrue:[World fullDrawOn: form getCanvas]
ifFalse:[Display displayOn: form].
self encodeAndDecode: form.!
----- Method: PNGReadWriterTest>>encodeAndDecodeForm: (in category 'helpers') -----
encodeAndDecodeForm: original
fileName := 'testForm', original depth printString,'.png'.
self encodeAndDecode: original.!
----- Method: PNGReadWriterTest>>encodeAndDecodeReverse: (in category 'helpers') -----
encodeAndDecodeReverse: original
"Make sure that the given form is encoded and decoded correctly"
| stream bytes decoded maxErr reversed |
fileName := 'testReverse', original depth printString,'.png'.
self assert: original class == Form. "won't work with ColorForm"
"Switch pixel order"
reversed := Form extent: original extent depth: original depth negated.
original displayOn: reversed.
self assert: original width = reversed width.
self assert: original height = reversed height.
self assert: original depth = reversed depth.
self deny: original nativeDepth = reversed nativeDepth.
original depth = 32
ifTrue:[self assert: original bits = reversed bits]
ifFalse:[self deny: original bits = reversed bits].
"encode"
stream := ByteArray new writeStream.
(PNGReadWriter on: stream) nextPutImage: reversed; close.
bytes := stream contents.
self writeEncoded: bytes.
"decode"
stream := bytes readStream.
decoded := (PNGReadWriter new on: stream) nextImage.
decoded display.
"compare"
self assert: original width = decoded width.
self assert: original height = decoded height.
self assert: original depth = decoded depth.
self assert: original bits = decoded bits.
self assert: original class == decoded class.
(original isColorForm) ifTrue:[
original colors with: decoded colors do:[:c1 :c2|
"we must round here due to encoding errors"
maxErr := 1. "max. error for 8bit rgb component"
self assert: ((c1 red * 255) truncated - (c2 red * 255) truncated) abs <= maxErr.
self assert: ((c1 green * 255) truncated - (c2 green * 255) truncated) abs <= maxErr.
self assert: ((c1 blue * 255) truncated - (c2 blue * 255) truncated) abs <= maxErr.
self assert: ((c1 alpha * 255) truncated - (c2 alpha * 255) truncated) abs <= maxErr.
].
].!
----- Method: PNGReadWriterTest>>encodeAndDecodeStream: (in category 'helpers') -----
encodeAndDecodeStream: file
| aForm |
file reset.
(PNGReadWriter new on: file) understandsImageFormat ifFalse:[^self error: 'don''t understand format!!' ].
file reset.
aForm := (PNGReadWriter new on: file) nextImage.
aForm ifNil:[^self error: 'nil form' ].
aForm display.
self encodeAndDecode: aForm.
!
----- Method: PNGReadWriterTest>>encodeAndDecodeWithColors: (in category 'helpers') -----
encodeAndDecodeWithColors: aColorForm
"Screw around with aColorForm colors"
| colors nColors indexedColors max myRandom |
fileName := 'testColors', aColorForm depth printString,'.png'.
indexedColors := Color indexedColors.
nColors := 1 bitShift: aColorForm depth.
colors := WriteStream on: Array new.
"Make first half translucent"
max := nColors // 2.
1 to: max do:[:i|
colors nextPut: ((indexedColors at: i) alpha: i / max asFloat).
].
"Make random choices for second half"
myRandom := Random seed: 42315.
max to: nColors do:[:i|
colors nextPut: (indexedColors atRandom: myRandom).
].
!
----- Method: PNGReadWriterTest>>encodeAndDecodeWithError: (in category 'helpers') -----
encodeAndDecodeWithError: aStream
self should:[self encodeAndDecodeStream: aStream] raise: Error!
----- Method: PNGReadWriterTest>>encodeColors:depth: (in category 'tests - decoding') -----
encodeColors: colorsAndFiles depth: requiredDepth
| color original ff encoded |
colorsAndFiles do:[:assoc|
color := assoc key.
original := Base64MimeConverter mimeDecodeToBytes: assoc value readStream.
ff := Form extent: 32 at 32 depth: requiredDepth.
ff fillColor: color.
encoded := WriteStream on: ByteArray new.
PNGReadWriter putForm: ff onStream: encoded.
self assert: (encoded contents = original contents).
].!
----- Method: PNGReadWriterTest>>readEncoded: (in category 'helpers') -----
readEncoded: bytes
"Answer a ReadStream on the file named by fileName, if possible; else a ReadStream on bytes"
fileName ifNil:[^ bytes readStream ].
^(FileStream oldFileOrNoneNamed: fileName) ifNil: [
Transcript nextPutAll: 'can''t open ', fileName; cr.
bytes readStream ].
!
----- Method: PNGReadWriterTest>>setUp (in category 'helpers') -----
setUp
fileName := nil.!
----- Method: PNGReadWriterTest>>tearDown (in category 'helpers') -----
tearDown
World changed.
fileName notNil ifTrue: [FileDirectory default deleteFileNamed: fileName]!
----- Method: PNGReadWriterTest>>test16Bit (in category 'tests - bits') -----
test16Bit
self encodeAndDecodeForm: (self drawStuffOn: (Form extent: 33 at 33 depth: 16))!
----- Method: PNGReadWriterTest>>test16BitDisplay (in category 'tests - bits') -----
test16BitDisplay
self encodeAndDecodeDisplay: 16!
----- Method: PNGReadWriterTest>>test16BitReversed (in category 'tests - bits') -----
test16BitReversed
self encodeAndDecodeReverse: (self drawStuffOn: (Form extent: 33 at 33 depth: 16))!
----- Method: PNGReadWriterTest>>test1Bit (in category 'tests - bits') -----
test1Bit
self encodeAndDecodeForm: (self drawStuffOn: (Form extent: 33 at 33 depth: 1))!
----- Method: PNGReadWriterTest>>test1BitColors (in category 'tests - bits') -----
test1BitColors
self encodeAndDecodeWithColors: (self drawStuffOn: (Form extent: 33 at 33 depth: 1))!
----- Method: PNGReadWriterTest>>test1BitDisplay (in category 'tests - bits') -----
test1BitDisplay
self encodeAndDecodeDisplay: 1!
----- Method: PNGReadWriterTest>>test1BitReversed (in category 'tests - bits') -----
test1BitReversed
self encodeAndDecodeReverse: (self drawStuffOn: (Form extent: 33 at 33 depth: 1))!
----- Method: PNGReadWriterTest>>test2Bit (in category 'tests - bits') -----
test2Bit
self encodeAndDecodeForm: (self drawStuffOn: (Form extent: 33 at 33 depth: 2))!
----- Method: PNGReadWriterTest>>test2BitColors (in category 'tests - bits') -----
test2BitColors
self encodeAndDecodeWithColors: (self drawStuffOn: (Form extent: 33 at 33 depth: 2))!
----- Method: PNGReadWriterTest>>test2BitDisplay (in category 'tests - bits') -----
test2BitDisplay
self encodeAndDecodeDisplay: 2!
----- Method: PNGReadWriterTest>>test2BitReversed (in category 'tests - bits') -----
test2BitReversed
self encodeAndDecodeReverse: (self drawStuffOn: (Form extent: 33 at 33 depth: 2))!
----- Method: PNGReadWriterTest>>test32Bit (in category 'tests - bits') -----
test32Bit
self encodeAndDecodeForm: (self drawStuffOn: (Form extent: 33 at 33 depth: 32))!
----- Method: PNGReadWriterTest>>test32BitDisplay (in category 'tests - bits') -----
test32BitDisplay
self encodeAndDecodeDisplay: 32!
----- Method: PNGReadWriterTest>>test32BitReversed (in category 'tests - bits') -----
test32BitReversed
self encodeAndDecodeReverse: (self drawStuffOn: (Form extent: 33 at 33 depth: 32))!
----- Method: PNGReadWriterTest>>test4Bit (in category 'tests - bits') -----
test4Bit
self encodeAndDecodeForm: (self drawStuffOn: (Form extent: 33 at 33 depth: 4))!
----- Method: PNGReadWriterTest>>test4BitColors (in category 'tests - bits') -----
test4BitColors
self encodeAndDecodeWithColors: (self drawStuffOn: (Form extent: 33 at 33 depth: 4))!
----- Method: PNGReadWriterTest>>test4BitDisplay (in category 'tests - bits') -----
test4BitDisplay
self encodeAndDecodeDisplay: 4!
----- Method: PNGReadWriterTest>>test4BitReversed (in category 'tests - bits') -----
test4BitReversed
self encodeAndDecodeReverse: (self drawStuffOn: (Form extent: 33 at 33 depth: 4))!
----- Method: PNGReadWriterTest>>test8Bit (in category 'tests - bits') -----
test8Bit
self encodeAndDecodeForm: (self drawStuffOn: (Form extent: 33 at 33 depth: 8))!
----- Method: PNGReadWriterTest>>test8BitColors (in category 'tests - bits') -----
test8BitColors
self encodeAndDecodeWithColors: (self drawStuffOn: (Form extent: 33 at 33 depth: 8))!
----- Method: PNGReadWriterTest>>test8BitDisplay (in category 'tests - bits') -----
test8BitDisplay
self encodeAndDecodeDisplay: 8!
----- Method: PNGReadWriterTest>>test8BitReversed (in category 'tests - bits') -----
test8BitReversed
self encodeAndDecodeReverse: (self drawStuffOn: (Form extent: 33 at 33 depth: 8))!
----- Method: PNGReadWriterTest>>testAlphaCoding (in category 'tests - bits') -----
testAlphaCoding
self encodeAndDecodeAlpha: (self drawTransparentStuffOn: (Form extent: 33 at 33 depth: 32))!
----- Method: PNGReadWriterTest>>testBlack16 (in category 'tests - colors') -----
testBlack16
self encodeAndDecodeColor: Color blue depth: 16!
----- Method: PNGReadWriterTest>>testBlack32 (in category 'tests - colors') -----
testBlack32
self encodeAndDecodeColor: Color blue depth: 32!
----- Method: PNGReadWriterTest>>testBlack8 (in category 'tests - colors') -----
testBlack8
self encodeAndDecodeColor: Color blue depth: 8!
----- Method: PNGReadWriterTest>>testBlue16 (in category 'tests - colors') -----
testBlue16
self encodeAndDecodeColor: Color blue depth: 16!
----- Method: PNGReadWriterTest>>testBlue32 (in category 'tests - colors') -----
testBlue32
self encodeAndDecodeColor: Color blue depth: 32!
----- Method: PNGReadWriterTest>>testBlue8 (in category 'tests - colors') -----
testBlue8
self encodeAndDecodeColor: Color blue depth: 8!
----- Method: PNGReadWriterTest>>testGreen16 (in category 'tests - colors') -----
testGreen16
self encodeAndDecodeColor: Color green depth: 16!
----- Method: PNGReadWriterTest>>testGreen32 (in category 'tests - colors') -----
testGreen32
self encodeAndDecodeColor: Color green depth: 32!
----- Method: PNGReadWriterTest>>testGreen8 (in category 'tests - colors') -----
testGreen8
self encodeAndDecodeColor: Color green depth: 8!
----- Method: PNGReadWriterTest>>testPngDecodingColors16 (in category 'tests - decoding') -----
testPngDecodingColors16
self decodeColors: self coloredFiles16 depth: 16.!
----- Method: PNGReadWriterTest>>testPngDecodingColors32 (in category 'tests - decoding') -----
testPngDecodingColors32
self decodeColors: self coloredFiles32 depth: 32.!
----- Method: PNGReadWriterTest>>testPngDecodingColors8 (in category 'tests - decoding') -----
testPngDecodingColors8
self decodeColors: self coloredFiles8 depth: 8.!
----- Method: PNGReadWriterTest>>testPngEncodingColors16 (in category 'tests - decoding') -----
testPngEncodingColors16
self encodeColors: self coloredFiles16 depth: 16.!
----- Method: PNGReadWriterTest>>testPngEncodingColors32 (in category 'tests - decoding') -----
testPngEncodingColors32
self encodeColors: self coloredFiles32 depth: 32.!
----- Method: PNGReadWriterTest>>testPngEncodingColors8 (in category 'tests - decoding') -----
testPngEncodingColors8
self encodeColors: self coloredFiles8 depth: 8.!
----- Method: PNGReadWriterTest>>testPngSuite (in category 'tests - bits') -----
testPngSuite
"Requires the suite from
ftp://swrinde.nde.swri.edu/pub/png/images/suite/PngSuite.zip
to be present as PngSuite.zip"
| file zip entries |
[file := FileStream readOnlyFileNamed: 'PngSuite.zip'] on: Error do:[:ex| ex return].
file ifNil:[^self].
[zip := ZipArchive new readFrom: file.
entries := zip members select:[:mbr| mbr fileName asLowercase endsWith: '.png'].
entries do:[:mbr|
(mbr fileName asLowercase first = $x)
ifTrue: [self encodeAndDecodeWithError: mbr contentStream ]
ifFalse: [self encodeAndDecodeStream: mbr contentStream ] ].
] ensure:[file close].!
----- Method: PNGReadWriterTest>>testRed16 (in category 'tests - colors') -----
testRed16
self encodeAndDecodeColor: Color red depth: 16!
----- Method: PNGReadWriterTest>>testRed32 (in category 'tests - colors') -----
testRed32
self encodeAndDecodeColor: Color red depth: 32!
----- Method: PNGReadWriterTest>>testRed8 (in category 'tests - colors') -----
testRed8
self encodeAndDecodeColor: Color red depth: 8!
----- Method: PNGReadWriterTest>>writeEncoded: (in category 'helpers') -----
writeEncoded: bytes
| file |
fileName ifNil:[^self].
false ifTrue:[^self].
file := FileStream forceNewFileNamed: fileName.
[file nextPutAll: bytes] ensure:[file close].!
TestCase subclass: #RectangleTest
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'GraphicsTests-Primitives'!
----- Method: RectangleTest>>testAreasOutside1 (in category 'testing') -----
testAreasOutside1
"RectangleTest new testAreasOutside1"
| frame rects visibleArea |
frame := 0 at 0 extent: 300 at 300.
rects := OrderedCollection new: 80.
0 to: 3 do: [:i |
0 to: 2 do: [:j |
rects add: (i at j * 20 extent: 10 at 10)
] ].
visibleArea := Array with: frame.
rects do: [:rect | | remnants |
remnants := OrderedCollection new.
visibleArea do: [:a | remnants addAll: (a areasOutside: rect)].
visibleArea := remnants.
].
visibleArea := visibleArea asArray.
self assert: (visibleArea allSatisfy: [:r | r area ~= 0]).
1 to: visibleArea size do: [:idx |
idx + 1 to: visibleArea size do: [:idx2 |
self deny: ((visibleArea at: idx) intersects: (visibleArea at: idx2)).
] ].
1 to: rects size do: [:idx |
1 to: visibleArea size do: [:idx2 |
self deny: ((rects at: idx) intersects: (visibleArea at: idx2)).
] ].
!
----- Method: RectangleTest>>testAreasOutside2 (in category 'testing') -----
testAreasOutside2
"RectangleTest new testAreasOutside2"
| frame rects visibleArea |
frame := 0 at 0 extent: 300 at 300.
rects := OrderedCollection new: 80.
rects add: (50 at 50 corner: 200 @ 200);
add: (100 at 100 corner: 250 at 250).
visibleArea := Array with: frame.
rects do: [:rect | | remnants |
remnants := OrderedCollection new.
visibleArea do: [:a | remnants addAll: (a areasOutside: rect)].
visibleArea := remnants.
].
visibleArea := visibleArea asArray.
self assert: (visibleArea allSatisfy: [:r | r area ~= 0]).
1 to: visibleArea size do: [:idx |
idx + 1 to: visibleArea size do: [:idx2 |
self deny: ((visibleArea at: idx) intersects: (visibleArea at: idx2)).
] ].
1 to: rects size do: [:idx |
1 to: visibleArea size do: [:idx2 |
self deny: ((rects at: idx) intersects: (visibleArea at: idx2)).
] ].
!
----- Method: RectangleTest>>testCorner1 (in category 'testing') -----
testCorner1
"RectangleTest new testCorner1"
| rect |
rect := 10 at 10 extent: 20 at 30.
self deny: (rect containsPoint: rect corner).!
----- Method: RectangleTest>>testIntersection1 (in category 'testing') -----
testIntersection1
"RectangleTest new testIntersection1"
| rect1 rect2 |
rect1 := 10 at 10 corner: 20 at 30.
rect2 := rect1 corner extent: 20 at 40.
self deny: (rect1 intersects: rect2).!
----- Method: RectangleTest>>testIntersection2 (in category 'testing') -----
testIntersection2
"RectangleTest new testIntersection2"
| rect1 rect2 |
rect1 := 0 at 0 corner: 40 at 40.
rect2 := 40 at 40 corner: 50 at 50.
self deny: (rect1 intersects: rect2);
deny: (rect2 intersects: rect1).!
----- Method: RectangleTest>>testMergingDisjointRects (in category 'tests') -----
testMergingDisjointRects
| coll merge |
coll := OrderedCollection new.
coll add: (Rectangle left: -10 right: 0 top: -10 bottom: 0).
coll add: (Rectangle left: 0 right: 10 top: 0 bottom: 10).
merge := Rectangle merging: coll.
self assert: merge = (Rectangle left: -10 right: 10 top: -10 bottom: 10).!
----- Method: RectangleTest>>testMergingNestedRects (in category 'tests') -----
testMergingNestedRects
| coll merge |
coll := OrderedCollection new.
coll add: (Rectangle left: 1 right: 10 top: 1 bottom: 10).
coll add: (Rectangle left: 4 right: 5 top: 4 bottom: 5).
merge := Rectangle merging: coll.
self assert: merge = coll first.!
----- Method: RectangleTest>>testMergingOverlappingRects (in category 'tests') -----
testMergingOverlappingRects
| coll merge |
coll := OrderedCollection new.
coll add: (Rectangle left: 5 right: 10 top: 0 bottom: 15).
coll add: (Rectangle left: 0 right: 15 top: 5 bottom: 10).
merge := Rectangle merging: coll.
self assert: merge = (Rectangle left: 0 right: 15 top: 0 bottom: 15).!
----- Method: RectangleTest>>testMergingTrivial (in category 'tests') -----
testMergingTrivial
| coll merge |
coll := OrderedCollection new.
coll add: (Rectangle left: 1 right: 1 top: 1 bottom: 1).
merge := Rectangle merging: coll.
self assert: merge = coll first.
!
----- Method: RectangleTest>>testMergingTwoRects (in category 'tests') -----
testMergingTwoRects
| coll merge |
coll := OrderedCollection new.
coll add: (Rectangle left: 1 right: 1 top: 1 bottom: 1).
coll add: (Rectangle left: 10 right: 10 top: 10 bottom: 10).
merge := Rectangle merging: coll.
self assert: merge = (Rectangle left: 1 right: 10 top: 1 bottom: 10).!
ClassTestCase subclass: #BitBltTest
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'GraphicsTests-Primitives'!
----- Method: BitBltTest>>testAlphaCompositing (in category 'bugs') -----
testAlphaCompositing
"self run: #testAlphaCompositing"
| bb f1 f2 mixColor result eps |
f1 := Form extent: 1 at 1 depth: 32.
f2 := Form extent: 1 at 1 depth: 32.
eps := 0.5 / 255.
0 to: 255 do:[:i|
f1 colorAt: 0 at 0 put: Color blue.
mixColor := Color red alpha: i / 255.0.
f2 colorAt: 0 at 0 put: mixColor.
mixColor := f2 colorAt: 0 at 0.
bb := BitBlt toForm: f1.
bb sourceForm: f2.
bb combinationRule: Form blend.
bb copyBits.
result := f1 colorAt: 0 at 0.
self assert: (result red - mixColor alpha) abs < eps.
self assert: (result blue - (1.0 - mixColor alpha)) abs < eps.
self assert: result alpha = 1.0.
].!
----- Method: BitBltTest>>testAlphaCompositing2 (in category 'bugs') -----
testAlphaCompositing2
"self run: #testAlphaCompositing2"
| bb f1 f2 mixColor result eps |
f1 := Form extent: 1 at 1 depth: 32.
f2 := Form extent: 1 at 1 depth: 32.
eps := 0.5 / 255.
0 to: 255 do:[:i|
f1 colorAt: 0 at 0 put: Color transparent.
mixColor := Color red alpha: i / 255.0.
f2 colorAt: 0 at 0 put: mixColor.
mixColor := f2 colorAt: 0 at 0.
bb := BitBlt toForm: f1.
bb sourceForm: f2.
bb combinationRule: Form blend.
bb copyBits.
result := f1 colorAt: 0 at 0.
self assert: (result red - mixColor alpha) abs < eps.
self assert: result alpha = mixColor alpha.
].!
----- Method: BitBltTest>>testAlphaCompositing2Simulated (in category 'bugs') -----
testAlphaCompositing2Simulated
"self run: #testAlphaCompositing2Simulated"
| bb f1 f2 mixColor result eps |
Smalltalk at: #BitBltSimulation ifPresent: [:bitblt|
f1 := Form extent: 1 at 1 depth: 32.
f2 := Form extent: 1 at 1 depth: 32.
eps := 0.5 / 255.
0 to: 255 do:[:i|
f1 colorAt: 0 at 0 put: Color transparent.
mixColor := Color red alpha: i / 255.0.
f2 colorAt: 0 at 0 put: mixColor.
mixColor := f2 colorAt: 0 at 0.
bb := BitBlt toForm: f1.
bb sourceForm: f2.
bb combinationRule: Form blend.
bb copyBitsSimulated.
result := f1 colorAt: 0 at 0.
self assert: (result red - mixColor alpha) abs < eps.
self assert: result alpha = mixColor alpha.
].]!
----- Method: BitBltTest>>testAlphaCompositingSimulated (in category 'bugs') -----
testAlphaCompositingSimulated
"self run: #testAlphaCompositingSimulated"
| bb f1 f2 mixColor result eps |
Smalltalk at: #BitBltSimulation ifPresent:[:bitblt|
f1 := Form extent: 1 at 1 depth: 32.
f2 := Form extent: 1 at 1 depth: 32.
eps := 0.5 / 255.
0 to: 255 do:[:i|
f1 colorAt: 0 at 0 put: Color blue.
mixColor := Color red alpha: i / 255.0.
f2 colorAt: 0 at 0 put: mixColor.
mixColor := f2 colorAt: 0 at 0.
bb := BitBlt toForm: f1.
bb sourceForm: f2.
bb combinationRule: Form blend.
bb copyBitsSimulated.
result := f1 colorAt: 0 at 0.
self assert: (result red - mixColor alpha) abs < eps.
self assert: (result blue - (1.0 - mixColor alpha)) abs < eps.
self assert: result alpha = 1.0.
]].!
----- Method: BitBltTest>>testPeekerUnhibernateBug (in category 'bugs') -----
testPeekerUnhibernateBug
"self run: #testPeekerUnhibernateBug"
| bitBlt |
bitBlt := BitBlt bitPeekerFromForm: Display.
bitBlt destForm hibernate.
self shouldnt:[bitBlt pixelAt: 1 at 1] raise: Error.!
----- Method: BitBltTest>>testPokerUnhibernateBug (in category 'bugs') -----
testPokerUnhibernateBug
"self run: #testPokerUnhibernateBug"
| bitBlt |
bitBlt := BitBlt bitPokerToForm: Display.
bitBlt sourceForm hibernate.
self shouldnt:[bitBlt pixelAt: 1 at 1 put: 0] raise: Error.!
ClassTestCase subclass: #ColorTest
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'GraphicsTests-Primitives'!
----- Method: ColorTest>>testAsHTMLColor (in category 'tests') -----
testAsHTMLColor
self assert: (Color white asHTMLColor = '#ffffff').
self assert: (Color black asHTMLColor = '#000000').!
----- Method: ColorTest>>testColorFrom (in category 'tests') -----
testColorFrom
self assert: ((Color colorFrom: #white) asHTMLColor = '#ffffff').
self assert: ((Color colorFrom: #(1.0 0.5 0.0)) asHTMLColor = '#ff7f00').
self assert: ((Color colorFrom: (Color white)) asHTMLColor = '#ffffff').
self assert: ((Color colorFrom: '#FF8800') asHTMLColor = '#ff8800').!
----- Method: ColorTest>>testFromString (in category 'tests') -----
testFromString
self assert: ((Color fromString: '#FF8800') asHTMLColor = '#ff8800').!
----- Method: ColorTest>>testMultiplyByArray (in category 'testing') -----
testMultiplyByArray
| newColor oldColor tolerance |
tolerance := 0.001.
oldColor := Color r: 0.75 g: 0.5 b: 0.25.
newColor := oldColor * #(0.1 2 3).
self assert: (0.075 - newColor red) abs < tolerance.
self assert: (1 - newColor green) abs < tolerance.
self assert: (0.75 - newColor blue) abs < tolerance.!
----- Method: ColorTest>>testMultiplyByArrayIdentityTransform (in category 'testing') -----
testMultiplyByArrayIdentityTransform
| newColor oldColor tolerance |
tolerance := 0.001.
oldColor := Color r: 0.75 g: 0.5 b: 0.25.
newColor := oldColor * 2.
self assert: (1 - newColor red) abs < tolerance.
self assert: (1 - newColor green) abs < tolerance.
self assert: (0.5 - newColor blue) abs < tolerance.!
----- Method: ColorTest>>testMultiplyByNumber (in category 'testing') -----
testMultiplyByNumber
| newColor oldColor tolerance |
tolerance := 0.001.
oldColor := Color r: 0.75 g: 0.5 b: 0.25.
newColor := oldColor * 2.
self assert: (1 - newColor red) abs < tolerance.
self assert: (1 - newColor green) abs < tolerance.
self assert: (0.5 - newColor blue) abs < tolerance.!
----- Method: ColorTest>>testPrintHtmlString (in category 'tests') -----
testPrintHtmlString
"self debug: #testPrintHtmlString"
self shouldnt: [Color white printHtmlString ] raise: Error.
self assert: Color white printHtmlString = 'FFFFFF'.
self assert: Color red printHtmlString = 'FF0000'.
self assert: Color black printHtmlString = '000000'.!
ClassTestCase subclass: #FormTest
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'GraphicsTests-Primitives'!
!FormTest commentStamp: 'ar 7/21/2007 21:39' prior: 0!
Various tests for class form.!
----- Method: FormTest>>testIsAllWhite (in category 'tests') -----
testIsAllWhite "self run: #testIsAllWhite"
"Make sure #isAllWhite works for all bit depths"
| form |
#(-32 -16 -8 -4 -2 -1 1 2 4 8 16 32) do:[:d|
form := Form extent: 16 at 16 depth: d.
form fillBlack.
self deny: form isAllWhite.
form fillWhite.
self assert: form isAllWhite.
].
!
ClassTestCase subclass: #PointTest
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'GraphicsTests-Primitives'!
!PointTest commentStamp: '<historical>' prior: 0!
This is the unit test for the class Point. Unit tests are a good way to exercise the functionality of your system in a repeatable and automatic manner. They are therefore recommended if you plan to release anything. For more information, see:
- http://www.c2.com/cgi/wiki?UnitTest
- http://minnow.cc.gatech.edu/squeak/1547
- the sunit class category!
----- Method: PointTest>>testBearingToPoint (in category 'tests - testing') -----
testBearingToPoint
self assert: (0 at 0 bearingToPoint: 0 at 0) = 0.
self assert: (0 at 0 bearingToPoint: 0 at -1) = 0.
self assert: (0 at 0 bearingToPoint: 1 at 0) = 90.
self assert: (0 at 0 bearingToPoint: 0 at 1) = 180.
self assert: (0 at 0 bearingToPoint: -1 at 0) = 270.
self assert: (0 at 0 bearingToPoint: 1 at 1) = 135.
self assert: (0 at 0 bearingToPoint: 0.01 at 0) = 90.
self assert: (0 at 0 bearingToPoint: -2 at -3) = 326.
self assert: (0 at 0 bearingToPoint: -0 at 0) = 0.
self assert: (-2 at -3 bearingToPoint: 0 at 0) = 146.!
----- Method: PointTest>>testIsZero (in category 'tests - testing') -----
testIsZero
self assert: (0 at 0) isZero.
self deny: (0 at 1) isZero.
self deny: (1 at 0) isZero.
self deny: (1 at 1) isZero.!
----- Method: PointTest>>testTheta (in category 'testing - testing') -----
testTheta
| result dir tan x y |
self assert: ((0 at 1) theta - 90.0 degreesToRadians) abs < 1e-15.
self assert: ((0 at -1) theta - 270.0 degreesToRadians) abs < 1e-15.
" See code of old and new theta"
x := 1.0 . y := -1.0.
tan := y / x .
dir := tan arcTan.
result := 360.0 degreesToRadians + dir.
self assert: ((x at y) theta - result) abs < 1e-15.
x := -1.0. "Don't reuse old results whenyou want numeric precision!!"
tan := y / x .
dir := tan arcTan.
result := 180.0 degreesToRadians + dir.
self assert: ((x at y) theta - result) abs < 1e-15.
!
More information about the Packages
mailing list