summaryrefslogtreecommitdiffhomepage
path: root/test/drawing
diff options
context:
space:
mode:
authorRandy Morgan <[email protected]>2012-05-15 11:23:59 +0900
committerRandy Morgan <[email protected]>2012-05-15 11:23:59 +0900
commit2d744ba77906d460b608859c945a5741ec725e42 (patch)
tree0366b619ea15909d230a2fa485a95d395486d6cf /test/drawing
parent2e1e14dd8f91e8a1416faae9501fdf04638104c7 (diff)
downloadcaxlsx-2d744ba77906d460b608859c945a5741ec725e42.tar.gz
caxlsx-2d744ba77906d460b608859c945a5741ec725e42.zip
bring coverage up to 100% and patch a few minor bugs in cell style overrides and misnamed app attributes.
Diffstat (limited to 'test/drawing')
-rw-r--r--test/drawing/tc_axis.rb12
-rw-r--r--test/drawing/tc_chart.rb24
-rw-r--r--test/drawing/tc_pic.rb5
-rw-r--r--test/drawing/tc_scatter_chart.rb5
4 files changed, 40 insertions, 6 deletions
diff --git a/test/drawing/tc_axis.rb b/test/drawing/tc_axis.rb
index 7fe01395..c86d3c50 100644
--- a/test/drawing/tc_axis.rb
+++ b/test/drawing/tc_axis.rb
@@ -2,7 +2,7 @@ require 'tc_helper.rb'
class TestAxis < Test::Unit::TestCase
def setup
- @axis = Axlsx::Axis.new 12345, 54321
+ @axis = Axlsx::Axis.new 12345, 54321, :gridlines => false
end
def teardown
end
@@ -48,5 +48,15 @@ class TestAxis < Test::Unit::TestCase
assert_raise(ArgumentError, "requires valid gridlines") { @axis.gridlines = 'alice' }
assert_nothing_raised("accepts valid crosses") { @axis.gridlines = false }
end
+
+ def test_to_xml_string
+ str = '<?xml version="1.0" encoding="UTF-8"?>'
+ str << '<c:chartSpace xmlns:c="' << Axlsx::XML_NS_C << '" xmlns:a="' << Axlsx::XML_NS_A << '">'
+ doc = Nokogiri::XML(@axis.to_xml_string(str))
+ assert(doc.xpath('//a:noFill'))
+ assert(doc.xpath("//c:crosses[@val='#{@crosses.to_s}']"))
+ assert(doc.xpath("//c:crossAx[@val='#{@crossAx.to_s}']"))
+ assert(doc.xpath("//a:bodyPr[@rot='#{@label_rotation.to_s}']"))
+ end
end
diff --git a/test/drawing/tc_chart.rb b/test/drawing/tc_chart.rb
index 98a72e9c..13c400a3 100644
--- a/test/drawing/tc_chart.rb
+++ b/test/drawing/tc_chart.rb
@@ -22,11 +22,16 @@ class TestChart < Test::Unit::TestCase
@chart.title.text = 'wowzer'
assert_equal(@chart.title.text, "wowzer", "the title text via a string")
assert_equal(@chart.title.cell, nil, "the title cell is nil as we set the title with text.")
- @chart.title.cell = @row.cells.first
+ @chart.title = @row.cells.first
assert_equal(@chart.title.text, "one", "the title text was set via cell reference")
assert_equal(@chart.title.cell, @row.cells.first)
end
+ def test_to_from_marker_access
+ assert(@chart.to.is_a?(Axlsx::Marker))
+ assert(@chart.from.is_a?(Axlsx::Marker))
+ end
+
def test_style
assert_raise(ArgumentError) { @chart.style = 49 }
assert_nothing_raised { @chart.style = 2 }
@@ -34,16 +39,29 @@ class TestChart < Test::Unit::TestCase
end
def test_start_at
- @chart.start_at 15,25
+ @chart.start_at 15, 25
assert_equal(@chart.graphic_frame.anchor.from.col, 15)
assert_equal(@chart.graphic_frame.anchor.from.row, 25)
-
+ @chart.start_at @row.cells.first
+ assert_equal(@chart.graphic_frame.anchor.from.col, 0)
+ assert_equal(@chart.graphic_frame.anchor.from.row, 0)
+ @chart.start_at [5,6]
+ assert_equal(@chart.graphic_frame.anchor.from.col, 5)
+ assert_equal(@chart.graphic_frame.anchor.from.row, 6)
+
end
def test_end_at
@chart.end_at 25, 90
assert_equal(@chart.graphic_frame.anchor.to.col, 25)
assert_equal(@chart.graphic_frame.anchor.to.row, 90)
+ @chart.end_at @row.cells.last
+ assert_equal(@chart.graphic_frame.anchor.to.col, 2)
+ assert_equal(@chart.graphic_frame.anchor.to.row, 0)
+ @chart.end_at [10,11]
+ assert_equal(@chart.graphic_frame.anchor.to.col, 10)
+ assert_equal(@chart.graphic_frame.anchor.to.row, 11)
+
end
def test_add_series
diff --git a/test/drawing/tc_pic.rb b/test/drawing/tc_pic.rb
index 78750cbd..5fc1f1c3 100644
--- a/test/drawing/tc_pic.rb
+++ b/test/drawing/tc_pic.rb
@@ -6,7 +6,7 @@ class TestPic < Test::Unit::TestCase
@p = Axlsx::Package.new
ws = @p.workbook.add_worksheet
@test_img = File.dirname(__FILE__) + "/../../examples/image1.jpeg"
- @image = ws.add_image :image_src => @test_img
+ @image = ws.add_image :image_src => @test_img, :hyperlink => 'https://github.com/randym', :tooltip => "What's up doc?"
end
def teardown
@@ -14,11 +14,12 @@ class TestPic < Test::Unit::TestCase
def test_initialization
assert_equal(@p.workbook.images.first, @image)
+ assert_equal(@image.file_name, 'image1.jpeg')
assert_equal(@image.image_src, @test_img)
end
def test_hyperlink
- assert_equal(@image.hyperlink, nil)
+ assert_equal(@image.hyperlink.href, "https://github.com/randym")
@image.hyperlink = "http://axlsx.blogspot.com"
assert_equal(@image.hyperlink.href, "http://axlsx.blogspot.com")
end
diff --git a/test/drawing/tc_scatter_chart.rb b/test/drawing/tc_scatter_chart.rb
index 30178649..a60bba76 100644
--- a/test/drawing/tc_scatter_chart.rb
+++ b/test/drawing/tc_scatter_chart.rb
@@ -22,6 +22,11 @@ class TestScatterChart < Test::Unit::TestCase
def teardown
end
+ def test_scatter_style
+ @chart.scatterStyle = :marker
+ assert(@chart.scatterStyle == :marker)
+ assert_raise(ArgumentError) { @chart.scatterStyle = :buckshot }
+ end
def test_initialization
assert_equal(@chart.scatterStyle, :lineMarker, "scatterStyle defualt incorrect")
assert_equal(@chart.series_type, Axlsx::ScatterSeries, "series type incorrect")