File: PickTest.java

package info (click to toggle)
piccolo 1.2-1.1
  • links: PTS
  • area: main
  • in suites: bookworm, bullseye, buster, sid, trixie
  • size: 1,668 kB
  • sloc: java: 16,496; xml: 259; sh: 18; makefile: 13
file content (39 lines) | stat: -rw-r--r-- 1,124 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import edu.umd.cs.piccolo.PCamera;
import edu.umd.cs.piccolo.PCanvas;
import edu.umd.cs.piccolo.PLayer;
import edu.umd.cs.piccolo.PNode;
import edu.umd.cs.piccolo.nodes.PPath;
import edu.umd.cs.piccolo.util.PPickPath;
import junit.framework.TestCase;

public class PickTest extends TestCase {

	public PickTest(String name) {
		super(name);
	}

	public void testPick() {
		PCanvas canvas = new PCanvas();
		PCamera camera = canvas.getCamera();
		PLayer layer = canvas.getLayer();
		
		camera.setBounds(0, 0, 100, 100);
		
		PNode a = PPath.createRectangle(0, 0, 100, 100);
		PNode b = PPath.createRectangle(0, 0, 100, 100);
		PNode c = PPath.createRectangle(0, 0, 100, 100);
		
		layer.addChild(a);
		layer.addChild(b);
		layer.addChild(c);
		
		PPickPath pickPath = camera.pick(50, 50, 2);
		
		assertTrue(pickPath.getPickedNode() == c);
		assertTrue(pickPath.nextPickedNode() == b);
		assertTrue(pickPath.nextPickedNode() == a);
		assertTrue(pickPath.nextPickedNode() == camera);
		assertTrue(pickPath.nextPickedNode() == null);
		assertTrue(pickPath.nextPickedNode() == null);
	}
}