X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=test%2Fjalview%2Fbin%2FCommandsTest.java;h=65162f3f51f9ba404f71ad2bc60fc106ced7ec51;hb=a5928e2c1b9e2cea8d9c43f3d03f9cce2604f3b2;hp=9c763e19b48d4e73b04189c8a36b84ea93daadc3;hpb=dd27b3a58a81bcf699d547822d37aec77eb00e7e;p=jalview.git diff --git a/test/jalview/bin/CommandsTest.java b/test/jalview/bin/CommandsTest.java index 9c763e1..65162f3 100644 --- a/test/jalview/bin/CommandsTest.java +++ b/test/jalview/bin/CommandsTest.java @@ -3,6 +3,7 @@ package jalview.bin; import java.util.Date; import org.testng.Assert; +import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeClass; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; @@ -30,34 +31,49 @@ public class CommandsTest JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); } + @AfterMethod(alwaysRun = true) + public void tearDown() + { + Desktop.instance.closeAll_actionPerformed(null); + } + @Test(groups = "Functional", dataProvider = "cmdLines") public void commandsOpenTest(String cmdLine, String sequence) { String[] args = cmdLine.split("\\s+"); Jalview.main(args); - ArgParser argparser = new ArgParser(args); - boolean commandsSuccess = Commands.processArgs(argparser, false); - Assert.assertTrue(commandsSuccess, "Overall commandsSuccess is false"); + Commands cmds = Jalview.getInstance().getCommands(); + Assert.assertNotNull(cmds); + Assert.assertTrue(cmds.commandArgsProvided(), + "Commands were not provided in the args"); + Assert.assertTrue(cmds.argsWereParsed(), + "Overall command parse and operation is false"); if (sequence != null) { - AlignFrame[] afs = Desktop.getAlignFrames(); - boolean found = false; - ALIGNFRAME: for (AlignFrame af : afs) + Assert.assertTrue(lookForSequenceName(sequence), + "Sequence '" + sequence + + "' was not found in opened alignment files: " + + cmdLine); + } + + System.out.println("##### GOT TO END"); + } + + public static boolean lookForSequenceName(String sequenceName) + { + AlignFrame[] afs = Desktop.getAlignFrames(); + for (AlignFrame af : afs) + { + for (String name : af.getViewport().getAlignment().getSequenceNames()) { - for (String name : af.getViewport().getAlignment() - .getSequenceNames()) + if (sequenceName.equals(name)) { - if (sequence.equals(name)) - { - found = true; - break ALIGNFRAME; - } + return true; } } - Assert.assertTrue(found, "Sequence '" + sequence - + "' was not found in opened alignment files: " + cmdLine); } + return false; } @DataProvider(name = "cmdLines")