thinreports 0.6.0.pre3 → 0.7.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.
- data/README.rdoc +37 -32
- data/doc/yardoc_templates/default/layout/html/footer.erb +1 -1
- data/lib/thinreports.rb +2 -1
- data/lib/thinreports/config.rb +21 -0
- data/lib/thinreports/core/errors.rb +14 -1
- data/lib/thinreports/core/format/builder.rb +6 -1
- data/lib/thinreports/core/page.rb +6 -6
- data/lib/thinreports/core/shape.rb +8 -9
- data/lib/thinreports/core/shape/base/internal.rb +6 -12
- data/lib/thinreports/core/shape/basic.rb +3 -0
- data/lib/thinreports/core/shape/basic/block_format.rb +12 -0
- data/lib/thinreports/core/shape/basic/block_interface.rb +25 -0
- data/lib/thinreports/core/shape/basic/block_internal.rb +33 -0
- data/lib/thinreports/core/shape/basic/interface.rb +37 -11
- data/lib/thinreports/core/shape/basic/internal.rb +3 -12
- data/lib/thinreports/core/shape/image_block.rb +15 -0
- data/lib/thinreports/core/shape/image_block/format.rb +13 -0
- data/lib/thinreports/core/shape/image_block/interface.rb +19 -0
- data/lib/thinreports/core/shape/image_block/internal.rb +16 -0
- data/lib/thinreports/core/shape/list/events.rb +19 -2
- data/lib/thinreports/core/shape/list/manager.rb +17 -4
- data/lib/thinreports/core/shape/list/page.rb +2 -2
- data/lib/thinreports/core/shape/list/page_state.rb +4 -0
- data/lib/thinreports/core/shape/list/section_internal.rb +4 -0
- data/lib/thinreports/core/shape/manager/format.rb +1 -1
- data/lib/thinreports/core/shape/manager/internal.rb +24 -11
- data/lib/thinreports/core/shape/manager/target.rb +2 -2
- data/lib/thinreports/core/shape/style.rb +15 -0
- data/lib/thinreports/core/shape/style/base.rb +149 -0
- data/lib/thinreports/core/shape/style/basic.rb +17 -0
- data/lib/thinreports/core/shape/style/graphic.rb +60 -0
- data/lib/thinreports/core/shape/style/text.rb +138 -0
- data/lib/thinreports/core/shape/text/internal.rb +4 -0
- data/lib/thinreports/core/shape/text_block.rb +16 -0
- data/lib/thinreports/core/shape/{tblock → text_block}/format.rb +3 -3
- data/lib/thinreports/core/shape/{tblock → text_block}/formatter.rb +7 -7
- data/lib/thinreports/core/shape/{tblock → text_block}/formatter/basic.rb +1 -1
- data/lib/thinreports/core/shape/{tblock → text_block}/formatter/datetime.rb +1 -1
- data/lib/thinreports/core/shape/{tblock → text_block}/formatter/number.rb +1 -1
- data/lib/thinreports/core/shape/{tblock → text_block}/formatter/padding.rb +10 -8
- data/lib/thinreports/core/shape/{tblock → text_block}/interface.rb +2 -21
- data/lib/thinreports/core/shape/{tblock → text_block}/internal.rb +16 -10
- data/lib/thinreports/core/utils.rb +0 -8
- data/lib/thinreports/generator.rb +2 -2
- data/lib/thinreports/generator/configuration.rb +30 -0
- data/lib/thinreports/generator/pdf.rb +13 -10
- data/lib/thinreports/generator/pdf/configuration.rb +28 -0
- data/lib/thinreports/generator/pdf/document.rb +16 -56
- data/lib/thinreports/generator/pdf/document/draw_shape.rb +35 -17
- data/lib/thinreports/generator/pdf/document/font.rb +25 -9
- data/lib/thinreports/generator/pdf/document/graphics.rb +1 -1
- data/lib/thinreports/generator/pdf/document/graphics/attributes.rb +18 -4
- data/lib/thinreports/generator/pdf/document/graphics/basic.rb +1 -1
- data/lib/thinreports/generator/pdf/document/graphics/image.rb +18 -1
- data/lib/thinreports/generator/pdf/document/graphics/text.rb +29 -6
- data/lib/thinreports/generator/pdf/document/page.rb +70 -0
- data/lib/thinreports/generator/pdf/document/parse_color.rb +1 -1
- data/lib/thinreports/generator/pdf/document/parse_svg.rb +1 -1
- data/lib/thinreports/generator/pdf/drawer.rb +1 -1
- data/lib/thinreports/generator/pdf/drawer/base.rb +5 -7
- data/lib/thinreports/generator/pdf/drawer/list.rb +4 -4
- data/lib/thinreports/generator/pdf/drawer/list_section.rb +8 -3
- data/lib/thinreports/generator/pdf/drawer/page.rb +10 -3
- data/lib/thinreports/generator/pdf/prawn_ext.rb +16 -21
- data/lib/thinreports/layout/format.rb +2 -2
- data/lib/thinreports/layout/version.rb +2 -2
- data/lib/thinreports/report/base.rb +68 -31
- data/tasks/test.rake +48 -4
- data/test/benchmark/basic_estimate.tlf +1 -0
- data/test/benchmark/bench_basic_estimate.rb +95 -0
- data/test/case/character_spacing/character_spacing.rb +7 -0
- data/test/case/character_spacing/character_spacing.tlf +1 -0
- data/test/case/dynamic_image/dynamic_image.rb +41 -0
- data/test/case/dynamic_image/dynamic_image.tlf +1 -0
- data/test/case/dynamic_image/img200x100.png +0 -0
- data/test/case/dynamic_image/img50x50.png +0 -0
- data/test/case/dynamic_style/dynamic_style.rb +154 -0
- data/test/case/dynamic_style/dynamic_style.tlf +1 -0
- data/test/case/dynamic_style/dynamic_style_in_list.tlf +1 -0
- data/test/case/dynamic_style/image.png +0 -0
- data/test/case/eudc/eudc.rb +20 -0
- data/test/case/eudc/eudc.tlf +1 -0
- data/test/case/eudc/eudc.ttf +0 -0
- data/test/case/helper.rb +27 -0
- data/test/case/hidden_shapes/hidden_shapes.rb +13 -0
- data/test/case/hidden_shapes/hidden_shapes.tlf +1 -0
- data/test/case/list_events/list_events.rb +32 -0
- data/test/case/list_events/list_events.tlf +1 -0
- data/test/case/list_header_inheriting/list_header_inheriting.rb +19 -0
- data/test/case/list_header_inheriting/list_header_inheriting.tlf +1 -0
- data/test/case/list_manual_generation/list_manual_generation.rb +24 -0
- data/test/case/list_manual_generation/list_manual_generation.tlf +1 -0
- data/test/case/single_line_tblock/single_line_tblock.rb +15 -0
- data/test/case/single_line_tblock/single_line_tblock.tlf +1 -0
- data/test/case/tblock_styles/tblock_styles.rb +27 -0
- data/test/case/tblock_styles/tblock_styles.tlf +1 -0
- data/test/case/text_align/text_align.rb +9 -0
- data/test/case/text_align/text_align.tlf +1 -0
- data/test/unit/core/shape/base/test_internal.rb +65 -85
- data/test/unit/core/shape/basic/test_basic_format.rb +30 -0
- data/test/unit/core/shape/basic/test_basic_interface.rb +27 -0
- data/test/unit/core/shape/basic/test_basic_internal.rb +55 -0
- data/test/unit/core/shape/basic/test_interface.rb +84 -36
- data/test/unit/core/shape/basic/test_internal.rb +32 -24
- data/test/unit/core/shape/image_block/test_format.rb +58 -0
- data/test/unit/core/shape/image_block/test_interface.rb +23 -0
- data/test/unit/core/shape/image_block/test_internal.rb +28 -0
- data/test/unit/core/shape/list/test_events.rb +19 -11
- data/test/unit/core/shape/list/test_manager.rb +112 -0
- data/test/unit/core/shape/list/test_page.rb +57 -0
- data/test/unit/core/shape/list/test_section_format.rb +1 -1
- data/test/unit/core/shape/list/test_section_interface.rb +37 -30
- data/test/unit/core/shape/list/test_section_internal.rb +39 -14
- data/test/unit/core/shape/manager/test_format.rb +12 -18
- data/test/unit/core/shape/manager/test_internal.rb +127 -93
- data/test/unit/core/shape/manager/test_target.rb +63 -56
- data/test/unit/core/shape/styles/test_base.rb +219 -0
- data/test/unit/core/shape/styles/test_basic.rb +24 -0
- data/test/unit/core/shape/styles/test_graphic.rb +69 -0
- data/test/unit/core/shape/styles/test_text.rb +318 -0
- data/test/unit/core/shape/{tblock → text_block}/formatter/test_basic.rb +2 -2
- data/test/unit/core/shape/{tblock → text_block}/formatter/test_datetime.rb +2 -2
- data/test/unit/core/shape/{tblock → text_block}/formatter/test_number.rb +2 -2
- data/test/unit/core/shape/{tblock → text_block}/formatter/test_padding.rb +11 -6
- data/test/unit/core/shape/text_block/test_format.rb +160 -0
- data/test/unit/core/shape/{tblock → text_block}/test_formatter.rb +2 -2
- data/test/unit/core/shape/text_block/test_interface.rb +46 -0
- data/test/unit/core/shape/text_block/test_internal.rb +128 -0
- data/test/unit/core/test_shape.rb +31 -6
- data/test/unit/data/basic_layout1.tlf +1 -0
- data/test/unit/data/basic_layout2.tlf +1 -0
- data/test/unit/data/basic_list_layout.tlf +1 -0
- data/test/unit/generator/pdf/document/graphics/test_attributes.rb +81 -52
- data/test/unit/generator/pdf/document/graphics/test_text.rb +159 -0
- data/test/unit/generator/pdf/document/test_font.rb +21 -6
- data/test/unit/generator/pdf/document/test_graphics.rb +2 -2
- data/test/unit/generator/pdf/document/test_page.rb +95 -0
- data/test/unit/generator/pdf/document/test_parse_color.rb +2 -2
- data/test/unit/generator/pdf/test_configuration.rb +24 -0
- data/test/unit/generator/pdf/test_document.rb +28 -0
- data/test/unit/generator/test_configuration.rb +25 -0
- data/test/unit/generator/test_pdf.rb +19 -0
- data/test/unit/helper.rb +18 -0
- data/test/unit/layout/test_format.rb +24 -7
- data/test/unit/layout/test_version.rb +61 -27
- data/test/unit/report/test_base.rb +185 -89
- data/test/unit/test_config.rb +22 -0
- data/test/unit/test_report.rb +4 -4
- metadata +94 -43
- data/lib/thinreports/core/shape/tblock.rb +0 -16
- data/lib/thinreports/generator/pxd.rb +0 -75
- data/lib/thinreports/generator/pxd/helper.rb +0 -33
- data/lib/thinreports/generator/pxd/list_renderer.rb +0 -58
- data/lib/thinreports/generator/pxd/page_renderer.rb +0 -75
- data/tasks/clean.rake +0 -6
- data/test/unit/core/shape/tblock/test_format.rb +0 -125
- data/test/unit/core/shape/tblock/test_interface.rb +0 -40
- data/test/unit/core/shape/tblock/test_internal.rb +0 -139
|
@@ -5,38 +5,46 @@ require 'test/unit/helper'
|
|
|
5
5
|
class ThinReports::Core::Shape::Basic::TestInternal < MiniTest::Unit::TestCase
|
|
6
6
|
include ThinReports::TestHelpers
|
|
7
7
|
|
|
8
|
+
# Alias
|
|
8
9
|
Basic = ThinReports::Core::Shape::Basic
|
|
9
10
|
|
|
10
|
-
def
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
@internal = Basic::Internal.new(flexmock('parent'), format)
|
|
11
|
+
def create_internal(format_config = {})
|
|
12
|
+
Basic::Internal.new(flexmock('parent'),
|
|
13
|
+
Basic::Format.new(format_config))
|
|
15
14
|
end
|
|
16
15
|
|
|
17
|
-
def
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
@internal.visible(false)
|
|
21
|
-
|
|
22
|
-
assert_equal @internal.visible?, false
|
|
23
|
-
assert_equal @internal.format.display?, true
|
|
16
|
+
def test_id_should_operate_as_delegator_of_format
|
|
17
|
+
basic = create_internal('id' => 'basic-id')
|
|
18
|
+
assert_same basic.id, basic.format.id
|
|
24
19
|
end
|
|
25
20
|
|
|
26
|
-
def
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
21
|
+
def test_svg_tag_should_operate_as_delegator_of_format
|
|
22
|
+
basic = create_internal('svg' => {'tag' => 'rect'})
|
|
23
|
+
assert_same basic.svg_tag, basic.format.svg_tag
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def test_type_should_operate_as_delegator_of_format
|
|
27
|
+
basic = create_internal('type' => 's-ellipse')
|
|
28
|
+
assert_same basic.type, basic.format.type
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def test_style_should_return_instance_of_StyleGraphic
|
|
32
|
+
assert_instance_of ThinReports::Core::Shape::Style::Graphic,
|
|
33
|
+
create_internal.style
|
|
33
34
|
end
|
|
34
35
|
|
|
35
|
-
def
|
|
36
|
-
|
|
36
|
+
def test_type_of_asker_should_already_return_true_when_the_specified_type_is_basic
|
|
37
|
+
assert_equal create_internal.type_of?(:basic), true
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def test_type_of_asker_should_return_true_when_the_specified_type_equal_self_type_name
|
|
41
|
+
result = []
|
|
42
|
+
|
|
43
|
+
result << create_internal('type' => 's-rect').type_of?(:rect)
|
|
44
|
+
result << create_internal('type' => 's-ellipse').type_of?(:ellipse)
|
|
45
|
+
result << create_internal('type' => 's-line').type_of?(:line)
|
|
46
|
+
result << create_internal('type' => 's-image').type_of?(:image)
|
|
37
47
|
|
|
38
|
-
assert_equal
|
|
39
|
-
assert_equal @internal.type_of?(:rect), true
|
|
40
|
-
assert_equal @internal.type_of?(:tblock), false
|
|
48
|
+
assert_equal result.all?, true
|
|
41
49
|
end
|
|
42
50
|
end
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'test/unit/helper'
|
|
4
|
+
|
|
5
|
+
class ThinReports::Core::Shape::ImageBlock::TestFormat < MiniTest::Unit::TestCase
|
|
6
|
+
include ThinReports::TestHelpers
|
|
7
|
+
|
|
8
|
+
TEST_IMAGE_BLOCK_FORMAT = {
|
|
9
|
+
"type" => "s-iblock",
|
|
10
|
+
"id" => "image",
|
|
11
|
+
"display" => "true",
|
|
12
|
+
"box" => {
|
|
13
|
+
"x" => 100.0,
|
|
14
|
+
"y" => 100.0,
|
|
15
|
+
"width" => 100.0,
|
|
16
|
+
"height" => 100.0
|
|
17
|
+
},
|
|
18
|
+
"position-x" => "left",
|
|
19
|
+
"position-y" => "top",
|
|
20
|
+
"svg" => {
|
|
21
|
+
"tag" => "image",
|
|
22
|
+
"attrs" => {
|
|
23
|
+
"x" => 100.0,
|
|
24
|
+
"y" => 100.0,
|
|
25
|
+
"width" => 100.0,
|
|
26
|
+
"height" => 100.0
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
def test_build
|
|
32
|
+
build_format
|
|
33
|
+
rescue => e
|
|
34
|
+
flunk exception_details(e, 'Building failed.')
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def test_box_reader_via_TEST_IMAGE_BLOCK_FORMAT
|
|
38
|
+
assert_equal format(TEST_IMAGE_BLOCK_FORMAT).box.values_at('x', 'y', 'width', 'height'),
|
|
39
|
+
[100.0, 100.0, 100.0, 100.0]
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def test_position_x_reader_via_TEST_IMAGE_BLOCK_FORMAT
|
|
43
|
+
assert_equal format(TEST_IMAGE_BLOCK_FORMAT).position_x, 'left'
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def test_position_y_reader_via_TEST_IMAGE_BLOCK_FORMAT
|
|
47
|
+
assert_equal format(TEST_IMAGE_BLOCK_FORMAT).position_y, 'top'
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def build_format
|
|
51
|
+
ThinReports::Core::Shape::ImageBlock::Format.build(TEST_IMAGE_BLOCK_FORMAT)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def format(data)
|
|
55
|
+
ThinReports::Core::Shape::ImageBlock::Format.new(data)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'test/unit/helper'
|
|
4
|
+
|
|
5
|
+
class ThinReports::Core::Shape::ImageBlock::TestInterface < MiniTest::Unit::TestCase
|
|
6
|
+
include ThinReports::TestHelpers
|
|
7
|
+
|
|
8
|
+
ImageBlock = ThinReports::Core::Shape::ImageBlock
|
|
9
|
+
|
|
10
|
+
def setup
|
|
11
|
+
@interface = ImageBlock::Interface.new(flexmock('parent'),
|
|
12
|
+
ImageBlock::Format.new({}))
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def test_src_should_work_the_same_as_value_method
|
|
16
|
+
@interface.src('/path/to/image.png')
|
|
17
|
+
assert_equal @interface.src, '/path/to/image.png'
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def test_properly_initialized_internal_property
|
|
21
|
+
assert_instance_of ImageBlock::Internal, @interface.internal
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'test/unit/helper'
|
|
4
|
+
|
|
5
|
+
class ThinReports::Core::Shape::ImageBlock::TestInternal < MiniTest::Unit::TestCase
|
|
6
|
+
include ThinReports::TestHelpers
|
|
7
|
+
|
|
8
|
+
ImageBlock = ThinReports::Core::Shape::ImageBlock
|
|
9
|
+
|
|
10
|
+
def test_src_should_return_the_same_value_as_value_method
|
|
11
|
+
internal = init_internal
|
|
12
|
+
internal.write_value('/path/to/image.png')
|
|
13
|
+
|
|
14
|
+
assert_same internal.src, internal.read_value
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def test_type_of_asker_should_return_true_when_iblock_value_is_given
|
|
18
|
+
assert_equal init_internal.type_of?(:iblock), true
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def test_type_of_asker_should_return_true_when_block_value_is_given
|
|
22
|
+
assert_equal init_internal.type_of?(:block), true
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def init_internal
|
|
26
|
+
ImageBlock::Internal.new(flexmock('parent'), ImageBlock::Format.new({}))
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -11,18 +11,26 @@ class ThinReports::Core::Shape::List::TestEvents < MiniTest::Unit::TestCase
|
|
|
11
11
|
@events = List::Events.new
|
|
12
12
|
end
|
|
13
13
|
|
|
14
|
-
def
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
def test_page_footer_insert_event_should_be_able_to_be_used
|
|
15
|
+
@events.send(:verify_event_type, :page_footer_insert)
|
|
16
|
+
rescue ThinReports::Errors::UnknownEventType
|
|
17
|
+
flunk ':page_footer_insert cannot be used.'
|
|
17
18
|
end
|
|
18
19
|
|
|
19
|
-
def
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
def test_footer_insert_event_should_be_able_to_be_used
|
|
21
|
+
@events.send(:verify_event_type, :footer_insert)
|
|
22
|
+
rescue ThinReports::Errors::UnknownEventType
|
|
23
|
+
flunk ':footer_insert cannot be used.'
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def test_page_finalize_event_should_be_able_to_be_used
|
|
27
|
+
@events.send(:verify_event_type, :page_finalize)
|
|
28
|
+
rescue ThinReports::Errors::UnknownEventType
|
|
29
|
+
flunk ':page_finalize cannot be used.'
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def test_list_property_of_PageEvent_should_equal_to_target_property
|
|
33
|
+
ev = List::Events::PageEvent.new(:page_finalize, 'list', 'page')
|
|
34
|
+
assert_same ev.list, ev.target
|
|
27
35
|
end
|
|
28
36
|
end
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'test/unit/helper'
|
|
4
|
+
|
|
5
|
+
class ThinReports::Core::Shape::List::TestManager < MiniTest::Unit::TestCase
|
|
6
|
+
include ThinReports::TestHelpers
|
|
7
|
+
|
|
8
|
+
# Alias
|
|
9
|
+
List = ThinReports::Core::Shape::List
|
|
10
|
+
|
|
11
|
+
def create_report(&block)
|
|
12
|
+
create_basic_report('basic_list_layout.tlf', &block)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def list_manager
|
|
16
|
+
report = create_report {|r| r.start_new_page }
|
|
17
|
+
report.page.list(:list).manager
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def test_config_should_return_the_instance_of_ListConfiguration
|
|
21
|
+
assert_same list_manager.config.class, List::Configuration
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def test_current_page_should_return_the_instance_of_ListPage
|
|
25
|
+
assert_instance_of List::Page, list_manager.current_page
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def test_current_page_state_should_return_the_instance_of_ListPageState
|
|
29
|
+
assert_instance_of List::PageState, list_manager.current_page_state
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def test_switch_current_should_replace_own_current_page_property_by_the_given_page
|
|
33
|
+
report = create_report {|r| r.start_new_page }
|
|
34
|
+
list = report.page.list(:list)
|
|
35
|
+
new_page = List::Page.new(report.page, list.internal.format)
|
|
36
|
+
|
|
37
|
+
list.manager.switch_current!(new_page)
|
|
38
|
+
|
|
39
|
+
assert_same list.manager.current_page, new_page
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def test_switch_current_should_replace_own_current_page_state_property_by_internal_property_of_the_given_page
|
|
43
|
+
report = create_report {|r| r.start_new_page }
|
|
44
|
+
list = report.page.list(:list)
|
|
45
|
+
new_page = List::Page.new(report.page, list.internal.format)
|
|
46
|
+
|
|
47
|
+
list.manager.switch_current!(new_page)
|
|
48
|
+
|
|
49
|
+
assert_same list.manager.current_page_state, new_page.internal
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def test_switch_current_should_return_the_self
|
|
53
|
+
report = create_report {|r| r.start_new_page }
|
|
54
|
+
list = report.page.list(:list)
|
|
55
|
+
new_page = List::Page.new(report.page, list.internal.format)
|
|
56
|
+
|
|
57
|
+
assert_same list.manager.switch_current!(new_page), list.manager
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def test_finalize_page_should_dispatch_page_finalize_event
|
|
61
|
+
flag = false
|
|
62
|
+
|
|
63
|
+
report = create_report do |r|
|
|
64
|
+
r.layout.config.list(:list) do
|
|
65
|
+
events.on :page_finalize do |e|
|
|
66
|
+
flag = true
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
report.start_new_page do |page|
|
|
72
|
+
page.list(:list).manager.finalize_page
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
assert flag, 'The :page_finalize event was not dispatched.'
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def test_page_property_which_dispatcher_of_finalize_page_event_should_return_the_current_page
|
|
79
|
+
page_used_in_event = nil
|
|
80
|
+
|
|
81
|
+
report = create_report do |r|
|
|
82
|
+
r.layout.config.list(:list) do
|
|
83
|
+
events.on :page_finalize do |e|
|
|
84
|
+
page_used_in_event = e.page
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
current_page = report.start_new_page
|
|
90
|
+
current_page.list(:list).manager.finalize_page
|
|
91
|
+
|
|
92
|
+
assert_same page_used_in_event, current_page
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def test_list_property_which_dispatcher_of_finalize_event_should_return_the_current_page_of_list
|
|
96
|
+
list_used_in_event = nil
|
|
97
|
+
|
|
98
|
+
report = create_report do |r|
|
|
99
|
+
r.layout.config.list(:list) do
|
|
100
|
+
events.on :page_finalize do |e|
|
|
101
|
+
list_used_in_event = e.list
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
report.start_new_page
|
|
107
|
+
current_list = report.page.list(:list)
|
|
108
|
+
current_list.manager.finalize_page
|
|
109
|
+
|
|
110
|
+
assert_same list_used_in_event, current_list
|
|
111
|
+
end
|
|
112
|
+
end
|
|
@@ -7,4 +7,61 @@ class ThinReports::Core::Shape::List::TestPage < MiniTest::Unit::TestCase
|
|
|
7
7
|
|
|
8
8
|
# Alias
|
|
9
9
|
List = ThinReports::Core::Shape::List
|
|
10
|
+
|
|
11
|
+
def create_report(&block)
|
|
12
|
+
create_basic_report('basic_list_layout.tlf', &block)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def create_report_for_checking_dispatched_event(event)
|
|
16
|
+
@target_event = event
|
|
17
|
+
@is_dispatched = false
|
|
18
|
+
|
|
19
|
+
create_report do |r|
|
|
20
|
+
r.layout.config.list(:list) do |list|
|
|
21
|
+
list.events.on(event) {|e| @is_dispatched = true }
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def assert_dispatched_event
|
|
27
|
+
assert @is_dispatched, "The :#{@target_event} event was not dispatched."
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def test_page_finalize_event_should_be_dispatched_when_page_break_is_called
|
|
31
|
+
report = create_report_for_checking_dispatched_event :page_finalize
|
|
32
|
+
report.start_new_page do
|
|
33
|
+
list(:list).page_break
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
assert_dispatched_event
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def test_page_finalize_event_should_be_dispatched_when_list_was_overflowed
|
|
40
|
+
report = create_report_for_checking_dispatched_event :page_finalize
|
|
41
|
+
report.start_new_page do
|
|
42
|
+
6.times { list(:list).add_row }
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
assert_dispatched_event
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def test_page_finalize_event_should_be_dispatched_when_a_new_page_is_created
|
|
49
|
+
report = create_report_for_checking_dispatched_event :page_finalize
|
|
50
|
+
report.start_new_page do
|
|
51
|
+
list(:list).add_row
|
|
52
|
+
end
|
|
53
|
+
report.start_new_page
|
|
54
|
+
|
|
55
|
+
assert_dispatched_event
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def test_page_finalize_event_should_be_dispatched_when_report_is_finalized
|
|
59
|
+
report = create_report_for_checking_dispatched_event :page_finalize
|
|
60
|
+
report.start_new_page do
|
|
61
|
+
list(:list).add_row
|
|
62
|
+
end
|
|
63
|
+
report.finalize
|
|
64
|
+
|
|
65
|
+
assert_dispatched_event
|
|
66
|
+
end
|
|
10
67
|
end
|
|
@@ -21,7 +21,7 @@ class ThinReports::Core::Shape::List::TestSectionFormat < MiniTest::Unit::TestCa
|
|
|
21
21
|
def test_build
|
|
22
22
|
shape_format = flexmock(:id => 'mock')
|
|
23
23
|
|
|
24
|
-
flexmock(Shape::
|
|
24
|
+
flexmock(Shape::TextBlock::Format).
|
|
25
25
|
should_receive(:build).times(2).and_return(shape_format)
|
|
26
26
|
flexmock(Shape::Basic::Format).
|
|
27
27
|
should_receive(:build).times(1).and_return(shape_format)
|
|
@@ -8,45 +8,52 @@ class ThinReports::Core::Shape::List::TestSectionInterface < MiniTest::Unit::Tes
|
|
|
8
8
|
# Alias
|
|
9
9
|
List = ThinReports::Core::Shape::List
|
|
10
10
|
|
|
11
|
-
def
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
@interface = List::SectionInterface.new(parent, format, :section)
|
|
11
|
+
def create_interface(format_config = {})
|
|
12
|
+
List::SectionInterface.new(flexmock('parent'),
|
|
13
|
+
List::SectionFormat.new(format_config),
|
|
14
|
+
:section)
|
|
16
15
|
end
|
|
17
16
|
|
|
18
|
-
def
|
|
19
|
-
|
|
17
|
+
def test_internal_should_return_instance_of_SectionInternal
|
|
18
|
+
assert_instance_of List::SectionInternal, create_interface.internal
|
|
20
19
|
end
|
|
21
20
|
|
|
22
|
-
def
|
|
23
|
-
|
|
21
|
+
def test_initialize_should_properly_set_the_specified_section_name_to_internal
|
|
22
|
+
assert_equal create_interface.internal.section_name, :section
|
|
24
23
|
end
|
|
25
24
|
|
|
26
|
-
def
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
flexmock(ThinReports::Core::Shape).
|
|
30
|
-
should_receive(:Interface).with(@interface, shape_format).once
|
|
31
|
-
|
|
32
|
-
@interface.manager.init_item(shape_format)
|
|
25
|
+
def test_initialize_should_properly_initialize_manager
|
|
26
|
+
assert_instance_of ThinReports::Core::Shape::Manager::Internal,
|
|
27
|
+
create_interface.manager
|
|
33
28
|
end
|
|
34
29
|
|
|
35
|
-
def
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
30
|
+
def test_height_should_operate_as_delegator_of_internal
|
|
31
|
+
list = create_interface('height' => 100)
|
|
32
|
+
assert_same list.height, list.internal.height
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def test_copied_interface_should_succeed_an_section_name_of_original
|
|
36
|
+
list = create_interface
|
|
37
|
+
assert_same list.copy(flexmock('new_parent')).internal.section_name,
|
|
38
|
+
list.internal.section_name
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def test_copied_interface_should_have_all_the_copies_of_Shape_which_original_holds
|
|
42
|
+
list = create_interface
|
|
43
|
+
copied_list(list) do |new_list|
|
|
44
|
+
assert_equal new_list.manager.shapes.size, 3
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def copied_list(list, &block)
|
|
49
|
+
tblock = ThinReports::Core::Shape::TextBlock
|
|
50
|
+
new_parent = flexmock('new_parent')
|
|
44
51
|
|
|
45
|
-
|
|
46
|
-
|
|
52
|
+
%w( foo bar hoge ).each do |id|
|
|
53
|
+
list.manager.format.shapes[id.to_sym] = tblock::Format.new('type' => 's-tblock', 'id' => id)
|
|
54
|
+
list.item(id).value(10)
|
|
55
|
+
end
|
|
47
56
|
|
|
48
|
-
|
|
49
|
-
@interface.internal.section_name
|
|
50
|
-
assert_same copied_interface.manager.shapes[:foo], copied_foo
|
|
57
|
+
block.call(list.copy(new_parent))
|
|
51
58
|
end
|
|
52
59
|
end
|