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
|
@@ -8,23 +8,48 @@ class ThinReports::Core::Shape::List::TestSectionInternal < MiniTest::Unit::Test
|
|
|
8
8
|
# Alias
|
|
9
9
|
List = ThinReports::Core::Shape::List
|
|
10
10
|
|
|
11
|
-
def
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
:relative_left => 100,
|
|
15
|
-
:relative_top => 200,
|
|
16
|
-
:svg_tag => 'g')
|
|
17
|
-
@internal = List::SectionInternal.new(parent, format)
|
|
11
|
+
def create_internal(format_config = {})
|
|
12
|
+
List::SectionInternal.new(flexmock('parent'),
|
|
13
|
+
List::SectionFormat.new(format_config))
|
|
18
14
|
end
|
|
19
15
|
|
|
20
|
-
def
|
|
21
|
-
|
|
22
|
-
|
|
16
|
+
def test_height_should_operate_as_delegator_of_format
|
|
17
|
+
list = create_internal('height' => 100)
|
|
18
|
+
assert_same list.height, list.format.height
|
|
23
19
|
end
|
|
24
20
|
|
|
25
|
-
def
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
21
|
+
def test_relative_left_should_operate_as_delegator_of_format
|
|
22
|
+
list = create_internal('translate' => {'x' => 10})
|
|
23
|
+
assert_same list.relative_left, list.format.relative_left
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def test_relative_top_should_operate_as_delegator_of_format
|
|
27
|
+
list = create_internal('translate' => {'y' => 10})
|
|
28
|
+
assert_same list.relative_top, list.format.relative_top
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def test_svg_tag_should_operate_as_delegator_of_format
|
|
32
|
+
list = create_internal('svg' => {'tag' => 'g'})
|
|
33
|
+
assert_same list.svg_tag, list.format.svg_tag
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def test_move_top_to_should_properly_set_value_to_states_as_relative_top
|
|
37
|
+
list = create_internal
|
|
38
|
+
list.move_top_to(200)
|
|
39
|
+
|
|
40
|
+
assert_equal list.states[:relative_top], 200
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def test_relative_position_should_return_Array_included_coordinates
|
|
44
|
+
list = create_internal('translate' => {'x' => 100, 'y' => 200})
|
|
45
|
+
|
|
46
|
+
assert_equal list.relative_position, [100, 200]
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def test_Y_coordinate_which_relative_position_returns_should_be_calculated_position_with_relative_top_of_states
|
|
50
|
+
list = create_internal('translate' => {'x' => 100, 'y' => 100})
|
|
51
|
+
list.move_top_to(50)
|
|
52
|
+
|
|
53
|
+
assert_equal list.relative_position.last, 150
|
|
29
54
|
end
|
|
30
55
|
end
|
|
@@ -5,36 +5,30 @@ require 'test/unit/helper'
|
|
|
5
5
|
class ThinReports::Core::Shape::Manager::TestFormat < MiniTest::Unit::TestCase
|
|
6
6
|
include ThinReports::TestHelpers
|
|
7
7
|
|
|
8
|
-
class TestFormat < ThinReports::Core::Shape::Manager::Format
|
|
9
|
-
end
|
|
8
|
+
class TestFormat < ThinReports::Core::Shape::Manager::Format; end
|
|
10
9
|
|
|
11
|
-
def
|
|
10
|
+
def test_identifier_should_return_the_same_as_object_id_when_id_is_not_given
|
|
12
11
|
format = TestFormat.new({})
|
|
13
12
|
assert_equal format.identifier, format.object_id
|
|
14
13
|
end
|
|
15
14
|
|
|
16
|
-
def
|
|
17
|
-
|
|
18
|
-
assert_equal format.identifier, :any_id
|
|
15
|
+
def test_identifier_should_return_the_specified_id_when_id_is_given
|
|
16
|
+
assert_equal TestFormat.new({}, :any_id).identifier, :any_id
|
|
19
17
|
end
|
|
20
18
|
|
|
21
|
-
def
|
|
22
|
-
|
|
23
|
-
assert_instance_of ThinReports::Core::OrderedHash, format.shapes
|
|
19
|
+
def test_shapes_should_return_instance_of_OrderedHash
|
|
20
|
+
assert_instance_of ThinReports::Core::OrderedHash, TestFormat.new({}).shapes
|
|
24
21
|
end
|
|
25
22
|
|
|
26
|
-
def
|
|
23
|
+
def test_find_shape_should_return_format_of_shape_when_shape_is_found
|
|
27
24
|
format = TestFormat.new({}) do |f|
|
|
28
|
-
f.shapes[:foo] = 'foo'
|
|
29
|
-
|
|
25
|
+
f.shapes[:foo] = ThinReports::Core::Shape::TextBlock::Format.new('id' => 'foo',
|
|
26
|
+
'type' => 's-tblock')
|
|
30
27
|
end
|
|
31
|
-
|
|
32
|
-
assert_equal format.find_shape(:foo), 'foo'
|
|
33
|
-
assert_equal format.find_shape(:boo), 'boo'
|
|
28
|
+
assert_equal format.find_shape(:foo).id, 'foo'
|
|
34
29
|
end
|
|
35
30
|
|
|
36
|
-
def
|
|
37
|
-
|
|
38
|
-
assert_nil format.find_shape(:unknown)
|
|
31
|
+
def test_find_shape_should_return_nil_when_shape_is_not_found
|
|
32
|
+
assert_nil TestFormat.new({}).find_shape(:unknown)
|
|
39
33
|
end
|
|
40
34
|
end
|
|
@@ -5,133 +5,167 @@ require 'test/unit/helper'
|
|
|
5
5
|
class ThinReports::Core::Shape::Manager::TestInternal < MiniTest::Unit::TestCase
|
|
6
6
|
include ThinReports::TestHelpers
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
8
|
+
# Alias
|
|
9
|
+
Shape = ThinReports::Core::Shape
|
|
10
|
+
|
|
11
|
+
def create_shape_format(type, id, other_config = {})
|
|
12
|
+
Shape::Format(type).new({'id' => id,
|
|
13
|
+
'type' => type,
|
|
14
|
+
'display' => 'true'}.merge(other_config))
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def create_internal(&block)
|
|
18
|
+
report = create_basic_report('basic_layout1.tlf')
|
|
19
|
+
format = report.layout.format
|
|
18
20
|
|
|
19
|
-
|
|
21
|
+
# Add to default dummy shapes.
|
|
22
|
+
format.shapes[:t1] = create_shape_format('s-tblock', 't1', 'value' => '')
|
|
23
|
+
format.shapes[:t2] = create_shape_format('s-tblock', 't2', 'value' => '')
|
|
24
|
+
format.shapes[:ls] = create_shape_format('s-list', 'ls')
|
|
20
25
|
|
|
21
|
-
|
|
22
|
-
with(:tblock).and_return(@format_tblock)
|
|
23
|
-
layout_format.should_receive(:find_shape).
|
|
24
|
-
with(:list).and_return(@format_list)
|
|
25
|
-
layout_format.should_receive(:find_shape).
|
|
26
|
-
with(:rect).and_return(@format_rect)
|
|
27
|
-
layout_format.should_receive(:find_shape).
|
|
28
|
-
with(:unknown).and_return(nil)
|
|
26
|
+
block.call(format) if block_given?
|
|
29
27
|
|
|
30
|
-
|
|
31
|
-
@init_item_handler)
|
|
28
|
+
report.start_new_page.manager
|
|
32
29
|
end
|
|
33
30
|
|
|
34
|
-
def
|
|
35
|
-
|
|
36
|
-
assert_same @manager.find_format('list'), @format_list
|
|
37
|
-
assert_nil @manager.find_format(:unknown)
|
|
31
|
+
def test_find_format_should_return_format_with_the_specified_Symbol_id
|
|
32
|
+
assert_equal create_internal.find_format(:t1).id, 't1'
|
|
38
33
|
end
|
|
39
34
|
|
|
40
|
-
def
|
|
41
|
-
|
|
42
|
-
assert_equal @manager.valid_type?('s-list'), true
|
|
43
|
-
# With only limitation.
|
|
44
|
-
assert_equal @manager.valid_type?('s-list', :only => 's-list'), true
|
|
45
|
-
assert_equal @manager.valid_type?('s-list', :only => 'other'), false
|
|
46
|
-
# With except limitation.
|
|
47
|
-
assert_equal @manager.valid_type?('s-list', :except => 'other'), true
|
|
48
|
-
assert_equal @manager.valid_type?('s-list', :except => 's-list'), false
|
|
35
|
+
def test_find_format_should_return_format_with_the_specified_String_id
|
|
36
|
+
assert_equal create_internal.find_format('t2').id, 't2'
|
|
49
37
|
end
|
|
50
38
|
|
|
51
|
-
def
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
should_receive(:call).times(0)
|
|
63
|
-
|
|
64
|
-
# Should must not be initialized when given a initialized item.
|
|
65
|
-
assert_same @manager.find_item(:tblock), @item_tblock
|
|
39
|
+
def test_find_format_should_return_nil_when_format_with_specified_id_is_not_found
|
|
40
|
+
assert_nil create_internal.find_format(:unknown)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def test_find_item_should_return_shape_with_the_specified_id
|
|
44
|
+
assert_instance_of Shape::TextBlock::Interface, create_internal.find_item(:t1)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def test_find_item_should_return_shape_in_shapes_registry_when_the_specified_shape_exists_in_registry
|
|
48
|
+
internal = create_internal
|
|
49
|
+
internal.find_item(:t1)
|
|
66
50
|
|
|
67
|
-
|
|
68
|
-
|
|
51
|
+
assert_same internal.find_item(:t1), internal.shapes[:t1]
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def test_find_item_should_return_shape_when_passing_in_the_specified_only_filter
|
|
55
|
+
internal = create_internal
|
|
56
|
+
assert_equal internal.find_item(:t1, :only => 's-tblock').id, 't1'
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def test_find_item_should_return_nil_when_not_passing_in_the_specified_only_filter
|
|
60
|
+
internal = create_internal
|
|
61
|
+
assert_nil internal.find_item(:t1, :only => 's-list')
|
|
69
62
|
end
|
|
70
63
|
|
|
71
|
-
def
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
64
|
+
def test_find_item_should_return_shape_when_passing_in_the_specified_except_filter
|
|
65
|
+
internal = create_internal
|
|
66
|
+
assert_equal internal.find_item(:ls, :except => 's-tblock').id, 'ls'
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def test_find_item_should_return_shape_when_not_passing_in_the_specified_except_filter
|
|
70
|
+
internal = create_internal
|
|
71
|
+
assert_nil internal.find_item(:ls, :except => 's-list')
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def test_final_shape_should_return_nil_when_shape_is_not_found
|
|
75
|
+
internal = create_internal
|
|
76
|
+
assert_nil internal.final_shape(:unknown)
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def test_final_shape_should_return_nil_when_shape_is_stored_in_shapes_and_hidden
|
|
80
|
+
internal = create_internal
|
|
81
|
+
internal.find_item(:t1).hide
|
|
75
82
|
|
|
76
|
-
|
|
77
|
-
|
|
83
|
+
assert_nil internal.final_shape(:t1)
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
def test_final_shape_should_return_shape_when_shape_is_stored_in_shapes_and_not_Block
|
|
87
|
+
internal = create_internal do |f|
|
|
88
|
+
f.shapes[:rect] = create_shape_format('s-rect', 'rect')
|
|
89
|
+
end
|
|
90
|
+
internal.find_item(:rect)
|
|
78
91
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
92
|
+
assert_equal internal.final_shape(:rect).id, 'rect'
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def test_final_shape_should_return_shape_when_shape_is_stored_in_shapes_and_TextBlock_with_value
|
|
96
|
+
internal = create_internal
|
|
97
|
+
internal.find_item(:t1).value('value')
|
|
82
98
|
|
|
83
|
-
|
|
84
|
-
assert_nil @manager.find_item(:tblock, :only => 's-list')
|
|
99
|
+
assert_equal internal.final_shape(:t1).id, 't1'
|
|
85
100
|
end
|
|
86
101
|
|
|
87
|
-
def
|
|
88
|
-
|
|
102
|
+
def test_final_shape_should_return_nil_when_shape_is_stored_in_shapes_and_TextBlock_with_no_value
|
|
103
|
+
internal = create_internal
|
|
104
|
+
internal.find_item(:t2)
|
|
89
105
|
|
|
90
|
-
|
|
106
|
+
assert_nil internal.final_shape(:t2)
|
|
91
107
|
end
|
|
92
108
|
|
|
93
|
-
def
|
|
94
|
-
|
|
109
|
+
def test_final_shape_should_return_shape_when_shape_is_stored_in_shapes_and_ImageBlock_with_src
|
|
110
|
+
internal = create_internal do |f|
|
|
111
|
+
f.shapes[:iblock] = create_shape_format('s-iblock', 'iblock')
|
|
112
|
+
end
|
|
113
|
+
internal.find_item(:iblock).src('/path/to/image.png')
|
|
95
114
|
|
|
96
|
-
|
|
115
|
+
assert_equal internal.final_shape(:iblock).id, 'iblock'
|
|
97
116
|
end
|
|
98
117
|
|
|
99
|
-
def
|
|
100
|
-
|
|
118
|
+
def test_final_shape_should_return_nil_when_shape_is_stored_in_shapes_and_ImageBlock_with_no_src
|
|
119
|
+
internal = create_internal do |f|
|
|
120
|
+
f.shapes[:iblock] = create_shape_format('s-iblock', 'iblock')
|
|
121
|
+
end
|
|
101
122
|
|
|
102
|
-
|
|
103
|
-
|
|
123
|
+
assert_nil internal.final_shape(:iblock)
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
def test_final_shape_should_return_nil_when_shape_isnot_stored_in_shapes_and_hidden
|
|
127
|
+
internal = create_internal do |f|
|
|
128
|
+
f.shapes[:t3] = create_shape_format('s-tblock', 't3', 'display' => 'false')
|
|
129
|
+
end
|
|
104
130
|
|
|
105
|
-
|
|
106
|
-
assert_same @manager.final_shape(:rect), @item_rect
|
|
131
|
+
assert_nil internal.final_shape(:t3)
|
|
107
132
|
end
|
|
108
133
|
|
|
109
|
-
def
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
134
|
+
def test_final_shape_should_return_shape_when_shape_isnot_stored_in_shapes_and_not_Block
|
|
135
|
+
internal = create_internal do |f|
|
|
136
|
+
f.shapes[:rect] = create_shape_format('s-rect', 'rect')
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
assert_equal internal.final_shape(:rect).id, 'rect'
|
|
114
140
|
end
|
|
115
141
|
|
|
116
|
-
def
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
142
|
+
def test_final_shape_should_return_nil_when_shape_isnot_stored_in_shapes_and_ImageBlock
|
|
143
|
+
internal = create_internal do |f|
|
|
144
|
+
f.shapes[:iblock] = create_shape_format('s-iblock', 'iblock')
|
|
145
|
+
end
|
|
120
146
|
|
|
121
|
-
|
|
122
|
-
|
|
147
|
+
assert_nil internal.final_shape(:iblock)
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
def test_final_shape_should_return_shape_when_shape_isnot_stored_in_shapes_and_TextBlock_with_value
|
|
151
|
+
internal = create_internal do |f|
|
|
152
|
+
f.shapes[:t3] = create_shape_format('s-tblock', 't3', 'value' => 'default value')
|
|
153
|
+
end
|
|
123
154
|
|
|
124
|
-
|
|
155
|
+
assert_equal internal.final_shape(:t3).id, 't3'
|
|
125
156
|
end
|
|
126
157
|
|
|
127
|
-
def
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
158
|
+
def test_final_shape_should_return_shape_when_shape_isnot_stored_in_shapes_and_TextBlock_with_reference
|
|
159
|
+
internal = create_internal do |f|
|
|
160
|
+
f.shapes[:t3] = create_shape_format('s-tblock', 't3', 'ref-id' => 't1')
|
|
161
|
+
end
|
|
131
162
|
|
|
132
|
-
|
|
133
|
-
|
|
163
|
+
assert_equal internal.final_shape(:t3).id, 't3'
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
def test_final_shape_should_return_nil_when_shape_isnot_stored_in_shapes_and_TextBlock_with_no_value_no_reference
|
|
167
|
+
internal = create_internal
|
|
134
168
|
|
|
135
|
-
|
|
169
|
+
assert_nil internal.final_shape(:t1)
|
|
136
170
|
end
|
|
137
171
|
end
|
|
@@ -8,102 +8,109 @@ class ThinReports::Core::Shape::Manager::TestTarget < MiniTest::Unit::TestCase
|
|
|
8
8
|
# Alias
|
|
9
9
|
Shape = ThinReports::Core::Shape
|
|
10
10
|
|
|
11
|
-
class TestFormat < Shape::Manager::Format; end
|
|
12
|
-
|
|
13
11
|
class TestManager
|
|
14
12
|
include Shape::Manager::Target
|
|
15
13
|
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
attr_reader :layout, :report
|
|
15
|
+
|
|
16
|
+
def initialize(report, layout)
|
|
17
|
+
@report = report
|
|
18
|
+
@layout = layout
|
|
19
|
+
|
|
20
|
+
initialize_manager(layout.format) do |f|
|
|
18
21
|
Shape::Interface(self, f)
|
|
19
22
|
end
|
|
20
23
|
end
|
|
21
24
|
end
|
|
22
25
|
|
|
23
|
-
def
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
def create_shape_format(type, id)
|
|
27
|
+
Shape::Format(type).new('id' => id, 'type' => type)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def create_manager
|
|
31
|
+
report = create_basic_report('basic_layout1.tlf')
|
|
32
|
+
layout = report.layout
|
|
30
33
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
# Add to dummy shapes.
|
|
35
|
+
layout.format.shapes[:t1] = create_shape_format('s-tblock', 't1')
|
|
36
|
+
layout.format.shapes[:t2] = create_shape_format('s-tblock', 't2')
|
|
37
|
+
layout.format.shapes[:ls] = create_shape_format('s-list', 'ls')
|
|
38
|
+
|
|
39
|
+
TestManager.new(report, layout)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def test_manager_should_return_instance_of_ManagerInternal
|
|
43
|
+
assert_instance_of Shape::Manager::Internal, create_manager.manager
|
|
37
44
|
end
|
|
38
45
|
|
|
39
|
-
def
|
|
40
|
-
|
|
46
|
+
def test_item_should_properly_return_shape_with_the_specified_Symbol_id
|
|
47
|
+
assert_equal create_manager.item(:t1).id, 't1'
|
|
41
48
|
end
|
|
42
49
|
|
|
43
|
-
def
|
|
44
|
-
|
|
50
|
+
def test_item_should_properly_return_shape_with_the_specified_String_id
|
|
51
|
+
assert_equal create_manager.item('t2').id, 't2'
|
|
45
52
|
end
|
|
46
53
|
|
|
47
|
-
def
|
|
54
|
+
def test_item_should_raise_when_the_shape_with_the_specified_id_is_not_found
|
|
48
55
|
assert_raises ThinReports::Errors::UnknownItemId do
|
|
49
|
-
|
|
56
|
+
create_manager.item(:unknown)
|
|
50
57
|
end
|
|
51
58
|
end
|
|
52
59
|
|
|
53
|
-
def
|
|
60
|
+
def test_item_should_set_an_shape_as_argument_when_a_block_is_given
|
|
61
|
+
id = nil
|
|
62
|
+
create_manager.item(:t1) {|s| id = s.id }
|
|
63
|
+
assert_equal id, 't1'
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def test_item_should_raise_when_type_of_shape_with_the_specified_id_is_list
|
|
54
67
|
assert_raises ThinReports::Errors::UnknownItemId do
|
|
55
|
-
|
|
68
|
+
create_manager.item(:ls)
|
|
56
69
|
end
|
|
57
70
|
end
|
|
58
71
|
|
|
59
|
-
def
|
|
60
|
-
|
|
61
|
-
value(1000)
|
|
62
|
-
end
|
|
63
|
-
assert_equal @manager.item(:tblock1).value, 1000
|
|
72
|
+
def test_list_should_properly_return_list_with_the_specified_Symbol_id
|
|
73
|
+
assert_equal create_manager.list(:ls).id, 'ls'
|
|
64
74
|
end
|
|
65
75
|
|
|
66
|
-
def
|
|
67
|
-
|
|
68
|
-
t.value(1000)
|
|
69
|
-
end
|
|
70
|
-
assert_equal @manager.item(:tblock2).value, 1000
|
|
76
|
+
def test_list_should_properly_return_list_with_the_specified_String_id
|
|
77
|
+
assert_equal create_manager.list('ls').id, 'ls'
|
|
71
78
|
end
|
|
72
79
|
|
|
73
|
-
def
|
|
80
|
+
def test_list_should_raise_when_type_of_shape_with_the_specified_id_is_not_list
|
|
74
81
|
assert_raises ThinReports::Errors::UnknownItemId do
|
|
75
|
-
|
|
82
|
+
create_manager.list(:t1)
|
|
76
83
|
end
|
|
77
84
|
end
|
|
78
85
|
|
|
79
|
-
def
|
|
80
|
-
|
|
81
|
-
|
|
86
|
+
def test_values_should_properly_set_values_to_shapes_with_specified_id
|
|
87
|
+
manager = create_manager
|
|
88
|
+
manager.values(:t1 => 1000, 't2' => 'value')
|
|
82
89
|
|
|
83
|
-
|
|
84
|
-
assert_includes @manager.manager.lists, :list
|
|
90
|
+
assert_equal [manager.item(:t1).value, manager.item(:t2).value], [1000, 'value']
|
|
85
91
|
end
|
|
86
92
|
|
|
87
|
-
def
|
|
93
|
+
def test_items_should_show_deprecation_warning
|
|
88
94
|
out, err = capture_io do
|
|
89
|
-
|
|
95
|
+
create_manager.items(:t1 => 1000)
|
|
90
96
|
end
|
|
91
97
|
assert_match %r!DEPRECATION!, err
|
|
92
98
|
end
|
|
93
99
|
|
|
94
|
-
def
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
assert_equal
|
|
100
|
+
def test_item_exists_asker_should_return_true_when_shape_with_specified_Symbol_id_is_found
|
|
101
|
+
assert_equal create_manager.item_exists?(:t1), true
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
def test_item_exists_asker_should_return_true_when_shape_with_specified_String_id_is_found
|
|
105
|
+
assert_equal create_manager.item_exists?('t2'), true
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
def test_item_exists_asker_should_return_false_when_shape_with_specified_id_not_found
|
|
109
|
+
assert_equal create_manager.item_exists?('unknown'), false
|
|
100
110
|
end
|
|
101
111
|
|
|
102
|
-
def
|
|
103
|
-
|
|
104
|
-
assert_equal
|
|
105
|
-
assert_equal @manager.item_exists?(:unknown), false
|
|
106
|
-
# Alias method
|
|
107
|
-
assert_equal @manager.exists?(:tblock1), true
|
|
112
|
+
def test_exists_asker_should_operate_like_as_item_exists_asker
|
|
113
|
+
manager = create_manager
|
|
114
|
+
assert_equal manager.exists?(:unknown), manager.item_exists?(:unknown)
|
|
108
115
|
end
|
|
109
116
|
end
|