Clover icon

Coverage Report

  1. Project Clover database Thu Aug 13 2020 12:04:21 BST
  2. Package jalview.gui

File AlignFrameTest.java

 

Code metrics

2
281
9
1
631
391
11
0.04
31.22
9
1.22

Classes

Class Line # Actions
AlignFrameTest 60 281 11
0.9965753699.7%
 

Contributing tests

This file is covered by 5 tests. .

Source view

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 org.testng.annotations.AfterMethod;
34    import org.testng.annotations.BeforeClass;
35    import org.testng.annotations.BeforeMethod;
36    import org.testng.annotations.Test;
37   
38    import jalview.api.FeatureColourI;
39    import jalview.bin.Cache;
40    import jalview.bin.Jalview;
41    import jalview.datamodel.Alignment;
42    import jalview.datamodel.AlignmentI;
43    import jalview.datamodel.HiddenColumns;
44    import jalview.datamodel.Sequence;
45    import jalview.datamodel.SequenceFeature;
46    import jalview.datamodel.SequenceGroup;
47    import jalview.datamodel.SequenceI;
48    import jalview.io.DataSourceType;
49    import jalview.io.FileLoader;
50    import jalview.project.Jalview2xmlTests;
51    import jalview.renderer.ResidueShaderI;
52    import jalview.schemes.BuriedColourScheme;
53    import jalview.schemes.FeatureColour;
54    import jalview.schemes.HelixColourScheme;
55    import jalview.schemes.JalviewColourScheme;
56    import jalview.schemes.StrandColourScheme;
57    import jalview.schemes.TurnColourScheme;
58    import jalview.util.MessageManager;
59   
 
