[squeak-dev] The Trunk: GraphicsTests-mt.59.mcz

commits at source.squeak.org commits at source.squeak.org
Wed May 4 10:00:58 UTC 2022


Marcel Taeumel uploaded a new version of GraphicsTests to project The Trunk:
http://source.squeak.org/trunk/GraphicsTests-mt.59.mcz

==================== Summary ====================

Name: GraphicsTests-mt.59
Author: mt
Time: 4 May 2022, 12:00:53.679048 pm
UUID: 8e40978d-084f-1d4c-b78b-06f02ea3362f
Ancestors: GraphicsTests-EG.58

Complements Graphics-mt.515

=============== Diff against GraphicsTests-mt.57 ===============

Item was added:
+ TestCase subclass: #GIFReadWriterTest
+ 	instanceVariableNames: 'colorBlack'
+ 	classVariableNames: ''
+ 	poolDictionaries: ''
+ 	category: 'GraphicsTests-Files'!

Item was added:
+ ----- Method: GIFReadWriterTest>>animatedColorFrames (in category 'support') -----
+ animatedColorFrames
+ 	"Responds with a collection of AnimatedImageFrames
+ 	each containing equal-sized rectangles of green, red, 
+ 	yellow. and black. When animated, these rectangles move
+ 	into each other's positions, then back"
+ 	| frames topLeft topRight bottomLeft bottomRight revFrames |
+ 	frames := OrderedCollection new.
+ 	topLeft := (0 at 0 extent: 200 at 200).
+ 	topRight := (200 at 0 extent: 400 at 200).
+ 	bottomLeft := (0 at 200 extent: 200 at 400).
+ 	bottomRight := (200 at 200 extent: 400 at 400).
+ 	
+ 	0 to: 200 by: 20 do: [ :num |
+ 		| newTopLeft newTopRight newBottomLeft newBottomRight canvas |
+ 		newTopLeft := topLeft translateBy: (num at 0).
+ 		newTopRight := topRight translateBy: (0 at num).
+ 		newBottomLeft := (bottomLeft origin - (0 at num)) corner: (bottomLeft extent - (0 at num)).
+ 		newBottomRight := (bottomRight origin - (num at 0)) extent: (bottomLeft extent - (0 at 0)).
+ 		canvas := FormCanvas extent: 400 at 400 depth: 32.
+ 		canvas
+ 			fillRectangle: newTopLeft color: Color green;
+ 			fillRectangle: newTopRight color: Color red;
+ 			fillRectangle: newBottomLeft color: Color yellow;
+ 			fillRectangle: newBottomRight color: Color black.
+ 		frames add: (AnimatedImageFrame new
+ 			form: canvas form;
+ 			disposal: #restoreBackground;
+ 			delay: 60) ].
+ 
+ 	revFrames := frames reversed.
+ 	revFrames do: [ :f | frames add: f ].
+ 	^ frames!

Item was added:
+ ----- Method: GIFReadWriterTest>>expectedFailures (in category 'failures') -----
+ expectedFailures
+ 
+ 	^ #(
+ 		testAnimatedColorsOutInRealBlack
+ 		testColorsFileOutInRealBlack
+ 		testColorsOutInRealBlack
+ 	)!

Item was added:
+ ----- Method: GIFReadWriterTest>>setUp (in category 'running') -----
+ setUp
+ 
+ 	super setUp.
+ 	colorBlack := Color r: 0 g: 0 b: 1/255.!

Item was added:
+ ----- Method: GIFReadWriterTest>>testAnimatedColorsOutIn (in category 'tests') -----
+ testAnimatedColorsOutIn
+ 	"Ensure that the colored rectangles in the created
+ 	animated gif are correct at different frames"
+ 	| frames outBytes writer reader inBytes activeFrame |
+ 	frames := self animatedColorFrames.
+ 	
+ 	"Write out the GIF bytes to the byte stream"
+ 	outBytes := WriteStream on: (ByteArray new).
+ 	writer := GIFReadWriter on: outBytes.
+ 	frames do: [ :f | writer nextPutFrame: f ].
+ 	writer close.
+ 	
+ 	"Read the GIF byte stream back into a GIF"
+ 	inBytes := ReadStream on: (outBytes contents).
+ 	reader := GIFReadWriter on: inBytes.
+ 	reader
+ 		readHeader;
+ 		readBody.
+ 	
+ 	self assert: reader isAnimated equals: true.
+ 	activeFrame := reader frames at: 1.
+ 	self assert: (activeFrame form colorAt: 100 at 100) equals: Color green.
+ 	self assert: (activeFrame form colorAt: 300 at 100) equals: Color red.
+ 	self assert: (activeFrame form colorAt: 100 at 300) equals: Color yellow.
+ 	self assert: (activeFrame form colorAt: 300 at 300) equals: colorBlack.
+ 	activeFrame := reader frames at: 11.
+ 	self assert: (activeFrame form colorAt: 100 at 100) equals: Color yellow.
+ 	self assert: (activeFrame form colorAt: 300 at 100) equals: Color green.
+ 	self assert: (activeFrame form colorAt: 100 at 300) equals: colorBlack.
+ 	self assert: (activeFrame form colorAt: 300 at 300) equals: Color red.
+ 	!

