1 /*************************************************************************
2 * @author Ali Echihabi (ali_echihabi@ieee.org, ali.echihabi@souss.ca)
4 * Plugin for PHP unit Testing.
7 *************************************************************************/
9 package net.sourceforge.phpeclipse.phpunit;
11 import net.sourceforge.phpeclipse.phpunit.testpool.TestCase;
12 import net.sourceforge.phpeclipse.phpunit.testpool.TestSuite;
14 import org.eclipse.jface.resource.ImageDescriptor;
15 import org.eclipse.jface.viewers.LabelProvider;
16 import org.eclipse.swt.graphics.Image;
18 public class TestPoolLabelProvider extends LabelProvider {
20 public String getText(Object element) {
24 if (element instanceof TestSuite)
25 return ((TestSuite) element).getName();
26 else if (element instanceof TestCase) {
28 text = ((TestCase) element).getTestName();
30 // has the form: TESTSUITENAME_TESTNAME
33 text = "UNKNOWN ELEMENT TYPE";
39 public Image getImage(Object element) {
42 ImageDescriptor descriptor = null;
44 if (element instanceof TestSuite) {
46 TestSuite suite = (TestSuite) element;
47 descriptor = PHPUnitImages.DESC_TEST_SUITE_PASS;
50 descriptor = PHPUnitImages.DESC_TEST_SUITE_ERROR;
51 else if (suite.hasFailure())
52 descriptor = PHPUnitImages.DESC_TEST_SUITE_FAILURE;
53 else if (suite.isAllPass())
54 descriptor = PHPUnitImages.DESC_TEST_SUITE_PASS;
56 } else if (element instanceof TestCase) {
58 TestCase test = (TestCase) element;
60 descriptor = PHPUnitImages.DESC_TEST_PASS;
63 descriptor = PHPUnitImages.DESC_TEST_ERROR;
64 else if (test.isFailure())
65 descriptor = PHPUnitImages.DESC_TEST_FAILURE;
66 else if (test.isPass())
67 descriptor = PHPUnitImages.DESC_TEST_PASS;
71 image = descriptor.createImage();