1 2 17 18 19 20 package org.apache.poi.hssf.record; 21 22 23 import junit.framework.TestCase; 24 25 33 public class TestLegendRecord 34 extends TestCase 35 { 36 byte[] data = new byte[] { 37 (byte)0x76,(byte)0x0E,(byte)0x00,(byte)0x00,(byte)0x86,(byte)0x07,(byte)0x00,(byte)0x00,(byte)0x19,(byte)0x01,(byte)0x00,(byte)0x00,(byte)0x8B,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x03,(byte)0x01,(byte)0x1F,(byte)0x00 38 }; 39 40 public TestLegendRecord(String name) 41 { 42 super(name); 43 } 44 45 public void testLoad() 46 throws Exception 47 { 48 LegendRecord record = new LegendRecord((short)0x1015, (short)data.length, data); 49 50 51 assertEquals( (int)0xe76, record.getXAxisUpperLeft()); 52 53 assertEquals( (int)0x786, record.getYAxisUpperLeft()); 54 55 assertEquals( (int)0x119, record.getXSize()); 56 57 assertEquals( (int)0x8b, record.getYSize()); 58 59 assertEquals( (byte)0x3, record.getType()); 60 61 assertEquals( (byte)0x1, record.getSpacing()); 62 63 assertEquals( (short)0x1f, record.getOptions()); 64 assertEquals( true, record.isAutoPosition() ); 65 assertEquals( true, record.isAutoSeries() ); 66 assertEquals( true, record.isAutoXPositioning() ); 67 assertEquals( true, record.isAutoYPositioning() ); 68 assertEquals( true, record.isVertical() ); 69 assertEquals( false, record.isDataTable() ); 70 71 72 assertEquals( 24, record.getRecordSize() ); 73 74 record.validateSid((short)0x1015); 75 } 76 77 public void testStore() 78 { 79 LegendRecord record = new LegendRecord(); 80 81 82 83 record.setXAxisUpperLeft( (int)0xe76 ); 84 85 record.setYAxisUpperLeft( (int)0x786 ); 86 87 record.setXSize( (int)0x119 ); 88 89 record.setYSize( (int)0x8b ); 90 91 record.setType( (byte)0x3 ); 92 93 record.setSpacing( (byte)0x1 ); 94 95 record.setOptions( (short)0x1f ); 96 record.setAutoPosition( true ); 97 record.setAutoSeries( true ); 98 record.setAutoXPositioning( true ); 99 record.setAutoYPositioning( true ); 100 record.setVertical( true ); 101 record.setDataTable( false ); 102 103 104 byte [] recordBytes = record.serialize(); 105 assertEquals(recordBytes.length - 4, data.length); 106 for (int i = 0; i < data.length; i++) 107 assertEquals("At offset " + i, data[i], recordBytes[i+4]); 108 } 109 } 110 | Popular Tags |