test/hexapdf/layout/test_text_layouter.rb in hexapdf-0.26.1 vs test/hexapdf/layout/test_text_layouter.rb in hexapdf-0.26.2
- old
+ new
@@ -29,24 +29,27 @@
if obj.item.kind_of?(HexaPDF::Layout::InlineBox)
assert_same(item, obj.item)
else
assert_same(item.style, obj.item.style)
assert_equal(item.items, obj.item.items)
+ assert_equal(item.properties, obj.item.properties)
end
end
def assert_glue(obj, fragment)
assert_kind_of(HexaPDF::Layout::TextLayouter::Glue, obj)
assert_same(fragment.style, obj.item.style)
+ assert_equal(fragment.properties, obj.item.properties)
end
def assert_penalty(obj, penalty, item = nil)
assert_kind_of(HexaPDF::Layout::TextLayouter::Penalty, obj)
assert_equal(penalty, obj.penalty)
if item
assert_same(item.style, obj.item.style)
assert_equal(item.items, obj.item.items)
+ assert_equal(item.properties, obj.item.properties)
end
end
def assert_line_wrapping(result, widths)
rest, lines = *result
@@ -81,16 +84,14 @@
@doc = HexaPDF::Document.new
@font = @doc.fonts.add("Times")
@obj = HexaPDF::Layout::TextLayouter::SimpleTextSegmentation
end
- def setup_fragment(text, style = nil)
- if style
- HexaPDF::Layout::TextFragment.create(text, style)
- else
- HexaPDF::Layout::TextFragment.create(text, font: @font)
- end
+ def setup_fragment(text, style = {font: @font})
+ fragment = HexaPDF::Layout::TextFragment.create(text, style)
+ fragment.properties['key'] = :value
+ fragment
end
it "handles InlineBox objects" do
input = HexaPDF::Layout::InlineBox.create(width: 10, height: 10) {}
result = @obj.call([input, input])
@@ -136,14 +137,16 @@
assert_penalty(result[index],
HexaPDF::Layout::TextLayouter::Penalty::PARAGRAPH_BREAK)
assert_equal([], result[index].item.items)
assert(result[index].item.items.frozen?)
assert_same(frag.style, result[index].item.style)
+ assert_equal(frag.properties, result[index].item.properties)
end
assert_penalty(result[15], HexaPDF::Layout::TextLayouter::Penalty::LINE_BREAK)
assert_equal([], result[15].item.items)
assert(result[15].item.items.frozen?)
assert_same(frag.style, result[15].item.style)
+ assert_equal(frag.properties, result[15].item.properties)
end
it "insert a standard penalty after a hyphen" do
frag = setup_fragment("hy-phen-a-tion - cool!")