Class: ODDB::FiPDF::TestParagraphWrapper
- Inherits:
-
Test::Unit::TestCase
- Object
- Test::Unit::TestCase
- ODDB::FiPDF::TestParagraphWrapper
show all
- Defined in:
- ext/fipdf/test/paragraph_wrapper_test.rb
Defined Under Namespace
Classes: StubFormat, StubParagraph
Instance Method Summary
collapse
Instance Method Details
#test_3_line_paragraph_no_new_page ⇒ Object
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
|
# File 'ext/fipdf/test/paragraph_wrapper_test.rb', line 131
def test_3_line_paragraph_no_new_page
@wrapper.instance_eval <<-EOS
def lines_per_height(*args)
3
end
EOS
height = 10
width = 200
fmt_name = StubFormat.new
fmt_name.line_count = 3
fmt_name.spacing_before = 0
fmt_name.height = 10
formats = {
:preformatted => "foo",
:paragraph => fmt_name,
}
@paragraph.preformatted = false
@paragraph.text = "foo baar"
result = @wrapper.need_new_page?(height, width, formats)
assert_equal(false, result)
end
|
#test_3_line_paragraph_widow ⇒ Object
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
|
# File 'ext/fipdf/test/paragraph_wrapper_test.rb', line 110
def test_3_line_paragraph_widow
@wrapper.instance_eval <<-EOS
def lines_per_height(*args)
2
end
EOS
height = 10
width = 200
fmt_name = StubFormat.new
fmt_name.line_count = 3
fmt_name.spacing_before = 0
fmt_name.height = 11
formats = {
:preformatted => "foo",
:paragraph => fmt_name,
}
@paragraph.preformatted = false
@paragraph.text = "foo baar"
result = @wrapper.need_new_page?(height, width, formats)
assert_equal(true, result)
end
|
#test_enforce_page_height_no_widow ⇒ Object
57
58
59
60
61
62
63
64
65
66
|
# File 'ext/fipdf/test/paragraph_wrapper_test.rb', line 57
def test_enforce_page_height_no_widow
fmt = StubFormat.new
fmt.line_count = 20
first_height = 43
fmt.size = 5
column_height = 50
width = 200
result = @wrapper.enforce_page_break?(first_height, column_height, width, fmt)
assert_equal(false, result)
end
|
#test_enforce_page_height_with_widow ⇒ Object
47
48
49
50
51
52
53
54
55
56
|
# File 'ext/fipdf/test/paragraph_wrapper_test.rb', line 47
def test_enforce_page_height_with_widow
fmt = StubFormat.new
first_height = 45
fmt.size = 5
fmt.line_count = 20
column_height = 50
width = 200
result = @wrapper.enforce_page_break?(first_height, column_height, width, fmt)
assert_equal(18, result)
end
|
160
161
162
163
164
165
166
167
168
|
# File 'ext/fipdf/test/paragraph_wrapper_test.rb', line 160
def test_format_paragraph_bold
paragraph = ODDB::Text::Paragraph.new
paragraph.set_format(:bold)
paragraph << "Bold Text!"
wrapper = ParagraphWrapper.new(paragraph)
formatted = wrapper.format_text
expected = "<b>Bold Text!</b>"
assert_equal(expected, formatted)
end
|
169
170
171
172
173
174
175
176
177
|
# File 'ext/fipdf/test/paragraph_wrapper_test.rb', line 169
def test_format_paragraph_italic
paragraph = ODDB::Text::Paragraph.new
paragraph.set_format(:italic)
paragraph << "Kursiv Text!"
wrapper = ParagraphWrapper.new(paragraph)
formatted = wrapper.format_text
expected = "<i>Kursiv Text!</i>"
assert_equal(expected, formatted)
end
|
178
179
180
181
182
183
184
185
186
187
188
189
190
|
# File 'ext/fipdf/test/paragraph_wrapper_test.rb', line 178
def test_format_paragraph_mixed
paragraph = ODDB::Text::Paragraph.new
paragraph.set_format(:italic)
paragraph << "Kursiv Text!"
paragraph.set_format(:bold)
paragraph << " und ein bisschen Bold..."
paragraph.set_format(:bold, :italic)
paragraph << " und auch mal beide."
wrapper = ParagraphWrapper.new(paragraph)
formatted = wrapper.format_text
expected = "<i>Kursiv Text!</i><b> und ein bisschen Bold...</b><b><i> und auch mal beide.</i></b>"
assert_equal(expected, formatted)
end
|
191
192
193
194
195
196
197
198
199
200
201
|
# File 'ext/fipdf/test/paragraph_wrapper_test.rb', line 191
def test_format_paragraph_symbol
paragraph = ODDB::Text::Paragraph.new
paragraph.set_format(:symbol)
paragraph << "a"
paragraph.set_format
paragraph << "-Tocopherol"
wrapper = ParagraphWrapper.new(paragraph)
formatted = wrapper.format_text
expected = "<f:Symbol>a</f>-Tocopherol"
assert_equal(expected, formatted)
end
|
#test_lines_per_height ⇒ Object
152
153
154
155
156
157
158
159
|
# File 'ext/fipdf/test/paragraph_wrapper_test.rb', line 152
def test_lines_per_height
height = 10
size = 2
fmt = StubFormat.new
fmt.size = 2
fmt.line_count = 2
assert_equal(5, @wrapper.lines_per_height(height, fmt))
end
|
#test_need_new_page_no ⇒ Object
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
# File 'ext/fipdf/test/paragraph_wrapper_test.rb', line 88
def test_need_new_page_no
@wrapper.instance_eval <<-EOS
def lines_per_height(*args)
2
end
EOS
height = 15
width = 200
fmt_name = StubFormat.new
fmt_name.line_count = 3
fmt_name.spacing_before = 0
fmt_name.height = 8
fmt_name.size = 2
formats = {
:preformatted => "foo",
:paragraph => fmt_name,
}
@paragraph.preformatted = false
@paragraph.text = "foo baar"
result = @wrapper.need_new_page?(height, width, formats)
assert_equal(false, result)
end
|
#test_need_new_page_paragraph_total_more_3_old_2 ⇒ Object
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
# File 'ext/fipdf/test/paragraph_wrapper_test.rb', line 67
def test_need_new_page_paragraph_total_more_3_old_2
@wrapper.instance_eval <<-EOS
def lines_per_height(*args)
2
end
EOS
@paragraph.text = "foo"
height = 12
width = 200
fmt_name = StubFormat.new
fmt_name.line_count = 20
fmt_name.spacing_before = 0
fmt_name.height = 13
fmt_name.size = 1
formats = {
:preformatted => "foo",
:paragraph => fmt_name,
}
result = @wrapper.need_new_page?(height, width, formats)
assert_equal(false, result)
end
|