File: test-annotation.rb

package info (click to toggle)
ruby-gnome 4.3.4-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 22,320 kB
  • sloc: ruby: 55,206; ansic: 29,012; xml: 333; sh: 229; cpp: 45; makefile: 42
file content (94 lines) | stat: -rw-r--r-- 3,006 bytes parent folder | download | duplicates (3)
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# Copyright (C) 2008-2021  Ruby-GNOME Project Team
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA

class TestAnnotation < Test::Unit::TestCase
  include PopplerTestUtils

  def test_type
    assert_kind_of(Poppler::AnnotType, annotation.type)
  end

  def test_contents
    assert_nil(annotation.contents)
  end

  def test_name
    assert_nil(annotation.name)
  end

  def test_modified
    assert_nil(annotation.modified)
  end

  def test_flags
    assert_kind_of(Poppler::AnnotFlag, annotation.flags)
  end

  def test_color
    assert_nil(annotation.color)
  end

  def test_markup
    # We don't have a PDF that has annotation markup...
    assert_method_defined(Poppler::AnnotMarkup, :label)
    assert_method_defined(Poppler::AnnotMarkup, :popup_is_open?)
    assert_method_defined(Poppler::AnnotMarkup, :opacity)
    assert_method_defined(Poppler::AnnotMarkup, :date)
    assert_method_defined(Poppler::AnnotMarkup, :subject)
    assert_method_defined(Poppler::AnnotMarkup, :reply_to)
    assert_method_defined(Poppler::AnnotMarkup, :external_data)
  end

  def test_text
    # We don't have a PDF that has annotation text...
    assert_method_defined(Poppler::AnnotText, :open?)
    assert_method_defined(Poppler::AnnotText, :icon)
    assert_method_defined(Poppler::AnnotText, :state)
  end

  def test_free_text
    # We don't have a PDF that has annotation free text...
    assert_method_defined(Poppler::AnnotFreeText, :quadding)
    assert_method_defined(Poppler::AnnotFreeText, :callout_line)
  end

  def test_callout_line
    callout_line = Poppler::AnnotCalloutLine.new(true,
                                                 1.1, 2.2, 3.3,
                                                 4.4, 5.5, 6.6)
    assert(callout_line.multiline?)
    assert_equal(1.1, callout_line.x1)
    assert_equal(2.2, callout_line.y1)
    assert_equal(3.3, callout_line.x2)
    assert_equal(4.4, callout_line.y2)
    assert_equal(5.5, callout_line.x3)
    assert_equal(6.6, callout_line.y3)
    assert_equal([true, 1.1, 2.2, 3.3, 4.4, 5.5, 6.6], callout_line.to_a)
  end

  private
  def annotation
    document = Poppler::Document.new(form_pdf)
    page = document[0]
    page.annot_mapping[0].annot
  end

  def assert_method_defined(object, method)
    assert do
      object.method_defined?(method)
    end
  end
end