[MOBY-guts] biomoby commit
Paul Gordon
gordonp at dev.open-bio.org
Tue Apr 3 02:32:15 UTC 2007
gordonp
Mon Apr 2 22:32:14 EDT 2007
Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/test
In directory dev.open-bio.org:/tmp/cvs-serv6849/src/main/ca/ucalgary/seahawk/gui/test
Modified Files:
SeahawkTestCase.java
Log Message:
Refactoring, plus addition of asynchronous service test case
moby-live/Java/src/main/ca/ucalgary/seahawk/gui/test SeahawkTestCase.java,1.4,1.5
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/test/SeahawkTestCase.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/test/SeahawkTestCase.java 2007/02/08 16:59:58 1.4
+++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/test/SeahawkTestCase.java 2007/04/03 02:32:14 1.5
@@ -37,6 +37,7 @@
private final static String TEST_MOBY_XML = "ca/ucalgary/seahawk/gui/test/allDataTypes.xml";
private final static String TEST_EXTERNAL_URL = "http://www.google.com/";
private final static String TEST_DNA_SEQ = "AAGCTTGGCCAACGTAAATCTTTCGGCGGCA";
+ private final static String TEST_AA_SEQ = "MPGGFILAIDEGTTSARAIIYNQDLEVLGIGQYDFPQHYPSP";
private JFCTestHelper helper = null;
@@ -156,7 +157,7 @@
dnaDataType, clipSet.getDataType());
// add an object of another type (AminoAcidSequence)
- MobyDataObject mobyObject3 = MobyUtils.createMobySequence("MPGGFILAIDEGTTSARAIIY", "baz");
+ MobyDataObject mobyObject3 = MobyUtils.createMobySequence(TEST_AA_SEQ, "baz");
clipSet = contentGUI.addToClipboard(mobyObject3);
assertNotNull("The clipboard is null, but should be initialized, with two objects", clipSet);
assertTrue("The clipboard contains the wrong number (" + clipSet.size() + ") of items, expected 3",
@@ -569,9 +570,9 @@
public void testCloseOtherTabs(){
}
- public void testRunServices() throws Exception{
+ public void findService(String sequenceData, String targetMenuText, String targetServiceLabelText) throws Exception{
// load a dna sequence in a tab
- MobyDataObject mobyObject = MobyUtils.createMobySequence(TEST_DNA_SEQ, "foo");
+ MobyDataObject mobyObject = MobyUtils.createMobySequence(sequenceData, "foo");
contentGUI.loadPaneFromObject(new MobyContentInstance(mobyObject, "hyperlink-test"), true); //true = load in new tab
// give the JVM time to paint the new data
@@ -584,8 +585,9 @@
String text = pane.getDocument().getText(0, pane.getDocument().getLength());
// Find the position of the first XPointer link (should be a reference
// to the file version of the DNASequence we created above)
- int hyperlinkModelIndex = text.indexOf("DNASequence");
- assertFalse("Could not find a MOBY link in the DNASequence representation", hyperlinkModelIndex == -1);
+ String dataType = mobyObject.getDataType().getName();
+ int hyperlinkModelIndex = text.indexOf(dataType);
+ assertFalse("Could not find a MOBY link in the "+dataType+" representation", hyperlinkModelIndex == -1);
try{
Rectangle linkPos = pane.modelToView(hyperlinkModelIndex+4);
@@ -601,7 +603,8 @@
}
Robot robot = new Robot();
- robot.mouseMove(screenPos.x, screenPos.y);
+ robot.mouseMove(screenPos.x, screenPos.y+10);
+ sleep(1000);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
sleep(2000);
@@ -614,7 +617,7 @@
openPopup instanceof JPopupMenu);
// Move the mouse a bit to the right to bring up the submenu
- robot.mouseMove(screenPos.x+10, screenPos.y);
+ robot.mouseMove(screenPos.x+10, screenPos.y+8);
// Find a submenu with services
Component serviceTypeChoices = getSubComponentByName((JPopupMenu) openPopup,
@@ -631,7 +634,7 @@
JMenuItem serviceTypeChosen = ((JMenu) serviceTypeChoices).getItem(1);
for(int i = 2;
- serviceTypeChosen.getText().indexOf("Analysis") == -1 &&
+ serviceTypeChosen.getText().indexOf(targetMenuText) == -1 &&
i <= ((JMenu) serviceTypeChoices).getItemCount();
i++){
if(i == ((JMenu) serviceTypeChoices).getItemCount()){
@@ -649,64 +652,55 @@
sleep(1000);
serviceTypeChoices = serviceTypeChosen;
- Vector<JMenuItem> servicePathChosen = findMenuItem((JMenu) serviceTypeChosen, "...");
+ Vector<JMenuItem> servicePathChosen = findMenuItem((JMenu) serviceTypeChosen, targetServiceLabelText);
if(servicePathChosen == null || servicePathChosen.size() == 0){
- System.err.println("WARNING: Skipping test of secondary param services, none were found ending in '...'");
- return;
+ throw new Exception("Cannot find a target service, "+
+ "none were found ending in '"+targetServiceLabelText+"'");
}
- else{
- // Make sure it's visible
- showMenuItem((JMenu) serviceTypeChosen, servicePathChosen, robot);
- Point serviceMenuItemLoc = servicePathChosen.lastElement().getLocationOnScreen(); //so move the mouse there too
- // and click the service button
- robot.mouseMove(serviceMenuItemLoc.x+2, serviceMenuItemLoc.y+2);
- robot.keyPress(KeyEvent.VK_SHIFT);
- robot.mousePress(InputEvent.BUTTON1_MASK);
- robot.mouseRelease(InputEvent.BUTTON1_MASK);
- robot.keyRelease(KeyEvent.VK_SHIFT);
- //serviceChosen.doClick(300);
- sleep(2000);
- JDialog secondaryParamsDialog = null;
+ // Make sure it's visible
+ showMenuItem((JMenu) serviceTypeChosen, servicePathChosen, robot);
+ Point serviceMenuItemLoc = servicePathChosen.lastElement().getLocationOnScreen(); //so move the mouse there too
+ // and click the service button
+ robot.mouseMove(serviceMenuItemLoc.x+2, serviceMenuItemLoc.y+2);
+ robot.keyPress(KeyEvent.VK_SHIFT);
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+ robot.keyRelease(KeyEvent.VK_SHIFT);
+ //serviceChosen.doClick(300);
+ sleep(2000);
+ }
- DialogFinder dfinder = new DialogFinder(".*");
- List showingDialogs = dfinder.findAll();
- for(int i = 0; i < showingDialogs.size(); i++){
- JDialog dialog = (JDialog) showingDialogs.get(i);
- if(MobySecondaryInputGUI.TITLE.equals(dialog.getTitle())){
- secondaryParamsDialog = dialog;
- break;
- }
- }
+ public void testRunAsynchronousService() throws Exception{
+ try{
+ findService(TEST_AA_SEQ, "Bioinformatics", "(async)");
+ } catch(Exception e){
+ e.printStackTrace();
+ fail("Error while finding a service ending with \"(async)\" " +
+ "(asynchronous execution) under \"Bioinformatics\" in the popup");
+ }
- assertNotNull("Requesting a service with secondary parameters did not launch " +
- "a secondary parameter input component (was null)",
- secondaryParamsDialog);
- assertTrue("Secondary parameter input component was not a JDialog as expected (was a " +
- secondaryParamsDialog.getClass().getName(),
- secondaryParamsDialog instanceof JDialog);
- Component okButton = getSubComponentByName(secondaryParamsDialog.getContentPane(),
- MobySecondaryInputGUI.OK_BUTTON_NAME);
- assertNotNull("Could not find the OK button in the secondary input GUI dialog", okButton);
- Point okLoc = okButton.getLocationOnScreen(); //so move the mouse there too
- // and click the OK button
- robot.mouseMove(okLoc.x+2, okLoc.y+2);
- robot.mousePress(InputEvent.BUTTON1_MASK);
- robot.mouseRelease(InputEvent.BUTTON1_MASK);
- sleep(2000);
+ fillInSecondariesAndExecute();
- showingDialogs = dfinder.findAll();
- for(int i = 0; i < showingDialogs.size(); i++){
- JDialog dialog = (JDialog) showingDialogs.get(i);
- if(dialog.isVisible()){
- assertFalse("The secondary parameter window did not disappear when enter was pressed (" +
- "either the approval button does not have the default focus, or " +
- " there is an internal problem with the dialog validation)",
- MobySecondaryInputGUI.TITLE.equals(dialog.getTitle()));
- }
+ // Wait until the job is finished to proceed to the next test
+ while(contentGUI.getCurrentURL() == null){
+ sleep(1000);
+ if(contentGUI.isShowingFailure()){
+ break;
}
-
}
-
+ sleep(2000); //just to ensure HTML rendering finishes
+ }
+
+ public void testRunServiceSecondariesAndSCUFL() throws Exception{
+ try{
+ findService(TEST_DNA_SEQ, "Bioinformatics", "...");
+ } catch(Exception e){
+ e.printStackTrace();
+ fail("Error while a finding service ending with \"...\" " +
+ "(secondary input) under \"Analysis\" in the popup");
+ }
+ fillInSecondariesAndExecute();
+
// Wait until the job is finished to proceed to the next test
while(contentGUI.getCurrentURL() == null){
sleep(1000);
@@ -724,6 +718,49 @@
assertTrue("The SCUFL saved data file was empty", testFile.length() != 0);
}
+ public void fillInSecondariesAndExecute() throws Exception{
+ Robot robot = new Robot();
+ JDialog secondaryParamsDialog = null;
+
+ DialogFinder dfinder = new DialogFinder(".*");
+ List showingDialogs = dfinder.findAll();
+ for(int i = 0; i < showingDialogs.size(); i++){
+ JDialog dialog = (JDialog) showingDialogs.get(i);
+ if(MobySecondaryInputGUI.TITLE.equals(dialog.getTitle())){
+ secondaryParamsDialog = dialog;
+ break;
+ }
+ }
+
+ assertNotNull("Requesting a service with secondary parameters did not launch " +
+ "a secondary parameter input component (was null)",
+ secondaryParamsDialog);
+ assertTrue("Secondary parameter input component was not a JDialog as expected (was a " +
+ secondaryParamsDialog.getClass().getName(),
+ secondaryParamsDialog instanceof JDialog);
+ Component okButton = getSubComponentByName(secondaryParamsDialog.getContentPane(),
+ MobySecondaryInputGUI.OK_BUTTON_NAME);
+ assertNotNull("Could not find the OK button in the secondary input GUI dialog", okButton);
+ Point okLoc = okButton.getLocationOnScreen(); //so move the mouse there too
+ // and click the OK button
+ robot.mouseMove(okLoc.x+2, okLoc.y+2);
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+ sleep(2000);
+
+ showingDialogs = dfinder.findAll();
+ for(int i = 0; i < showingDialogs.size(); i++){
+ JDialog dialog = (JDialog) showingDialogs.get(i);
+ if(dialog.isVisible()){
+ assertFalse("The secondary parameter window did not disappear when enter was pressed (" +
+ "either the approval button does not have the default focus, or " +
+ "there is an internal problem with the dialog validation)",
+ MobySecondaryInputGUI.TITLE.equals(dialog.getTitle()));
+ }
+ }
+
+ }
+
// Load a document, then highlight a salient section that can be turned into Web Service choices
// via MobyServicesGUI.
public void testHighlightOptions() throws Exception{
@@ -853,17 +890,18 @@
public static Test suite() {
TestSuite suite = new TestSuite();
- suite.addTest(new SeahawkTestCase("testMain")); //done
- suite.addTest(new SeahawkTestCase("testHelpTab")); //done
- suite.addTest(new SeahawkTestCase("testHelpButton")); //done
- suite.addTest(new SeahawkTestCase("testClipboardTab")); //done
- suite.addTest(new SeahawkTestCase("testOpenButton")); //done
- suite.addTest(new SeahawkTestCase("testSave")); //done
- suite.addTest(new SeahawkTestCase("testPrint")); //done
- suite.addTest(new SeahawkTestCase("testNavigationButtons")); //done
- suite.addTest(new SeahawkTestCase("testRunServices")); //done
- suite.addTest(new SeahawkTestCase("testHighlightOptions"));//done
- suite.addTest(new SeahawkTestCase("testExternalBrowser"));//done
+ suite.addTest(new SeahawkTestCase("testMain")); //done
+ suite.addTest(new SeahawkTestCase("testHelpTab")); //done
+ suite.addTest(new SeahawkTestCase("testHelpButton")); //done
+ suite.addTest(new SeahawkTestCase("testClipboardTab")); //done
+ suite.addTest(new SeahawkTestCase("testOpenButton")); //done
+ suite.addTest(new SeahawkTestCase("testSave")); //done
+ suite.addTest(new SeahawkTestCase("testPrint")); //done
+ suite.addTest(new SeahawkTestCase("testNavigationButtons")); //done
+ suite.addTest(new SeahawkTestCase("testRunAsynchronousService")); //done
+ suite.addTest(new SeahawkTestCase("testRunServiceSecondariesAndSCUFL")); //done
+ suite.addTest(new SeahawkTestCase("testHighlightOptions"));//done
+ suite.addTest(new SeahawkTestCase("testExternalBrowser"));//doney
return suite;
}
@@ -906,15 +944,19 @@
}
public boolean findMenuItem(JMenu menu, String pattern, Vector<JMenuItem> result){
- JMenuItem serviceChosen = menu.getItem(0);
- for(int i = 1;
- serviceChosen.getText().indexOf(pattern) == -1 && i <= menu.getItemCount();
+ JMenuItem serviceChosen = null;
+ for(int i = 0;
+ i <= menu.getItemCount();
i++){
if(i == menu.getItemCount()){
return false;
}
+
+ serviceChosen = menu.getItem(i);
+ if(serviceChosen.getText().indexOf(pattern) != -1){
+ break;
+ }
else{
- serviceChosen = menu.getItem(i);
// Nested menu
if(serviceChosen instanceof JMenu){
if(findMenuItem((JMenu) serviceChosen, pattern, result)){
More information about the MOBY-guts
mailing list