Sha256: c0712a9f1a3b57e1e1d7d2d139d382b27954fd45db90d34a518f8b12da591b02
Contents?: true
Size: 1.6 KB
Versions: 1
Compression:
Stored size: 1.6 KB
Contents
# -*- encoding: utf-8 -*- require 'test_helper' require 'hexapdf/layout/inline_box' describe HexaPDF::Layout::InlineBox do before do @box = HexaPDF::Layout::InlineBox.create(width: 10, height: 15, style: {margin: [15, 10]}) end it "needs a box to wrap and an optional alignment on initialization" do ibox = HexaPDF::Layout::InlineBox.new(@box) assert_equal(@box, ibox.box) assert_equal(:baseline, ibox.valign) ibox = HexaPDF::Layout::InlineBox.new(@box, valign: :top) assert_equal(:top, ibox.valign) end it "draws the wrapped box at the correct position" do canvas = Object.new block = lambda do |c, x, y| assert_equal(canvas, c) assert_equal(10, x) assert_equal(15, y) end @box.box.stub(:draw, block) do @box.draw(canvas, 0, 0) end end it "returns true if the inline box is empty with no drawing operations" do assert(@box.empty?) refute(HexaPDF::Layout::InlineBox.create(width: 10, height: 15) {}.empty?) end describe "valign" do it "has a default value of :baseline" do assert_equal(:baseline, @box.valign) end it "can be changed on creation" do box = HexaPDF::Layout::InlineBox.create(width: 10, height: 15, valign: :test) assert_equal(:test, box.valign) end end it "returns the width including margins" do assert_equal(30, @box.width) end it "returns the height including margins" do assert_equal(45, @box.height) end it "returns 0 for x_min" do assert_equal(0, @box.x_min) end it "returns width for x_max" do assert_equal(@box.width, @box.x_max) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
hexapdf-0.7.0 | test/hexapdf/layout/test_inline_box.rb |