[squeak-dev] The Trunk: GraphicsTests-nice.35.mcz

commits at source.squeak.org commits at source.squeak.org
Wed Oct 9 00:48:17 UTC 2013


Nicolas Cellier uploaded a new version of GraphicsTests to project The Trunk:
http://source.squeak.org/trunk/GraphicsTests-nice.35.mcz

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

Name: GraphicsTests-nice.35
Author: nice
Time: 9 October 2013, 2:48:02.397 am
UUID: 2c305617-02d9-42fb-a7f3-08ccafb46c47
Ancestors: GraphicsTests-ul.34

An ersatz of CharacterScannerTest...
This illustrates several bugs that we recently corrected.
It would be interesting to try it in other images in order to measure our progress...
Of course, there are many more tests to write...

=============== Diff against GraphicsTests-ul.34 ===============

Item was added:
+ TestCase subclass: #CharacterScannerTest
+ 	instanceVariableNames: 'style mWidth spaceWidth'
+ 	classVariableNames: ''
+ 	poolDictionaries: ''
+ 	category: 'GraphicsTests-Text'!

Item was added:
+ ----- Method: CharacterScannerTest>>setUp (in category 'running') -----
+ setUp
+ 	style := TextStyle default copy.
+ 	style firstIndent: 0; restIndent: 0; rightIndent: 0.
+ 	mWidth := style defaultFont widthOf: $m.
+ 	spaceWidth := style defaultFont widthOf: Character space.!

