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