summaryrefslogtreecommitdiffhomepage
path: root/test/drawing
diff options
context:
space:
mode:
authorRandy Morgan <[email protected]>2012-02-02 20:26:15 +0900
committerRandy Morgan <[email protected]>2012-02-02 20:26:15 +0900
commit710f5eac4d8d7d017c42348180e9ae0a5e8fec3c (patch)
tree4cce6fc0e445705de8e3cad06152a7455c2942bf /test/drawing
parentd4a00926a263329befc9526a930b274210a13abf (diff)
downloadcaxlsx-710f5eac4d8d7d017c42348180e9ae0a5e8fec3c.tar.gz
caxlsx-710f5eac4d8d7d017c42348180e9ae0a5e8fec3c.zip
Adding in hyperlinking for images as per issue #22
Diffstat (limited to 'test/drawing')
-rw-r--r--test/drawing/tc_hyperlink.rb70
-rw-r--r--test/drawing/tc_pic.rb6
2 files changed, 76 insertions, 0 deletions
diff --git a/test/drawing/tc_hyperlink.rb b/test/drawing/tc_hyperlink.rb
new file mode 100644
index 00000000..a5564c96
--- /dev/null
+++ b/test/drawing/tc_hyperlink.rb
@@ -0,0 +1,70 @@
+require 'test/unit'
+require 'axlsx.rb'
+
+class TestHyperlink < Test::Unit::TestCase
+
+ def setup
+ @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, :hyperlink => "http://axlsx.blogspot.com"
+ @hyperlink = @image.hyperlink
+ end
+
+ def teardown
+ end
+
+
+ def test_href
+ assert_nothing_raised { @hyperlink.href = "http://axlsx.blogspot.com" }
+ assert_equal(@hyperlink.href, "http://axlsx.blogspot.com")
+ end
+
+ def test_invalidUrl
+ assert_nothing_raised { @hyperlink.invalidUrl = "http://axlsx.blogspot.com" }
+ assert_equal(@hyperlink.invalidUrl, "http://axlsx.blogspot.com")
+ end
+
+ def test_tgtFrame
+ assert_nothing_raised { @hyperlink.tgtFrame = "http://axlsx.blogspot.com" }
+ assert_equal(@hyperlink.tgtFrame, "http://axlsx.blogspot.com")
+ end
+
+ def test_tooltip
+ assert_nothing_raised { @hyperlink.tooltip = "http://axlsx.blogspot.com" }
+ assert_equal(@hyperlink.tooltip, "http://axlsx.blogspot.com")
+ end
+
+ def test_invalidUrl
+ assert_nothing_raised { @hyperlink.invalidUrl = "http://axlsx.blogspot.com" }
+ assert_equal(@hyperlink.invalidUrl, "http://axlsx.blogspot.com")
+ end
+
+ def test_action
+ assert_nothing_raised { @hyperlink.action = "flee" }
+ assert_equal(@hyperlink.action, "flee")
+ end
+
+ def test_endSnd
+ assert_nothing_raised { @hyperlink.endSnd = "true" }
+ assert_raise(ArgumentError) {@hyperlink.endSnd = "bob"}
+ assert_equal(@hyperlink.endSnd, "true")
+ end
+
+ def test_highlightClick
+ assert_nothing_raised { @hyperlink.highlightClick = false }
+ assert_raise(ArgumentError) {@hyperlink.highlightClick = "bob"}
+ assert_equal(@hyperlink.highlightClick, false )
+ end
+
+ def test_id
+ assert_equal(@hyperlink.send(:id), 2)
+ end
+
+ def test_history
+ assert_nothing_raised { @hyperlink.history = false }
+ assert_raise(ArgumentError) {@hyperlink.history = "bob"}
+ assert_equal(@hyperlink.history, false )
+ end
+
+end
diff --git a/test/drawing/tc_pic.rb b/test/drawing/tc_pic.rb
index 2d6c603d..9e4d62e6 100644
--- a/test/drawing/tc_pic.rb
+++ b/test/drawing/tc_pic.rb
@@ -17,6 +17,12 @@ class TestPic < Test::Unit::TestCase
assert_equal(@p.workbook.images.first, @image)
assert_equal(@image.image_src, @test_img)
end
+
+ def test_hyperlink
+ assert_equal(@image.hyperlink, nil)
+ @image.hyperlink = "http://axlsx.blogspot.com"
+ assert_equal(@image.hyperlink.href, "http://axlsx.blogspot.com")
+ end
def test_name
assert_raise(ArgumentError) { @image.name = 49 }