aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNick Burch <nick@apache.org>2005-06-19 15:37:11 +0000
committerNick Burch <nick@apache.org>2005-06-19 15:37:11 +0000
commit8805fad333962c8bb8bae3a1f472d9fd50dcc37c (patch)
tree9a7a0e7fde6bf803ba3dd416cd672666c170bc19 /src
parent46222b013c695d14c76cd31b03c9e3bf600965b2 (diff)
downloadpoi-8805fad333962c8bb8bae3a1f472d9fd50dcc37c.tar.gz
poi-8805fad333962c8bb8bae3a1f472d9fd50dcc37c.zip
Testing for ColorSchemeAtom record
git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@353719 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r--src/scratchpad/testcases/org/apache/poi/hslf/record/TestColorSchemeAtom.java89
1 files changed, 89 insertions, 0 deletions
diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/record/TestColorSchemeAtom.java b/src/scratchpad/testcases/org/apache/poi/hslf/record/TestColorSchemeAtom.java
new file mode 100644
index 0000000000..b49af1fcfe
--- /dev/null
+++ b/src/scratchpad/testcases/org/apache/poi/hslf/record/TestColorSchemeAtom.java
@@ -0,0 +1,89 @@
+
+/* ====================================================================
+ Copyright 2002-2004 Apache Software Foundation
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+
+
+
+package org.apache.poi.hslf.record;
+
+
+import junit.framework.TestCase;
+import java.io.ByteArrayOutputStream;
+
+/**
+ * Tests that ColorSchemAtom works properly
+ *
+ * @author Nick Burch (nick at torchbox dot com)
+ */
+public class TestColorSchemeAtom extends TestCase {
+ // From a real file
+ private byte[] data_a = new byte[] { 60, 0, 0xF0-256, 0x07, 0x20, 0, 0, 0,
+ 0xFF-256, 0xFF-256, 0xFF-256, 00, 00, 00, 00, 00,
+ 0x80-256, 0x80-256, 0x80-256, 00, 00, 00, 00, 00,
+ 0xBB-256, 0xE0-256, 0xE3-256, 00, 0x33, 0x33, 0x99-256, 00,
+ 00, 0x99-256, 0x99-256, 00, 0x99-256, 0xCC-256, 00, 00
+ };
+
+ public void testRecordType() throws Exception {
+ ColorSchemeAtom csa = new ColorSchemeAtom(data_a,0,data_a.length);
+ assertEquals(2032l, csa.getRecordType());
+ }
+
+ public void testToRGB() throws Exception {
+ byte[] rgb = ColorSchemeAtom.splitRGB(3669760);
+
+ assertEquals(3,rgb.length);
+ assertEquals(0, rgb[0]);
+ assertEquals(255-256, rgb[1]);
+ assertEquals(55, rgb[2]);
+ }
+
+ public void testFromRGB() throws Exception {
+ byte[] rgb_a = new byte[] { 0, 255-256, 55 };
+ byte[] rgb_b = new byte[] { 255-256, 127, 79 };
+
+ assertEquals( 3669760, ColorSchemeAtom.joinRGB( rgb_a ) );
+ assertEquals( 5210111, ColorSchemeAtom.joinRGB( rgb_b ) );
+
+ assertEquals( 3669760, ColorSchemeAtom.joinRGB( rgb_a[0], rgb_a[1], rgb_a[2] ) );
+ assertEquals( 5210111, ColorSchemeAtom.joinRGB( rgb_b[0], rgb_b[1], rgb_b[2] ) );
+ }
+
+ public void testRGBs() throws Exception {
+ ColorSchemeAtom csa = new ColorSchemeAtom(data_a,0,data_a.length);
+
+ assertEquals( 16777215 , csa.getBackgroundColourRGB() );
+ assertEquals( 0 , csa.getTextAndLinesColourRGB() );
+ assertEquals( 8421504 , csa.getShadowsColourRGB() );
+ assertEquals( 0 , csa.getTitleTextColourRGB() );
+ assertEquals( 14934203 , csa.getFillsColourRGB() );
+ assertEquals( 10040115 , csa.getAccentColourRGB() );
+ assertEquals( 10066176 , csa.getAccentAndHyperlinkColourRGB() );
+ assertEquals( 52377 , csa.getAccentAndFollowingHyperlinkColourRGB() );
+ }
+
+ public void testWrite() throws Exception {
+ ColorSchemeAtom csa = new ColorSchemeAtom(data_a,0,data_a.length);
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ csa.writeOut(baos);
+ byte[] b = baos.toByteArray();
+
+ assertEquals(data_a.length, b.length);
+ for(int i=0; i<data_a.length; i++) {
+ assertEquals(data_a[i],b[i]);
+ }
+ }
+}