-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtesttool.java.template
More file actions
34 lines (33 loc) · 1.57 KB
/
testtool.java.template
File metadata and controls
34 lines (33 loc) · 1.57 KB
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
@org.junit.Test
public void test%(tool)sSerialization() {
ClientState s = new ClientState();
ToolManager t = ToolManager.getServerToolManager(s);
String serializedTool = JythonBridge.serializeTool("%(tool)s");
Tool newTool = JythonBridge.deserializeTool(serializedTool);
BufferedImage testGraphics = new BufferedImage(50,50,BufferedImage.TYPE_INT_ARGB);
BufferedImage testGraphics2 = new BufferedImage(50,50,BufferedImage.TYPE_INT_ARGB);
BufferedImage clientImage = new BufferedImage(50,50,BufferedImage.TYPE_INT_ARGB);
BufferedImage resultImage = new BufferedImage(50,50,BufferedImage.TYPE_INT_ARGB);
Graphics2D tg = (Graphics2D)testGraphics.getGraphics();
Graphics2D tg2 = (Graphics2D)testGraphics2.getGraphics();
Graphics2D cig = (Graphics2D)clientImage.getGraphics();
Graphics2D rig = (Graphics2D)resultImage.getGraphics();
Tool oldTool = t.getToolByID("%(tool)s");
System.out.println(newTool);
String builder = newTool.mousePressed(locations[0],tg);
String builder2 = oldTool.mousePressed(locations[1],tg2);
newTool.draw(builder,cig);
oldTool.draw(builder2,rig);
for(int i = 1; i < locations.length - 1; i++) {
builder = newTool.mouseDragged(locations[i],tg);
builder2 = newTool.mouseDragged(locations[i],tg2);
newTool.draw(builder,cig);
oldTool.draw(builder2,rig);
}
for(int x = 0; x < clientImage.getWidth(); x++) {
for(int y = 0; y < clientImage.getHeight(); y++) {
Assert.assertEquals(clientImage.getRGB(x,y), resultImage.getRGB(x,y));
Assert.assertEquals(testGraphics.getRGB(x,y), testGraphics.getRGB(x,y));
}
}
}