Item was added:
+ ----- Method: GIFReadWriterTest>>testAnimatedColorsOutInRealBlack (in category 'tests') -----
+ testAnimatedColorsOutInRealBlack
+ 
+ 	colorBlack := Color black.
+ 	self testAnimatedColorsOutIn.!

Item was added:
+ ----- Method: GIFReadWriterTest>>testColorsFileOutIn (in category 'tests') -----
+ testColorsFileOutIn
+ 	"Ensure that the colors that are written match up
+ 	to the colors that are read in again"
+ 	| canvas form outBytes inBytes writer reader |
+ 	canvas := FormCanvas extent: 400 at 400.
+ 	canvas
+ 		fillRectangle: (0 at 0 extent: 200 at 200) color: Color green;
+ 		fillRectangle: (200 at 0 extent: 400 at 200) color: Color red;
+ 		fillRectangle: (0 at 200 extent: 200 at 400) color: Color yellow;
+ 		fillRectangle: (200 at 200 extent: 400 at 400) color: colorBlack.
+ 	form := canvas form.
+ 	outBytes := FileStream fileNamed: 'testColorsFileOutIn.gif'.
+ 	writer := GIFReadWriter on: outBytes.
+ 	writer
+ 		nextPutImage: form;
+ 		close.
+ 	inBytes := 'testColorsFileOutIn.gif' asDirectoryEntry readStream binary.
+ 	reader := GIFReadWriter on: inBytes.
+ 	reader
+ 		readHeader;
+ 		readBody.
+ 	inBytes close.
+ 	'testColorsFileOutIn.gif' asDirectoryEntry delete.
+ 	self assert: reader isAnimated equals: false.
+ 	self assert: (reader form colorAt: 50 at 50) equals: Color green.
+ 	self assert: (reader form colorAt: 250 at 50) equals: Color red.
+ 	self assert: (reader form colorAt: 50 at 250) equals: Color yellow.
+ 	self assert: (reader form colorAt: 250 at 250) equals: colorBlack.!

Item was added:
+ ----- Method: GIFReadWriterTest>>testColorsFileOutInRealBlack (in category 'tests') -----
+ testColorsFileOutInRealBlack
+ 
+ 	colorBlack := Color black.
+ 	self testColorsFileOutIn.!

Item was added:
+ ----- Method: GIFReadWriterTest>>testColorsOutIn (in category 'tests') -----
+ testColorsOutIn
+ 	"Ensure that the colors that are written match up
+ 	to the colors that are read in again"
+ 	| canvas form outBytes inBytes writer reader |
+ 	canvas := FormCanvas extent: 400 at 400.
+ 	canvas
+ 		fillRectangle: (0 at 0 extent: 200 at 200) color: Color green;
+ 		fillRectangle: (200 at 0 extent: 400 at 200) color: Color red;
+ 		fillRectangle: (0 at 200 extent: 200 at 400) color: Color yellow;
+ 		fillRectangle: (200 at 200 extent: 400 at 400) color: colorBlack.
+ 	form := canvas form.
+ 	outBytes := WriteStream on: (ByteArray new).
+ 	writer := GIFReadWriter on: outBytes.
+ 	writer
+ 		nextPutImage: form;
+ 		close.
+ 	outBytes := outBytes contents.
+ 	inBytes := ReadStream on: outBytes.
+ 	reader := GIFReadWriter on: inBytes.
+ 	reader
+ 		readHeader;
+ 		readBody.
+ 	self assert: reader isAnimated equals: false.
+ 	self assert: (reader form colorAt: 50 at 50) equals: Color green.
+ 	self assert: (reader form colorAt: 250 at 50) equals: Color red.
+ 	self assert: (reader form colorAt: 50 at 250) equals: Color yellow.
+ 	self assert: (reader form colorAt: 250 at 250) equals: colorBlack.!

Item was added:
+ ----- Method: GIFReadWriterTest>>testColorsOutInRealBlack (in category 'tests') -----
+ testColorsOutInRealBlack
+ 
+ 	colorBlack := Color black.
+ 	self testColorsOutIn.!



More information about the Squeak-dev mailing list