1 2 17 18 19 20 package org.apache.poi.hssf.record; 21 22 23 import junit.framework.TestCase; 24 25 33 public class TestAreaFormatRecord 34 extends TestCase 35 { 36 byte[] data = new byte[] { 37 (byte)0xFF,(byte)0xFF,(byte)0xFF,(byte)0x00, (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00, (byte)0x01,(byte)0x00, (byte)0x01,(byte)0x00, (byte)0x4E,(byte)0x00, (byte)0x4D,(byte)0x00 44 }; 45 46 public TestAreaFormatRecord(String name) 47 { 48 super(name); 49 } 50 51 public void testLoad() 52 throws Exception 53 { 54 55 AreaFormatRecord record = new AreaFormatRecord((short)0x100a, (short)data.length, data); 56 assertEquals( 0xFFFFFF, record.getForegroundColor()); 57 assertEquals( 0x000000, record.getBackgroundColor()); 58 assertEquals( 1, record.getPattern()); 59 assertEquals( 1, record.getFormatFlags()); 60 assertEquals( true, record.isAutomatic() ); 61 assertEquals( false, record.isInvert() ); 62 assertEquals( 0x4e, record.getForecolorIndex()); 63 assertEquals( 0x4d, record.getBackcolorIndex()); 64 65 66 assertEquals( 20, record.getRecordSize() ); 67 68 record.validateSid((short)0x100a); 69 } 70 71 public void testStore() 72 { 73 AreaFormatRecord record = new AreaFormatRecord(); 74 record.setForegroundColor( 0xFFFFFF ); 75 record.setBackgroundColor( 0x000000 ); 76 record.setPattern( (short)1 ); 77 record.setAutomatic( true ); 78 record.setInvert( false ); 79 record.setForecolorIndex( (short)0x4e ); 80 record.setBackcolorIndex( (short)0x4d ); 81 82 83 byte [] recordBytes = record.serialize(); 84 assertEquals(recordBytes.length - 4, data.length); 85 for (int i = 0; i < data.length; i++) 86 assertEquals("At offset " + i, data[i], recordBytes[i+4]); 87 } 88 } 89 | Popular Tags |