From 713bd69c8bce9094602fcd731d5e4cce9916b6c6 Mon Sep 17 00:00:00 2001 From: Randy Morgan Date: Thu, 7 Jun 2012 08:58:01 +0900 Subject: patch unit tests for sheet view and pane serialization. --- test/workbook/worksheet/tc_pane.rb | 23 +++-------------------- test/workbook/worksheet/tc_sheet_view.rb | 19 ++++++++++--------- 2 files changed, 13 insertions(+), 29 deletions(-) diff --git a/test/workbook/worksheet/tc_pane.rb b/test/workbook/worksheet/tc_pane.rb index 7cc06b49..e2bd1519 100644 --- a/test/workbook/worksheet/tc_pane.rb +++ b/test/workbook/worksheet/tc_pane.rb @@ -82,24 +82,7 @@ class TestPane < Test::Unit::TestCase end def test_to_xml - p = Axlsx::Package.new - @ws = p.workbook.add_worksheet :name => "sheetview" - @ws.sheet_view do |vs| - vs.pane do |p| - p.active_pane = :top_left - p.state = :frozen_split - p.x_split = 255 - p.y_split = 563 - p.top_left_cell = 'B5' - end - end - - doc = Nokogiri::XML.parse(@ws.to_xml_string) - - assert_equal(1, doc.xpath("//xmlns:worksheet/xmlns:sheetViews/xmlns:sheetView/xmlns:pane[@ySplit='563'] - [@xSplit='255'][@topLeftCell='B5'][@state='frozenSplit'][@activePane='topLeftCell']").size) - - assert doc.xpath( "//xmlns:worksheet/xmlns:sheetViews/xmlns:sheetView/xmlns:pane[@ySplit='563'] - [@xSplit='255'][@topLeftCell='B5'][@state='frozenSplit'][@activePane='topLeftCell']") + doc = Nokogiri::XML.parse(@pane.to_xml_string) + assert_equal(1, doc.xpath("//pane[@ySplit=2][@xSplit='2'][@topLeftCell='A2'][@state='frozen'][@activePane='bottomLeft']").size) end -end \ No newline at end of file +end diff --git a/test/workbook/worksheet/tc_sheet_view.rb b/test/workbook/worksheet/tc_sheet_view.rb index d5097b11..12b18c7e 100644 --- a/test/workbook/worksheet/tc_sheet_view.rb +++ b/test/workbook/worksheet/tc_sheet_view.rb @@ -203,20 +203,21 @@ class TestSheetView < Test::Unit::TestCase [@zoomScale='100'][@workbookViewId='0'][@zoomScaleSheetLayoutView='0'][@zoomScalePageLayoutView='0'] [@zoomScaleNormal='0'][@view='page_break_preview']").size) - assert doc.xpath("//xmlns:worksheet/xmlns:sheetViews/xmlns:sheetView[@topLeftCell=''][@colorId=''] + assert_equal(1, doc.xpath("//xmlns:worksheet/xmlns:sheetViews/xmlns:sheetView[@topLeftCell=''][@colorId=''] [@tabSelected='false'][@showWhiteSpace='false'][@showOutlineSymbols='false'][@showFormulas='false'] [@rightToLeft='false'][@windowProtection='false'][@showZeros='true'][@showRuler='true'] [@showRowColHeaders='true'][@showGridLines='true'][@defaultGridColor='true'] [@zoomScale='100'][@workbookViewId='0'][@zoomScaleSheetLayoutView='0'][@zoomScalePageLayoutView='0'] - [@zoomScaleNormal='0'][@view='page_break_preview']") + [@zoomScaleNormal='0'][@view='page_break_preview']").size) end def test_to_xml_string_show_selection p = Axlsx::Package.new - @ws = p.workbook.add_worksheet :name => "sheetview" - - doc = Nokogiri::XML(@ws.to_xml_string) - assert_equal(1, doc.xpath('//xmlns:worksheet/xmlns:sheetViews/xmlns:sheetView/xmlns:selection[@activeCell="A1"]').size) - assert_equal(1, doc.xpath('//xmlns:worksheet/xmlns:sheetViews/xmlns:sheetView/xmlns:selection[@sqref="A1"]').size) - end -end \ No newline at end of file + sheet_view = p.workbook.add_worksheet(:name => "sheetview") do |ws| + ws.sheet_view { |sv| sv.view = :page_break_preview } + end.sheet_view + doc = Nokogiri::XML(sheet_view.to_xml_string) + assert_equal(1, doc.xpath('//selection[@activeCell="A1"]').size) + assert_equal(1, doc.xpath('//selection[@sqref="A1"]').size) + end +end -- cgit v1.2.3