[MOBY-guts] biomoby commit

Paul Gordon gordonp at dev.open-bio.org
Sat Jun 16 00:30:35 UTC 2007


gordonp
Fri Jun 15 20:30:34 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-serv29405/src/main/ca/ucalgary/seahawk/gui/test

Modified Files:
	SeahawkTestCase.java 
Log Message:
Added tests for user preferences save/load, made hyperlink clicking more robust
moby-live/Java/src/main/ca/ucalgary/seahawk/gui/test SeahawkTestCase.java,1.7,1.8
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/test/SeahawkTestCase.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/test/SeahawkTestCase.java	2007/04/18 15:59:00	1.7
+++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/test/SeahawkTestCase.java	2007/06/16 00:30:34	1.8
@@ -1,12 +1,7 @@
 package ca.ucalgary.seahawk.gui.test;
 
-import ca.ucalgary.seahawk.gui.MobyContentGUI;
-import ca.ucalgary.seahawk.gui.MobyContentHelpPane;
-import ca.ucalgary.seahawk.gui.MobyContentPane;
-import ca.ucalgary.seahawk.gui.MobySaveDialog;
-import ca.ucalgary.seahawk.gui.MobySecondaryInputGUI;
-import ca.ucalgary.seahawk.gui.MobyServicesGUI;
-import ca.ucalgary.seahawk.util.MobyUtils;
+import ca.ucalgary.seahawk.gui.*;
+import ca.ucalgary.seahawk.util.*;
 
 import org.biomoby.shared.MobyDataType;
 import org.biomoby.shared.data.*;
@@ -605,7 +600,11 @@
 
 	Robot robot = new Robot();
 	robot.mouseMove(screenPos.x, screenPos.y+10);
-	sleep(1000);
+	sleep(2000);
+	robot.mouseMove(screenPos.x-10, screenPos.y+10);
+	sleep(2000);
+	robot.mouseMove(screenPos.x+10, screenPos.y+10);
+	sleep(2000);
 	robot.mousePress(InputEvent.BUTTON1_MASK);
 	robot.mouseRelease(InputEvent.BUTTON1_MASK);
 	sleep(2000);
@@ -728,6 +727,7 @@
 	Robot robot = new Robot();
 	JDialog secondaryParamsDialog = null;
 	
+	sleep(10000);  // wait for dialog to popup, may take a while when meta-data about the service is fetched
 	DialogFinder dfinder = new DialogFinder(".*");
 	List showingDialogs = dfinder.findAll();
 	for(int i = 0; i < showingDialogs.size(); i++){
@@ -820,7 +820,7 @@
 	robot.mouseMove(screenEndPos.x+2, screenEndPos.y+2);
 	robot.mousePress(InputEvent.BUTTON1_MASK);
 	robot.mouseRelease(InputEvent.BUTTON1_MASK);
-	sleep(2000);
+	sleep(3000);
 	finder.setName(MobyContentPane.MOBY_SERVICE_POPUP_NAME);
 	Object servicePopup = finder.find();
 	assertNotNull("Clicking the highlighted region did not open the service options popup (was null)", 
@@ -862,7 +862,7 @@
 	showMenuItem((JMenu) serviceTypeChoices, servicePathChosen, robot);
 
 	servicePathChosen.lastElement().doClick(300);
-	sleep(2000);
+	sleep(10000);
 	DialogFinder dfinder = new DialogFinder(".*");
 	List showingDialogs = dfinder.findAll();
 	for(int i = 0; i < showingDialogs.size(); i++){
@@ -891,6 +891,50 @@
 	MobyContentGUI.main(new String[]{});
     }
 
+    public void testUserPreferences() throws Exception{
+	File tempFile = File.createTempFile("test-seahawk", "");
+	try{
+	    java.io.FileOutputStream tempFileOS = new java.io.FileOutputStream(tempFile);
+	    tempFileOS.write("junk".getBytes());
+	    tempFileOS.close();
+	} catch(Exception e){
+	    e.printStackTrace();
+	    fail("Could not write to temporary file " + tempFile + ": " + e);
+	}
+	boolean failedAsShould = false;
+	try{
+	    SeahawkOptions.restoreSettings(tempFile.toURI().toURL());
+	} catch(Exception e){
+	    failedAsShould = true;
+	}
+	assertTrue("No exception was thrown, despite a poorly formatted preference file", 
+		   failedAsShould);
+
+	SeahawkOptions.setCacheExpiry(10.0);
+	assertTrue("Setting the cache expiry preference did not work, expected " +
+		   "current value of 10, but found " + SeahawkOptions.getCacheExpiry(),
+		   SeahawkOptions.getCacheExpiry() == 10.0);
+	try{
+	    java.io.FileOutputStream tempFileOS = new java.io.FileOutputStream(tempFile);
+	    SeahawkOptions.saveSettings(tempFileOS);
+	    tempFileOS.close();
+	} catch(Exception e){
+	    e.printStackTrace();
+	    fail("Could not save Seahawk settings to file " + tempFile + ": " + e);
+	}
+	SeahawkOptions.setCacheExpiry(20.0);
+	try{
+	    SeahawkOptions.restoreSettings(tempFile.toURI().toURL());
+	} catch(Exception e){
+	    e.printStackTrace();
+	    fail("Could not restore Seahawk settings from file " + tempFile + ": " + e);
+	}
+	assertTrue("The settings were not saved/restored properly, " +
+		   "expected cache expiry of 10, but got 20",
+		   SeahawkOptions.getCacheExpiry() == 10.0);
+	tempFile.delete();
+    }
+
     /**
      * @return a test suite for all the test methods of this test case.
      */
@@ -908,7 +952,8 @@
   	suite.addTest(new SeahawkTestCase("testRunAsynchronousService")); //done
   	suite.addTest(new SeahawkTestCase("testRunServiceSecondariesAndSCUFL")); //done
   	suite.addTest(new SeahawkTestCase("testHighlightOptions"));//done
-  	suite.addTest(new SeahawkTestCase("testExternalBrowser"));//doney
+  	suite.addTest(new SeahawkTestCase("testUserPreferences"));//done
+  	suite.addTest(new SeahawkTestCase("testExternalBrowser"));//done
         return suite;
     }
 




More information about the MOBY-guts mailing list