1 package net.sourceforge.phpeclipse.xdebug.php.launching;
3 import java.util.ArrayList;
6 import junit.framework.TestCase;
7 import net.sourceforge.phpeclipse.xdebug.php.model.XDebugStackFrame;
9 import org.eclipse.core.resources.IFile;
10 import org.eclipse.core.runtime.CoreException;
11 import org.eclipse.core.runtime.IPath;
12 import org.eclipse.core.runtime.Path;
13 import org.eclipse.core.runtime.Platform;
14 import org.eclipse.ui.PlatformUI;
16 public class PHPSourceLookupParticipantTest extends TestCase {
18 public void testFindSourceElementsObject() throws CoreException {
19 PHPSourceLookupParticipant psp = new PHPSourceLookupParticipant();
20 Object[] findSourceElements = psp.findSourceElements(new Object());
21 assertTrue("array should be empty", findSourceElements.length == 0);
24 public void testFindSourceElementsObject_WithNull() throws CoreException {
25 PHPSourceLookupParticipant psp = new PHPSourceLookupParticipant();
26 Object[] findSourceElements = psp.findSourceElements(null);
27 assertTrue("array should be empty", findSourceElements.length == 0);
30 public void testFindSourceElementsObject_WithXdebugStackFrame()
31 throws CoreException {
32 PHPSourceLookupParticipant psp = new PHPSourceLookupParticipant();
33 XDebugStackFrame frame = new MockXDebugStackFrame();
34 Object[] findSourceElements = psp.findSourceElements(frame);
35 assertTrue("array should be empty", findSourceElements.length == 0);
38 class MockXDebugStackFrame extends XDebugStackFrame {
39 public MockXDebugStackFrame() {
44 public void testFindSourceElementsObject_TestPippo() throws CoreException {
45 PHPSourceLookupParticipant psp = new PHPSourceLookupParticipant();
46 XDebugStackFrame frame = new PippoXDebugStackFrame();
47 Object[] findSourceElements = psp.findSourceElements(frame);
48 assertEquals(1, findSourceElements.length);
49 assertEquals("pippo", findSourceElements[0]);
52 class PippoXDebugStackFrame extends XDebugStackFrame {
53 public PippoXDebugStackFrame() {
57 public String getType() {
61 public String getSourceName() {
66 public void testGetSourceName() throws CoreException {
67 PHPSourceLookupParticipant psp = new PHPSourceLookupParticipant();
68 psp.getSourceName(null);
71 public void testAddMatching_withNull() {
72 PHPSourceLookupParticipant.addMatching(null, null, null);
75 public void testAddMatching_updatesList() {
77 List l = new ArrayList();
79 Object o1 = new Object();
80 Object o2 = new Object();
81 Object[] os = new Object[] { o1, o2 };
83 IPath p = new Path("/some/path");
86 PHPSourceLookupParticipant.addMatching(l, p, os);
87 assertTrue(l.isEmpty());