2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
23 import static org.junit.Assert.assertNotEquals;
24 import static org.testng.Assert.assertEquals;
25 import static org.testng.Assert.assertFalse;
26 import static org.testng.Assert.assertNotSame;
27 import static org.testng.Assert.assertSame;
28 import static org.testng.Assert.assertTrue;
30 import java.awt.Color;
31 import java.util.Iterator;
33 import javax.swing.SwingUtilities;
35 import org.junit.Assert;
36 import org.testng.annotations.AfterMethod;
37 import org.testng.annotations.BeforeClass;
38 import org.testng.annotations.BeforeMethod;
39 import org.testng.annotations.Test;
41 import jalview.api.FeatureColourI;
42 import jalview.bin.Cache;
43 import jalview.bin.Jalview;
44 import jalview.datamodel.Alignment;
45 import jalview.datamodel.AlignmentI;
46 import jalview.datamodel.HiddenColumns;
47 import jalview.datamodel.Sequence;
48 import jalview.datamodel.SequenceFeature;
49 import jalview.datamodel.SequenceGroup;
50 import jalview.datamodel.SequenceI;
51 import jalview.io.DataSourceType;
52 import jalview.io.FileLoader;
53 import jalview.project.Jalview2xmlTests;
54 import jalview.renderer.ResidueShaderI;
55 import jalview.schemes.BuriedColourScheme;
56 import jalview.schemes.FeatureColour;
57 import jalview.schemes.HelixColourScheme;
58 import jalview.schemes.JalviewColourScheme;
59 import jalview.schemes.StrandColourScheme;
60 import jalview.schemes.TurnColourScheme;
61 import jalview.util.MessageManager;
63 public class DesktopTests
66 @BeforeClass(alwaysRun = true)
67 public static void setUpBeforeClass() throws Exception
71 * use read-only test properties file
73 Cache.loadProperties("test/jalview/io/testProps.jvprops");
74 Jalview.main(new String[] { "--nonews" });
77 @AfterMethod(alwaysRun = true)
78 public void tearDown()
80 Desktop.instance.closeAll_actionPerformed(null);
85 * configure (read-only) properties for test to ensure Consensus is computed
86 * for colour Above PID testing
88 public AlignFrame loadTestFile()
90 Cache.loadProperties("test/jalview/io/testProps.jvprops");
91 Cache.applicationProperties.setProperty("SHOW_IDENTITY",
92 Boolean.TRUE.toString());
93 AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
94 "examples/uniref50.fa", DataSourceType.FILE);
97 * wait for Consensus thread to complete
104 } catch (InterruptedException x)
107 } while (af.getViewport().getCalcManager().isWorking());
111 public static void setUpJvOptionPane()
113 JvOptionPane.setInteractiveMode(false);
114 JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
117 @Test(groups = { "Functional" })
118 public void testInternalCopyPaste()
120 AlignFrame internalSource = loadTestFile();
124 SwingUtilities.invokeAndWait(new Runnable()
129 internalSource.selectAllSequenceMenuItem_actionPerformed(null);
130 internalSource.copy_actionPerformed();
131 Desktop.instance.paste();
134 } catch (Exception x)
136 Assert.fail("Unexpected exception " + x);
138 AlignFrame[] alfs = Desktop.getDesktopAlignFrames();
139 Assert.assertEquals("Expect just 2 alignment frames", 2, alfs.length);
140 // internal paste should yield a new alignment window with shared dataset
141 AlignmentI dataset = internalSource.getViewport().getAlignment()
143 Assert.assertNotNull(dataset);
145 for (AlignFrame alf : alfs)
148 "Internal paste should yield alignment with same dataset.",
149 dataset == alf.getViewport().getAlignment().getDataset());