From 3c170100d769742e076580e7e52054b28ea7f546 Mon Sep 17 00:00:00 2001 From: Evgeniy Berlog Date: Wed, 1 Aug 2012 19:34:08 +0000 Subject: code refactoring git-svn-id: https://svn.apache.org/repos/asf/poi/branches/gsoc2012@1368211 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/poi/hssf/usermodel/TestPatriarch.java | 40 ++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 src/testcases/org/apache/poi/hssf/usermodel/TestPatriarch.java (limited to 'src/testcases') diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestPatriarch.java b/src/testcases/org/apache/poi/hssf/usermodel/TestPatriarch.java new file mode 100644 index 0000000000..be5dc51594 --- /dev/null +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestPatriarch.java @@ -0,0 +1,40 @@ +package org.apache.poi.hssf.usermodel; + +import junit.framework.TestCase; +import org.apache.poi.ddf.EscherDgRecord; +import org.apache.poi.hssf.HSSFTestDataSamples; +import org.apache.poi.hssf.record.EscherAggregate; + +/** + * @author Evgeniy Berlog + * @date 01.08.12 + */ +public class TestPatriarch extends TestCase { + + public void testGetPatriarch(){ + HSSFWorkbook wb = new HSSFWorkbook(); + HSSFSheet sh = wb.createSheet(); + assertNull(sh.getDrawingPatriarch()); + + HSSFPatriarch patriarch = sh.createDrawingPatriarch(); + assertNotNull(patriarch); + patriarch.createSimpleShape(new HSSFClientAnchor()); + patriarch.createSimpleShape(new HSSFClientAnchor()); + + assertSame(patriarch, sh.getDrawingPatriarch()); + + EscherAggregate agg = patriarch._getBoundAggregate(); + + EscherDgRecord dg = agg.getEscherContainer().getChildById(EscherDgRecord.RECORD_ID); + int lastId = dg.getLastMSOSPID(); + + assertSame(patriarch, sh.createDrawingPatriarch()); + + wb = HSSFTestDataSamples.writeOutAndReadBack(wb); + sh = wb.getSheetAt(0); + patriarch = sh.createDrawingPatriarch(); + dg = patriarch._getBoundAggregate().getEscherContainer().getChildById(EscherDgRecord.RECORD_ID); + + assertEquals(lastId, dg.getLastMSOSPID()); + } +} -- cgit v1.2.3