Browse Source

Merge branch 'MouseGame' into 'main'

Merge MouseGame into Main

See merge request fdai7382/fertigjavagamelauncher!6
remotes/origin/textadventure
fdai7382 2 years ago
parent
commit
a2ee3daa63
  1. 21
      JavaGamelauncher/src/main/java/de/hs_fulda/gruppenprojekt/JavaGamelauncher/MouseGame.java
  2. 47
      JavaGamelauncher/src/test/java/de/hs_fulda/gruppenprojekt/JavaGamelauncher/MouseGameTest.java

21
JavaGamelauncher/src/main/java/de/hs_fulda/gruppenprojekt/JavaGamelauncher/MouseGame.java

@ -21,6 +21,9 @@ public class MouseGame extends JFrame {
private JPanel contentPane; private JPanel contentPane;
public Robot robot = new Robot(); public Robot robot = new Robot();
int resetX = 200;
int resetY = 170;
/** /**
* Launch the application. * Launch the application.
@ -43,9 +46,9 @@ public class MouseGame extends JFrame {
public MouseGame() throws AWTException { public MouseGame() throws AWTException {
//Fensterrahmen Haupt Layout //Fensterrahmen Haupt Layout
setTitle("Maze Game");
setTitle("Mouse Game");
setBounds(100, 100, 900, 650); setBounds(100, 100, 900, 650);
robot.mouseMove(200, 170);
robot.mouseMove(resetX, resetY);
contentPane = new JPanel(); contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
@ -119,16 +122,26 @@ public class MouseGame extends JFrame {
}//end standardkonstruktor }//end standardkonstruktor
public int getResetX() {
return resetX;
}
public int getResetY() {
return resetY;
}
private void reset(JPanel panel) { private void reset(JPanel panel) {
panel.addMouseListener(new MouseAdapter() { panel.addMouseListener(new MouseAdapter() {
@Override @Override
public void mouseEntered(MouseEvent e) { public void mouseEntered(MouseEvent e) {
robot.mouseMove(200, 170);
robot.mouseMove(resetX, resetY);
} }
}); });
} }
}//end class }//end class

47
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 static org.junit.Assert.*;
import java.awt.AWTException;
import java.awt.MouseInfo;
import java.awt.Point;
import java.awt.PointerInfo;
import org.junit.Test; import org.junit.Test;
public class MouseGameTest { public class MouseGameTest {
@Test @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); 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);
}
} }
Loading…
Cancel
Save