Skip to content

Commit

Permalink
Pass on text element test and examples
Browse files Browse the repository at this point in the history
They were duplicated and had almost no asserts.
  • Loading branch information
tinchodias committed May 10, 2024
1 parent e77072d commit 3161374
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 153 deletions.
96 changes: 37 additions & 59 deletions src/Bloc-Text-Alexandrie-Examples/BlTextElementExamples.class.st
@@ -1,27 +1,53 @@
Class {
#name : #BlTextElementExamples,
#superclass : #TestCase,
#superclass : #BlExamplesTest,
#category : #'Bloc-Text-Alexandrie-Examples'
}

{ #category : #example }
BlTextElementExamples >> helloText [

BlTextElementExamples >> textWithOverlappedAttributes [
<demo>
<sampleInstance>
^ 'mama' asRopedText fontSize: 80
]

{ #category : #example }
BlTextElementExamples >> loremIpsumText [
| text lineElements textElement |
text := ('Hello world!' , String cr , 'How are you?') asRopedText.
text foreground: Color purple.
text
fontSize: 15;
italic. "emphasis"
(text from: 1 to: 16)
foreground: Color red; "text color"
bold; "weight"
normal. "emphasis"
(text from: 7 to: text size - 4)
fontSize: 20;
foreground: Color blue;
monospace. "font-family"

<sampleInstance>
^ (String loremIpsum: 50) asRopedText
lineElements := Array streamContents: [ :aStream |
| anIterator |
anIterator := text iterator.
[ anIterator hasNext ] whileTrue: [
aStream nextPut:
(BlTextElement text: anIterator nextLine) ] ].

textElement :=
BlElement new
layout: BlLinearLayout vertical;
constraintsDo: [ :c |
c horizontal fitContent.
c vertical fitContent ];
addChildren: lineElements;
yourself.

^ textElement
]

{ #category : #example }
BlTextElementExamples >> simpleText [

BlTextElementExamples >> textWithPadding [
<demo>
<sampleInstance>

| text textElement |
text := (String loremIpsum: 50) asRopedText.
textElement := BlTextElement new.
Expand All @@ -30,51 +56,3 @@ BlTextElementExamples >> simpleText [
textElement padding: (BlInsets all: 20).
^ textElement
]

{ #category : #tests }
BlTextElementExamples >> testTextElement [

<sampleInstance>
| text textElement |
text := self helloText.
textElement := BlTextElement new.
textElement text: text.
textElement clipChildren: false.
self assert: textElement text equals: text.
^ textElement
]

{ #category : #example }
BlTextElementExamples >> textAttributes [

<sampleInstance>
| text lineElements textElement |
text := ('Hello world!' , String cr , 'How are you?') asRopedText.
text
fontSize: 16;
italic. "emphasis"
(text from: 1 to: 12)
foreground: Color red;
"weight"bold;
"emphasis"normal. "text color"
(text from: 13 to: text size)
fontSize: 20;
monospace. "font-family"

lineElements := Array streamContents: [ :aStream |
| anIterator |
anIterator := text iterator.
[ anIterator hasNext ] whileTrue: [
aStream nextPut:
(BlTextElement text: anIterator nextLine) ] ].

textElement := BlElement new
layout: BlLinearLayout vertical;
constraintsDo: [ :c |
c horizontal fitContent.
c vertical fitContent ];
addChildren: lineElements;
yourself.

^ textElement
]
94 changes: 0 additions & 94 deletions src/Bloc-Text-Tests/BlTextElementTest.class.st

This file was deleted.

0 comments on commit 3161374

Please sign in to comment.