thinreports 0.7.6 → 0.7.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +1 -0
- data/.travis.yml +11 -1
- data/Gemfile +2 -9
- data/MIT-LICENSE +1 -1
- data/README.rdoc +25 -26
- data/lib/thinreports/core/format/base.rb +0 -5
- data/lib/thinreports/core/format/builder.rb +5 -5
- data/lib/thinreports/core/page.rb +5 -3
- data/lib/thinreports/core/shape.rb +2 -0
- data/lib/thinreports/core/shape/basic/internal.rb +5 -1
- data/lib/thinreports/core/shape/list/configuration.rb +9 -3
- data/lib/thinreports/core/shape/list/manager.rb +11 -4
- data/lib/thinreports/core/shape/list/page.rb +3 -1
- data/lib/thinreports/core/shape/list/page_state.rb +4 -1
- data/lib/thinreports/core/shape/manager/internal.rb +1 -1
- data/lib/thinreports/core/shape/page_number.rb +15 -0
- data/lib/thinreports/core/shape/page_number/format.rb +25 -0
- data/lib/thinreports/core/shape/page_number/interface.rb +27 -0
- data/lib/thinreports/core/shape/page_number/internal.rb +57 -0
- data/lib/thinreports/core/shape/style/text.rb +6 -2
- data/lib/thinreports/core/shape/text_block/format.rb +1 -0
- data/lib/thinreports/generator/pdf.rb +1 -1
- data/lib/thinreports/generator/pdf/document/draw_shape.rb +14 -4
- data/lib/thinreports/generator/pdf/document/graphics/attributes.rb +9 -0
- data/lib/thinreports/generator/pdf/document/graphics/text.rb +4 -1
- data/lib/thinreports/generator/pdf/document/page.rb +18 -3
- data/lib/thinreports/generator/pdf/drawer/base.rb +3 -8
- data/lib/thinreports/generator/pdf/drawer/list.rb +31 -12
- data/lib/thinreports/generator/pdf/drawer/list_section.rb +5 -5
- data/lib/thinreports/generator/pdf/drawer/page.rb +22 -10
- data/lib/thinreports/generator/pdf/prawn_ext.rb +18 -1
- data/lib/thinreports/layout/base.rb +4 -2
- data/lib/thinreports/layout/format.rb +1 -5
- data/lib/thinreports/report/base.rb +36 -6
- data/lib/thinreports/report/internal.rb +7 -5
- data/lib/thinreports/version.rb +1 -1
- data/tasks/doc.rake +0 -1
- data/test/case/character_spacing/character_spacing.rb +4 -3
- data/test/case/dynamic_image/dynamic_image.rb +34 -34
- data/test/case/dynamic_style/dynamic_style.rb +141 -141
- data/test/case/eudc/eudc.rb +16 -16
- data/test/case/helper.rb +39 -20
- data/test/case/hidden_shapes/hidden_shapes.rb +4 -8
- data/test/case/list_events/list_events.rb +26 -26
- data/test/case/list_manual_generation/list_manual_generation.rb +16 -16
- data/test/case/list_page_number/list_page_number.rb +17 -0
- data/test/case/list_page_number/list_page_number.tlf +1 -0
- data/test/case/page_number/page_number.rb +33 -0
- data/test/case/page_number/page_number.tlf +1 -0
- data/test/case/password_setting/password_setting.rb +10 -0
- data/test/case/password_setting/password_setting.tlf +1 -0
- data/test/case/single_line_tblock/single_line_tblock.rb +10 -12
- data/test/case/tblock_overflow/tblock_overflow.rb +16 -16
- data/test/case/tblock_styles/tblock_styles.rb +24 -24
- data/test/case/text_align/text_align.rb +5 -6
- data/test/case/typeB_page_size/B4_ISO.tlf +1 -0
- data/test/case/typeB_page_size/B4_JIS.tlf +1 -0
- data/test/case/typeB_page_size/typeB_page_size.rb +17 -0
- data/test/case/word_wrap/word_wrap.rb +26 -0
- data/test/case/word_wrap/word_wrap.tlf +1 -0
- data/test/unit/core/format/test_builder.rb +1 -2
- data/test/unit/core/shape/basic/test_internal.rb +9 -1
- data/test/unit/core/shape/list/test_configuration.rb +6 -1
- data/test/unit/core/shape/list/test_manager.rb +10 -0
- data/test/unit/core/shape/list/test_page_state.rb +1 -1
- data/test/unit/core/shape/page_number/test_format.rb +73 -0
- data/test/unit/core/shape/page_number/test_interface.rb +30 -0
- data/test/unit/core/shape/page_number/test_internal.rb +81 -0
- data/test/unit/core/shape/styles/test_text.rb +12 -1
- data/test/unit/core/shape/text_block/formatter/test_datetime.rb +19 -17
- data/test/unit/core/shape/text_block/test_format.rb +5 -0
- data/test/unit/core/test_events.rb +5 -3
- data/test/unit/core/test_shape.rb +5 -1
- data/test/unit/generator/pdf/document/graphics/test_attributes.rb +6 -0
- data/test/unit/generator/pdf/document/test_draw_shape.rb +6 -0
- data/test/unit/generator/pdf/document/test_page.rb +29 -3
- data/test/unit/generator/test_pdf.rb +1 -10
- data/test/unit/helper.rb +33 -11
- data/test/unit/layout/test_base.rb +1 -1
- data/test/unit/report/test_base.rb +47 -0
- data/test/unit/report/test_internal.rb +22 -0
- data/test/unit/tmp/.gitkeep +0 -0
- data/thinreports.gemspec +14 -13
- metadata +89 -53
- data/.yardopts +0 -1
- data/test/case/list_header_inheriting/list_header_inheriting.rb +0 -17
- data/test/case/list_header_inheriting/list_header_inheriting.tlf +0 -1
@@ -66,7 +66,6 @@ class ThinReports::Core::Format::TestBuilder < MiniTest::Unit::TestCase
|
|
66
66
|
<svg width="595.2" height="841.8">
|
67
67
|
<g class="canvas">
|
68
68
|
<rect x="100" y="100" width="100" height="100" fill="red" x-attr="cleaned attr"></rect>
|
69
|
-
<%= r(:"t1")%>
|
70
69
|
<!--LAYOUT<text x="60" y="103">t1</text>LAYOUT-->
|
71
70
|
</g>
|
72
71
|
</svg>
|
@@ -111,4 +110,4 @@ class ThinReports::Core::Format::TestBuilder < MiniTest::Unit::TestCase
|
|
111
110
|
def test_shape_tag
|
112
111
|
assert_equal TestFormat.shape_tag(flexmock(:id => :foo)), '<%= r(:"foo")%>'
|
113
112
|
end
|
114
|
-
end
|
113
|
+
end
|
@@ -47,4 +47,12 @@ class ThinReports::Core::Shape::Basic::TestInternal < MiniTest::Unit::TestCase
|
|
47
47
|
|
48
48
|
assert_equal result.all?, true
|
49
49
|
end
|
50
|
-
|
50
|
+
|
51
|
+
def test_identifier
|
52
|
+
basic = create_internal('id' => 'basic-id')
|
53
|
+
assert_equal basic.identifier, 'basic-id'
|
54
|
+
|
55
|
+
flexmock(basic.style).should_receive(:identifier => 'style-identifier')
|
56
|
+
assert_equal basic.identifier, 'basic-idstyle-identifier'
|
57
|
+
end
|
58
|
+
end
|
@@ -29,6 +29,10 @@ class ThinReports::Core::Shape::List::TestConfiguration < MiniTest::Unit::TestCa
|
|
29
29
|
def test_store_return_nil_when_uninitialized_yet
|
30
30
|
assert_nil @config.store
|
31
31
|
end
|
32
|
+
|
33
|
+
def test_type
|
34
|
+
assert_equal @config.type, List::TYPE_NAME
|
35
|
+
end
|
32
36
|
|
33
37
|
def test_copy
|
34
38
|
copied_store = flexmock('copied store')
|
@@ -49,4 +53,5 @@ class ThinReports::Core::Shape::List::TestConfiguration < MiniTest::Unit::TestCa
|
|
49
53
|
assert_same copied_config.events, copied_events
|
50
54
|
assert_same copied_config.store, copied_store
|
51
55
|
end
|
52
|
-
end
|
56
|
+
end
|
57
|
+
|
@@ -109,4 +109,14 @@ class ThinReports::Core::Shape::List::TestManager < MiniTest::Unit::TestCase
|
|
109
109
|
|
110
110
|
assert_same list_used_in_event, current_list
|
111
111
|
end
|
112
|
+
|
113
|
+
def test_page_count
|
114
|
+
report = create_report
|
115
|
+
assert_equal report.page_count, 0
|
116
|
+
|
117
|
+
report.list(:list).page_break
|
118
|
+
report.list(:list).page_break
|
119
|
+
|
120
|
+
assert_equal report.list(:list).manager.page_count, 2
|
121
|
+
end
|
112
122
|
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
require 'test/unit/helper'
|
4
|
+
|
5
|
+
class ThinReports::Core::Shape::PageNumber::TestFormat < MiniTest::Unit::TestCase
|
6
|
+
include ThinReports::TestHelpers
|
7
|
+
|
8
|
+
TEST_PAGENO_FORMAT = {
|
9
|
+
"type" => "s-pageno",
|
10
|
+
"id" => "",
|
11
|
+
"display" => "true",
|
12
|
+
"box" => {
|
13
|
+
"x" => 100.0,
|
14
|
+
"y" => 100.0,
|
15
|
+
"width" => 100.0,
|
16
|
+
"height" => 100.0
|
17
|
+
},
|
18
|
+
"format" => "{page} / {total}",
|
19
|
+
"overflow" => "truncate",
|
20
|
+
"target" => "",
|
21
|
+
"svg" => {
|
22
|
+
"tag" => "text",
|
23
|
+
"attrs" => {
|
24
|
+
"x" => 308.2,
|
25
|
+
"y" => 239,
|
26
|
+
"kerning" => "auto",
|
27
|
+
"id" => "goog_939685354",
|
28
|
+
"fill" => "#000000",
|
29
|
+
"fill-opacity" => "1",
|
30
|
+
"font-size" => "18",
|
31
|
+
"font-family" => "Helvetica",
|
32
|
+
"font-weight" => "normal",
|
33
|
+
"font-style" => "normal",
|
34
|
+
"text-anchor" => "middle",
|
35
|
+
"text-decoration" => "none"
|
36
|
+
}
|
37
|
+
}
|
38
|
+
}
|
39
|
+
|
40
|
+
Format = ThinReports::Core::Shape::PageNumber::Format
|
41
|
+
|
42
|
+
def format(raw_format = nil)
|
43
|
+
Format.new(raw_format || TEST_PAGENO_FORMAT)
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_build
|
47
|
+
Format.build(TEST_PAGENO_FORMAT)
|
48
|
+
rescue => e
|
49
|
+
flunk exception_details(e, 'Failed to build')
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_id
|
53
|
+
pageno = format('id' => 'pageno_id')
|
54
|
+
assert_equal pageno.id, 'pageno_id'
|
55
|
+
|
56
|
+
pageno = format('id' => '')
|
57
|
+
assert_equal pageno.id, '__pageno1'
|
58
|
+
assert_same pageno.id, pageno.id
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_overflow
|
62
|
+
assert_equal format.overflow, 'truncate'
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_target
|
66
|
+
assert_equal format.target, ''
|
67
|
+
assert_equal format("target" => "list-id").target, 'list-id'
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_default_format
|
71
|
+
assert_equal format.default_format, '{page} / {total}'
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
require 'test/unit/helper'
|
4
|
+
|
5
|
+
class ThinReports::Core::Shape::PageNumber::TestInterface < MiniTest::Unit::TestCase
|
6
|
+
include ThinReports::TestHelpers
|
7
|
+
|
8
|
+
PageNumber = ThinReports::Core::Shape::PageNumber
|
9
|
+
|
10
|
+
def init_pageno(format = {})
|
11
|
+
PageNumber::Interface.new(flexmock('parent'), PageNumber::Format.new(format))
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_format
|
15
|
+
pageno = init_pageno('format' => '{page}')
|
16
|
+
|
17
|
+
assert_equal pageno.format, '{page}'
|
18
|
+
pageno.format('{page} / {total}')
|
19
|
+
assert_equal pageno.format, '{page} / {total}'
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_reset_format
|
23
|
+
pageno = init_pageno('format' => '{page}')
|
24
|
+
|
25
|
+
pageno.format('-- {page} --')
|
26
|
+
pageno.reset_format
|
27
|
+
|
28
|
+
assert_equal pageno.format, '{page}'
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
require 'test/unit/helper'
|
4
|
+
|
5
|
+
class ThinReports::Core::Shape::PageNumber::TestInternal < MiniTest::Unit::TestCase
|
6
|
+
include ThinReports::TestHelpers
|
7
|
+
|
8
|
+
PageNumber = ThinReports::Core::Shape::PageNumber
|
9
|
+
|
10
|
+
def setup
|
11
|
+
@report = create_basic_report('basic_layout1.tlf')
|
12
|
+
@report.start_new_page
|
13
|
+
end
|
14
|
+
|
15
|
+
def init_pageno(format = {})
|
16
|
+
PageNumber::Internal.new(@report.page, PageNumber::Format.new(format))
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_read_format
|
20
|
+
pageno = init_pageno('format' => 'Page {page}')
|
21
|
+
|
22
|
+
assert_equal pageno.read_format, 'Page {page}'
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_write_format
|
26
|
+
pageno = init_pageno('format' => 'Page {page}')
|
27
|
+
pageno.write_format('{page}')
|
28
|
+
|
29
|
+
assert_equal pageno.read_format, '{page}'
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_reset_format
|
33
|
+
pageno = init_pageno('format' => '{page}')
|
34
|
+
pageno.write_format('Page {page}')
|
35
|
+
pageno.reset_format
|
36
|
+
|
37
|
+
assert_equal pageno.read_format, '{page}'
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_build_format
|
41
|
+
pageno = init_pageno('format' => '{page} / {total}')
|
42
|
+
assert_equal pageno.build_format(1, 100), '1 / 100'
|
43
|
+
|
44
|
+
pageno.write_format('{page}')
|
45
|
+
assert_equal pageno.build_format(1, 100), '1'
|
46
|
+
|
47
|
+
@report.start_page_number_from 5
|
48
|
+
pageno = init_pageno('format' => '{page} / {total}')
|
49
|
+
assert_equal pageno.build_format(1, 100), '5 / 104'
|
50
|
+
|
51
|
+
# if counted target is a List shape
|
52
|
+
pageno = init_pageno('format' => '{page} / {total}',
|
53
|
+
'target' => 'list-id')
|
54
|
+
assert_equal pageno.build_format(1, 100), '1 / 100'
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_type_of
|
58
|
+
pageno = init_pageno
|
59
|
+
assert pageno.type_of?(:pageno)
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_style
|
63
|
+
pageno = init_pageno
|
64
|
+
style = pageno.style
|
65
|
+
|
66
|
+
assert_instance_of PageNumber::Style, style
|
67
|
+
assert_same pageno.style, style
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_for_report
|
71
|
+
pageno = init_pageno('target' => '')
|
72
|
+
assert_equal pageno.for_report?, true
|
73
|
+
|
74
|
+
pageno = init_pageno('target' => 'list-id')
|
75
|
+
assert_equal pageno.for_report?, false
|
76
|
+
end
|
77
|
+
|
78
|
+
def test_Style_class
|
79
|
+
refute_includes PageNumber::Style.accessible_styles, :valign
|
80
|
+
end
|
81
|
+
end
|
@@ -13,7 +13,7 @@ class ThinReports::Core::Shape::Style::TestText < MiniTest::Unit::TestCase
|
|
13
13
|
format ||= create_format
|
14
14
|
ThinReports::Core::Shape::Style::Text.new(format)
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
def test_bold_should_return_true_when_font_weight_property_of_format_is_bold
|
18
18
|
format = create_format('svg' => {'attrs' => {'font-weight' => 'bold'}})
|
19
19
|
style = create_text_style(format)
|
@@ -302,6 +302,17 @@ class ThinReports::Core::Shape::Style::TestText < MiniTest::Unit::TestCase
|
|
302
302
|
create_text_style.valign = :unknonw
|
303
303
|
end
|
304
304
|
end
|
305
|
+
|
306
|
+
def test_initialize
|
307
|
+
klass = Class.new(ThinReports::Core::Shape::Style::Text)
|
308
|
+
klass.class_eval do
|
309
|
+
accessible_styles.delete(:valign)
|
310
|
+
end
|
311
|
+
|
312
|
+
style = klass.new(create_format('valign' => ''))
|
313
|
+
assert_equal style.valign, :top, 'should be set :top as default to @valign style ' +
|
314
|
+
'if :valign is not accessible'
|
315
|
+
end
|
305
316
|
|
306
317
|
def test_identifier_should_return_the_same_value_as_create_identifier_method_when_valign_has_not_been_changed
|
307
318
|
style = create_text_style
|
@@ -5,43 +5,45 @@ require 'test/unit/helper'
|
|
5
5
|
class ThinReports::Core::Shape::TextBlock::Formatter::TestDatetime < MiniTest::Unit::TestCase
|
6
6
|
include ThinReports::TestHelpers
|
7
7
|
|
8
|
-
#
|
9
|
-
|
8
|
+
# Aliases
|
9
|
+
TextBlock = ThinReports::Core::Shape::TextBlock
|
10
|
+
Formatter = TextBlock::Formatter::Datetime
|
10
11
|
|
11
12
|
def setup
|
12
13
|
@datetime_format = '%Y/%m/%d %H:%M:%S'
|
13
|
-
@time
|
14
|
-
|
15
|
-
@format = flexmock(:format_base => '',
|
16
|
-
:format_datetime_format => @datetime_format)
|
14
|
+
@time = Time.now
|
17
15
|
end
|
18
16
|
|
17
|
+
def text_block_format(format = {})
|
18
|
+
default = {'base' => '', 'datetime' => {'format' => '%Y/%m/%d %H:%M:%S'}}
|
19
|
+
TextBlock::Format.new('format' => default.merge(format))
|
20
|
+
end
|
21
|
+
|
19
22
|
def test_apply_datetime_format_without_basic_format
|
20
|
-
formatter = Formatter.new(
|
23
|
+
formatter = Formatter.new(text_block_format)
|
21
24
|
|
22
|
-
assert_equal
|
25
|
+
assert_equal @time.strftime(@datetime_format),
|
26
|
+
formatter.apply(@time)
|
23
27
|
end
|
24
28
|
|
25
29
|
def test_apply_datetime_format_with_basic_format
|
26
|
-
|
27
|
-
format = flexmock(@format, :format_base => 'Now: {value}')
|
28
|
-
|
29
|
-
formatter = Formatter.new(format)
|
30
|
+
formatter = Formatter.new(text_block_format('base' => 'Now: {value}'))
|
30
31
|
|
31
|
-
assert_equal
|
32
|
-
|
32
|
+
assert_equal "Now: #{@time.strftime(@datetime_format)}",
|
33
|
+
formatter.apply(@time)
|
34
|
+
|
33
35
|
end
|
34
36
|
|
35
37
|
def test_not_apply_datetime_format_and_return_raw_value
|
36
38
|
# When value is invalid
|
37
|
-
formatter = Formatter.new(
|
39
|
+
formatter = Formatter.new(text_block_format)
|
38
40
|
|
39
41
|
assert_same formatter.apply(val = 'invalid value'), val
|
40
42
|
assert_same formatter.apply(val = 123456), val
|
41
43
|
|
42
44
|
# When format is empty
|
43
|
-
|
45
|
+
formatter = Formatter.new(text_block_format('datetime' => {'format' => ''}))
|
44
46
|
|
45
47
|
assert_same formatter.apply(@time), @time
|
46
48
|
end
|
47
|
-
end
|
49
|
+
end
|
@@ -11,6 +11,7 @@ class ThinReports::Core::Shape::TextBlock::TestFormat < MiniTest::Unit::TestCase
|
|
11
11
|
"display" => "true",
|
12
12
|
"multiple" => "false",
|
13
13
|
"overflow" => "truncate",
|
14
|
+
"word-wrap" => "break-word",
|
14
15
|
"box" => {
|
15
16
|
"x" => 100.0,
|
16
17
|
"y" => 100.0,
|
@@ -55,6 +56,10 @@ class ThinReports::Core::Shape::TextBlock::TestFormat < MiniTest::Unit::TestCase
|
|
55
56
|
def test_value_reader_via_TEST_TBLOCK_FORMAT
|
56
57
|
assert_equal format(TEST_TBLOCK_FORMAT).value, ''
|
57
58
|
end
|
59
|
+
|
60
|
+
def test_word_wrap_reader_via_TEST_TBLOCK_FORMAT
|
61
|
+
assert_equal format(TEST_TBLOCK_FORMAT).word_wrap, 'break-word'
|
62
|
+
end
|
58
63
|
|
59
64
|
def test_ref_id_reader_via_TEST_TBLOCK_FORMAT
|
60
65
|
assert_equal format(TEST_TBLOCK_FORMAT).ref_id, ''
|
@@ -77,12 +77,14 @@ class ThinReports::Core::TestEvents < MiniTest::Unit::TestCase
|
|
77
77
|
end
|
78
78
|
|
79
79
|
def test_copy
|
80
|
-
@events.on(:change) {
|
81
|
-
@events.on(:load) {
|
80
|
+
@events.on(:change) { :on_change }
|
81
|
+
@events.on(:load) { :on_load }
|
82
82
|
|
83
83
|
copied = @events.copy
|
84
84
|
|
85
|
-
|
85
|
+
assert @events.events.all? {|k,f|
|
86
|
+
copied.events[k].call == f.call
|
87
|
+
}
|
86
88
|
refute_same @events.events, copied.events
|
87
89
|
|
88
90
|
@events.unlisten(:change)
|
@@ -8,6 +8,10 @@ class ThinReports::Core::TestShape < MiniTest::Unit::TestCase
|
|
8
8
|
# Alias
|
9
9
|
ShapeModule = ThinReports::Core::Shape
|
10
10
|
|
11
|
+
def test_find_by_type_should_return_PageNumber
|
12
|
+
assert_same ShapeModule.find_by_type('s-pageno'), ShapeModule::PageNumber
|
13
|
+
end
|
14
|
+
|
11
15
|
def test_find_by_type_should_return_ImageBlock
|
12
16
|
assert_same ShapeModule.find_by_type('s-iblock'), ShapeModule::ImageBlock
|
13
17
|
end
|
@@ -57,4 +61,4 @@ class ThinReports::Core::TestShape < MiniTest::Unit::TestCase
|
|
57
61
|
ShapeModule::Configuration('s-line')
|
58
62
|
end
|
59
63
|
end
|
60
|
-
end
|
64
|
+
end
|
@@ -56,6 +56,12 @@ class ThinReports::Generator::PDF::Graphics::TestAttributes < MiniTest::Unit::Te
|
|
56
56
|
assert_equal valigns.map {|a| @pdf.text_valign(a) },
|
57
57
|
[:top, :center, :bottom, :top]
|
58
58
|
end
|
59
|
+
|
60
|
+
def test_text_word_wrap
|
61
|
+
assert_equal @pdf.text_word_wrap('break-word'), :break_word
|
62
|
+
assert_equal @pdf.text_word_wrap('none'), :none
|
63
|
+
assert_equal @pdf.text_word_wrap(''), :none
|
64
|
+
end
|
59
65
|
|
60
66
|
def test_extract_base64_string
|
61
67
|
base64 = 'data:image/png;base64,iVBORw0KGg1+/AAy/plYlzil'
|
@@ -33,4 +33,10 @@ class ThinReports::Generator::PDF::TestDrawShape < MiniTest::Unit::TestCase
|
|
33
33
|
tblock = create_tblock_interface('id' => 'text', 'line-height' => '')
|
34
34
|
assert_nil @pdf.send(:shape_text_attrs, tblock.internal)[:line_height]
|
35
35
|
end
|
36
|
+
|
37
|
+
def test_shape_text_attrs
|
38
|
+
tblock = create_tblock_interface('id' => 'text', 'word-wrap' => 'none')
|
39
|
+
assert_includes @pdf.send(:shape_text_attrs, tblock.internal).keys, :word_wrap
|
40
|
+
end
|
36
41
|
end
|
42
|
+
|
@@ -8,7 +8,33 @@ class ThinReports::Generator::PDF::Document::TestPage < MiniTest::Unit::TestCase
|
|
8
8
|
def create_pdf
|
9
9
|
@pdf = ThinReports::Generator::PDF::Document.new
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
|
+
def test_page_geometry
|
13
|
+
page_geometry = Prawn::Document::PageGeometry::SIZES
|
14
|
+
assert_equal page_geometry['B4_JIS'], [728.5, 1031.8]
|
15
|
+
assert_equal page_geometry['B5_JIS'], [515.9, 728.5]
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_B4_paper_size_should_be_converted_to_B4_JIS
|
19
|
+
create_pdf
|
20
|
+
|
21
|
+
format = create_basic_layout_format('basic_layout1.tlf')
|
22
|
+
flexmock(format).should_receive(:page_paper_type).and_return('B4')
|
23
|
+
|
24
|
+
@pdf.start_new_page(format)
|
25
|
+
assert_equal @pdf.internal.page.size, 'B4_JIS'
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_B4_ISO_paper_size_should_be_converted_to_B4
|
29
|
+
create_pdf
|
30
|
+
|
31
|
+
format = create_basic_layout_format('basic_layout1.tlf')
|
32
|
+
flexmock(format).should_receive(:page_paper_type).and_return('B4_ISO')
|
33
|
+
|
34
|
+
@pdf.start_new_page(format)
|
35
|
+
assert_equal @pdf.internal.page.size, 'B4'
|
36
|
+
end
|
37
|
+
|
12
38
|
def test_change_page_format_should_return_true_at_first_time
|
13
39
|
create_pdf
|
14
40
|
format = create_basic_layout_format('basic_layout1.tlf')
|
@@ -77,7 +103,7 @@ class ThinReports::Generator::PDF::Document::TestPage < MiniTest::Unit::TestCase
|
|
77
103
|
@pdf.start_new_page(format)
|
78
104
|
@pdf.start_new_page(format)
|
79
105
|
end
|
80
|
-
|
106
|
+
|
81
107
|
def test_add_blank_page_should_create_an_A4_size_page_in_first_page
|
82
108
|
create_pdf
|
83
109
|
flexmock(@pdf.internal).should_receive(:start_new_page).with(:size => 'A4').once
|
@@ -92,4 +118,4 @@ class ThinReports::Generator::PDF::Document::TestPage < MiniTest::Unit::TestCase
|
|
92
118
|
|
93
119
|
@pdf.add_blank_page
|
94
120
|
end
|
95
|
-
end
|
121
|
+
end
|