60    public class AlignFrameTest
61    {
62    AlignFrame af;
63   
 
64  1 toggle @BeforeClass(alwaysRun = true)
65    public static void setUpBeforeClass() throws Exception
66    {
67  1 setUpJvOptionPane();
68    /*
69    * use read-only test properties file
70    */
71  1 Cache.loadProperties("test/jalview/io/testProps.jvprops");
72  1 Jalview.main(new String[] { "-nonews" });
73    }
74   
 
75  5 toggle @AfterMethod(alwaysRun = true)
76    public void tearDown()
77    {
78  5 Desktop.instance.closeAll_actionPerformed(null);
79    }
80   
81    /**
82    * configure (read-only) properties for test to ensure Consensus is computed for
83    * colour Above PID testing
84    */
 
85  5 toggle @BeforeMethod(alwaysRun = true)
86    public void setUp()
87    {
88  5 Cache.loadProperties("test/jalview/io/testProps.jvprops");
89  5 Cache.applicationProperties.setProperty("SHOW_IDENTITY",
90    Boolean.TRUE.toString());
91  5 af = new FileLoader().LoadFileWaitTillLoaded("examples/uniref50.fa",
92    DataSourceType.FILE);
93   
94    /*
95    * wait for Consensus thread to complete
96    */
97  5 do
98    {
99  5 try
100    {
101  5 Thread.sleep(50);
102    } catch (InterruptedException x)
103    {
104    }
105  5 } while (af.getViewport().getCalcManager().isWorking());
106    }
107   
 
108  1 toggle public static void setUpJvOptionPane()
109    {
110  1 JvOptionPane.setInteractiveMode(false);
111  1 JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
112    }
113   
 
114  1 toggle @Test(groups = "Functional")
115    public void testHideFeatureColumns()
116    {
117  1 SequenceI seq1 = new Sequence("Seq1", "ABCDEFGHIJ");
118  1 SequenceI seq2 = new Sequence("Seq2", "ABCDEFGHIJ");
119  1 seq1.addSequenceFeature(new SequenceFeature("Metal", "", 1, 5, 0f, null));
120  1 seq2.addSequenceFeature(new SequenceFeature("Metal", "", 6, 10, 10f,
121    null));
122  1 seq1.addSequenceFeature(new SequenceFeature("Turn", "", 2, 4,
123    Float.NaN, null));
124  1 seq2.addSequenceFeature(new SequenceFeature("Turn", "", 7, 9,
125    Float.NaN, null));
126  1 AlignmentI al = new Alignment(new SequenceI[] { seq1, seq2 });
127  1 AlignFrame alignFrame = new AlignFrame(al, al.getWidth(),
128    al.getHeight());
129   
130    /*
131    * make all features visible (select feature columns checks visibility)
132    */
133  1 alignFrame.getFeatureRenderer().findAllFeatures(true);
134   
135    /*
136    * hiding a feature not present does nothing
137    */
138  1 assertFalse(alignFrame.hideFeatureColumns("exon", true));
139  1 assertTrue(alignFrame.getViewport().getColumnSelection().isEmpty());
140   
141  1 assertEquals(alignFrame.getViewport().getAlignment().getHiddenColumns()
142    .getNumberOfRegions(), 0);
143   
144  1 assertFalse(alignFrame.hideFeatureColumns("exon", false));
145  1 assertTrue(alignFrame.getViewport().getColumnSelection().isEmpty());
146   
147  1 assertEquals(alignFrame.getViewport().getAlignment().getHiddenColumns()
148    .getNumberOfRegions(), 0);
149   
150    /*
151    * hiding a feature in all columns does nothing
152    */
153  1 assertFalse(alignFrame.hideFeatureColumns("Metal", true));
154  1 assertTrue(alignFrame.getViewport().getColumnSelection().isEmpty());
155   
156  1 assertEquals(alignFrame.getViewport().getAlignment().getHiddenColumns()
157    .getNumberOfRegions(), 0);
158   
159   
160    /*
161    * threshold Metal to hide features where score < 5
162    * seq1 feature in columns 1-5 is hidden
163    * seq2 feature in columns 6-10 is shown
164    */
165  1 FeatureColourI fc = new FeatureColour(null, Color.red, Color.blue, null,
166    0f, 10f);
167  1 fc.setAboveThreshold(true);
168  1 fc.setThreshold(5f);
169  1 alignFrame.getFeatureRenderer().setColour("Metal", fc);
170  1 assertTrue(alignFrame.hideFeatureColumns("Metal", true));
171  1 HiddenColumns hidden = alignFrame.getViewport().getAlignment().getHiddenColumns();
172  1 assertEquals(hidden.getNumberOfRegions(), 1);
173  1 Iterator<int[]> regions = hidden.iterator();
174  1 int[] next = regions.next();
175  1 assertEquals(next[0], 5);
176  1 assertEquals(next[1], 9);
177   
178    /*
179    * hide a feature present in some columns
180    * sequence positions [2-4], [7-9] are column positions
181    * [1-3], [6-8] base zero
182    */
183  1 alignFrame.getViewport().showAllHiddenColumns();
184  1 assertTrue(alignFrame.hideFeatureColumns("Turn", true));
185  1 regions = alignFrame.getViewport().getAlignment()
186    .getHiddenColumns().iterator();
187  1 assertEquals(alignFrame.getViewport().getAlignment().getHiddenColumns()
188    .getNumberOfRegions(), 2);
189  1 next = regions.next();
190  1 assertEquals(next[0], 1);
191  1 assertEquals(next[1], 3);
192  1 next = regions.next();
193  1 assertEquals(next[0], 6);
194  1 assertEquals(next[1], 8);
195    }
196   
197    /**
198    * Test that changing background (alignment) colour scheme
199    * <ul>
200    * <li>with Apply Colour to All Groups not selected, does not change group
201    * colours</li>
202    * <li>with Apply Colour to All Groups selected, does change group colours</li>
203    * <li>in neither case, changes alignment or group colour thresholds (PID or
204    * Conservation)</li>
205    * </ul>
206    */
 
207  1 toggle @Test(groups = "Functional")
208    public void testChangeColour_background_groupsAndThresholds()
209    {
210  1 AlignViewport av = af.getViewport();
211  1 AlignmentI al = av.getAlignment();
212   
213    /*
214    * Colour alignment by Buried Index
215    */
216  1 af.applyToAllGroups_actionPerformed(false);
217  1 af.changeColour_actionPerformed(JalviewColourScheme.Buried.toString());
218  1 assertTrue(av.getGlobalColourScheme() instanceof BuriedColourScheme);
219  1 assertFalse(av.getResidueShading().conservationApplied());
220  1 assertEquals(av.getResidueShading().getThreshold(), 0);
221   
222    /*
223    * Apply Conservation 20%
224    */
225  1 af.conservationMenuItem_actionPerformed(true);
226  1 SliderPanel sp = SliderPanel.getSliderPanel();
227  1 assertEquals(sp.getTitle(), MessageManager.formatMessage(
228    "label.conservation_colour_increment",
229    new String[] { "Background" }));
230  1 assertTrue(sp.isForConservation());
231  1 sp.valueChanged(20);
232  1 assertTrue(av.getResidueShading().conservationApplied());
233  1 assertEquals(av.getResidueShading().getConservationInc(), 20);
234   
235    /*
236    * Apply PID threshold 10% (conservation still applies as well)
237    */
238  1 af.abovePIDThreshold_actionPerformed(true);
239  1 sp = SliderPanel.getSliderPanel();
240  1 assertFalse(sp.isForConservation());
241  1 assertEquals(sp.getTitle(), MessageManager.formatMessage(
242    "label.percentage_identity_threshold",
243    new String[] { "Background" }));
244  1 sp.valueChanged(10);
245  1 assertEquals(av.getResidueShading().getThreshold(), 10);
246  1 assertTrue(av.getResidueShading().conservationApplied());
247  1 assertEquals(av.getResidueShading().getConservationInc(), 20);
248   
249    /*
250    * create a group with Strand colouring, 30% Conservation
251    * and 40% PID threshold
252    */
253  1 SequenceGroup sg = new SequenceGroup();
254  1 sg.addSequence(al.getSequenceAt(0), false);
255  1 sg.setStartRes(15);
256  1 sg.setEndRes(25);
257  1 av.setSelectionGroup(sg);
258   
259    /*
260    * apply 30% Conservation to group
261    * (notice menu action applies to selection group even if mouse click
262    * is at a sequence not in the group)
263    */
264  1 PopupMenu popupMenu = new PopupMenu(af.alignPanel, al.getSequenceAt(2),
265    null);
266  1 popupMenu.changeColour_actionPerformed(JalviewColourScheme.Strand
267    .toString());
268  1 assertTrue(sg.getColourScheme() instanceof StrandColourScheme);
269  1 assertEquals(al.getGroups().size(), 1);
270  1 assertSame(al.getGroups().get(0), sg);
271  1 popupMenu.conservationMenuItem_actionPerformed(true);
272  1 sp = SliderPanel.getSliderPanel();
273  1 assertTrue(sp.isForConservation());
274  1 assertEquals(sp.getTitle(), MessageManager.formatMessage(
275    "label.conservation_colour_increment",
276    new String[] { sg.getName() }));
277  1 sp.valueChanged(30);
278  1 assertTrue(sg.getGroupColourScheme().conservationApplied());
279  1 assertEquals(sg.getGroupColourScheme().getConservationInc(), 30);
280   
281    /*
282    * apply 40% PID threshold to group
283    */
284  1 popupMenu.abovePIDColour_actionPerformed(true);
285  1 sp = SliderPanel.getSliderPanel();
286  1 assertFalse(sp.isForConservation());
287  1 assertEquals(sp.getTitle(), MessageManager.formatMessage(
288    "label.percentage_identity_threshold",
289    new String[] { sg.getName() }));
290  1 sp.valueChanged(40);
291  1 assertEquals(sg.getGroupColourScheme().getThreshold(), 40);
292    // conservation threshold is unchanged:
293  1 assertTrue(sg.getGroupColourScheme().conservationApplied());
294  1 assertEquals(sg.getGroupColourScheme().getConservationInc(), 30);
295   
296    /*
297    * change alignment colour - group colour, and all thresholds,
298    * should be unaffected
299    */
300  1 af.changeColour_actionPerformed(JalviewColourScheme.Turn.toString());
301  1 assertTrue(av.getGlobalColourScheme() instanceof TurnColourScheme);
302  1 assertTrue(av.getResidueShading().conservationApplied());
303  1 assertEquals(av.getResidueShading().getConservationInc(), 20);
304  1 assertEquals(av.getResidueShading().getThreshold(), 10);
305  1 assertTrue(sg.getColourScheme() instanceof StrandColourScheme);
306  1 assertTrue(sg.getGroupColourScheme().conservationApplied());
307  1 assertEquals(sg.getGroupColourScheme().getConservationInc(), 30);
308  1 assertEquals(sg.getGroupColourScheme().getThreshold(), 40);
309   
310    /*
311    * Now change alignment colour with Apply Colour To All Groups
312    * - group colour should change, but not colour thresholds
313    */
314  1 af.applyToAllGroups_actionPerformed(true);
315  1 af.changeColour_actionPerformed(JalviewColourScheme.Helix.toString());
316  1 assertTrue(av.getGlobalColourScheme() instanceof HelixColourScheme);
317  1 assertTrue(av.getResidueShading().conservationApplied());
318  1 assertEquals(av.getResidueShading().getConservationInc(), 20);
319  1 assertEquals(av.getResidueShading().getThreshold(), 10);
320  1 assertTrue(sg.getColourScheme() instanceof HelixColourScheme);
321  1 assertTrue(sg.getGroupColourScheme().conservationApplied());
322  1 assertEquals(sg.getGroupColourScheme().getConservationInc(), 30);
323  1 assertEquals(sg.getGroupColourScheme().getThreshold(), 40);
324    }
325   
326    /**
327    * Test residue colouring with various options
328    * <ol>
329    * <li>no PID or Conservation threshold</li>
330    * <li>colour by Conservation applied</li>
331    * <li>colour by Conservation removed</li>
332    * <li>colour above PID - various values</li>
333    * <li>colour above PID removed</li>
334    * <li>Above PID plus By Conservation combined</li>
335    * <li>remove Above PID to leave just By Conservation</li>
336    * <li>re-add Above PID</li>
337    * <li>remove By Conservation to leave just Above PID</li>
338    * <li>remove Above PID to leave original colours</li>
339    * </ol>
340    */
 
341  1 toggle @Test(groups = "Functional")
342    public void testColourThresholdActions()
343    {
344  1 AlignViewport av = af.getViewport();
345  1 AlignmentI al = av.getAlignment();
346   
347    /*
348    * Colour alignment by Helix Propensity, no thresholds
349    */
350  1 af.applyToAllGroups_actionPerformed(false);
351  1 af.changeColour_actionPerformed(JalviewColourScheme.Helix.toString());
352  1 assertTrue(av.getGlobalColourScheme() instanceof HelixColourScheme);
353  1 assertFalse(av.getResidueShading().conservationApplied());
354  1 assertEquals(av.getResidueShading().getThreshold(), 0);
355   
356    /*
357    * inspect the colour of
358    * FER_CAPAN.9(I), column 15 (14 base 0)
359    * FER_CAPAN.10(SER), column 16 (15 base 0)
360    */
361  1 SequenceI ferCapan = al.findName("FER_CAPAN");
362  1 ResidueShaderI rs = av.getResidueShading();
363  1 Color c = rs.findColour('I', 14, ferCapan);
364  1 Color i_original = new Color(138, 117, 138);
365  1 assertEquals(c, i_original);
366  1 c = rs.findColour('S', 15, ferCapan);
367  1 Color s_original = new Color(54, 201, 54);
368  1 assertEquals(c, s_original);
369   
370    /*
371    * colour by conservation with increment 10
372    */
373  1 af.conservationMenuItem_actionPerformed(true);
374  1 SliderPanel sp = SliderPanel.getSliderPanel();
375  1 assertTrue(sp.isForConservation());
376  1 assertEquals(sp.getValue(), 30); // initial slider setting
377  1 c = rs.findColour('I', 14, ferCapan);
378  1 Color i_faded = new Color(255, 255, 255);
379  1 assertEquals(c, i_faded);
380  1 sp.valueChanged(10);
381  1 assertSame(rs, av.getResidueShading());
382  1 assertEquals(rs.getConservationInc(), 10);
383  1 c = rs.findColour('I', 14, ferCapan);
384  1 i_faded = new Color(196, 186, 196);
385  1 assertEquals(c, i_faded);
386  1 c = rs.findColour('S', 15, ferCapan);
387  1 Color s_faded = new Color(144, 225, 144);
388  1 assertEquals(c, s_faded);
389   
390    /*
391    * deselect By Conservation - colour should revert
392    */
393  1 af.conservationMenuItem_actionPerformed(false);
394  1 c = rs.findColour('S', 15, ferCapan);
395  1 assertEquals(c, s_original);
396   
397    /*
398    * now Above PID, threshold = 0%
399    * should be no change
400    */
401  1 af.abovePIDThreshold_actionPerformed(true);
402  1 sp = SliderPanel.getSliderPanel();
403  1 assertFalse(sp.isForConservation());
404  1 assertEquals(sp.getValue(), 0); // initial slider setting
405  1 c = rs.findColour('I', 14, ferCapan);
406  1 assertEquals(c, i_original);
407  1 c = rs.findColour('S', 15, ferCapan);
408  1 assertEquals(c, s_original);
409   
410    /*
411    * Above PID, threshold = 1%
412    * 15.I becomes White because no match to consensus (V)
413    * 16.S remains coloured as matches 66.66% consensus
414    */
415  1 sp.valueChanged(1);
416  1 c = rs.findColour('I', 14, ferCapan);
417  1 assertEquals(c, Color.white);
418  1 c = rs.findColour('S', 15, ferCapan);
419  1 assertEquals(c, s_original);
420   
421    /*
422    * threshold 66% - no further change yet...
423    */
424  1 sp.valueChanged(66);
425  1 c = rs.findColour('I', 14, ferCapan);
426  1 assertEquals(c, Color.white);
427  1 c = rs.findColour('S', 15, ferCapan);
428  1 assertEquals(c, s_original);
429   
430    /*
431    * threshold 67% - now both residues are white
432    */
433  1 sp.valueChanged(67);
434  1 c = rs.findColour('I', 14, ferCapan);
435  1 assertEquals(c, Color.white);
436  1 c = rs.findColour('S', 15, ferCapan);
437  1 assertEquals(c, Color.white);
438   
439    /*
440    * deselect Above PID - colours should revert
441    */
442  1 af.abovePIDThreshold_actionPerformed(false);
443  1 c = rs.findColour('I', 14, ferCapan);
444  1 assertEquals(c, i_original);
445  1 c = rs.findColour('S', 15, ferCapan);
446  1 assertEquals(c, s_original);
447   
448    /*
449    * Now combine Above 50% PID and By Conservation 10%
450    * 15.I is White because no match to consensus (V)
451    * 16.S is coloured but faded
452    */
453  1 af.abovePIDThreshold_actionPerformed(true);
454  1 sp = SliderPanel.getSliderPanel();
455  1 assertFalse(sp.isForConservation());
456  1 sp.valueChanged(50);
457  1 af.conservationMenuItem_actionPerformed(true);
458  1 sp = SliderPanel.getSliderPanel();
459  1 assertTrue(sp.isForConservation());
460  1 sp.valueChanged(10);
461  1 c = rs.findColour('I', 14, ferCapan);
462  1 assertEquals(c, Color.white);
463  1 c = rs.findColour('S', 15, ferCapan);
464  1 assertEquals(c, s_faded);
465   
466    /*
467    * turn off Above PID - should just leave Conservation fading as before
468    */
469  1 af.abovePIDThreshold_actionPerformed(false);
470  1 c = rs.findColour('I', 14, ferCapan);
471  1 assertEquals(c, i_faded);
472  1 c = rs.findColour('S', 15, ferCapan);
473  1 assertEquals(c, s_faded);
474   
475    /*
476    * Now add Above 50% PID to conservation colouring
477    * - should give the same as PID followed by conservation (above)
478    */
479  1 af.abovePIDThreshold_actionPerformed(true);
480  1 SliderPanel.getSliderPanel().valueChanged(50);
481  1 c = rs.findColour('I', 14, ferCapan);
482  1 assertEquals(c, Color.white);
483  1 c = rs.findColour('S', 15, ferCapan);
484  1 assertEquals(c, s_faded);
485   
486    /*
487    * turn off By Conservation
488    * should leave I white, S original (unfaded) colour
489    */
490  1 af.conservationMenuItem_actionPerformed(false);
491  1 c = rs.findColour('I', 14, ferCapan);
492  1 assertEquals(c, Color.white);
493  1 c = rs.findColour('S', 15, ferCapan);
494  1 assertEquals(c, s_original);
495   
496    /*
497    * finally turn off Above PID to leave original colours
498    */
499  1 af.abovePIDThreshold_actionPerformed(false);
500  1 c = rs.findColour('I', 14, ferCapan);
501  1 assertEquals(c, i_original);
502  1 c = rs.findColour('S', 15, ferCapan);
503  1 assertEquals(c, s_original);
504    }
505   
506    /**
507    * Verify that making a New View transfers alignment and group colour schemes,
508    * including any thresholds, to the new view. Because New View is performed by
509    * saving and reloading a 'project' file, this is similar to verifying a
510    * project save and reload.
511    *
512    * @see Jalview2xmlTests#testStoreAndRecoverColourThresholds()
513    */
 
514  1 toggle @Test(groups = "Functional")
515    public void testNewView_colourThresholds()
516    {
517  1 AlignViewport av = af.getViewport();
518  1 AlignmentI al = av.getAlignment();
519   
520    /*
521    * Colour alignment by Buried Index, Above 10% PID, By Conservation 20%
522    */
523  1 af.changeColour_actionPerformed(JalviewColourScheme.Buried.toString());
524  1 assertTrue(av.getGlobalColourScheme() instanceof BuriedColourScheme);
525  1 af.abovePIDThreshold_actionPerformed(true);
526  1 SliderPanel sp = SliderPanel.getSliderPanel();
527  1 assertFalse(sp.isForConservation());
528  1 sp.valueChanged(10);
529  1 af.conservationMenuItem_actionPerformed(true);
530  1 sp = SliderPanel.getSliderPanel();
531  1 assertTrue(sp.isForConservation());
532  1 sp.valueChanged(20);
533  1 ResidueShaderI rs = av.getResidueShading();
534  1 assertEquals(rs.getThreshold(), 10);
535  1 assertTrue(rs.conservationApplied());
536  1 assertEquals(rs.getConservationInc(), 20);
537   
538    /*
539    * create a group with Strand colouring, 30% Conservation
540    * and 40% PID threshold
541    */
542  1 SequenceGroup sg = new SequenceGroup();
543  1 sg.addSequence(al.getSequenceAt(0), false);
544  1 sg.setStartRes(15);
545  1 sg.setEndRes(25);
546  1 av.setSelectionGroup(sg);
547  1 PopupMenu popupMenu = new PopupMenu(af.alignPanel, al.getSequenceAt(0),
548    null);
549  1 popupMenu.changeColour_actionPerformed(JalviewColourScheme.Strand
550    .toString());
551  1 assertTrue(sg.getColourScheme() instanceof StrandColourScheme);
552  1 assertEquals(al.getGroups().size(), 1);
553  1 assertSame(al.getGroups().get(0), sg);
554  1 popupMenu.conservationMenuItem_actionPerformed(true);
555  1 sp = SliderPanel.getSliderPanel();
556  1 assertTrue(sp.isForConservation());
557  1 sp.valueChanged(30);
558  1 popupMenu.abovePIDColour_actionPerformed(true);
559  1 sp = SliderPanel.getSliderPanel();
560  1 assertFalse(sp.isForConservation());
561  1 sp.valueChanged(40);
562  1 rs = sg.getGroupColourScheme();
563  1 assertTrue(rs.conservationApplied());
564  1 assertEquals(rs.getConservationInc(), 30);
565  1 assertEquals(rs.getThreshold(), 40);
566   
567    /*
568    * set slider panel focus to the background alignment
569    */
570  1 af.conservationMenuItem_actionPerformed(true);
571  1 sp = SliderPanel.getSliderPanel();
572  1 assertTrue(sp.isForConservation());
573  1 assertEquals(sp.getTitle(), MessageManager.formatMessage(
574    "label.conservation_colour_increment",
575    new String[] { "Background" }));
576   
577    /*
578    * make a new View, verify alignment and group colour schemes
579    */
580  1 af.newView_actionPerformed(null);
581  1 assertEquals(af.alignPanel.getViewName(), "View 1");
582  1 AlignViewport av2 = af.getViewport();
583  1 assertNotSame(av, av2);
584  1 assertSame(av2, af.alignPanel.av);
585  1 rs = av2.getResidueShading();
586  1 assertNotSame(av.getResidueShading(), rs);
587  1 assertEquals(rs.getThreshold(), 10);
588  1 assertTrue(rs.conservationApplied(), rs.toString());
589  1 assertEquals(rs.getConservationInc(), 20);
590  1 assertEquals(av2.getAlignment().getGroups().size(), 1);
591  1 sg = av2.getAlignment().getGroups().get(0);
592  1 rs = sg.getGroupColourScheme();
593  1 assertTrue(rs.conservationApplied());
594  1 assertEquals(rs.getConservationInc(), 30);
595  1 assertEquals(rs.getThreshold(), 40);
596   
597    /*
598    * check the Conservation SliderPanel (still open) is linked to
599    * and updates the new view (JAL-2385)
600    */
601  1 sp = SliderPanel.getSliderPanel();
602  1 assertTrue(sp.isForConservation());
603  1 assertEquals(sp.getTitle(), MessageManager.formatMessage(
604    "label.conservation_colour_increment",
605    new String[] { "View 1" }));
606  1 sp.valueChanged(22);
607  1 assertEquals(av2.getResidueShading().getConservationInc(), 22);
608    }
609   
610    /**
611    * Verify that making a New View preserves the dataset reference for the
612    * alignment. Otherwise, see a 'duplicate jar entry' reference when trying to
613    * save alignments with multiple views, and codon mappings will not be shared
614    * across all panels in a split frame.
615    *
616    * @see Jalview2xmlTests#testStoreAndRecoverColourThresholds()
617    */
 
618  1 toggle @Test(groups = "Functional")
619    public void testNewView_dsRefPreserved()
620    {
621  1 AlignViewport av = af.getViewport();
622  1 AlignmentI al = av.getAlignment();
623  1 AlignmentI original_ds = al.getDataset();
624  1 af.newView_actionPerformed(null);
625  1 assertNotEquals("New view didn't select the a new panel", av,
626    af.getViewport());
627  1 org.testng.Assert.assertEquals(original_ds,
628    af.getViewport().getAlignment().getDataset(),
629    "Dataset was not preserved in new view");
630    }
631    }