// XAAL toolkit // Copyright (C) 2009 Ville Karavirta // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see . package tests.xaal.objects.graphical; import java.awt.Color; import junit.framework.TestCase; import xaal.objects.graphical.Style; import xaal.util.XaalConstants; /** * @author vkaravir * */ public class StyleTest extends TestCase { /** * @param name */ public StyleTest(String name) { super(name); } /* (non-Javadoc) * @see junit.framework.TestCase#setUp() */ protected void setUp() throws Exception { super.setUp(); } /* (non-Javadoc) * @see junit.framework.TestCase#tearDown() */ protected void tearDown() throws Exception { super.tearDown(); } public void testUses() { Style s1 = new Style(); Style s2 = new Style(); s1.setColor(Color.blue); assertEquals(Color.blue, s1.getColor()); assertEquals(Color.black, s2.getColor()); s2.setUses(s1); assertEquals(Color.blue, s2.getColor()); s2.setColor(Color.red); assertEquals(Color.red, s2.getColor()); s1.setColor((Color)null); assertEquals(null, s1.getColor()); s1.setColor((String)null); assertEquals(null, s1.getColor()); s1.setColor("blue"); assertEquals(XaalConstants.DEFAULT_PROPERTY_STROKEWIDTH, s1.getStrokeWidth()); assertEquals(XaalConstants.DEFAULT_PROPERTY_STROKEWIDTH, s2.getStrokeWidth()); s2.setStrokeWidth(2); assertEquals(XaalConstants.DEFAULT_PROPERTY_STROKEWIDTH, s1.getStrokeWidth()); assertEquals(2, s2.getStrokeWidth()); assertEquals(null, s1.getFillColor()); s1.setFillColor(Color.blue); assertEquals(Color.blue, s1.getFillColor()); assertEquals(Color.blue, s2.getFillColor()); assertEquals(Color.blue, s2.getFillColor()); s2.setFillColor(Color.red); assertEquals(Color.red, s2.getFillColor()); s1.setFillColor((Color)null); assertEquals(null, s1.getFillColor()); assertEquals(false, s1.isForwardArrow()); assertEquals(false, s1.isBackwardArrow()); s1.setForwardArrow(true); assertEquals(true, s2.isForwardArrow()); s2.setForwardArrow(false); assertEquals(false, s2.isForwardArrow()); Style s3 = new Style(s1); Style s4 = new Style(); assertEquals(Color.black, s4.getColor()); assertEquals(Color.blue, s3.getColor()); s4.setUses(s3); assertEquals(Color.blue, s4.getColor()); assertEquals(s3, s4.getUses()); } }