Browse Source

bug 58325: enable TestXSSFShape unit tests.

pull/1557/head
Antony Liu 3 months ago
parent
commit
68d6d2546a
  1. 3
      OpenXmlFormats/Drawing/SpreadsheetDrawing.cs
  2. 37
      testcases/ooxml/XSSF/UserModel/TestUnfixedBugs.cs
  3. 68
      testcases/ooxml/XSSF/UserModel/TestXSSFShape.cs

3
OpenXmlFormats/Drawing/SpreadsheetDrawing.cs

@ -1394,7 +1394,8 @@ namespace NPOI.OpenXmlFormats.Dml.Spreadsheet
public static CT_Drawing Parse(XmlDocument xmldoc, XmlNamespaceManager namespaceManager) public static CT_Drawing Parse(XmlDocument xmldoc, XmlNamespaceManager namespaceManager)
{ {
XmlNodeList cellanchorNodes = xmldoc.SelectNodes("/xdr:wsDr/*", namespaceManager);
XmlNode root = xmldoc.SelectSingleNode("/xdr:wsDr", namespaceManager);
XmlNodeList cellanchorNodes = root.SelectNodes("descendant::xdr:oneCellAnchor|descendant::xdr:twoCellAnchor|descendant::xdr:absCellAnchor", namespaceManager);
CT_Drawing ctDrawing = new CT_Drawing(); CT_Drawing ctDrawing = new CT_Drawing();
foreach (XmlNode node in cellanchorNodes) foreach (XmlNode node in cellanchorNodes)
{ {

37
testcases/ooxml/XSSF/UserModel/TestUnfixedBugs.cs

@ -355,43 +355,6 @@ namespace TestCases.XSSF.UserModel
ClassicAssert.AreEqual(contents, cell.ToString(), "Did not have expected contents at rownum " + rowNum); ClassicAssert.AreEqual(contents, cell.ToString(), "Did not have expected contents at rownum " + rowNum);
//ClassicAssert.AreEqual(contents + ".0", cell.ToString(), "Did not have expected contents at rownum " + rowNum); //ClassicAssert.AreEqual(contents + ".0", cell.ToString(), "Did not have expected contents at rownum " + rowNum);
} }
[Test]
public void test58325_one()
{
check58325(XSSFTestDataSamples.OpenSampleWorkbook("58325_lt.xlsx"), 1);
}
[Test]
[Ignore("TODO FIX CI TESTS")]
public void test58325_three()
{
check58325(XSSFTestDataSamples.OpenSampleWorkbook("58325_db.xlsx"), 3);
}
private void check58325(XSSFWorkbook wb, int expectedShapes)
{
XSSFSheet sheet = wb.GetSheet("MetasNM001") as XSSFSheet;
ClassicAssert.IsNotNull(sheet);
StringBuilder str = new StringBuilder();
str.Append("sheet " + sheet.SheetName + " - ");
XSSFDrawing drawing = sheet.GetDrawingPatriarch();
//drawing = ((XSSFSheet)sheet).createDrawingPatriarch();
List<XSSFShape> shapes = drawing.GetShapes();
str.Append("drawing.Shapes.size() = " + shapes.Count);
IEnumerator<XSSFShape> it = shapes.GetEnumerator();
while (it.MoveNext())
{
XSSFShape shape = it.Current;
str.Append(", " + shape.ToString());
str.Append(", Col1:" + ((XSSFClientAnchor)shape.GetAnchor()).Col1);
str.Append(", Col2:" + ((XSSFClientAnchor)shape.GetAnchor()).Col2);
str.Append(", Row1:" + ((XSSFClientAnchor)shape.GetAnchor()).Row1);
str.Append(", Row2:" + ((XSSFClientAnchor)shape.GetAnchor()).Row2);
}
ClassicAssert.AreEqual(expectedShapes, shapes.Count,
"Having shapes: " + str);
}
} }
} }

68
testcases/ooxml/XSSF/UserModel/TestXSSFShape.cs

@ -0,0 +1,68 @@
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NPOI.XSSF;
using NPOI.XSSF.UserModel;
using NUnit.Framework;
using NUnit.Framework.Legacy;
namespace TestCases.XSSF.UserModel
{
[TestFixture]
internal class TestXSSFShape
{
[Test]
public void Test58325_one()
{
Check58325(XSSFTestDataSamples.OpenSampleWorkbook("58325_lt.xlsx"), 1);
}
[Test]
public void Test58325_three()
{
Check58325(XSSFTestDataSamples.OpenSampleWorkbook("58325_db.xlsx"), 3);
}
private void Check58325(XSSFWorkbook wb, int expectedShapes)
{
XSSFSheet sheet = wb.GetSheet("MetasNM001") as XSSFSheet;
ClassicAssert.IsNotNull(sheet);
StringBuilder str = new StringBuilder();
str.Append("sheet " + sheet.SheetName + " - ");
XSSFDrawing drawing = sheet.GetDrawingPatriarch();
//drawing = ((XSSFSheet)sheet).createDrawingPatriarch();
List<XSSFShape> shapes = drawing.GetShapes();
str.Append("drawing.Shapes.size() = " + shapes.Count);
IEnumerator<XSSFShape> it = shapes.GetEnumerator();
while (it.MoveNext())
{
XSSFShape shape = it.Current;
str.Append(", " + shape.ToString());
str.Append(", Col1:" + ((XSSFClientAnchor)shape.GetAnchor()).Col1);
str.Append(", Col2:" + ((XSSFClientAnchor)shape.GetAnchor()).Col2);
str.Append(", Row1:" + ((XSSFClientAnchor)shape.GetAnchor()).Row1);
str.Append(", Row2:" + ((XSSFClientAnchor)shape.GetAnchor()).Row2);
}
ClassicAssert.AreEqual(expectedShapes, shapes.Count,
"Having shapes: " + str);
}
}
}
Loading…
Cancel
Save