1 2 17 18 19 20 package org.apache.poi.hssf.record; 21 22 23 import junit.framework.TestCase; 24 25 32 public class TestTextRecord 33 extends TestCase 34 { 35 byte[] data = new byte[] { 36 (byte)0x02, (byte)0x02, (byte)0x01,(byte)0x00, (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00, (byte)0xD6,(byte)0xFF,(byte)0xFF,(byte)0xFF, (byte)0xC4,(byte)0xFF,(byte)0xFF,(byte)0xFF, (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00, (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00, (byte)0xB1,(byte)0x00, (byte)0x4D,(byte)0x00, (byte)0x50,(byte)0x2B, (byte)0x00,(byte)0x00 }; 49 50 public TestTextRecord(String name) 51 { 52 super(name); 53 } 54 55 public void testLoad() 56 throws Exception 57 { 58 59 TextRecord record = new TextRecord((short)0x1025, (short)data.length, data); 60 assertEquals( TextRecord.HORIZONTAL_ALIGNMENT_CENTER, record.getHorizontalAlignment()); 61 assertEquals( TextRecord.VERTICAL_ALIGNMENT_CENTER, record.getVerticalAlignment()); 62 assertEquals( TextRecord.DISPLAY_MODE_TRANSPARENT, record.getDisplayMode()); 63 assertEquals( 0, record.getRgbColor()); 64 assertEquals( -42, record.getX()); 65 assertEquals( -60, record.getY()); 66 assertEquals( 0, record.getWidth()); 67 assertEquals( 0, record.getHeight()); 68 assertEquals( 177, record.getOptions1()); 69 assertEquals( true, record.isAutoColor() ); 70 assertEquals( false, record.isShowKey() ); 71 assertEquals( false, record.isShowValue() ); 72 assertEquals( false, record.isVertical() ); 73 assertEquals( true, record.isAutoGeneratedText() ); 74 assertEquals( true, record.isGenerated() ); 75 assertEquals( false, record.isAutoLabelDeleted() ); 76 assertEquals( true, record.isAutoBackground() ); 77 assertEquals( TextRecord.ROTATION_NONE, record.getRotation() ); 78 assertEquals( false, record.isShowCategoryLabelAsPercentage() ); 79 assertEquals( false, record.isShowValueAsPercentage() ); 80 assertEquals( false, record.isShowBubbleSizes() ); 81 assertEquals( false, record.isShowLabel() ); 82 assertEquals( 77, record.getIndexOfColorValue()); 83 assertEquals( 11088, record.getOptions2()); 84 assertEquals( 0, record.getDataLabelPlacement() ); 85 assertEquals( 0, record.getTextRotation()); 86 87 88 assertEquals( 36, record.getRecordSize() ); 89 90 record.validateSid((short)0x1025); 91 92 } 93 94 public void testStore() 95 { 96 TextRecord record = new TextRecord(); 97 record.setHorizontalAlignment( TextRecord.HORIZONTAL_ALIGNMENT_CENTER ); 98 record.setVerticalAlignment( TextRecord.VERTICAL_ALIGNMENT_CENTER ); 99 record.setDisplayMode( TextRecord.DISPLAY_MODE_TRANSPARENT ); 100 record.setRgbColor( 0 ); 101 record.setX( -42 ); 102 record.setY( -60 ); 103 record.setWidth( 0 ); 104 record.setHeight( 0 ); 105 record.setAutoColor( true ); 106 record.setShowKey( false ); 107 record.setShowValue( false ); 108 record.setVertical( false ); 109 record.setAutoGeneratedText( true ); 110 record.setGenerated( true ); 111 record.setAutoLabelDeleted( false ); 112 record.setAutoBackground( true ); 113 record.setRotation( TextRecord.ROTATION_NONE ); 114 record.setShowCategoryLabelAsPercentage( false ); 115 record.setShowValueAsPercentage( false ); 116 record.setShowBubbleSizes( false ); 117 record.setShowLabel( false ); 118 record.setIndexOfColorValue( (short)77 ); 119 record.setOptions2( (short)0x2b50 ); 120 record.setTextRotation( (short)0 ); 122 123 124 byte [] recordBytes = record.serialize(); 125 assertEquals(recordBytes.length - 4, data.length); 126 for (int i = 0; i < data.length; i++) 127 assertEquals("At offset " + i, data[i], recordBytes[i+4]); 128 } 129 } 130 | Popular Tags |