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
95
96
97
98
99
100
|
require 'tc_helper.rb'
class TestVmlDrawing < Test::Unit::TestCase
def setup
p = Axlsx::Package.new
wb = p.workbook
@ws = wb.add_worksheet
@ws.add_comment :ref => 'A1', :text => 'penut machine', :author => 'crank'
@ws.add_comment :ref => 'C3', :text => 'rust bucket', :author => 'PO'
@comments = @ws.comments
end
def test_initialize
assert_raise(ArgumentError) { Axlsx::VmlDrawing.new }
end
def test_row
shape = @comments.first.vml_shape
assert_equal(shape.row, 0)
shape = @comments.last.vml_shape
assert_equal(shape.row, 2)
end
def test_column
shape = @comments.first.vml_shape
assert_equal(shape.column, 0)
shape = @comments.last.vml_shape
assert_equal(shape.column, 2)
end
def test_left_column
shape = @comments.first.vml_shape
shape.left_column = 3
assert(shape.left_column == 3)
assert_raise(ArgumentError) { shape.left_column = [] }
end
def test_left_offset
shape = @comments.first.vml_shape
shape.left_offset = 3
assert(shape.left_offset == 3)
assert_raise(ArgumentError) { shape.left_offset = [] }
end
def test_right_column
shape = @comments.first.vml_shape
shape.right_column = 3
assert(shape.right_column == 3)
assert_raise(ArgumentError) { shape.right_column = [] }
end
def test_right_offset
shape = @comments.first.vml_shape
shape.right_offset = 3
assert(shape.right_offset == 3)
assert_raise(ArgumentError) { shape.right_offset = [] }
end
def test_top_offset
shape = @comments.first.vml_shape
shape.top_offset = 3
assert(shape.top_offset == 3)
assert_raise(ArgumentError) { shape.top_offset = [] }
end
def test_bottom_offset
shape = @comments.first.vml_shape
shape.bottom_offset = 3
assert(shape.bottom_offset == 3)
assert_raise(ArgumentError) { shape.bottom_offset = [] }
end
def test_bottom_row
shape = @comments.first.vml_shape
shape.bottom_row = 3
assert(shape.bottom_row == 3)
assert_raise(ArgumentError) { shape.bottom_row = [] }
end
def test_top_row
shape = @comments.first.vml_shape
shape.top_row = 3
assert(shape.top_row == 3)
assert_raise(ArgumentError) { shape.top_row = [] }
end
def test_to_xml_string
str = @comments.vml_drawing.to_xml_string()
doc = Nokogiri::XML(str)
assert_equal(doc.xpath("//v:shape").size, 2)
@comments.each do |comment|
shape = comment.vml_shape
assert(doc.xpath("//v:shape/x:ClientData/x:Row[text()='#{shape.row}']").size == 1)
assert(doc.xpath("//v:shape/x:ClientData/x:Column[text()='#{shape.column}']").size == 1)
assert(doc.xpath("//v:shape/x:ClientData/x:Anchor[text()='#{shape.left_column}, #{shape.left_offset}, #{shape.top_row}, #{shape.top_offset}, #{shape.right_column}, #{shape.right_offset}, #{shape.bottom_row}, #{shape.bottom_offset}']").size == 1)
end
end
end
|