First commit in a looooooong time. I had connectivity problems.
authorshleh <shleh>
Fri, 17 Sep 2004 19:30:36 +0000 (19:30 +0000)
committershleh <shleh>
Fri, 17 Sep 2004 19:30:36 +0000 (19:30 +0000)
Using a testPool to show progress and test result info. Added icons...

28 files changed:
net.sourceforge.phpeclipse.phpunit/.classpath [new file with mode: 0644]
net.sourceforge.phpeclipse.phpunit/.project [new file with mode: 0644]
net.sourceforge.phpeclipse.phpunit/build.properties [new file with mode: 0644]
net.sourceforge.phpeclipse.phpunit/icons/sample.gif [new file with mode: 0644]
net.sourceforge.phpeclipse.phpunit/icons/test.gif [new file with mode: 0644]
net.sourceforge.phpeclipse.phpunit/icons/testerr.gif [new file with mode: 0644]
net.sourceforge.phpeclipse.phpunit/icons/testfail.gif [new file with mode: 0644]
net.sourceforge.phpeclipse.phpunit/icons/testok.gif [new file with mode: 0644]
net.sourceforge.phpeclipse.phpunit/icons/tsuite.gif [new file with mode: 0644]
net.sourceforge.phpeclipse.phpunit/icons/tsuiteerror.gif [new file with mode: 0644]
net.sourceforge.phpeclipse.phpunit/icons/tsuitefail.gif [new file with mode: 0644]
net.sourceforge.phpeclipse.phpunit/icons/tsuiteok.gif [new file with mode: 0644]
net.sourceforge.phpeclipse.phpunit/plugin.xml
net.sourceforge.phpeclipse.phpunit/src/Messages.java [new file with mode: 0644]
net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/PHPUnitPlugin.java [new file with mode: 0644]
net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/PHPUnitView.java
net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/ProgressInfoComposite.java
net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/ReportListener.java
net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/ResultsInfoComposite.java
net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/SettingsInfoComposite.java [new file with mode: 0644]
net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/TestPool.java [deleted file]
net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/TestPoolContentProvider.java [new file with mode: 0644]
net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/TestPoolLabelProvider.java [new file with mode: 0644]
net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/TestSuite.java [deleted file]
net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/actions/RunTestsAction.java
net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/testpool/TestCase.java [moved from net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/TestCase.java with 59% similarity]
net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/testpool/TestPool.java [new file with mode: 0644]
net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/testpool/TestSuite.java [new file with mode: 0644]

diff --git a/net.sourceforge.phpeclipse.phpunit/.classpath b/net.sourceforge.phpeclipse.phpunit/.classpath
new file mode 100644 (file)
index 0000000..26a1867
--- /dev/null
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+    <classpathentry kind="src" path="src/"/>
+    <classpathentry kind="src" path="/org.eclipse.ui"/>
+    <classpathentry kind="src" path="/org.eclipse.ui.views"/>
+    <classpathentry kind="src" path="/org.eclipse.core.boot"/>
+    <classpathentry kind="src" path="/org.eclipse.core.runtime"/>
+    <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+    <classpathentry kind="lib" path="C:/Documents and Settings/Ali Echihabi/My Documents/eclipse/eclipse-SDK-3_1.0-win32/eclipse/plugins/org.junit_3.8.1/junit.jar"/>
+    <classpathentry kind="src" path="/org.eclipse.core.resources"/>
+    <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/net.sourceforge.phpeclipse.phpunit/.project b/net.sourceforge.phpeclipse.phpunit/.project
new file mode 100644 (file)
index 0000000..7c1262f
--- /dev/null
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>net.sourceforge.phpeclipse.phpunit</name>
+       <comment></comment>
+       <projects>
+               <project>org.eclipse.core.boot</project>
+               <project>org.eclipse.core.resources</project>
+               <project>org.eclipse.core.runtime</project>
+               <project>org.eclipse.ui</project>
+               <project>org.eclipse.ui.views</project>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.jdt.core.javabuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.ManifestBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.SchemaBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>net.sourceforge.metrics.builder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.pde.PluginNature</nature>
+               <nature>org.eclipse.jdt.core.javanature</nature>
+               <nature>net.sourceforge.metrics.nature</nature>
+       </natures>
+</projectDescription>
diff --git a/net.sourceforge.phpeclipse.phpunit/build.properties b/net.sourceforge.phpeclipse.phpunit/build.properties
new file mode 100644 (file)
index 0000000..e07c485
--- /dev/null
@@ -0,0 +1,4 @@
+source.phpunit.jar = src/
+bin.includes = plugin.xml,\
+               *.jar,\
+               phpunit.jar
diff --git a/net.sourceforge.phpeclipse.phpunit/icons/sample.gif b/net.sourceforge.phpeclipse.phpunit/icons/sample.gif
new file mode 100644 (file)
index 0000000..34fb3c9
Binary files /dev/null and b/net.sourceforge.phpeclipse.phpunit/icons/sample.gif differ
diff --git a/net.sourceforge.phpeclipse.phpunit/icons/test.gif b/net.sourceforge.phpeclipse.phpunit/icons/test.gif
new file mode 100644 (file)
index 0000000..8f73ccb
Binary files /dev/null and b/net.sourceforge.phpeclipse.phpunit/icons/test.gif differ
diff --git a/net.sourceforge.phpeclipse.phpunit/icons/testerr.gif b/net.sourceforge.phpeclipse.phpunit/icons/testerr.gif
new file mode 100644 (file)
index 0000000..f866a2e
Binary files /dev/null and b/net.sourceforge.phpeclipse.phpunit/icons/testerr.gif differ
diff --git a/net.sourceforge.phpeclipse.phpunit/icons/testfail.gif b/net.sourceforge.phpeclipse.phpunit/icons/testfail.gif
new file mode 100644 (file)
index 0000000..de59bac
Binary files /dev/null and b/net.sourceforge.phpeclipse.phpunit/icons/testfail.gif differ
diff --git a/net.sourceforge.phpeclipse.phpunit/icons/testok.gif b/net.sourceforge.phpeclipse.phpunit/icons/testok.gif
new file mode 100644 (file)
index 0000000..f824bd8
Binary files /dev/null and b/net.sourceforge.phpeclipse.phpunit/icons/testok.gif differ
diff --git a/net.sourceforge.phpeclipse.phpunit/icons/tsuite.gif b/net.sourceforge.phpeclipse.phpunit/icons/tsuite.gif
new file mode 100644 (file)
index 0000000..5198579
Binary files /dev/null and b/net.sourceforge.phpeclipse.phpunit/icons/tsuite.gif differ
diff --git a/net.sourceforge.phpeclipse.phpunit/icons/tsuiteerror.gif b/net.sourceforge.phpeclipse.phpunit/icons/tsuiteerror.gif
new file mode 100644 (file)
index 0000000..7cd107c
Binary files /dev/null and b/net.sourceforge.phpeclipse.phpunit/icons/tsuiteerror.gif differ
diff --git a/net.sourceforge.phpeclipse.phpunit/icons/tsuitefail.gif b/net.sourceforge.phpeclipse.phpunit/icons/tsuitefail.gif
new file mode 100644 (file)
index 0000000..d247a8f
Binary files /dev/null and b/net.sourceforge.phpeclipse.phpunit/icons/tsuitefail.gif differ
diff --git a/net.sourceforge.phpeclipse.phpunit/icons/tsuiteok.gif b/net.sourceforge.phpeclipse.phpunit/icons/tsuiteok.gif
new file mode 100644 (file)
index 0000000..e3db1eb
Binary files /dev/null and b/net.sourceforge.phpeclipse.phpunit/icons/tsuiteok.gif differ
index 8cdf02d..a86b87c 100644 (file)
@@ -4,7 +4,7 @@
    name="net.sourceforge.phpeclipse.phpunit"
    version="1.0.0"
    provider-name="Ali Echihabi"
