summaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorRandy Morgan <[email protected]>2012-06-07 09:03:57 +0900
committerRandy Morgan <[email protected]>2012-06-07 09:03:57 +0900
commit70bf38b72a42b25976f750ff86e7521c356c157e (patch)
tree36fddd470dc1bf157b2c4a2a57bf016523f40793 /test
parent713bd69c8bce9094602fcd731d5e4cce9916b6c6 (diff)
parent2d6d18c2e0b8e1b68adae27500c002cfb4cd01b4 (diff)
downloadcaxlsx-70bf38b72a42b25976f750ff86e7521c356c157e.tar.gz
caxlsx-70bf38b72a42b25976f750ff86e7521c356c157e.zip
Merge branch 'master' into pane
Diffstat (limited to 'test')
-rw-r--r--test/drawing/tc_cat_axis.rb6
-rw-r--r--test/drawing/tc_drawing.rb7
-rw-r--r--test/drawing/tc_num_data.rb6
-rw-r--r--test/drawing/tc_pic.rb19
-rw-r--r--test/workbook/worksheet/tc_data_validation.rb8
5 files changed, 40 insertions, 6 deletions
diff --git a/test/drawing/tc_cat_axis.rb b/test/drawing/tc_cat_axis.rb
index a4f25a1c..6529b45d 100644
--- a/test/drawing/tc_cat_axis.rb
+++ b/test/drawing/tc_cat_axis.rb
@@ -10,7 +10,7 @@ class TestCatAxis < Test::Unit::TestCase
def test_initialization
assert_equal(@axis.auto, 1, "axis auto default incorrect")
assert_equal(@axis.lblAlgn, :ctr, "label align default incorrect")
- assert_equal(@axis.lblOffset, "100%", "label offset default incorrect")
+ assert_equal(@axis.lblOffset, "100", "label offset default incorrect")
end
def test_auto
@@ -24,8 +24,8 @@ class TestCatAxis < Test::Unit::TestCase
end
def test_lblOffset
- assert_raise(ArgumentError, "requires valid label offset") { @axis.lblOffset = 100 }
- assert_nothing_raised("accepts valid label offset") { @axis.lblOffset = "20%" }
+ assert_raise(ArgumentError, "requires valid label offset") { @axis.lblOffset = 'foo' }
+ assert_nothing_raised("accepts valid label offset") { @axis.lblOffset = "20" }
end
end
diff --git a/test/drawing/tc_drawing.rb b/test/drawing/tc_drawing.rb
index ce77ef9b..4d213d56 100644
--- a/test/drawing/tc_drawing.rb
+++ b/test/drawing/tc_drawing.rb
@@ -32,7 +32,12 @@ class TestDrawing < Test::Unit::TestCase
assert_equal(600, image.width)
assert_equal(400, image.height)
end
-
+ def test_add_two_cell_anchor_image
+ src = File.dirname(__FILE__) + "/../../examples/image1.jpeg"
+ image = @ws.add_image(:image_src => src, :start_at=>[0,0], :end_at => [15,0])
+ assert(@ws.drawing.anchors.last.is_a?(Axlsx::TwoCellAnchor))
+ assert(image.is_a?(Axlsx::Pic))
+ end
def test_charts
assert(@ws.drawing.charts.empty?)
chart = @ws.add_chart(Axlsx::Pie3DChart, :title=>"bob", :start_at=>[0,0], :end_at=>[1,1])
diff --git a/test/drawing/tc_num_data.rb b/test/drawing/tc_num_data.rb
index 85bf5614..2549af4d 100644
--- a/test/drawing/tc_num_data.rb
+++ b/test/drawing/tc_num_data.rb
@@ -9,7 +9,11 @@ class TestNumData < Test::Unit::TestCase
def test_initialize
assert_equal(@num_data.format_code, "General")
end
-
+
+ def test_formula_based_cell
+
+ end
+
def test_format_code
assert_raise(ArgumentError) {@num_data.format_code = 7}
assert_nothing_raised {@num_data.format_code = 'foo_bar'}
diff --git a/test/drawing/tc_pic.rb b/test/drawing/tc_pic.rb
index 5fc1f1c3..a892678d 100644
--- a/test/drawing/tc_pic.rb
+++ b/test/drawing/tc_pic.rb
@@ -18,6 +18,25 @@ class TestPic < Test::Unit::TestCase
assert_equal(@image.image_src, @test_img)
end
+ def test_anchor_swapping
+ #swap from one cell to two cell when end_at is specified
+ assert(@image.anchor.is_a?(Axlsx::OneCellAnchor))
+ start_at = @image.anchor.from
+ @image.end_at 10,5
+ assert(@image.anchor.is_a?(Axlsx::TwoCellAnchor))
+ assert_equal(start_at.col, @image.anchor.from.col)
+ assert_equal(start_at.row, @image.anchor.from.row)
+ assert_equal(10,@image.anchor.to.col)
+ assert_equal(5, @image.anchor.to.row)
+
+ #swap from two cell to one cell when width or height are specified
+ @image.width = 200
+ assert(@image.anchor.is_a?(Axlsx::OneCellAnchor))
+ assert_equal(start_at.col, @image.anchor.from.col)
+ assert_equal(start_at.row, @image.anchor.from.row)
+ assert_equal(200, @image.width)
+
+ end
def test_hyperlink
assert_equal(@image.hyperlink.href, "https://github.com/randym")
@image.hyperlink = "http://axlsx.blogspot.com"
diff --git a/test/workbook/worksheet/tc_data_validation.rb b/test/workbook/worksheet/tc_data_validation.rb
index c30ce251..17622d7d 100644
--- a/test/workbook/worksheet/tc_data_validation.rb
+++ b/test/workbook/worksheet/tc_data_validation.rb
@@ -256,4 +256,10 @@ class TestDataValidation < Test::Unit::TestCase
[@promptTitle='Be carful!'][@prompt='Only values from list'][@errorTitle='Wrong input'][@error='Only values from list']
[@showErrorMessage='true'][@allowBlank='true'][@showInputMessage='true'][@showDropDown='true'][@type='list'][@errorStyle='stop']")
end
-end \ No newline at end of file
+
+ def test_empty_attributes
+ v = Axlsx::DataValidation.new
+ assert_equal(nil, v.send(:get_valid_attributes))
+
+ end
+end