1 2 17 18 19 20 package org.apache.poi.hssf.record; 21 22 23 import junit.framework.TestCase; 24 25 33 public class TestTickRecord 34 extends TestCase 35 { 36 byte[] data = new byte[] { 37 (byte)0x02, (byte)0x00, (byte)0x03, (byte)0x01, 38 (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, 39 (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, 40 (byte)0x00, (byte)0x00, (byte)0x00, 41 (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, 42 (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x23, (byte)0x00, 43 (byte)0x4D, (byte)0x00, (byte)0x00, (byte)0x00 44 }; 45 46 public TestTickRecord(String name) 47 { 48 super(name); 49 } 50 51 public void testLoad() 52 throws Exception 53 { 54 TickRecord record = new TickRecord((short)0x101e, (short)data.length, data); 55 assertEquals( (byte)2, record.getMajorTickType()); 56 assertEquals( (byte)0, record.getMinorTickType()); 57 assertEquals( (byte)3, record.getLabelPosition()); 58 assertEquals( (short)1, record.getBackground()); 59 assertEquals( 0, record.getLabelColorRgb()); 60 assertEquals( (short)0, record.getZero1()); 61 assertEquals( (short)0, record.getZero2()); 62 assertEquals( (short)35, record.getOptions()); 63 assertEquals( true, record.isAutoTextColor() ); 64 assertEquals( true, record.isAutoTextBackground() ); 65 assertEquals( (short)0x0, record.getRotation() ); 66 assertEquals( true, record.isAutorotate() ); 67 assertEquals( (short)77, record.getTickColor()); 68 assertEquals( (short)0x0, record.getZero3()); 69 70 71 assertEquals( 34, record.getRecordSize() ); 72 73 record.validateSid((short)0x101e); 74 } 75 76 public void testStore() 77 { 78 TickRecord record = new TickRecord(); 79 record.setMajorTickType( (byte)2 ); 80 record.setMinorTickType( (byte)0 ); 81 record.setLabelPosition( (byte)3 ); 82 record.setBackground( (byte)1 ); 83 record.setLabelColorRgb( 0 ); 84 record.setZero1( (short)0 ); 85 record.setZero2( (short)0 ); 86 record.setOptions( (short)35 ); 87 record.setAutoTextColor( true ); 88 record.setAutoTextBackground( true ); 89 record.setRotation( (short)0 ); 90 record.setAutorotate( true ); 91 record.setTickColor( (short)77 ); 92 record.setZero3( (short)0 ); 93 94 95 byte [] recordBytes = record.serialize(); 96 assertEquals(recordBytes.length - 4, data.length); 97 for (int i = 0; i < data.length; i++) 98 assertEquals("At offset " + i, data[i], recordBytes[i+4]); 99 } 100 101 102 107 public static void main(String [] args) { 108 System.out.println("Testing org.apache.poi.hssf.record.TickRecord"); 109 junit.textui.TestRunner.run(TestTickRecord.class); 110 } 111 112 } 113 | Popular Tags |