X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=test%2Fjalview%2Fgui%2FPopupMenuTest.java;h=e9b6e548b4f9321b0258e8f532d0e72df78874d2;hb=447c5c1b22bd12a78730640321264fb38c39ec7b;hp=46397d33b7c09c2e65701c4fad253edfccba469c;hpb=28fda83cbef0c9c82cd09a343af4e1721085c104;p=jalview.git
diff --git a/test/jalview/gui/PopupMenuTest.java b/test/jalview/gui/PopupMenuTest.java
index 46397d3..e9b6e54 100644
--- a/test/jalview/gui/PopupMenuTest.java
+++ b/test/jalview/gui/PopupMenuTest.java
@@ -1,19 +1,56 @@
+/*
+ * 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.gui;
+import static jalview.util.UrlConstants.DB_ACCESSION;
+import static jalview.util.UrlConstants.SEQUENCE_ID;
import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertFalse;
import static org.testng.AssertJUnit.assertTrue;
+import jalview.bin.Cache;
import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.Annotation;
+import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.DBRefEntry;
+import jalview.datamodel.DBRefSource;
+import jalview.datamodel.HiddenColumns;
+import jalview.datamodel.Sequence;
+import jalview.datamodel.SequenceFeature;
+import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
-import jalview.io.AppletFormatAdapter;
+import jalview.io.DataSourceType;
+import jalview.io.FileFormat;
import jalview.io.FormatAdapter;
+import jalview.urls.api.UrlProviderFactoryI;
+import jalview.urls.desktop.DesktopUrlProviderFactory;
+import jalview.util.MessageManager;
+import jalview.util.UrlConstants;
import java.awt.Component;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
import java.util.List;
import javax.swing.JMenu;
@@ -21,11 +58,20 @@ import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
import javax.swing.JSeparator;
+import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
public class PopupMenuTest
{
+
+ @BeforeClass(alwaysRun = true)
+ public void setUpJvOptionPane()
+ {
+ JvOptionPane.setInteractiveMode(false);
+ JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
+ }
+
// 4 sequences x 13 positions
final static String TEST_DATA = ">FER_CAPAA Ferredoxin\n"
+ "TIETHKEAELVG-\n"
@@ -41,30 +87,49 @@ public class PopupMenuTest
PopupMenu testee = null;
- @BeforeMethod(alwaysRun = true)
+ @BeforeMethod(alwaysRun = true)
public void setUp() throws IOException
{
+ Cache.loadProperties("test/jalview/io/testProps.jvprops");
+ String inMenuString = ("EMBL-EBI Search | http://www.ebi.ac.uk/ebisearch/search.ebi?db=allebi&query=$"
+ + SEQUENCE_ID
+ + "$"
+ + "|"
+ + "UNIPROT | http://www.uniprot.org/uniprot/$" + DB_ACCESSION + "$")
+ + "|"
+ + ("INTERPRO | http://www.ebi.ac.uk/interpro/entry/$"
+ + DB_ACCESSION + "$")
+ + "|"
+ +
+ // Gene3D entry tests for case (in)sensitivity
+ ("Gene3D | http://gene3d.biochem.ucl.ac.uk/Gene3D/search?sterm=$"
+ + DB_ACCESSION + "$&mode=protein");
+
+ UrlProviderFactoryI factory = new DesktopUrlProviderFactory(
+ UrlConstants.DEFAULT_LABEL, inMenuString, "");
+ Preferences.sequenceUrlLinks = factory.createUrlProvider();
+
alignment = new FormatAdapter().readFile(TEST_DATA,
- AppletFormatAdapter.PASTE, "FASTA");
+ DataSourceType.PASTE, FileFormat.Fasta);
AlignFrame af = new AlignFrame(alignment, 700, 500);
parentPanel = new AlignmentPanel(af, af.getViewport());
testee = new PopupMenu(parentPanel, null, null);
int i = 0;
for (SequenceI seq : alignment.getSequences())
{
- final AlignmentAnnotation annotation = new AlignmentAnnotation("label" + i,
- "desc" + i, i);
+ final AlignmentAnnotation annotation = new AlignmentAnnotation(
+ "label" + i, "desc" + i, i);
annotation.setCalcId("calcId" + i);
seq.addAlignmentAnnotation(annotation);
annotation.setSequenceRef(seq);
}
}
- @Test(groups ={ "Functional" })
+ @Test(groups = { "Functional" })
public void testConfigureReferenceAnnotationsMenu_noSequenceSelected()
{
JMenuItem menu = new JMenuItem();
- List seqs = new ArrayList();
+ List seqs = new ArrayList<>();
testee.configureReferenceAnnotationsMenu(menu, seqs);
assertFalse(menu.isEnabled());
// now try null list
@@ -78,7 +143,7 @@ public class PopupMenuTest
* are no reference annotations to add to the alignment. The menu item should
* be disabled.
*/
- @Test(groups ={ "Functional" })
+ @Test(groups = { "Functional" })
public void testConfigureReferenceAnnotationsMenu_noReferenceAnnotations()
{
JMenuItem menu = new JMenuItem();
@@ -99,7 +164,7 @@ public class PopupMenuTest
* reference annotations are already on the alignment. The menu item should be
* disabled.
*/
- @Test(groups ={ "Functional" })
+ @Test(groups = { "Functional" })
public void testConfigureReferenceAnnotationsMenu_alreadyAdded()
{
JMenuItem menu = new JMenuItem();
@@ -119,7 +184,7 @@ public class PopupMenuTest
* The menu item should be enabled, and acquire a tooltip which lists the
* annotation sources (calcIds) and type (labels).
*/
- @Test(groups ={ "Functional" })
+ @Test(groups = { "Functional" })
public void testConfigureReferenceAnnotationsMenu()
{
JMenuItem menu = new JMenuItem();
@@ -130,7 +195,12 @@ public class PopupMenuTest
testee.configureReferenceAnnotationsMenu(menu, seqs);
assertTrue(menu.isEnabled());
- String expected = "
Add annotations for JMOL/secondary structure PBD/Temp