Item was added:
+ ----- Method: CharacterScannerTest>>testBreakAnywhere (in category 'testing') -----
+ testBreakAnywhere
+ 	| p text cbs indicesOfM |
+ 	text := ((String new: 2 withAll: $m) , (String space) , (String new: 2 withAll: $m)) asText.
+ 	p := NewParagraph new.
+ 	p
+ 		compose: text
+ 		style: style
+ 		from: 1
+ 		in: (0 @ 0 corner: mWidth+1 @ (style lineGrid * 6)).
+ 	indicesOfM := (1 to: text size) select: [:i | (text at: i) = $m].
+ 	self assert: p lines size equals: indicesOfM size description: 'Each m is on a new line'.
+ 	self assert: (p lines collect: #first) equals: indicesOfM description: 'Each line begins with m'.
+ 	
+ 	cbs := indicesOfM collect: [:i | p characterBlockForIndex: i].
+ 	self assert: (cbs collect: #left as: Set) size = 1 description: 'Selecting before each m align on same column'
+ 	 
+ 		!

Item was added:
+ ----- Method: CharacterScannerTest>>testBreakAnywhereWhenFirstCharDoesNotFit (in category 'testing') -----
+ testBreakAnywhereWhenFirstCharDoesNotFit
+ 	| p text cbs |
+ 	text := ((String new: 2 withAll: $m) , (String space) , (String new: 2 withAll: $m)) asText.
+ 	p := NewParagraph new.
+ 	p
+ 		compose: text
+ 		style: style
+ 		from: 1
+ 		in: (0 @ 0 corner: mWidth-1 @ (style lineGrid * 7)).
+ 	self assert: p lines size equals: text size + 1 description: 'Each character is on a new line, past end also'.
+ 	self assert: (p lines collect: #first) equals: (1 to: text size + 1) description: 'Each character is on a new line'.
+ 	
+ 	cbs := (1 to: text size + 1) collect: [:i | p characterBlockForIndex: i].
+ 	self assert: (cbs collect: #left as: Set) size = 1 description: 'Selecting before each character align on left'
+ 	 
+ 		!

Item was added:
+ ----- Method: CharacterScannerTest>>testBreakAtLastCr (in category 'testing') -----
+ testBreakAtLastCr
+ 	| p text cbfirst cblast cbend cbend2 |
+ 	text := ((String new: 4 withAll: $m) , (String new: 2 withAll: Character space) , String cr) asText.
+ 	p := NewParagraph new.
+ 	p
+ 		compose: text
+ 		style: style
+ 		from: 1
+ 		in: (0 @ 0 corner: mWidth*4+(spaceWidth*2)+1 @ (style lineGrid * 4)).
+ 	self assert: p lines size = 2 description: 'An empty last line after CR must be materialized'.
+ 	self assert: p lines first last = 7 description: 'The CR is included in the line preceding it'.
+ 	
+ 	cbfirst := p characterBlockForIndex: 1.
+ 	cblast := p characterBlockForIndex: text size.
+ 	self assert: cblast origin y = cbfirst origin y description: 'The CR coordinate is still on the first line'.
+ 	cbend := p characterBlockForIndex: text size + 1.
+ 	self assert: cbend origin y >= cblast corner y description: 'Past end is located on the next line'.
+ 	
+ 	cbend2 := p characterBlockAtPoint: 0 @ (cbend corner y + style lineGrid).
+ 	self assert: cbend = cbend2 description: 'Clicking below the second line gives the past end location'.
+ 	self assert: cbend origin = cbend2 origin.
+ 	self assert: cbend corner = cbend2 corner.
+ 	 
+ 		!

Item was added:
+ ----- Method: CharacterScannerTest>>testBreakAtLastSpace (in category 'testing') -----
+ testBreakAtLastSpace
+ 	| p text cbfirst cblast cbend cbend2 |
+ 	text := ((String new: 4 withAll: $m) , (String new: 3 withAll: Character space)) asText.
+ 	p := NewParagraph new.
+ 	p
+ 		compose: text
+ 		style: style
+ 		from: 1
+ 		in: (0 @ 0 corner: mWidth*4+(spaceWidth*2)+1 @ (style lineGrid * 4)).
+ 	self assert: p lines size = 2 description: 'In leftFlush alignment, spaces at end of line overflowing the right margin should flow on next line'.
+ 	self assert: p lines first last = 7 description: 'The space which is crossing the right margin is included in the first line as if it were a CR'.
+ 	
+ 	cbfirst := p characterBlockForIndex: 1.
+ 	cblast := p characterBlockForIndex: text size.
+ 	self assert: cblast origin y = cbfirst origin y description: 'The last space coordinate is still on the first line'.
+ 	cbend := p characterBlockForIndex: text size + 1.
+ 	self assert: cbend origin y >= cblast corner y description: 'Past end is located on the next line'.
+ 	
+ 	cbend2 := p characterBlockAtPoint: 0 @ (cbend corner y + style lineGrid).
+ 	self assert: cbend = cbend2 description: 'Clicking below the second line gives the past end location'.
+ 	self assert: cbend origin = cbend2 origin.
+ 	self assert: cbend corner = cbend2 corner.
+ 	 
+ 		!

Item was added:
+ ----- Method: CharacterScannerTest>>testBreakAtSpace (in category 'testing') -----
+ testBreakAtSpace
+ 	| p text cbfirst cblast cbend cbend2 |
+ 	text := ((String new: 4 withAll: $m) , (String new: 4 withAll: Character space)) asText.
+ 	p := NewParagraph new.
+ 	p
+ 		compose: text
+ 		style: style
+ 		from: 1
+ 		in: (0 @ 0 corner: mWidth*4+(spaceWidth*2)+1 @ (style lineGrid * 4)).
+ 	self assert: p lines size = 2 description: 'In leftFlush alignment, spaces at end of line overflowing the right margin should flow on next line'.
+ 	self assert: p lines first last = 7 description: 'The space which is crossing the right margin is included in the first line as if it were a CR'.
+ 	
+ 	cbfirst := p characterBlockForIndex: 1.
+ 	cblast := p characterBlockForIndex: text size.
+ 	self assert: cblast origin y >= cbfirst corner y description: 'The last space coordinate is under the first line'.
+ 	cbend := p characterBlockForIndex: text size + 1.
+ 	self assert: cbend origin x >= cblast corner x description: 'Past end is located right of last space'.
+ 	
+ 	cbend2 := p characterBlockAtPoint: 0 @ (cbend corner y + style lineGrid).
+ 	self assert: cbend = cbend2 description: 'Clicking below the second line gives the past end location'.
+ 	self assert: cbend origin = cbend2 origin.
+ 	self assert: cbend corner = cbend2 corner.
+ 	 
+ 		!

Item was added:
+ ----- Method: CharacterScannerTest>>testClickLeftOfCenteredText (in category 'testing') -----
+ testClickLeftOfCenteredText
+ 	| p text cbfirst cbfirst2 |
+ 	style := TextStyle default.
+ 	mWidth := style defaultFont widthOf: $m.
+ 	spaceWidth := style defaultFont widthOf: Character space.
+ 	text := (String new: 4 withAll: $m) asText.
+ 	text addAttribute: TextAlignment centered from: 1 to: text size.
+ 	p := NewParagraph new.
+ 	p
+ 		compose: text
+ 		style: style
+ 		from: 1
+ 		in: (2 @ 2 extent: mWidth*8 @ (style lineGrid * 2)).
+ 	
+ 	cbfirst := p characterBlockForIndex: 1.
+ 	cbfirst2 := p characterBlockAtPoint: 1 @ cbfirst center y.
+ 	self assert: cbfirst = cbfirst2.
+ 	self assert: cbfirst origin = cbfirst2 origin description: 'Clicking left of the margin shall position the cursor correctly'.!



More information about the Squeak-dev mailing list