X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=test%2Fjalview%2Fschemes%2FFeatureColourTest.java;h=1beca80759ad0b1864daf3de6880baceb9805cc5;hb=136c0793b90b72b928c4d77dc109dd5c644e00d3;hp=9d9d996e4fd75fe331353ed15de0c12cafcd9ef3;hpb=528c0f1815bc67b54618ad5b16c2162946974caf;p=jalview.git diff --git a/test/jalview/schemes/FeatureColourTest.java b/test/jalview/schemes/FeatureColourTest.java index 9d9d996..1beca80 100644 --- a/test/jalview/schemes/FeatureColourTest.java +++ b/test/jalview/schemes/FeatureColourTest.java @@ -1,3 +1,23 @@ +/* + * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) + * Copyright (C) $$Year-Rel$$ The Jalview Authors + * + * This file is part of Jalview. + * + * Jalview 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. + * + * Jalview 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 Jalview. If not, see . + * The Jalview Authors are detailed in the 'AUTHORS' file. + */ package jalview.schemes; import static org.testng.AssertJUnit.assertEquals; @@ -6,14 +26,25 @@ import static org.testng.AssertJUnit.assertTrue; import static org.testng.AssertJUnit.fail; import jalview.datamodel.SequenceFeature; +import jalview.gui.JvOptionPane; +import jalview.util.ColorUtils; import jalview.util.Format; import java.awt.Color; +import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; public class FeatureColourTest { + + @BeforeClass(alwaysRun = true) + public void setUpJvOptionPane() + { + JvOptionPane.setInteractiveMode(false); + JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); + } + @Test(groups = { "Functional" }) public void testCopyConstructor() { @@ -56,7 +87,8 @@ public class FeatureColourTest public void testIsColored_simpleColour() { FeatureColour fc = new FeatureColour(Color.RED); - assertTrue(fc.isColored(new SequenceFeature())); + assertTrue(fc + .isColored(new SequenceFeature("Cath", "", 1, 2, 0f, null))); } @Test(groups = { "Functional" }) @@ -64,7 +96,8 @@ public class FeatureColourTest { FeatureColour fc = new FeatureColour(); fc.setColourByLabel(true); - assertTrue(fc.isColored(new SequenceFeature())); + assertTrue(fc + .isColored(new SequenceFeature("Cath", "", 1, 2, 0f, null))); } @Test(groups = { "Functional" }) @@ -81,13 +114,15 @@ public class FeatureColourTest assertEquals(Color.WHITE, fc.getColor(sf)); // score 120 is adjusted to top of range - sf.setScore(120f); + sf = new SequenceFeature(sf, sf.getBegin(), sf.getEnd(), + sf.getFeatureGroup(), 120f); assertEquals(Color.BLACK, fc.getColor(sf)); // value below threshold is still rendered // setting threshold has no effect yet... fc.setThreshold(60f); - sf.setScore(36f); + sf = new SequenceFeature(sf, sf.getBegin(), sf.getEnd(), + sf.getFeatureGroup(), 36f); assertTrue(fc.isColored(sf)); assertEquals(new Color(204, 204, 204), fc.getColor(sf)); @@ -97,7 +132,9 @@ public class FeatureColourTest // colour is still returned though ?!? assertEquals(new Color(204, 204, 204), fc.getColor(sf)); - sf.setScore(84); // above threshold now + sf = new SequenceFeature(sf, sf.getBegin(), sf.getEnd(), + sf.getFeatureGroup(), 84f); + // above threshold now assertTrue(fc.isColored(sf)); assertEquals(new Color(51, 51, 51), fc.getColor(sf)); } @@ -106,7 +143,8 @@ public class FeatureColourTest public void testGetColor_simpleColour() { FeatureColour fc = new FeatureColour(Color.RED); - assertEquals(Color.RED, fc.getColor(new SequenceFeature())); + assertEquals(Color.RED, + fc.getColor(new SequenceFeature("Cath", "", 1, 2, 0f, null))); } @Test(groups = { "Functional" }) @@ -116,7 +154,7 @@ public class FeatureColourTest fc.setColourByLabel(true); SequenceFeature sf = new SequenceFeature("type", "desc", 0, 20, 1f, null); - Color expected = UserColourScheme.createColourFromName("desc"); + Color expected = ColorUtils.createColourFromName("desc"); assertEquals(expected, fc.getColor(sf)); }