You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by on...@apache.org on 2015/10/27 08:43:23 UTC
svn commit: r1710730 -
/poi/trunk/src/scratchpad/testcases/org/apache/poi/hssf/usermodel/TestHSSFChart.java
Author: onealj
Date: Tue Oct 27 07:43:23 2015
New Revision: 1710730
URL: http://svn.apache.org/viewvc?rev=1710730&view=rev
Log:
bug 26862: add test case for HSSFWorkbook.cloneSheet copies charts
Modified:
poi/trunk/src/scratchpad/testcases/org/apache/poi/hssf/usermodel/TestHSSFChart.java
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hssf/usermodel/TestHSSFChart.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hssf/usermodel/TestHSSFChart.java?rev=1710730&r1=1710729&r2=1710730&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hssf/usermodel/TestHSSFChart.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hssf/usermodel/TestHSSFChart.java Tue Oct 27 07:43:23 2015
@@ -17,6 +17,8 @@
package org.apache.poi.hssf.usermodel;
+import java.io.IOException;
+
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
@@ -236,4 +238,37 @@ public final class TestHSSFChart {
HSSFChart chart = charts[ 2 ] ;
chart.removeSeries( chart.getSeries()[ 0 ] ) ;
}
+
+ /**
+ * Bug 26862: HSSFWorkbook.cloneSheet copies charts
+ */
+ @Test
+ public void test26862() throws IOException, Exception {
+ HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("SimpleChart.xls");
+ HSSFSheet srcSheet = wb.getSheetAt(0);
+ HSSFChart[] srcCharts = HSSFChart.getSheetCharts(srcSheet);
+ assertEquals(1, srcCharts.length);
+ HSSFChart srcChart = srcCharts[0];
+
+ // Clone the sheet
+ HSSFSheet clonedSheet = wb.cloneSheet(0);
+
+ // Verify the chart was copied
+ HSSFChart[] clonedCharts = HSSFChart.getSheetCharts(clonedSheet);
+ assertEquals(1, clonedCharts.length);
+ HSSFChart clonedChart = clonedCharts[0];
+ assertNotSame(srcChart, clonedChart); //refer to different objects
+ assertEquals(srcChart.getType(), clonedChart.getType());
+ assertEquals(srcChart.getChartTitle(), clonedChart.getChartTitle());
+ assertEquals(srcChart.getChartWidth(), clonedChart.getChartWidth());
+ assertEquals(srcChart.getChartHeight(), clonedChart.getChartHeight());
+ assertEquals(srcChart.getChartX(), clonedChart.getChartX());
+ assertEquals(srcChart.getChartY(), clonedChart.getChartY());
+
+ // Check if chart was shallow copied or deep copied
+ clonedChart.setChartWidth(clonedChart.getChartWidth()+10);
+ assertEquals(srcChart.getChartWidth()+10, clonedChart.getChartWidth());
+
+ wb.close();
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org