File: rbpdf_htmlcell_test.rb

package info (click to toggle)
ruby-rbpdf 1.19.0-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 16,252 kB
  • ctags: 704
  • sloc: ruby: 135,876; makefile: 10
file content (64 lines) | stat: -rw-r--r-- 1,217 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
require 'test_helper'

class RbpdfTest < Test::Unit::TestCase
  test "write_html_cell Basic test" do
    pdf = RBPDF.new
    pdf.add_page()

    htmlcontent = '<p>foo</p>'
    pdf.write_html_cell(0, 5, 10, '', htmlcontent, 0, 1)

    pno = pdf.get_page
    assert_equal pno, 1

    y = pdf.get_y
    assert_in_delta 17.3, y, 0.1

    no = pdf.get_num_pages
    assert_equal no, 1
  end

  test "write_html_cell Page Break test 1" do
    pdf = RBPDF.new
    pdf.add_page()

    pdf.set_top_margin(30)

    h = pdf.get_page_height
    pdf.set_y(h - 15)

    htmlcontent = '<p>foo</p>'
    pdf.write_html_cell(0, 5, 10, '', htmlcontent, 0, 1)

    pno = pdf.get_page
    assert_equal pno, 2

    y = pdf.get_y
    assert_in_delta 40.0, y, 0.1

    no = pdf.get_num_pages
    assert_equal no, 2
  end

  test "write_html_cell Page Break test 2" do
    pdf = RBPDF.new
    pdf.add_page()

    pdf.set_top_margin(30)

    h = pdf.get_page_height
    pdf.set_y(h - 15)

    htmlcontent = '<p>foo</p>'
    pdf.write_html_cell(0, 5, 10, '', htmlcontent, "LRBT", 1)

    pno = pdf.get_page
    assert_equal pno, 2

    y = pdf.get_y
    assert_in_delta 40.0, y, 0.1

    no = pdf.get_num_pages
    assert_equal no, 2
  end
end