thinreports 0.8.2 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/CONTRIBUTING.md +2 -0
- data/.travis.yml +3 -3
- data/CHANGELOG.md +98 -1
- data/README.md +0 -9
- data/Rakefile +1 -2
- data/examples/character_spacing/character_spacing.tlf +293 -1
- data/examples/dynamic_image/dynamic_image.tlf +661 -1
- data/examples/dynamic_style/dynamic_style.rb +4 -4
- data/examples/dynamic_style/dynamic_style.tlf +1835 -1
- data/examples/dynamic_style/dynamic_style_in_list.tlf +344 -1
- data/examples/eudc/eudc.tlf +180 -1
- data/examples/hidden_shapes/hidden_shapes.tlf +449 -1
- data/examples/list_events/list_events.rb +1 -28
- data/examples/list_events/list_events.tlf +361 -0
- data/examples/list_manual_generation/list_manual_generation.tlf +132 -1
- data/examples/list_page_number/list_page_number.tlf +254 -1
- data/examples/page_number/page_number.tlf +215 -1
- data/examples/palleted_png/palleted_png.rb +2 -0
- data/examples/palleted_png/palleted_png.tlf +47 -1
- data/examples/password_setting/password_setting.tlf +45 -1
- data/examples/report_callbacks/report_callbacks.rb +1 -18
- data/examples/report_callbacks/report_callbacks.tlf +147 -1
- data/examples/single_line_tblock/single_line_tblock.tlf +170 -1
- data/examples/tblock_overflow/tblock_overflow.tlf +538 -1
- data/examples/tblock_styles/font_size.tlf +383 -1
- data/examples/tblock_styles/tblock_styles.tlf +889 -1
- data/examples/text_align/text_align.tlf +241 -1
- data/examples/typeB_page_size/B4_ISO.tlf +45 -1
- data/examples/typeB_page_size/B4_JIS.tlf +45 -1
- data/examples/word_wrap/word_wrap.tlf +297 -1
- data/lib/thinreports.rb +0 -1
- data/lib/thinreports/config.rb +3 -0
- data/lib/thinreports/core/errors.rb +0 -3
- data/lib/thinreports/core/format/base.rb +4 -4
- data/lib/thinreports/core/shape.rb +1 -9
- data/lib/thinreports/core/shape/basic.rb +3 -3
- data/lib/thinreports/core/shape/basic/block_format.rb +1 -1
- data/lib/thinreports/core/shape/basic/format.rb +2 -14
- data/lib/thinreports/core/shape/basic/internal.rb +2 -2
- data/lib/thinreports/core/shape/image_block.rb +3 -3
- data/lib/thinreports/core/shape/image_block/format.rb +0 -2
- data/lib/thinreports/core/shape/image_block/internal.rb +1 -1
- data/lib/thinreports/core/shape/list.rb +3 -7
- data/lib/thinreports/core/shape/list/format.rb +37 -24
- data/lib/thinreports/core/shape/list/manager.rb +1 -36
- data/lib/thinreports/core/shape/list/page.rb +0 -15
- data/lib/thinreports/core/shape/list/page_state.rb +1 -1
- data/lib/thinreports/core/shape/list/section_format.rb +14 -12
- data/lib/thinreports/core/shape/list/section_internal.rb +4 -7
- data/lib/thinreports/core/shape/manager/format.rb +0 -2
- data/lib/thinreports/core/shape/manager/internal.rb +1 -1
- data/lib/thinreports/core/shape/page_number.rb +1 -1
- data/lib/thinreports/core/shape/page_number/format.rb +9 -6
- data/lib/thinreports/core/shape/page_number/interface.rb +1 -1
- data/lib/thinreports/core/shape/page_number/internal.rb +2 -6
- data/lib/thinreports/core/shape/style/base.rb +11 -13
- data/lib/thinreports/core/shape/style/basic.rb +4 -4
- data/lib/thinreports/core/shape/style/graphic.rb +4 -10
- data/lib/thinreports/core/shape/style/text.rb +36 -69
- data/lib/thinreports/core/shape/text.rb +3 -3
- data/lib/thinreports/core/shape/text/format.rb +3 -13
- data/lib/thinreports/core/shape/text/internal.rb +2 -2
- data/lib/thinreports/core/shape/text_block.rb +3 -3
- data/lib/thinreports/core/shape/text_block/format.rb +9 -6
- data/lib/thinreports/core/shape/text_block/interface.rb +7 -7
- data/lib/thinreports/core/shape/text_block/internal.rb +1 -1
- data/lib/thinreports/generator/pdf.rb +0 -1
- data/lib/thinreports/generator/pdf/document.rb +2 -2
- data/lib/thinreports/generator/pdf/document/draw_shape.rb +25 -51
- data/lib/thinreports/generator/pdf/document/draw_template_items.rb +66 -0
- data/lib/thinreports/generator/pdf/document/font.rb +3 -8
- data/lib/thinreports/generator/pdf/document/graphics/attributes.rb +97 -77
- data/lib/thinreports/generator/pdf/document/graphics/basic.rb +18 -13
- data/lib/thinreports/generator/pdf/document/graphics/image.rb +17 -12
- data/lib/thinreports/generator/pdf/document/page.rb +1 -1
- data/lib/thinreports/generator/pdf/drawer/list.rb +5 -1
- data/lib/thinreports/generator/pdf/drawer/list_section.rb +1 -4
- data/lib/thinreports/generator/pdf/drawer/page.rb +9 -9
- data/lib/thinreports/layout.rb +3 -3
- data/lib/thinreports/layout/base.rb +0 -16
- data/lib/thinreports/layout/format.rb +38 -57
- data/lib/thinreports/layout/legacy_schema.rb +354 -0
- data/lib/thinreports/layout/version.rb +1 -1
- data/lib/thinreports/report.rb +0 -1
- data/lib/thinreports/report/base.rb +3 -17
- data/lib/thinreports/report/internal.rb +13 -55
- data/lib/thinreports/report/page.rb +1 -1
- data/lib/thinreports/version.rb +1 -1
- data/test/data/legacy_layout/all-items.tlf +1 -0
- data/test/schema_helper.rb +121 -0
- data/test/test_helper.rb +13 -50
- data/test/unit/core/format/test_base.rb +35 -31
- data/test/unit/core/shape/base/test_internal.rb +1 -1
- data/test/unit/core/shape/basic/test_block_format.rb +23 -0
- data/test/unit/core/shape/basic/{test_basic_interface.rb → test_block_interface.rb} +1 -1
- data/test/unit/core/shape/basic/{test_basic_internal.rb → test_block_internal.rb} +4 -7
- data/test/unit/core/shape/basic/test_format.rb +25 -47
- data/test/unit/core/shape/basic/test_interface.rb +5 -5
- data/test/unit/core/shape/basic/test_internal.rb +6 -11
- data/test/unit/core/shape/image_block/test_interface.rb +5 -5
- data/test/unit/core/shape/image_block/test_internal.rb +2 -2
- data/test/unit/core/shape/list/test_format.rb +86 -44
- data/test/unit/core/shape/list/test_manager.rb +10 -65
- data/test/unit/core/shape/list/test_page.rb +10 -61
- data/test/unit/core/shape/list/test_page_state.rb +1 -1
- data/test/unit/core/shape/list/test_section_format.rb +19 -28
- data/test/unit/core/shape/list/test_section_interface.rb +14 -6
- data/test/unit/core/shape/list/test_section_internal.rb +17 -23
- data/test/unit/core/shape/manager/test_format.rb +1 -1
- data/test/unit/core/shape/manager/test_internal.rb +59 -98
- data/test/unit/core/shape/manager/test_target.rb +21 -30
- data/test/unit/core/shape/page_number/test_format.rb +34 -52
- data/test/unit/core/shape/page_number/test_interface.rb +1 -1
- data/test/unit/core/shape/page_number/test_internal.rb +2 -2
- data/test/unit/core/shape/styles/test_base.rb +16 -41
- data/test/unit/core/shape/styles/test_basic.rb +7 -7
- data/test/unit/core/shape/styles/test_graphic.rb +27 -32
- data/test/unit/core/shape/styles/test_text.rb +68 -311
- data/test/unit/core/shape/text/test_format.rb +30 -59
- data/test/unit/core/shape/text/test_internal.rb +5 -5
- data/test/unit/core/shape/text_block/formatter/test_datetime.rb +13 -13
- data/test/unit/core/shape/text_block/test_format.rb +145 -146
- data/test/unit/core/shape/text_block/test_interface.rb +9 -9
- data/test/unit/core/shape/text_block/test_internal.rb +9 -9
- data/test/unit/core/test_shape.rb +19 -31
- data/test/unit/generator/pdf/document/graphics/test_attributes.rb +112 -122
- data/test/unit/generator/pdf/document/graphics/test_basic.rb +45 -0
- data/test/unit/generator/pdf/document/graphics/test_image.rb +5 -5
- data/test/unit/generator/pdf/document/test_font.rb +4 -10
- data/test/unit/generator/pdf/document/test_page.rb +13 -11
- data/test/unit/generator/pdf/document/test_parse_color.rb +5 -5
- data/test/unit/generator/test_base.rb +5 -5
- data/test/unit/generator/test_configuration.rb +4 -8
- data/test/unit/generator/test_pdf.rb +3 -2
- data/test/unit/layout/test_base.rb +16 -22
- data/test/unit/layout/test_format.rb +66 -86
- data/test/unit/layout/test_legacy_schema.rb +587 -0
- data/test/unit/layout/test_version.rb +20 -20
- data/test/unit/report/test_base.rb +32 -45
- data/test/unit/report/test_internal.rb +43 -99
- data/test/unit/test_config.rb +4 -2
- data/test/unit/test_layout.rb +1 -1
- metadata +20 -48
- data/examples/list_events/list_events_0_7_7.tlf +0 -1
- data/examples/list_events/list_events_0_8.tlf +0 -1
- data/lib/thinreports/core/events.rb +0 -69
- data/lib/thinreports/core/format/builder.rb +0 -62
- data/lib/thinreports/core/shape/list/configuration.rb +0 -54
- data/lib/thinreports/core/shape/list/events.rb +0 -47
- data/lib/thinreports/core/shape/list/store.rb +0 -33
- data/lib/thinreports/generator/pdf/configuration.rb +0 -33
- data/lib/thinreports/generator/pdf/document/parse_svg.rb +0 -104
- data/lib/thinreports/layout/configuration.rb +0 -29
- data/test/data/layout_block.tlf +0 -1
- data/test/data/layout_list.tlf +0 -1
- data/test/data/layout_list_noheader.tlf +0 -1
- data/test/data/layout_text1.tlf +0 -1
- data/test/data/layout_text2.tlf +0 -1
- data/test/unit/core/format/test_builder.rb +0 -109
- data/test/unit/core/shape/basic/test_basic_format.rb +0 -30
- data/test/unit/core/shape/image_block/test_format.rb +0 -58
- data/test/unit/core/shape/list/test_configuration.rb +0 -69
- data/test/unit/core/shape/list/test_events.rb +0 -36
- data/test/unit/core/shape/list/test_store.rb +0 -41
- data/test/unit/core/test_events.rb +0 -93
- data/test/unit/generator/pdf/document/test_draw_shape.rb +0 -44
- data/test/unit/generator/pdf/test_configuration.rb +0 -31
- data/test/unit/layout/test_configuration.rb +0 -21
- data/test/unit/report/test_events.rb +0 -22
|
@@ -4,337 +4,94 @@ require 'test_helper'
|
|
|
4
4
|
|
|
5
5
|
class Thinreports::Core::Shape::Style::TestText < Minitest::Test
|
|
6
6
|
include Thinreports::TestHelper
|
|
7
|
-
|
|
8
|
-
def
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
7
|
+
|
|
8
|
+
def test_color
|
|
9
|
+
style = create_text_style('color' => 'red')
|
|
10
|
+
assert_equal 'red', style.color
|
|
11
|
+
|
|
12
|
+
style.color = 'blue'
|
|
13
|
+
assert_equal 'blue', style.styles['color']
|
|
14
|
+
assert_equal 'blue', style.color
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
def test_font_size
|
|
18
|
-
|
|
19
|
-
style
|
|
20
|
-
|
|
21
|
-
assert_equal style.font_size, '12'
|
|
18
|
+
style = create_text_style('font-size' => 18.0)
|
|
19
|
+
assert_equal 18.0, style.font_size
|
|
22
20
|
|
|
23
21
|
style.font_size = 19
|
|
24
|
-
|
|
25
|
-
assert_equal style.
|
|
22
|
+
assert_equal 19, style.styles['font-size']
|
|
23
|
+
assert_equal 19, style.font_size
|
|
26
24
|
end
|
|
27
25
|
|
|
28
|
-
def
|
|
29
|
-
|
|
30
|
-
style
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
def test_bold_should_return_false_when_font_weight_property_of_format_is_not_bold
|
|
36
|
-
format = create_format('svg' => {'attrs' => {'font-weight' => 'normal'}})
|
|
37
|
-
style = create_text_style(format)
|
|
38
|
-
|
|
39
|
-
assert_equal style.bold, false
|
|
26
|
+
def test_initialize_font_style
|
|
27
|
+
default_font_style = ['bold', 'italic']
|
|
28
|
+
style = create_text_style('font-style' => default_font_style)
|
|
29
|
+
|
|
30
|
+
refute_same default_font_style, style.styles['font-style']
|
|
31
|
+
assert_equal default_font_style, style.styles['font-style']
|
|
40
32
|
end
|
|
41
|
-
|
|
42
|
-
def
|
|
43
|
-
style = create_text_style
|
|
33
|
+
|
|
34
|
+
def test_bold
|
|
35
|
+
style = create_text_style('font-style' => ['bold'])
|
|
36
|
+
assert_equal true, style.bold
|
|
37
|
+
|
|
44
38
|
style.bold = false
|
|
45
|
-
|
|
46
|
-
assert_equal style.
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
def test_bold_should_set_bold_to_font_weight_style_when_value_is_true
|
|
50
|
-
style = create_text_style
|
|
51
|
-
style.bold = true
|
|
52
|
-
|
|
53
|
-
assert_equal style.styles['font-weight'], 'bold'
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
def test_bold_should_return_true_when_font_weight_of_internal_style_is_bold
|
|
57
|
-
style = create_text_style
|
|
58
|
-
style.styles['font-weight'] = 'bold'
|
|
59
|
-
|
|
60
|
-
assert_equal style.bold, true
|
|
39
|
+
assert_equal [], style.styles['font-style']
|
|
40
|
+
assert_equal false, style.bold
|
|
61
41
|
end
|
|
62
|
-
|
|
63
|
-
def
|
|
64
|
-
style = create_text_style
|
|
65
|
-
style.
|
|
66
|
-
|
|
67
|
-
assert_equal style.bold, false
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
def test_italic_should_return_true_when_font_style_property_of_format_is_italic
|
|
71
|
-
format = create_format('svg' => {'attrs' => {'font-style' => 'italic'}})
|
|
72
|
-
style = create_text_style(format)
|
|
73
|
-
|
|
74
|
-
assert_equal style.italic, true
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
def test_italic_should_return_false_when_font_style_property_of_format_is_not_italic
|
|
78
|
-
format = create_format('svg' => {'attrs' => {'font-style' => 'normal'}})
|
|
79
|
-
style = create_text_style(format)
|
|
80
|
-
|
|
81
|
-
assert_equal style.italic, false
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
def test_italic_should_set_normal_to_font_style_style_when_value_is_false
|
|
85
|
-
style = create_text_style
|
|
42
|
+
|
|
43
|
+
def test_italic
|
|
44
|
+
style = create_text_style('font-style' => ['italic'])
|
|
45
|
+
assert_equal true, style.italic
|
|
46
|
+
|
|
86
47
|
style.italic = false
|
|
87
|
-
|
|
88
|
-
assert_equal style.
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
def test_italic_should_set_italic_to_font_style_style_when_value_is_true
|
|
92
|
-
style = create_text_style
|
|
93
|
-
style.italic = true
|
|
94
|
-
|
|
95
|
-
assert_equal style.styles['font-style'], 'italic'
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
def test_italic_should_return_false_when_font_style_of_internal_style_is_not_italic
|
|
99
|
-
style = create_text_style
|
|
100
|
-
style.styles['font-style'] = 'normal'
|
|
101
|
-
|
|
102
|
-
assert_equal style.italic, false
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
def test_italic_should_return_true_when_font_style_of_internal_style_is_italic
|
|
106
|
-
style = create_text_style
|
|
107
|
-
style.styles['font-style'] = 'italic'
|
|
108
|
-
|
|
109
|
-
assert_equal style.italic, true
|
|
110
|
-
end
|
|
111
|
-
|
|
112
|
-
def test_underline_should_return_true_when_underline_is_included_in_text_decoration_property_of_format
|
|
113
|
-
format = create_format('svg' => {'attrs' => {'text-decoration' => 'underline line-through'}})
|
|
114
|
-
style = create_text_style(format)
|
|
115
|
-
|
|
116
|
-
assert_equal style.underline, true
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
-
def test_underline_should_return_false_when_underline_is_not_included_in_text_decoration_property_of_format
|
|
120
|
-
format = create_format('svg' => {'attrs' => {'text-decoration' => 'line-through'}})
|
|
121
|
-
style = create_text_style(format)
|
|
122
|
-
|
|
123
|
-
assert_equal style.underline, false
|
|
124
|
-
end
|
|
125
|
-
|
|
126
|
-
def test_underline_should_return_true_when_underline_is_included_in_text_decoration_of_internal_style
|
|
127
|
-
style = create_text_style
|
|
128
|
-
style.styles['text-decoration'] = 'underline line-through'
|
|
129
|
-
|
|
130
|
-
assert_equal style.underline, true
|
|
131
|
-
end
|
|
132
|
-
|
|
133
|
-
def test_underline_should_return_false_when_underline_is_not_included_in_text_decoration_of_internal_style
|
|
134
|
-
style = create_text_style
|
|
135
|
-
style.styles['text-decoration'] = 'none'
|
|
136
|
-
|
|
137
|
-
assert_equal style.underline, false
|
|
48
|
+
assert_equal [], style.styles['font-style']
|
|
49
|
+
assert_equal false, style.italic
|
|
138
50
|
end
|
|
139
|
-
|
|
140
|
-
def
|
|
141
|
-
|
|
142
|
-
style
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
assert_includes style.styles['text-decoration'], 'underline'
|
|
146
|
-
end
|
|
147
|
-
|
|
148
|
-
def test_underline_should_remove_underline_from_text_decoration_when_value_is_false
|
|
149
|
-
format = create_format('svg' => {'attrs' => {'text-decoration' => 'underline line-through'}})
|
|
150
|
-
style = create_text_style(format)
|
|
51
|
+
|
|
52
|
+
def test_underline
|
|
53
|
+
style = create_text_style('font-style' => ['underline'])
|
|
54
|
+
assert_equal true, style.underline
|
|
55
|
+
|
|
151
56
|
style.underline = false
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
end
|
|
155
|
-
|
|
156
|
-
def test_linethrough_should_return_true_when_line_through_is_included_in_text_decoration_property_of_format
|
|
157
|
-
format = create_format('svg' => {'attrs' => {'text-decoration' => 'underline line-through'}})
|
|
158
|
-
style = create_text_style(format)
|
|
159
|
-
|
|
160
|
-
assert_equal style.linethrough, true
|
|
161
|
-
end
|
|
162
|
-
|
|
163
|
-
def test_linethrough_should_return_false_when_line_through_is_not_included_in_text_decoration_property_of_format
|
|
164
|
-
format = create_format('svg' => {'attrs' => {'text-decoration' => 'underline'}})
|
|
165
|
-
style = create_text_style(format)
|
|
166
|
-
|
|
167
|
-
assert_equal style.linethrough, false
|
|
168
|
-
end
|
|
169
|
-
|
|
170
|
-
def test_linethrough_should_return_true_when_line_through_is_included_in_text_decoration_of_internal_style
|
|
171
|
-
style = create_text_style
|
|
172
|
-
style.styles['text-decoration'] = 'underline line-through'
|
|
173
|
-
|
|
174
|
-
assert_equal style.linethrough, true
|
|
175
|
-
end
|
|
176
|
-
|
|
177
|
-
def test_linethrough_should_return_false_when_line_through_is_not_included_in_text_decoration_of_internal_style
|
|
178
|
-
style = create_text_style
|
|
179
|
-
style.styles['text-decoration'] = 'underline'
|
|
180
|
-
|
|
181
|
-
assert_equal style.linethrough, false
|
|
57
|
+
assert_equal [], style.styles['font-style']
|
|
58
|
+
assert_equal false, style.underline
|
|
182
59
|
end
|
|
183
|
-
|
|
184
|
-
def
|
|
185
|
-
|
|
186
|
-
style
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
assert_includes style.styles['text-decoration'], 'line-through'
|
|
190
|
-
end
|
|
191
|
-
|
|
192
|
-
def test_linethrough_should_remove_line_through_from_text_decoration_when_value_is_false
|
|
193
|
-
format = create_format('svg' => {'attrs' => {'text-decoration' => 'underline line-through'}})
|
|
194
|
-
style = create_text_style(format)
|
|
60
|
+
|
|
61
|
+
def test_linethrough
|
|
62
|
+
style = create_text_style('font-style' => ['linethrough'])
|
|
63
|
+
assert_equal true, style.linethrough
|
|
64
|
+
|
|
195
65
|
style.linethrough = false
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
end
|
|
199
|
-
|
|
200
|
-
def test_text_decoration_should_return_none
|
|
201
|
-
assert_equal create_text_style.send(:text_decoration, false, false), 'none'
|
|
202
|
-
end
|
|
203
|
-
|
|
204
|
-
def test_text_decoration_should_return_underline
|
|
205
|
-
assert_equal create_text_style.send(:text_decoration, true, false), 'underline'
|
|
206
|
-
end
|
|
207
|
-
|
|
208
|
-
def test_text_decoration_should_return_line_through
|
|
209
|
-
assert_equal create_text_style.send(:text_decoration, false, true), 'line-through'
|
|
210
|
-
end
|
|
211
|
-
|
|
212
|
-
def test_text_decoration_should_return_underline_line_through
|
|
213
|
-
assert_equal create_text_style.send(:text_decoration, true, true), 'underline line-through'
|
|
214
|
-
end
|
|
215
|
-
|
|
216
|
-
def test_interface_text_align_should_return_Symbol_left_when_value_is_undefined
|
|
217
|
-
assert_equal create_text_style.send(:interface_text_align, nil), :left
|
|
218
|
-
end
|
|
219
|
-
|
|
220
|
-
def test_interface_text_align_should_return_Symbol_left_when_value_is_String_start
|
|
221
|
-
assert_equal create_text_style.send(:interface_text_align, 'start'), :left
|
|
222
|
-
end
|
|
223
|
-
|
|
224
|
-
def test_interface_text_align_should_return_Symbol_left_when_value_is_unknown_align_type
|
|
225
|
-
assert_equal create_text_style.send(:interface_text_align, 'unknown'), :left
|
|
226
|
-
end
|
|
227
|
-
|
|
228
|
-
def test_interface_text_align_should_return_Symbol_center_when_value_is_String_middle
|
|
229
|
-
assert_equal create_text_style.send(:interface_text_align, 'middle'), :center
|
|
230
|
-
end
|
|
231
|
-
|
|
232
|
-
def test_interface_text_align_should_return_Symbol_right_when_value_is_String_end
|
|
233
|
-
assert_equal create_text_style.send(:interface_text_align, 'end'), :right
|
|
234
|
-
end
|
|
235
|
-
|
|
236
|
-
def test_internal_text_align_should_return_nil_when_value_is_unknown
|
|
237
|
-
assert_equal create_text_style.send(:internal_text_align, :unknown), nil
|
|
238
|
-
end
|
|
239
|
-
|
|
240
|
-
def test_internal_text_align_should_return_String_start_when_value_is_Symbol_left
|
|
241
|
-
assert_equal create_text_style.send(:internal_text_align, :left), 'start'
|
|
242
|
-
end
|
|
243
|
-
|
|
244
|
-
def test_internal_text_align_should_return_String_middle_when_value_is_Symbol_center
|
|
245
|
-
assert_equal create_text_style.send(:internal_text_align, :center), 'middle'
|
|
246
|
-
end
|
|
247
|
-
|
|
248
|
-
def test_internal_text_align_should_return_String_end_when_value_is_Symbol_right
|
|
249
|
-
assert_equal create_text_style.send(:internal_text_align, :right), 'end'
|
|
66
|
+
assert_equal [], style.styles['font-style']
|
|
67
|
+
assert_equal false, style.linethrough
|
|
250
68
|
end
|
|
251
|
-
|
|
252
|
-
def
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
format_center = create_format('svg' => {'attrs' => {'text-anchor' => 'middle'}})
|
|
257
|
-
format_right = create_format('svg' => {'attrs' => {'text-anchor' => 'end'}})
|
|
258
|
-
|
|
259
|
-
result << create_text_style(format_left).align
|
|
260
|
-
result << create_text_style(format_center).align
|
|
261
|
-
result << create_text_style(format_right).align
|
|
262
|
-
|
|
263
|
-
assert_equal result, [:left, :center, :right]
|
|
264
|
-
end
|
|
265
|
-
|
|
266
|
-
def test_copy_should_properly_copy_the_valign_property_of_the_original
|
|
267
|
-
style = create_text_style
|
|
268
|
-
style.valign = :center
|
|
269
|
-
|
|
270
|
-
assert_equal style.copy.valign, :center
|
|
271
|
-
end
|
|
272
|
-
|
|
273
|
-
def test_align_should_property_return_align_type_with_reference_to_text_anchor_of_internal_style
|
|
274
|
-
style = create_text_style
|
|
275
|
-
style.styles['text-anchor'] = 'middle'
|
|
276
|
-
|
|
277
|
-
assert_equal style.align, :center
|
|
278
|
-
end
|
|
279
|
-
|
|
280
|
-
def test_align_should_set_interface_align_type_to_text_anchor
|
|
281
|
-
style = create_text_style
|
|
69
|
+
|
|
70
|
+
def test_align
|
|
71
|
+
style = create_text_style('text-align' => 'center')
|
|
72
|
+
assert_equal :center, style.align
|
|
73
|
+
|
|
282
74
|
style.align = :right
|
|
283
|
-
|
|
284
|
-
assert_equal style.
|
|
285
|
-
end
|
|
286
|
-
|
|
287
|
-
def test_align_should_raise_when_the_specified_type_is_unknown
|
|
288
|
-
assert_raises ArgumentError do
|
|
289
|
-
create_text_style.align = :unknown
|
|
290
|
-
end
|
|
291
|
-
end
|
|
292
|
-
|
|
293
|
-
def test_valign_should_return_top_when_valign_of_format_is_blank
|
|
294
|
-
assert_equal create_text_style.valign, :top
|
|
295
|
-
end
|
|
296
|
-
|
|
297
|
-
def test_valign_should_return_valign_type_of_format_as_default
|
|
298
|
-
format = create_format('valign' => 'bottom')
|
|
299
|
-
style = create_text_style(format)
|
|
300
|
-
|
|
301
|
-
assert_equal style.valign, :bottom
|
|
302
|
-
end
|
|
303
|
-
|
|
304
|
-
def test_valign_should_properly_set_valign_type
|
|
305
|
-
style = create_text_style
|
|
306
|
-
style.valign = :center
|
|
307
|
-
|
|
308
|
-
assert_equal style.valign, :center
|
|
309
|
-
end
|
|
310
|
-
|
|
311
|
-
def test_valign_should_raise_when_the_specified_type_is_unknown
|
|
312
|
-
assert_raises ArgumentError do
|
|
313
|
-
create_text_style.valign = :unknonw
|
|
314
|
-
end
|
|
75
|
+
assert_equal 'right', style.styles['text-align']
|
|
76
|
+
assert_equal :right, style.align
|
|
315
77
|
end
|
|
316
78
|
|
|
317
|
-
def
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
accessible_styles.delete(:valign)
|
|
321
|
-
end
|
|
79
|
+
def test_valign
|
|
80
|
+
style = create_text_style('vertical-align' => '')
|
|
81
|
+
assert_equal :top, style.valign
|
|
322
82
|
|
|
323
|
-
style
|
|
324
|
-
assert_equal
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
style = create_text_style
|
|
330
|
-
assert_equal style.identifier, style.send(:create_identifier, style.styles)
|
|
83
|
+
style.valign = :middle
|
|
84
|
+
assert_equal 'middle', style.styles['vertical-align']
|
|
85
|
+
assert_equal :middle, style.valign
|
|
86
|
+
|
|
87
|
+
assert_deprecated { style.valign = :center }
|
|
88
|
+
assert_equal :middle, style.valign
|
|
331
89
|
end
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
style.send(:create_identifier, style.styles) + 'bottom'
|
|
90
|
+
|
|
91
|
+
private
|
|
92
|
+
|
|
93
|
+
def create_text_style(default_style = {})
|
|
94
|
+
format = Thinreports::Core::Shape::Text::Format.new('style' => default_style)
|
|
95
|
+
Thinreports::Core::Shape::Style::Text.new(format)
|
|
339
96
|
end
|
|
340
97
|
end
|
|
@@ -5,69 +5,40 @@ require 'test_helper'
|
|
|
5
5
|
class Thinreports::Core::Shape::Text::TestFormat < Minitest::Test
|
|
6
6
|
include Thinreports::TestHelper
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
"text-decoration" => "none",
|
|
33
|
-
"letter-spacing" => "normal"
|
|
34
|
-
},
|
|
35
|
-
"content" => "<text class=\"s-text-l0\" xml:space=\"preserve\" " +
|
|
36
|
-
"stroke=\"none\" fill=\"inherit\" fill-opacity=\"1\" " +
|
|
37
|
-
"text-decoration=\"none\" x=\"92\" y=\"93\">" +
|
|
38
|
-
"Text Content1</text>" +
|
|
39
|
-
"<text class=\"s-text-l1\" xml:space=\"preserve\" " +
|
|
40
|
-
"stroke=\"none\" fill=\"inherit\" fill-opacity=\"1\" " +
|
|
41
|
-
"text-decoration=\"none\" x=\"92\" y=\"107\">" +
|
|
42
|
-
"Text Content2</text>"
|
|
8
|
+
TEXT_FORMAT = {
|
|
9
|
+
'id' => 'text_1',
|
|
10
|
+
'type' => 'text',
|
|
11
|
+
'x' => 100.0,
|
|
12
|
+
'y' => 200.0,
|
|
13
|
+
'width' => 300.0,
|
|
14
|
+
'height' => 400.0,
|
|
15
|
+
'description' => 'Description for item',
|
|
16
|
+
'display' => true,
|
|
17
|
+
'texts' => [
|
|
18
|
+
'1st text line',
|
|
19
|
+
'2nd text line'
|
|
20
|
+
],
|
|
21
|
+
'valign' => 'top',
|
|
22
|
+
'style' => {
|
|
23
|
+
'font-family' => ['Arial'],
|
|
24
|
+
'font-size' => 12,
|
|
25
|
+
'color' => '#000000',
|
|
26
|
+
'font-style' => ['bold', 'italic', 'linethrough', 'underline'],
|
|
27
|
+
'text-align' => 'left',
|
|
28
|
+
'vertical-align' => 'top',
|
|
29
|
+
'line-height' => 60,
|
|
30
|
+
'line-height-ratio' => 1.5,
|
|
31
|
+
'letter-spacing' => 'normal'
|
|
43
32
|
}
|
|
44
33
|
}
|
|
45
34
|
|
|
46
|
-
|
|
47
|
-
Format = Thinreports::Core::Shape::Text::Format
|
|
35
|
+
Text = Thinreports::Core::Shape::Text
|
|
48
36
|
|
|
49
|
-
def
|
|
50
|
-
|
|
51
|
-
rescue => e
|
|
52
|
-
flunk exception_details(e, 'Building failed.')
|
|
53
|
-
end
|
|
37
|
+
def test_attribute_readers
|
|
38
|
+
format = Text::Format.new(TEXT_FORMAT)
|
|
54
39
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
assert_instance_of ::Hash, format.box
|
|
59
|
-
assert_equal format.box['x'], 100.0
|
|
60
|
-
|
|
61
|
-
assert_instance_of ::Array, format.text
|
|
62
|
-
assert_equal format.text.first, 'Text Content1'
|
|
63
|
-
|
|
64
|
-
assert_equal format.valign, 'top'
|
|
65
|
-
assert_equal format.line_height, 60
|
|
66
|
-
|
|
67
|
-
assert_equal format.svg_content, TEST_TEXT_FORMAT['svg']['content']
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
def build_format
|
|
71
|
-
Format.build(TEST_TEXT_FORMAT)
|
|
40
|
+
assert_equal TEXT_FORMAT['texts'], format.texts
|
|
41
|
+
assert_equal 'top', format.valign
|
|
42
|
+
assert_equal 60, format.line_height
|
|
72
43
|
end
|
|
73
44
|
end
|