diff --git a/JavaGamelauncher/src/main/java/de/hs_fulda/gruppenprojekt/JavaGamelauncher/MouseGame.java b/JavaGamelauncher/src/main/java/de/hs_fulda/gruppenprojekt/JavaGamelauncher/MouseGame.java index 427aa3a..aeacbb7 100644 --- a/JavaGamelauncher/src/main/java/de/hs_fulda/gruppenprojekt/JavaGamelauncher/MouseGame.java +++ b/JavaGamelauncher/src/main/java/de/hs_fulda/gruppenprojekt/JavaGamelauncher/MouseGame.java @@ -20,7 +20,10 @@ public class MouseGame extends JFrame { private JPanel contentPane; public Robot robot = new Robot(); - + + int resetX = 200; + int resetY = 170; + /** * Launch the application. @@ -43,9 +46,9 @@ public class MouseGame extends JFrame { public MouseGame() throws AWTException { //Fensterrahmen Haupt Layout - setTitle("Maze Game"); + setTitle("Mouse Game"); setBounds(100, 100, 900, 650); - robot.mouseMove(200, 170); + robot.mouseMove(resetX, resetY); contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); @@ -119,16 +122,26 @@ public class MouseGame extends JFrame { - }//end standardkonstruktor + public int getResetX() { + return resetX; + } + + + public int getResetY() { + return resetY; + } + + private void reset(JPanel panel) { panel.addMouseListener(new MouseAdapter() { @Override public void mouseEntered(MouseEvent e) { - robot.mouseMove(200, 170); + robot.mouseMove(resetX, resetY); } }); } + }//end class diff --git a/JavaGamelauncher/src/test/java/de/hs_fulda/gruppenprojekt/JavaGamelauncher/MouseGameTest.java b/JavaGamelauncher/src/test/java/de/hs_fulda/gruppenprojekt/JavaGamelauncher/MouseGameTest.java index b7a28c9..6c1d51a 100644 --- a/JavaGamelauncher/src/test/java/de/hs_fulda/gruppenprojekt/JavaGamelauncher/MouseGameTest.java +++ b/JavaGamelauncher/src/test/java/de/hs_fulda/gruppenprojekt/JavaGamelauncher/MouseGameTest.java @@ -2,13 +2,58 @@ package de.hs_fulda.gruppenprojekt.JavaGamelauncher; import static org.junit.Assert.*; +import java.awt.AWTException; +import java.awt.MouseInfo; +import java.awt.Point; +import java.awt.PointerInfo; + import org.junit.Test; public class MouseGameTest { + @Test - public void test() { + public void mouseResetTest() throws AWTException { + //Given + MouseGame mg = new MouseGame(); + + //When + mg.robot.mouseMove(200, 170); + PointerInfo info = MouseInfo.getPointerInfo(); + Point location = info.getLocation(); + + if(location.x==200 && location.y==170) { + assertTrue(true); + } + //Then assertTrue(true); } - + + @Test + public void titelUeberpruefen() throws AWTException { + //Given + MouseGame mg = new MouseGame(); + + //Then + assertTrue(mg.getTitle()=="Mouse Game"); + } + + @Test + public void resetXPruefen() throws AWTException { + //Given + MouseGame mg = new MouseGame(); + + //Then + assertTrue(mg.getResetX()==200); + } + + @Test + public void resetYPruefen() throws AWTException { + //Given + MouseGame mg = new MouseGame(); + + //Then + assertTrue(mg.getResetY()==170); + } + }