[MOBY-guts] biomoby commit
Paul Gordon
gordonp at dev.open-bio.org
Wed Nov 22 22:23:55 UTC 2006
gordonp
Wed Nov 22 17:23:54 EST 2006
Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/test
In directory dev.open-bio.org:/tmp/cvs-serv19867/src/main/ca/ucalgary/seahawk/gui/test
Modified Files:
SeahawkTestCase.java
Log Message:
Changes to improve Seahawk Unit Test generality
moby-live/Java/src/main/ca/ucalgary/seahawk/gui/test SeahawkTestCase.java,1.2,1.3
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/test/SeahawkTestCase.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/test/SeahawkTestCase.java 2006/10/25 13:54:50 1.2
+++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/test/SeahawkTestCase.java 2006/11/22 22:23:54 1.3
@@ -30,11 +30,11 @@
import java.io.File;
import java.net.URL;
import java.util.List;
+import java.util.Vector;
public class SeahawkTestCase extends JFCTestCase{
- private final static String TEST_MOBYEX_XML = "testdata/moby_exception.xml";
- //private final static String TEST_MOBY_XML = "testdata/runNCBIBlastn18884.xml";
- private final static String TEST_MOBY_XML = "testdata/allDataTypes.xml";
+ private final static String TEST_MOBYEX_XML = "ca/ucalgary/seahawk/gui/test/moby_exception.xml";
+ 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";
@@ -604,7 +604,7 @@
robot.mouseMove(screenPos.x, screenPos.y);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
- sleep(3000);
+ sleep(2000);
finder.setName(MobyContentPane.MOBY_SERVICE_POPUP_NAME);
Object openPopup = finder.find();
assertNotNull("Clicking the hyperlink did not open the service options popup (was null)",
@@ -641,61 +641,23 @@
serviceTypeChosen = ((JMenu) serviceTypeChoices).getItem(i);
}
}
- assertNotNull("Could not find Parsing services submenu required to test service execution",
- serviceTypeChosen);
- Point submenuPos = serviceTypeChosen.getLocationOnScreen();
- // Put mouse on parsing service item to show submenu...
- robot.mouseMove(submenuPos.x, submenuPos.y);
- sleep(1000);
- serviceTypeChoices = serviceTypeChosen;
-
- serviceTypeChosen = ((JMenu) serviceTypeChoices).getItem(1);
- for(int i = 2;
- serviceTypeChosen.getText().indexOf("Analysis") == -1 &&
- i <= ((JMenu) serviceTypeChoices).getItemCount();
- i++){
- if(i == ((JMenu) serviceTypeChoices).getItemCount()){
- serviceTypeChosen = null; break;
- }
- else{
- serviceTypeChosen = ((JMenu) serviceTypeChoices).getItem(i);
- }
- }
- assertNotNull("Could not find Parsing services submenu required to test service execution",
+ assertNotNull("Could not find Analysis services submenu required to test service execution",
serviceTypeChosen);
- submenuPos = serviceTypeChosen.getLocationOnScreen();
- // Put mouse on parsing service item to show submenu...
- robot.mouseMove(submenuPos.x, submenuPos.y);
- sleep(1000);
- serviceTypeChoices = serviceTypeChosen;
+ Point submenuPos = serviceTypeChosen.getLocationOnScreen();
+ // Put mouse on parsing service item to show submenu...
+ robot.mouseMove(submenuPos.x, submenuPos.y);
+ sleep(1000);
+ serviceTypeChoices = serviceTypeChosen;
- JMenuItem serviceChosen = ((JMenu) serviceTypeChosen).getItem(0);
- for(int i = 1;
- serviceChosen.getText().indexOf("...") == -1 && i <= ((JMenu) serviceTypeChoices).getItemCount();
- i++){
- if(i == ((JMenu) serviceTypeChoices).getItemCount()){
- serviceChosen = null; break;
- }
- else{
- serviceChosen = ((JMenu) serviceTypeChoices).getItem(i);
- }
- }
- if(serviceChosen == null){
+ Vector<JMenuItem> servicePathChosen = findMenuItem((JMenu) serviceTypeChosen, "...");
+ if(servicePathChosen == null || servicePathChosen.size() == 0){
System.err.println("WARNING: Skipping test of secondary param services, none were found ending in '...'");
- serviceChosen = ((JMenu) serviceTypeChosen).getItem(0);
- 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);
- assertFalse("Dialogs with title \""+MobySecondaryInputGUI.TITLE+
- "\" was found, but service launched had no secondary params",
- MobySecondaryInputGUI.TITLE.equals(dialog.getTitle()));
- }
+ return;
}
else{
- Point serviceMenuItemLoc = serviceChosen.getLocationOnScreen(); //so move the mouse there too
+ // 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);
@@ -758,7 +720,7 @@
File testFile = File.createTempFile("test-seahawk", "");
testFile.deleteOnExit();
MobySaveDialog.exportSCUFL(contentGUI.getCurrentPane(), testFile);
- sleep(2000);
+ sleep(1000);
assertTrue("The SCUFL saved data file was empty", testFile.length() != 0);
}
@@ -847,46 +809,15 @@
}
sleep(500); //give time to draw the menu again
- // Pick a service that doesn't take secondary parameters Parsing -> ExplodeOutCrossReferences
- assertTrue("There was not at least 2 items (clipboard + a real service) in the service popup submenu",
- ((JMenu) serviceTypeChoices).getItemCount() > 1);
- JMenuItem serviceTypeChosen = ((JMenu) serviceTypeChoices).getItem(1);
- for(int i = 2;
- serviceTypeChosen.getText().indexOf("Parsing") == -1 &&
- i <= ((JMenu) serviceTypeChoices).getItemCount();
- i++){
- if(i == ((JMenu) serviceTypeChoices).getItemCount()){
- serviceTypeChosen = null; break;
- }
- else{
- serviceTypeChosen = ((JMenu) serviceTypeChoices).getItem(i);
- }
- }
- assertNotNull("Could not find Parsing services submenu required to test service execution",
- serviceTypeChosen);
- Point submenuPos = serviceTypeChosen.getLocationOnScreen();
- // Put mouse on parsing service item to show submenu...
- robot.mouseMove(submenuPos.x, submenuPos.y);
- sleep(1000);
-
- JMenuItem serviceChosen = ((JMenu) serviceTypeChosen).getItem(0);
- for(int i = 1;
- serviceChosen.getText().indexOf("ExplodeOutCrossReferences") == -1 &&
- i <= ((JMenu) serviceTypeChosen).getItemCount();
- i++){
- if(i == ((JMenu) serviceTypeChosen).getItemCount()){
- serviceChosen = null; break;
- }
- else{
- serviceChosen = ((JMenu) serviceTypeChosen).getItem(i);
- }
- }
- if(serviceChosen == null){
- System.err.println("Skipping test of non-secondary param services, none were found");
+ Vector<JMenuItem> servicePathChosen = findMenuItem((JMenu) serviceTypeChoices, "ExplodeOutCrossReferences");
+ if(servicePathChosen == null || servicePathChosen.size() == 0){
+ System.err.println("WARNING: Skipping test of service run, no 'ExplodeOutCrossReferences' service was found");
return;
}
+ // Make sure it's visible
+ showMenuItem((JMenu) serviceTypeChoices, servicePathChosen, robot);
- serviceChosen.doClick(300);
+ servicePathChosen.lastElement().doClick(300);
sleep(2000);
DialogFinder dfinder = new DialogFinder(".*");
List showingDialogs = dfinder.findAll();
@@ -945,4 +876,55 @@
junit.textui.TestRunner.run(suite());
}
+
+ public void showMenuItem(JMenu menu, Vector<JMenuItem> path, Robot robot) throws Exception{
+ for(int i = 0; i < path.size(); i++){
+ JMenuItem pathItem = path.elementAt(i);
+ for(int j = 0; j < menu.getItemCount(); j++){
+ if(pathItem.equals(menu.getItem(j))){
+ Point serviceMenuItemLoc = pathItem.getLocationOnScreen(); //so move the mouse there too
+ // and click the service button
+ robot.mouseMove(serviceMenuItemLoc.x+2, serviceMenuItemLoc.y+2);
+ if(pathItem instanceof JMenu){ //not terminal
+ menu = (JMenu) pathItem;
+ }
+ else{
+ i = path.size(); //terminal, end outer loop
+ }
+ Thread.sleep(1000);
+ break;
+ }
+ }
+ }
+ }
+
+ // Depth-first search of submenus for a menu item matching the pattern
+ public Vector<JMenuItem> findMenuItem(JMenu menu, String pattern){
+ Vector<JMenuItem> result = new Vector<JMenuItem>();
+ findMenuItem(menu, pattern, result);
+ return result;
+ }
+
+ 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();
+ i++){
+ if(i == menu.getItemCount()){
+ return false;
+ }
+ else{
+ serviceChosen = menu.getItem(i);
+ // Nested menu
+ if(serviceChosen instanceof JMenu){
+ if(findMenuItem((JMenu) serviceChosen, pattern, result)){
+ break;
+ }
+ }
+ }
+ }
+ result.insertElementAt(serviceChosen, 0); //build the menu tree path
+ //System.err.println("Returning menu element " + serviceChosen);
+ return true;
+ }
}
More information about the MOBY-guts
mailing list