mirror of
https://github.com/apache/poi.git
synced 2025-02-10 20:14:46 +00:00
Tried to reproduce bug 48403 but couldn't, still adding the related unit test
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1705830 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
aacf48d5aa
commit
dce1c426df
@ -19,14 +19,17 @@ package org.apache.poi.hssf.usermodel;
|
||||
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.io.IOException;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.apache.poi.hssf.HSSFTestDataSamples;
|
||||
import org.apache.poi.hssf.record.PaletteRecord;
|
||||
import org.apache.poi.hssf.util.HSSFColor;
|
||||
import org.junit.Test;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
* @author Brian Sanders (bsanders at risklabs dot com)
|
||||
@ -137,7 +140,7 @@ public final class TestHSSFPalette extends TestCase {
|
||||
assertEquals("FFFF:0:FFFF", p.getColor((short)14).getHexString());
|
||||
}
|
||||
|
||||
public void testFindSimilar() {
|
||||
public void testFindSimilar() throws IOException {
|
||||
HSSFWorkbook book = new HSSFWorkbook();
|
||||
HSSFPalette p = book.getCustomPalette();
|
||||
|
||||
@ -219,6 +222,8 @@ public final class TestHSSFPalette extends TestCase {
|
||||
p.getColor((short)12).getHexString(),
|
||||
p.findSimilarColor(255, 2, 10).getHexString()
|
||||
);
|
||||
|
||||
book.close();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -283,4 +288,27 @@ public final class TestHSSFPalette extends TestCase {
|
||||
private static interface ColorComparator {
|
||||
void compare(HSSFColor expected, HSSFColor palette);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test48403() throws Exception {
|
||||
HSSFWorkbook wb = new HSSFWorkbook();
|
||||
|
||||
Color color = Color.decode("#006B6B");
|
||||
HSSFPalette palette = wb.getCustomPalette();
|
||||
|
||||
HSSFColor hssfColor = palette.findColor((byte) color.getRed(),
|
||||
(byte) color.getGreen(), (byte) color.getBlue());
|
||||
assertNull(hssfColor);
|
||||
|
||||
palette.setColorAtIndex(
|
||||
(short) (PaletteRecord.STANDARD_PALETTE_SIZE - 1),
|
||||
(byte) color.getRed(), (byte) color.getGreen(),
|
||||
(byte) color.getBlue());
|
||||
hssfColor = palette.getColor((short) (PaletteRecord.STANDARD_PALETTE_SIZE - 1));
|
||||
assertNotNull(hssfColor);
|
||||
assertEquals(55, hssfColor.getIndex());
|
||||
assertArrayEquals(new short[] {0, 107, 107}, hssfColor.getTriplet());
|
||||
|
||||
wb.close();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user