X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=test%2Fjalview%2Fschemes%2FFeatureColourTest.java;h=822fcd4eb98cf4956616ca8edc5f2ea08c9ee854;hb=e957648a02a9e25795a92a4f39a5e3c1e7adb230;hp=e13f5421c2749ed44d5ff3f21b6447a1d6f2649c;hpb=579d3d1bccf00ce126ab3574758c6558b1bc3367;p=jalview.git diff --git a/test/jalview/schemes/FeatureColourTest.java b/test/jalview/schemes/FeatureColourTest.java index e13f542..822fcd4 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" }) @@ -106,7 +139,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,14 +150,15 @@ 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)); } @Test(groups = { "Functional" }) public void testGetColor_Graduated() { - // graduated colour from score 0 to 100, gray(128, 128, 128) to red(255, 0, 0) + // graduated colour from score 0 to 100, gray(128, 128, 128) to red(255, 0, + // 0) FeatureColour fc = new FeatureColour(Color.GRAY, Color.RED, 0f, 100f); // feature score is 75 which is 3/4 of the way from GRAY to RED SequenceFeature sf = new SequenceFeature("type", "desc", 0, 20, 75f, @@ -166,7 +201,7 @@ public class FeatureColourTest String redHex = Format.getHexString(Color.RED); String hexColour = redHex; assertEquals("domain\t" + hexColour, fc.toJalviewFormat("domain")); - + /* * colour by label (no threshold) */