new class to manage icons. Showing failures,etc on a test suite.
[phpeclipse.git] / net.sourceforge.phpeclipse.phpunit / src / net / sourceforge / phpeclipse / phpunit / TestPoolLabelProvider.java
index 344bb08..3e27112 100644 (file)
@@ -6,9 +6,6 @@
  */
 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;
 
@@ -24,9 +21,6 @@ import org.eclipse.swt.graphics.Image;
  */
 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) {
                
                String text = "";
@@ -50,44 +44,39 @@ public class TestPoolLabelProvider extends LabelProvider {
        public Image getImage(Object element) {
                
                Image image = null;
-               
-               try {
+               ImageDescriptor descriptor = null;
                        
-                       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";
-                               
-                       }
+               if(element instanceof TestSuite) {
                        
+                       TestSuite suite = (TestSuite)element;
+                       descriptor = PHPUnitImages.DESC_TEST_SUITE_PASS;
+
+
+                       if(suite.hasError())
+                               descriptor = PHPUnitImages.DESC_TEST_SUITE_ERROR;
+                       else if(suite.hasFailure())
+                               descriptor = PHPUnitImages.DESC_TEST_SUITE_FAILURE;
+                       else if(suite.isAllPass())
+                               descriptor = PHPUnitImages.DESC_TEST_SUITE_PASS;
+                                       
+                                                               
+               } else if(element instanceof TestCase) {
                        
-                       ImageDescriptor descriptor = ImageDescriptor.createFromURL(new URL("file://" + iconsPath + "//" + icon));
-                       image = descriptor.createImage();
+                       TestCase test = (TestCase)element;
                        
-               } catch (MalformedURLException e) {
+                       descriptor = PHPUnitImages.DESC_TEST_PASS;
                        
-                       e.printStackTrace();
-                       image = ImageDescriptor.getMissingImageDescriptor().createImage();
+                       if(test.isError())
+                               descriptor = PHPUnitImages.DESC_TEST_ERROR;
+                       else if(test.isFailure())
+                               descriptor = PHPUnitImages.DESC_TEST_FAILURE;
+                       else if(test.isPass())
+                               descriptor = PHPUnitImages.DESC_TEST_PASS;
+                                       
                }
                
-               
-               
-               
+               image = descriptor.createImage();
+       
                
                return image;