-   class="">
+   class="net.sourceforge.phpeclipse.phpunit.PHPUnitPlugin">
 
    <runtime>
       <library name="phpunit.jar"/>
@@ -20,7 +20,7 @@
       <category
             name="PHP Unit"
             parentCategory="PHPUnit"
-            id="net.sourceforge.phpeclipse.phpunit">
+            id="net.sourceforge.phpeclipse.phpunit.PHPUnitView">
       </category>
       <view
             name="PHP Unit Testing"
@@ -33,6 +33,7 @@
          point="org.eclipse.ui.popupMenus">
       <objectContribution
             objectClass="org.eclipse.core.resources.IFile"
+            adaptable="true"
             nameFilter="*.php"
             id="net.sourceforge.phpeclipse.phpunit.actions.runTestsAction">
          <action
diff --git a/net.sourceforge.phpeclipse.phpunit/src/Messages.java b/net.sourceforge.phpeclipse.phpunit/src/Messages.java
new file mode 100644 (file)
index 0000000..d716c94
--- /dev/null
@@ -0,0 +1,43 @@
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+/*
+ * Created on Jul 28, 2004
+ *
+ * To change the template for this generated file go to
+ * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
+ */
+
+/**
+ * @author Ali Echihabi
+ *
+ * To change the template for this generated type comment go to
+ * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
+ */
+public class Messages {
+
+       private static final String BUNDLE_NAME = "net.sourceforge.phpeclipse.phpunit.test"; //$NON-NLS-1$
+
+       private static final ResourceBundle RESOURCE_BUNDLE =
+               ResourceBundle.getBundle(BUNDLE_NAME);
+
+       /**
+        * 
+        */
+       private Messages() {
+
+               // TODO Auto-generated constructor stub
+       }
+       /**
+        * @param key
+        * @return
+        */
+       public static String getString(String key) {
+               // TODO Auto-generated method stub
+               try {
+                       return RESOURCE_BUNDLE.getString(key);
+               } catch (MissingResourceException e) {
+                       return '!' + key + '!';
+               }
+       }
+}
diff --git a/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/PHPUnitPlugin.java b/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/PHPUnitPlugin.java
new file mode 100644 (file)
index 0000000..e3873a4
--- /dev/null
@@ -0,0 +1,182 @@
+/*
+ * Created on Sep 4, 2004
+ *
+ * To change the template for this generated file go to
+ * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
+ */
+package net.sourceforge.phpeclipse.phpunit;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ResourceBundle;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPluginDescriptor;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.resource.ImageRegistry;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+/**
+ * @author Ali Echihabi
+ *
+ * To change the template for this generated type comment go to
+ * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
+ */
+public class PHPUnitPlugin extends AbstractUIPlugin {
+
+
+
+       private static PHPUnitPlugin plugin;
+       private ResourceBundle resourceBundle;
+
+
+       /**
+        * @param descriptor
+        */
+       public PHPUnitPlugin(IPluginDescriptor descriptor) {
+               super(descriptor);
+               
+               plugin = this;
+
+               
+       
+               
+       }
+
+       public static PHPUnitPlugin getDefault() {
+               return plugin;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.plugin.AbstractUIPlugin#createImageRegistry()
+        */
+       protected ImageRegistry createImageRegistry() {
+               // TODO Auto-generated method stub
+               return super.createImageRegistry();
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.plugin.AbstractUIPlugin#getDialogSettings()
+        */
+       public IDialogSettings getDialogSettings() {
+               // TODO Auto-generated method stub
+               return super.getDialogSettings();
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.plugin.AbstractUIPlugin#getImageRegistry()
+        */
+       public ImageRegistry getImageRegistry() {
+               // TODO Auto-generated method stub
+               return super.getImageRegistry();
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.plugin.AbstractUIPlugin#getPreferenceStore()
+        */
+       public IPreferenceStore getPreferenceStore() {
+               // TODO Auto-generated method stub
+               return super.getPreferenceStore();
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.plugin.AbstractUIPlugin#getWorkbench()
+        */
+       public IWorkbench getWorkbench() {
+               // TODO Auto-generated method stub
+               return super.getWorkbench();
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.core.runtime.Plugin#initializeDefaultPluginPreferences()
+        */
+       protected void initializeDefaultPluginPreferences() {
+               // TODO Auto-generated method stub
+               super.initializeDefaultPluginPreferences();
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.plugin.AbstractUIPlugin#initializeDefaultPreferences(org.eclipse.jface.preference.IPreferenceStore)
+        */
+       protected void initializeDefaultPreferences(IPreferenceStore store) {
+               // TODO Auto-generated method stub
+               super.initializeDefaultPreferences(store);
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.plugin.AbstractUIPlugin#initializeImageRegistry(org.eclipse.jface.resource.ImageRegistry)
+        */
+       protected void initializeImageRegistry(ImageRegistry reg) {
+               // TODO Auto-generated method stub
+               super.initializeImageRegistry(reg);
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.plugin.AbstractUIPlugin#loadDialogSettings()
+        */
+       protected void loadDialogSettings() {
+               // TODO Auto-generated method stub
+               super.loadDialogSettings();
+       }
+
+
+
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.plugin.AbstractUIPlugin#refreshPluginActions()
+        */
+       protected void refreshPluginActions() {
+               // TODO Auto-generated method stub
+               super.refreshPluginActions();
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.plugin.AbstractUIPlugin#saveDialogSettings()
+        */
+       protected void saveDialogSettings() {
+               // TODO Auto-generated method stub
+               super.saveDialogSettings();
+       }
+
+
+
+       /* (non-Javadoc)
+        * @see org.eclipse.core.runtime.Plugin#shutdown()
+        */
+       public void shutdown() throws CoreException {
+               // TODO Auto-generated method stub
+               super.shutdown();
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.core.runtime.Plugin#startup()
+        */
+       public void startup() throws CoreException {
+               // TODO Auto-generated method stub
+               super.startup();
+       }
+
+       /**
+        * @param string
+        */
+       public static ImageDescriptor getImageDescriptor(String name) {
+               
+               String iconPath = "icons/";
+               try {
+                       URL installURL = getDefault().getDescriptor().getInstallURL();
+                       URL url = new URL(installURL, iconPath + name);
+                       
+                       System.out.println("url:" + url.toExternalForm());
+                       
+                       return ImageDescriptor.createFromURL(url);
+               } catch (MalformedURLException e) {
+                       // should not happen
+                       return ImageDescriptor.getMissingImageDescriptor();
+               }               
+               
+               
+       }
+
+}
index 847d620..1f16ca6 100644 (file)
@@ -1,16 +1,25 @@
 package net.sourceforge.phpeclipse.phpunit;
 
+
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
 import java.io.IOException;
 
+import net.sourceforge.phpeclipse.phpunit.testpool.TestCase;
+import net.sourceforge.phpeclipse.phpunit.testpool.TestPool;
+import net.sourceforge.phpeclipse.phpunit.testpool.TestSuite;
+
 import org.eclipse.jface.action.Action;
 import org.eclipse.jface.action.IToolBarManager;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.MouseEvent;
 import org.eclipse.swt.events.MouseListener;
-import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Group;
 import org.eclipse.ui.IActionBars;
 import org.eclipse.ui.ISharedImages;
 import org.eclipse.ui.PlatformUI;
@@ -41,6 +50,9 @@ import org.eclipse.ui.part.ViewPart;
 
 public class PHPUnitView extends ViewPart {
 
+
+
+
        /*
         * like J Unit
         * a tree.
@@ -50,49 +62,62 @@ public class PHPUnitView extends ViewPart {
         * hierarchy: package->testsuite1->testcase->test_function
         */
 
-       private int numTests; // total number of tests
-       private int numTestsRun; // number of tests run so far
-       private int numFailures; // number of failures so far
-       private int numErrors; // number of errors so far
-       private int numPasses; // number of passes so far (they should add up)   
+       private static PHPUnitView view = null;
 
        private XMLReportHandler handler;
-
-
-
+       
        private TestPool testPool;
 
        private Button startButton;
 
        private ProgressInfoComposite progressInfoComposite;
        private ResultsInfoComposite resultsInfoComposite;
-       private Group settingsInfoComposite; //TODO: move somewhere else, launcher, wizard or preferences.
+       private SettingsInfoComposite settingsInfoComposite; //TODO: move somewhere else, launcher, wizard or preferences.
        
 
 
        public PHPUnitView() {
-               handler = new XMLReportHandler();
-               testPool = new TestPool();
                
+               if(view == null)
+                       view = this;
 
        }
+       
+       public static PHPUnitView getDefault() {
+               
+               
+               return view; 
+       }
 
        public void createPartControl(Composite parent) {
 
-               parent.setLayout(new FillLayout(SWT.VERTICAL));
+               //parent.setLayout(new FillLayout(SWT.VERTICAL));
+
+               GridLayout gridLayout = new GridLayout();
+               gridLayout.numColumns = 1;
+               
+               // set title and layout
+               parent.setLayout(gridLayout);           
+               
 
                //Launch ToolBar:
                setActions();
 
-               //Build the progress info Composite             s               
+               //Build the progress info Composites            
                progressInfoComposite = new ProgressInfoComposite(parent);
+               progressInfoComposite.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING));
                
-
+               
+       
                //Build the result info composite
                resultsInfoComposite = new ResultsInfoComposite(parent);
+               resultsInfoComposite.setLayoutData(new GridData(GridData.GRAB_VERTICAL | GridData.FILL_BOTH));
                
                //build the settings composite
-               buildSettingsComposite(parent);
+               //buildSettingsComposite(parent);
+               
+               settingsInfoComposite = new SettingsInfoComposite(parent, SWT.NONE);
+
 
                startButton = new Button(parent, SWT.CENTER);
                startButton.setText("Start Tests");
@@ -104,12 +129,20 @@ public class PHPUnitView extends ViewPart {
 
                        public void mouseDown(MouseEvent arg0) {
 
-                               startTests();
+
 
                        }
 
                        public void mouseUp(MouseEvent arg0) {
 
+                               try {
+                                       String testFile = settingsInfoComposite.getTestSuite();
+                                       startTests(testFile);
+                               } catch (IOException e) {
+                                       // TODO Auto-generated catch block
+                                       e.printStackTrace();
+                               }
+
                        }
 
                }); // end add action listener.
@@ -122,8 +155,8 @@ public class PHPUnitView extends ViewPart {
        private void buildSettingsComposite(Composite parent) {
                
                
-               settingsInfoComposite = new Group(parent, SWT.NONE);
-//             settingsInfoComposite.setText("Settings");
+               //settingsInfoComposite = new Group(parent, SWT.NONE);
+               //settingsInfoComposite.setText("Settings");
 //             settingsInfoComposite.setLayout(new GridLayout(2,false));
 //             
 //             
@@ -138,9 +171,7 @@ public class PHPUnitView extends ViewPart {
 //             phpPathLabel.setText("php Path:");
 //             //testSuiteLabel.setLayoutData(new GridData())
 //             Text phpPathText = new Text(settingsInfoComposite, SWT.NONE);
-               
 
-               
        }
 
        private void setActions() {
@@ -180,41 +211,41 @@ public class PHPUnitView extends ViewPart {
         * 
         * @param testID
         */
-       public void markTestPassed(String testID) {
+       private void markTestPassed(String testID) {
 
                // testid, use it in hashmap to retrieve tree item of test and
                // change icon color, increment pass counter, etc...
 
-               testPool.getTest(testID).setVerdict(Test.PASS);
+               testPool.getTest(testID).setVerdict(TestCase.PASS);
                
 
        }
 
-       public void markTestStarted(String testID) {
+       private void markTestStarted(String testID) {
 
                
 
        }
 
-       public void createNewTest(String testName, String testID) {
+       private void createNewTest(String testName, String testID) {
 
-               testPool.addTest(new Test(testName, testID));
+               testPool.addTest(new TestCase(testName, testID));
        }
 
-       public void markTestFail(String testID) {
-               numFailures++;
-               testPool.getTest(testID).setVerdict(Test.FAIL);
+       private void markTestFail(String testID) {
+               
+               testPool.getTest(testID).setVerdict(TestCase.FAIL);
                
        }
 
-       public void markTestingStarted(int numTestsToBeRun) {
+       private void markTestingStarted(int numTestsToBeRun) {
+               
                
-               this.numTests = numTestsToBeRun;
                //reportArea.append("Tests started expecting: " + numTests + " \n");
                
        }
 
-       public void markTestingFinished() {
+       private void markTestingFinished() {
 
                
                //reportArea.append("end all tests \n");
@@ -222,25 +253,107 @@ public class PHPUnitView extends ViewPart {
        }
 
        // action to start tests:
-       private void startTests() {
+       public void startTests() throws IOException {
+
+//             // preparation:
+//             // take the full test suite (could containt other test suites).
+//             // create temp php file that starts that suite and uses socketTestReport 
+//             // as a test result reporter.
+//             // add listener: localhost , port 13579
+//             // start listening at port.
+//
+//             testPool = new TestPool("RUN MONDAY 11:15 PM");
+//             listenForReports();
+//             
+//             try {
+//                     Runtime.getRuntime().exec("php.exe \"C:/Program Files/Apache Group/Apache2/htdocs/phpUnit/suite.php\"");
+//             } catch (Exception e) {
+//                     
+//                     e.printStackTrace();
+//             }
+
+       startTests("C:/Program Files/Apache Group/Apache2/htdocs/phpUnit/suite.php");
+
+       }
+
+       public void startTests(String testSuite) throws IOException {
+               
+               //testSuite: the name of the file containing the suite we want to run.
+               // we will put that test suite inside a contained that uses our SocketResult.
+
+
+               //reset from previous run
+               reset();
+               
+               //where the plugin's temp files should go
+               String tempFolder = "C:\\tmp"; 
+               String tempFileName = "temTest.php";
+               
+               //create the file.
+               File testFile = new File(tempFolder + "/" + tempFileName);
+               BufferedWriter out = new BufferedWriter(new FileWriter(testFile));
+
+               out.write("<?php" + "\n");
+               out.write("$path = \"C:/Documents and Settings/Ali Echihabi/My Documents/workspace.eclipse2.1/PHPUnit/phpunit\";" + "\n");
+               out.write("include_once($path . \"/phpunit_test.php\");" + "\n");
+               out.write("include_once $path . \"/socketTestResult.php\";" + "\n");
+
+               //include the test suite that we want to run.
+               String testSuiteName = "ManyFailingTests2";
+               String testSuitePath = "C:/eclipse/eclipse/runtime-workspace/PHPProject/testSuite.php";
+               
+               out.write("include_once(\"" + testSuitePath + "\");" + "\n");
+               
 
-               // preparation:
-               // take the full test suite (could containt other test suites).
-               // create temp php file that starts that suite and uses socketTestReport 
-               // as a test result reporter.
-               // add listener: localhost , port 13579
-               // start listening at port.
+               out.write("" + "\n");
+               out.write("" + "\n");           
+               
+               out.write("$suite = new TestSuite();" + "\n");
+               out.write("$suite->addTest(new TestSuite(\"" + testSuiteName + "\"));" + "\n");
+               
+               
+               
+               //out.write("$suite->addTest(new TestSuite(\"MoreTesterTests\"));" + "\n");
+       
+               //out.write("$suite->addTest(new TestSuite(\"ManyFailingTests\"));" + "\n");
+               //out.write("$suite->addTest(new TestSuite(\"AssertEqualsTests\"));" + "\n");           
+                       
+               out.write("$result = new SocketTestResult();" + "\n");
+               out.write("$suite->run($result);" + "\n");
+               out.write("$result->report();   " + "\n");
 
+               out.write("" + "\n");
+               out.write("" + "\n");
+               
+               out.write("?>" + "\n");
+               
+               out.flush();
+               out.close();
                
                listenForReports();
                
                try {
-                       Runtime.getRuntime().exec("php.exe \"C:/Program Files/Apache Group/Apache2/htdocs/phpUnit/suite.php\"");
-               } catch (IOException e) {
-                       // TODO Auto-generated catch block
+                       Runtime.getRuntime().exec("php.exe " + tempFolder + "/" + tempFileName);
+               } catch (Exception e) {
+                       
                        e.printStackTrace();
                }
+               
+               //testFile.delete();
+               
+       }
 
+       /**
+        * 
+        */
+       private void reset() {
+               
+               handler = new XMLReportHandler();
+               testPool = new TestPool("Ali Baba");
+                
+               progressInfoComposite.resetInfo();
+               resultsInfoComposite.resetInfo();
+               
        }
 
        /**
@@ -281,9 +394,14 @@ public class PHPUnitView extends ViewPart {
                         markTestingStarted(new Integer(testCount).intValue());
                         
                        
-               }else if (command.equals("testStarted")) {
+               } else if (command.equals("testSuiteStarted")) {
+
+                       createNewTestSuite("TestSuiteName: " + testID, testID, new Integer(testCount).intValue());
+                       markTestSuiteStarted(testID);
+
+               } else if (command.equals("testStarted")) {
 
-                       createNewTest("testName", testID);
+                       createNewTest("TestName: " + testID, testID);
                        markTestStarted(testID);
 
                } else if (command.equals("testFINISHED")) {
@@ -295,10 +413,42 @@ public class PHPUnitView extends ViewPart {
                        markTestingFinished();
                }
 
+               
+               update();
+
 
-               progressInfoComposite.updateInfo(numTests, numTestsRun, numFailures, numErrors);
+
+       }
+
+       /**
+        * 
+        */
+       private void update() {
+               
+               //progressInfoComposite.updateInfo(numTests, testPool.getNumTestsRun(), numFailures, numErrors);
+               progressInfoComposite.updateInfo(testPool);
                resultsInfoComposite.updateInfo(testPool);
+               
+       }
+
+       /**
+        * @param testID
+        */
+       private void markTestSuiteStarted(String testID) {
+               // TODO Auto-generated method stub
+               
+       }
 
+       /**
+        * @param string
+        * @param testID
+        * @param testCount
+        */
+       private void createNewTestSuite(String name, String testID, int testCount) {
+               
+               TestSuite suite = new TestSuite(name, testID, testCount);
+               testPool.addTestSuite(suite);
+               
        }
 
        /**
@@ -306,7 +456,6 @@ public class PHPUnitView extends ViewPart {
         */
        private void markTestFinished() {
                        
-               numTestsRun++;
                
        }
 
index 7d779e4..3781fde 100644 (file)
@@ -6,6 +6,8 @@
  */
 package net.sourceforge.phpeclipse.phpunit;
 
+import net.sourceforge.phpeclipse.phpunit.testpool.TestPool;
+
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.layout.FillLayout;
 import org.eclipse.swt.layout.GridData;
@@ -74,13 +76,21 @@ public class ProgressInfoComposite extends Composite {
                labelErrorsVal.setText("0");            
        }
 
+       public void resetInfo() {
+       
+               labelErrorsVal.setText("0");
+               labelFailuresVal.setText("0");
+               labelRunsVal.setText("0 / 0");
+               progressBar.setSelection(0);    
+       
+       }
+
        public void updateInfo(int numTests, int numTestsRun, int numFailures, int numErrors) {
                
                //update progress bar
                progressBar.setMaximum(numTests);
                progressBar.setSelection(numTestsRun);
-               
-               System.out.println("numTestsRun: " + numTestsRun);
+       
        
                //update labels
                labelRunsVal.setText(numTestsRun + " / " + numTests);
@@ -93,4 +103,26 @@ public class ProgressInfoComposite extends Composite {
                
        }
 
+
+       public void updateInfo(TestPool testPool) {
+               
+               int numTestsOverall = testPool.getNumTestsOverall();
+               int numTestsRun = testPool.getNumTestsRun();
+               
+               //update progress bar
+               progressBar.setMaximum(numTestsOverall);
+               progressBar.setSelection(numTestsRun);
+       
+       
+               //update labels
+               labelRunsVal.setText(numTestsRun + " / " + numTestsOverall);
+               labelFailuresVal.setText("" + testPool.getNumFailures());
+               labelErrorsVal.setText("" + testPool.getNumErrors());
+               
+               //TODO: change Failures label to red if some exist.
+               
+               
+               
+       }
+
 }
index bb4686d..a26ec25 100644 (file)
@@ -30,9 +30,9 @@ public class ReportListener extends Thread {
                        while ( (report = in.readLine()) != null &&
                                        (report != "end_all_tests") ) {
 
-                               System.out.println("received something...");
+                               //System.out.println("received something...");
                                view.handleReport(report);
-                               System.out.println(report);
+                               //System.out.println(report);
                        }
 
                        //reportArea.append("Finished!");
index 8f50171..627da42 100644 (file)
@@ -6,10 +6,13 @@
  */
 package net.sourceforge.phpeclipse.phpunit;
 
+import net.sourceforge.phpeclipse.phpunit.testpool.TestPool;
+
+import org.eclipse.jface.viewers.TreeViewer;
 import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Text;
 
 /**
  * @author Ali Echihabi
@@ -20,7 +23,8 @@ import org.eclipse.swt.widgets.Text;
 public class ResultsInfoComposite extends Composite {
 
 
-       private Text reportArea; // TODO: replace with Tree display like JUnit
+       
+       private TreeViewer treeViewer;
        
        /**
         * @param arg0
@@ -28,32 +32,38 @@ public class ResultsInfoComposite extends Composite {
         */
        public ResultsInfoComposite(Composite parent) {
 
-               super(parent, SWT.NONE);
+               super(parent, SWT.BORDER);
 
-               setLayout(new FillLayout(SWT.VERTICAL));
+               GridLayout layout = new GridLayout();
+               layout.numColumns = 1;
+               
+               setLayout(layout);
+               
+               treeViewer = new TreeViewer(this, SWT.BORDER | SWT.SHADOW_ETCHED_IN);
 
-               reportArea =
-                       new Text(
-                               this,
-                               SWT.MULTI
-                                       | SWT.BORDER
-                                       | SWT.WRAP
-                                       | SWT.V_SCROLL
-                                       | SWT.READ_ONLY);
+               treeViewer.getControl().setLayoutData(new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.FILL_BOTH | GridData.GRAB_VERTICAL));
                
+               
+               TestPoolLabelProvider labelProvider = new TestPoolLabelProvider();
+               TestPoolContentProvider contentProvider= new TestPoolContentProvider();
+               
+               treeViewer.setContentProvider(contentProvider);
+               treeViewer.setLabelProvider(labelProvider);
+                               
        }
 
        
+       public void resetInfo() {
+               
+               treeViewer.setInput(null);
+       }
        
        public void updateInfo(TestPool testPool) {
                
                // take care of the TreeView and its content and label providers.
+       
+               treeViewer.setInput(testPool.getRoot());
                
        }
-       
-
-
-
-       
 
 }
diff --git a/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/SettingsInfoComposite.java b/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/SettingsInfoComposite.java
new file mode 100644 (file)
index 0000000..1babb56
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * Created on Sep 11, 2004
+ *
+ * To change the template for this generated file go to
+ * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
+ */
+package net.sourceforge.phpeclipse.phpunit;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseListener;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.FileDialog;
+
+/**
+ * @author Ali Echihabi
+ *
+ * To change the template for this generated type comment go to
+ * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
+ */
+public class SettingsInfoComposite extends Composite {
+
+       FileDialog dialog;
+       Button button;
+       
+       String testSuitePath;
+
+       /**
+        * @param arg0
+        * @param arg1
+        */
+       public SettingsInfoComposite(Composite parent, int style) {
+               
+               super(parent, style);
+               
+               dialog = new FileDialog(parent.getShell());
+               
+               button = new Button(parent, SWT.NONE);
+               button.setText("Browser for test...");
+               
+               button.addMouseListener(new MouseListener() {
+                       public void mouseDoubleClick(MouseEvent arg0) {
+                               // TODO Auto-generated method stub
+
+                       }
+
+                       public void mouseDown(MouseEvent arg0) {
+                       
+                               testSuitePath = dialog.open();
+                               System.out.println("file: " + testSuitePath);
+
+                       }
+
+                       public void mouseUp(MouseEvent arg0) {
+                               // TODO Auto-generated method stub
+
+                       }
+               });
+               
+               
+               
+               
+               
+       }
+       
+       
+       public String getTestSuite() {
+               
+               return testSuitePath;
+       }
+       
+       
+
+}
diff --git a/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/TestPool.java b/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/TestPool.java
deleted file mode 100644 (file)
index a4ba019..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Created on Jul 31, 2004
- *
- * To change the template for this generated file go to
- * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
- */
-package net.sourceforge.phpeclipse.phpunit;
-
-import java.util.HashMap;
-
-/**
- * @author Ali Echihabi
- *
- * To change the template for this generated type comment go to
- * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
- */
-public class TestPool {
-
-       private HashMap tests;
-
-       public TestPool() {
-               
-               tests = new HashMap();
-       }
-
-       public void addTest(TestCase test) {
-               
-               tests.put(test.getTestID(), test);
-               
-       }
-       
-       public TestCase getTest(String testID) {
-                               
-               return (TestCase) tests.get(testID);
-       }
-
-}
diff --git a/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/TestPoolContentProvider.java b/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/TestPoolContentProvider.java
new file mode 100644 (file)
index 0000000..96489da
--- /dev/null
@@ -0,0 +1,91 @@
+/*
+ * Created on Aug 8, 2004
+ *
+ * To change the template for this generated file go to
+ * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
+ */
+package net.sourceforge.phpeclipse.phpunit;
+
+import java.util.Vector;
+
+import net.sourceforge.phpeclipse.phpunit.testpool.*;
+
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+
+/**
+ * @author Ali Echihabi
+ *
+ * To change the template for this generated type comment go to
+ * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
+ */
+public class TestPoolContentProvider implements ITreeContentProvider {
+
+
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
+        */
+       public Object[] getChildren(Object parentElement) {
+
+               if(parentElement instanceof TestSuite) {
+
+                       Vector allChildren = new Vector();
+                       allChildren.addAll(((TestSuite)parentElement).getTestCases());
+                       allChildren.addAll(((TestSuite)parentElement).getTestSuites());
+                       
+                       return allChildren.toArray();
+                       
+               } else {
+                       return new Object[0];
+               }
+               
+               
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object)
+        */
+       public Object getParent(Object element) {
+               
+               if(element instanceof TestSuite)
+                       return ((TestSuite)element).getParent();
+               else if (element instanceof TestCase) 
+                       return ((TestCase)element).getParentSuite();
+               else
+                       return null;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
+        */
+       public boolean hasChildren(Object element) {
+
+               return getChildren(element).length > 0;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
+        */
+       public Object[] getElements(Object inputElement) {
+               
+               return getChildren(inputElement);
+               
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.viewers.IContentProvider#dispose()
+        */
+       public void dispose() {
+               
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
+        */
+       public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+               // TODO Auto-generated method stub
+
+       }
+
+}
diff --git a/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/TestPoolLabelProvider.java b/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/TestPoolLabelProvider.java
new file mode 100644 (file)
index 0000000..6977a6d
--- /dev/null
@@ -0,0 +1,89 @@
+/*
+ * Created on Aug 8, 2004
+ *
+ * To change the template for this generated file go to
+ * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
+ */
+package net.sourceforge.phpeclipse.phpunit;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import net.sourceforge.phpeclipse.phpunit.testpool.TestCase;
+import net.sourceforge.phpeclipse.phpunit.testpool.TestSuite;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * @author Ali Echihabi
+ *
+ * To change the template for this generated type comment go to
+ * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
+ */
+public class TestPoolLabelProvider extends LabelProvider {
+
+       //TODO: replace with installDir + path
+       private static String iconsPath = "C:\\Documents and Settings\\Ali Echihabi\\My Documents\\workspace.eclipse2.1\\net.sourceforge.phpeclipse.phpunit\\icons";
+
+       public String getText(Object element) {
+               
+               if(element instanceof TestSuite) 
+                       return ((TestSuite)element).getName();
+               else if(element instanceof TestCase)
+                       return ((TestCase)element).getTestName();
+               else
+                       return "UNKNOWN ELEMENT TYPE";
+               
+               
+               
+       }
+
+       public Image getImage(Object element) {
+               
+               Image image = null;
+               
+               try {
+                       
+                       String icon = "";
+                       if(element instanceof TestSuite) {
+                               
+                               TestSuite suite = (TestSuite)element;
+                               
+                               //TODO check if there has been an error, a failure...
+                               
+                               icon = "tsuite.gif";
+                               
+                       } else if(element instanceof TestCase) {
+                               
+                               TestCase test = (TestCase)element;
+                               
+                               if(test.isError())
+                                       icon = "testerr.gif";
+                               else if(test.isFailure())
+                                       icon = "testfail.gif";
+                               else if(test.isPass())
+                                       icon = "testok.gif";
+                               
+                       }
+                       
+                       
+                       ImageDescriptor descriptor = ImageDescriptor.createFromURL(new URL("file://" + iconsPath + "//" + icon));
+                       image = descriptor.createImage();
+                       
+               } catch (MalformedURLException e) {
+                       
+                       e.printStackTrace();
+                       image = ImageDescriptor.getMissingImageDescriptor().createImage();
+               }
+               
+               
+               
+               
+               
+               return image;
+               
+       }
+
+}
diff --git a/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/TestSuite.java b/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/TestSuite.java
deleted file mode 100644 (file)
index faced9d..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Created on Jul 31, 2004
- *
- * To change the template for this generated file go to
- * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
- */
-package net.sourceforge.phpeclipse.phpunit;
-
-import java.util.Vector;
-
-/**
- * @author Ali Echihabi
- *
- * To change the template for this generated type comment go to
- * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
- */
-public class TestSuite {
-
-       private Vector testCases;
-       private String name;
-       private String id;
-       
-       public void addTestCase(TestCase test) {
-               
-       }
-       
-       public void removeTestCase(TestCase test) {}
-       
-       public boolean contains(TestCase test) {
-               return false;
-       }
-       
-       
-
-}
index bfb6799..2e1c39c 100644 (file)
@@ -6,10 +6,17 @@
  */
 package net.sourceforge.phpeclipse.phpunit.actions;
 
+import java.io.IOException;
+
+import net.sourceforge.phpeclipse.phpunit.PHPUnitView;
+
+import org.eclipse.core.resources.IFile;
 import org.eclipse.jface.action.IAction;
 import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.swt.widgets.Item;
 import org.eclipse.ui.IObjectActionDelegate;
 import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.views.navigator.ResourceNavigator;
 
 /**
  * @author Ali Echihabi
@@ -19,19 +26,60 @@ import org.eclipse.ui.IWorkbenchPart;
  */
 public class RunTestsAction implements IObjectActionDelegate {
 
+
+       
+
        /* (non-Javadoc)
         * @see org.eclipse.ui.IObjectActionDelegate#setActivePart(org.eclipse.jface.action.IAction, org.eclipse.ui.IWorkbenchPart)
         */
        public void setActivePart(IAction action, IWorkbenchPart targetPart) {
                // TODO Auto-generated method stub
                
+               System.out.println(targetPart.getTitle());
+               ResourceNavigator nav = (ResourceNavigator)targetPart;
+               
+               Item selectedItem = nav.getViewer().getTree().getSelection()[0];
+               
+               Object d = selectedItem.getData();
+//             
+//             try {
+//                     
+//                     IFile data = (IFile) selectedItem.getData();
+//                     
+//             }
+//             catch(Exception e) {
+//                     
+//                     e.printStackTrace();
+//                     
+//             }
+//             
+               
+               
+               
+//             Shell shell =  PHPUnitPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell();
+//             
+//             if(shell instanceof IStructuredSelection) {
+//                     
+//                     Object testObj = ((IStructuredSelection) )
+//             } 
+//             
+               
+               
+               
        }
 
        /* (non-Javadoc)
         * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
         */
        public void run(IAction action) {
-               // TODO Auto-generated method stub
+               
+               try {
+                       PHPUnitView.getDefault().startTests();
+               } catch (IOException e) {
+                       // TODO Auto-generated catch block
+                       e.printStackTrace();
+               }
+               
                
        }
 
@@ -4,7 +4,8 @@
  * To change the template for this generated file go to
  * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
  */
-package net.sourceforge.phpeclipse.phpunit;
+package net.sourceforge.phpeclipse.phpunit.testpool;
+
 
 /**
  * @author Ali Echihabi
@@ -14,6 +15,15 @@ package net.sourceforge.phpeclipse.phpunit;
  */
 public class TestCase {
 
+       public static final String PASS = "PASS";
+       public static final String FAIL = "FAIL";
+       public static final String ERROR = "ERROR";
+
+
+       private TestSuite parentSuite;
+       
+       
+
        /**
         * @param testName
         * @param testID
@@ -24,9 +34,6 @@ public class TestCase {
                this.testID = testID;
        }
 
-       static final String PASS = "PASS";
-       static final String FAIL = "PASS";
-       static final String ERROR = "PASS";
 
        String testName;
        String testID;
@@ -72,6 +79,53 @@ public class TestCase {
         */
        public void setVerdict(String string) {
                verdict = string;
+               
+               
+               
+               
+                       
+       }
+
+       /**
+        * @param suite
+        */
+       public void setParentSuite(TestSuite suite) {
+               this.parentSuite = suite;
+               
+       }
+
+       /**
+        * @return
+        */
+       public Object getParentSuite() {
+               
+               return parentSuite;
+       }
+
+       /**
+        * @return
+        */
+       public boolean isError() {
+               
+               return getVerdict().equals(TestCase.ERROR);
+       }
+
+       /**
+        * @return
+        */
+       public boolean isFailure() {
+               
+               return getVerdict().equals(TestCase.FAIL);
+               
+       }
+
+       /**
+        * @return
+        */
+       public boolean isPass() {
+               
+               return getVerdict().equals(TestCase.PASS);
+
        }
 
 }
diff --git a/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/testpool/TestPool.java b/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/testpool/TestPool.java
new file mode 100644 (file)
index 0000000..008cb3d
--- /dev/null
@@ -0,0 +1,180 @@
+/*
+ * Created on Jul 31, 2004
+ *
+ * To change the template for this generated file go to
+ * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
+ */
+package net.sourceforge.phpeclipse.phpunit.testpool;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Vector;
+
+
+/**
+ * @author Ali Echihabi
+ *
+ * To change the template for this generated type comment go to
+ * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
+ */
+public class TestPool {
+
+       //private TestSuite currentParentTestSuite;
+       private HashMap tests;
+       private TestSuite root;
+       private TestSuite currentTestSuite;
+       
+       
+       /**
+        * 
+        */
+       public TestPool(String rootTitle) {
+               
+               tests = new HashMap();
+               root = new TestSuite(rootTitle, "-1", 0);
+               
+               currentTestSuite = root;
+               
+       }
+
+       /**
+        * @param test
+        */
+       public void addTest(TestCase test) {
+               
+               tests.put(test.getTestID(), test);
+               
+               currentTestSuite.addTestCase(test);
+               
+               
+               //if we run all tests. then this is the end of this test suite.
+               if( currentTestSuite != root && currentTestSuite.isFinished()) {
+                       
+                       currentTestSuite = currentTestSuite.getParent();
+
+               }                               
+               
+       } 
+
+       /**
+        * @param suite
+        * @param numTestsRunSinceStartOfTestSuite
+        */
+       public void addTestSuite(TestSuite suite) {
+       
+       //add as sibling
+               currentTestSuite.addTestSuite(suite);
+               suite.setParent(currentTestSuite);
+
+               currentTestSuite = suite;
+       }
+
+       /**
+        * @return
+        */
+       public TestSuite getRoot() {
+               
+               return root;
+       }
+       
+       /**
+        * @param r
+        */
+       public void setRoot(TestSuite r) {
+               this.root = r;
+       }
+
+
+       
+       /**
+        * @param testID
+        * @return
+        */
+       public TestCase getTest(String testID) {
+                               
+               return (TestCase) tests.get(testID);
+       }
+
+       public String toString() {
+               
+               String string = "";
+               
+               TestSuite node = root;
+               
+               string = root.toString();
+
+               return string;                  
+       
+       }
+
+       private int countSuiteExpectedTests(TestSuite suite) {
+               
+               int total = 0;
+               
+               total += suite.getNumTestCasesExpected();
+               
+               for(int i = 0; i < suite.getTestSuites().size(); i++) 
+                       total += countSuiteExpectedTests((TestSuite) suite.getTestSuites().elementAt(i));
+               
+               return total;
+       
+       }
+
+       public int getNumTestsOverall() {
+       
+               return countSuiteExpectedTests(root);
+                               
+       }
+       
+       public int getNumTestsRun() {
+               
+               return tests.size();
+               
+                       
+       }
+       
+       public int getNumFailures() {
+               
+               int total = 0;
+               
+               Iterator i = tests.keySet().iterator();
+               String key = "";
+               while (i.hasNext()) {
+                       
+                       
+                       key = (String) i.next();
+                       TestCase element = (TestCase) tests.get(key);
+                       
+                       
+                       if(element.isFailure())
+                               total++;
+                       
+               }
+                       
+               return total;
+       }
+       
+       public int getNumErrors() {
+
+               int total = 0;
+               
+//             Iterator i = tests.keySet().iterator();
+//             String key = "";
+//             while (i.hasNext()) {
+//                     
+//                     
+//                     key = (String) i.next();
+//                     TestCase element = (TestCase) tests.get(key);
+//                                             
+//                     if(element.isError())
+//                             total++;
+//                     
+//             }
+                       
+               return total;
+       
+       }
+       
+       
+
+}
diff --git a/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/testpool/TestSuite.java b/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/testpool/TestSuite.java
new file mode 100644 (file)
index 0000000..9d565da
--- /dev/null
@@ -0,0 +1,206 @@
+/*
+ * Created on Jul 31, 2004
+ *
+ * To change the template for this generated file go to
+ * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
+ */
+package net.sourceforge.phpeclipse.phpunit.testpool;
+
+import java.util.Vector;
+
+/**
+ * @author Ali Echihabi
+ *
+ * To change the template for this generated type comment go to
+ * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
+ */
+public class TestSuite {
+
+
+
+       private Vector testCases; // current or actual.
+       private Vector testSuites; // current or actual.
+       private String name;
+       private String id;
+       private int numTestCasesExpected; //expected
+       private int numTestCasesRunSoFar;
+       TestSuite parent;
+
+       /**
+        * @param name
+        * @param testID
+        * @param testCount
+        */
+       public TestSuite(String name, String testID, int testCount) {
+               
+               this.parent = null;
+               this.id = testID;
+               this.name = name;
+               this.numTestCasesExpected = testCount;
+               
+               testCases = new Vector();
+               testSuites = new Vector();
+               
+       }
+
+       /**
+        * @param name
+        * @param testID
+        * @param testCount
+        */
+       public TestSuite(TestSuite parent, String name, String testID, int testCount) {
+               
+               this.parent = parent;
+               this.id = testID;
+               this.name = name;
+               this.numTestCasesExpected = testCount;
+       
+               testCases = new Vector();
+               testSuites = new Vector();
+       }
+                       
+       public void addTestCase(TestCase test) {
+               testCases.addElement(test);
+               test.setParentSuite(this);
+               numTestCasesRunSoFar++;
+       }
+       
+       public void removeTestCase(TestCase test) {}
+       
+       public boolean contains(TestCase test) {
+               
+               return false;
+               
+       }
+       
+       public String toString() {
+               
+               String string = "";
+               
+               //print test cases.
+               TestCase tc = null;
+               for(int i = 0; i < testCases.size(); i++) {
+                       
+                       tc = (TestCase) testCases.elementAt(i);
+                       string += "  - " + tc.getTestID() + ", " + tc.getTestName() + "\n";
+                       
+                       
+               }
+               
+               for(int i = 0; i < testSuites.size(); i++) 
+                       string += ((TestSuite) testSuites.elementAt(i)).toString();
+               
+               //print its own test suites.            
+               return string;
+       }
+
+       /**
+        * @return
+        */
+       public String getId() {
+               return id;
+       }
+
+       /**
+        * @return
+        */
+       public String getName() {
+               return name;
+       }
+
+       /**
+        * @return
+        */
+       public int getNumTestCasesExpected() {
+               return numTestCasesExpected;
+       }
+
+       /**
+        * @param string
+        */
+       public void setId(String string) {
+               id = string;
+       }
+
+       /**
+        * @param string
+        */
+       public void setName(String string) {
+               name = string;
+       }
+
+       /**
+        * @param i
+        */
+       public void setNumTestCasesExpected(int i) {
+               numTestCasesExpected = i;
+       }
+
+       /**
+        * @param suite
+        */
+       public void addTestSuite(TestSuite suite) {
+               testSuites.addElement(suite);
+               
+       }
+
+       /**
+        * @return
+        */
+       public boolean isFinished() {
+               
+               return numTestCasesRunSoFar >= numTestCasesExpected;
+               
+       }
+
+       /**
+        * @return
+        */
+       public TestSuite getParent() {
+               return parent;
+       }
+
+       /**
+        * @param suite
+        */
+       public void setParent(TestSuite suite) {
+               parent = suite;
+       }
+
+       /**
+        * @return
+        */
+       public int getNumTestCases() {
+               
+               return testCases.size();
+       }
+
+       /**
+        * @return
+        */
+       public Vector getTestCases() {
+               return testCases;
+       }
+
+       /**
+        * @return
+        */
+       public Vector getTestSuites() {
+               return testSuites;
+       }
+
+       /**
+        * @param vector
+        */
+       public void setTestCases(Vector vector) {
+               testCases = vector;
+       }
+
+       /**
+        * @param vector
+        */
+       public void setTestSuites(Vector vector) {
+               testSuites = vector;
+       }
+
+}