Class |
Line # |
Actions |
|||
---|---|---|---|---|---|
DesktopTests | 63 | 26 | 9 |
1 | /* | |
2 | * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) | |
3 | * Copyright (C) $$Year-Rel$$ The Jalview Authors | |
4 | * | |
5 | * This file is part of Jalview. | |
6 | * | |
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. | |
11 | * | |
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. | |
16 | * | |
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. | |
20 | */ | |
21 | package jalview.gui; | |
22 | ||
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; | |
29 | ||
30 | import java.awt.Color; | |
31 | import java.util.Iterator; | |
32 | ||
33 | import javax.swing.SwingUtilities; | |
34 | ||
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; | |
40 | ||
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; | |
62 | ||
63 | public class DesktopTests | |
64 | { | |
65 | ||
66 | 1 | @BeforeClass(alwaysRun = true) |
67 | public static void setUpBeforeClass() throws Exception | |
68 | { | |
69 | 1 | setUpJvOptionPane(); |
70 | /* | |
71 | * use read-only test properties file | |
72 | */ | |
73 | 1 | Cache.loadProperties("test/jalview/io/testProps.jvprops"); |
74 | 1 | Jalview.main(new String[] { "--nonews" }); |
75 | } | |
76 | ||
77 | 1 | @AfterMethod(alwaysRun = true) |
78 | public void tearDown() | |
79 | { | |
80 | 1 | Desktop.instance.closeAll_actionPerformed(null); |
81 | } | |
82 | ||
83 | /** | |
84 | * | |
85 | * configure (read-only) properties for test to ensure Consensus is computed | |
86 | * for colour Above PID testing | |
87 | */ | |
88 | 1 | public AlignFrame loadTestFile() |
89 | { | |
90 | 1 | Cache.loadProperties("test/jalview/io/testProps.jvprops"); |
91 | 1 | Cache.applicationProperties.setProperty("SHOW_IDENTITY", |
92 | Boolean.TRUE.toString()); | |
93 | 1 | AlignFrame af = new FileLoader().LoadFileWaitTillLoaded( |
94 | "examples/uniref50.fa", DataSourceType.FILE); | |
95 | ||
96 | /* | |
97 | * wait for Consensus thread to complete | |
98 | */ | |
99 | 1 | do |
100 | { | |
101 | 1 | try |
102 | { | |
103 | 1 | Thread.sleep(50); |
104 | } catch (InterruptedException x) | |
105 | { | |
106 | } | |
107 | 1 | } while (af.getViewport().getCalcManager().isWorking()); |
108 | 1 | return af; |
109 | } | |
110 | ||
111 | 1 | public static void setUpJvOptionPane() |
112 | { | |
113 | 1 | JvOptionPane.setInteractiveMode(false); |
114 | 1 | JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); |
115 | } | |
116 | ||
117 | 1 | @Test(groups = { "Functional" }) |
118 | public void testInternalCopyPaste() | |
119 | { | |
120 | 1 | AlignFrame internalSource = loadTestFile(); |
121 | ||
122 | 1 | try |
123 | { | |
124 | 1 | SwingUtilities.invokeAndWait(new Runnable() |
125 | { | |
126 | 1 | @Override |
127 | public void run() | |
128 | { | |
129 | 1 | internalSource.selectAllSequenceMenuItem_actionPerformed(null); |
130 | 1 | internalSource.copy_actionPerformed(); |
131 | 1 | Desktop.instance.paste(); |
132 | } | |
133 | }); | |
134 | } catch (Exception x) | |
135 | { | |
136 | 0 | Assert.fail("Unexpected exception " + x); |
137 | } | |
138 | 1 | AlignFrame[] alfs = Desktop.getDesktopAlignFrames(); |
139 | 1 | Assert.assertEquals("Expect just 2 alignment frames", 2, alfs.length); |
140 | // internal paste should yield a new alignment window with shared dataset | |
141 | 1 | AlignmentI dataset = internalSource.getViewport().getAlignment() |
142 | .getDataset(); | |
143 | 1 | Assert.assertNotNull(dataset); |
144 | ||
145 | 1 | for (AlignFrame alf : alfs) |
146 | { | |
147 | 2 | Assert.assertTrue( |
148 | "Internal paste should yield alignment with same dataset.", | |
149 | dataset == alf.getViewport().getAlignment().getDataset()); | |
150 | } | |
151 | ||
152 | } | |
153 | } |