From c57265d7bb554025d62100e313a00084f8c935b3 Mon Sep 17 00:00:00 2001 From: fdai7382 Date: Fri, 27 Jan 2023 22:53:08 +0100 Subject: [PATCH 1/6] =?UTF-8?q?[MouseGameTest=20Class]:=20Test:=20"mouseRe?= =?UTF-8?q?setTest"=20hinzugef=C3=BCgt.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../JavaGamelauncher/MouseGameTest.java | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) 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..400ec5f 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,12 +2,30 @@ 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); } From adf1c0bf4ed42839001e564ea97154a1fd216df7 Mon Sep 17 00:00:00 2001 From: fdai7382 Date: Fri, 27 Jan 2023 23:05:00 +0100 Subject: [PATCH 2/6] [MouseGameTest Class]: Test: "titelUeberpruefen" erstellt --- .../gruppenprojekt/JavaGamelauncher/MouseGame.java | 3 ++- .../JavaGamelauncher/MouseGameTest.java | 11 ++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) 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..8b6d6fd 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 @@ -43,7 +43,7 @@ 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); @@ -131,4 +131,5 @@ public class MouseGame extends JFrame { } }); } + }//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 400ec5f..759c21d 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 @@ -28,5 +28,14 @@ public class MouseGameTest { //Then assertTrue(true); } - + + @Test + public void titelUeberpruefen() throws AWTException { + //Given + MouseGame mg = new MouseGame(); + + //Then + assertTrue(mg.getTitle()=="Mouse Game"); + } + } From d0d0eb69e1de3c5cae6311a718f74ced2919158a Mon Sep 17 00:00:00 2001 From: fdai7382 Date: Fri, 27 Jan 2023 23:19:49 +0100 Subject: [PATCH 3/6] refactoring: [MouseGame Class]: Auslagern der X-Variable des Resets. --- .../hs_fulda/gruppenprojekt/JavaGamelauncher/MouseGame.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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 8b6d6fd..177b942 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,6 +20,8 @@ public class MouseGame extends JFrame { private JPanel contentPane; public Robot robot = new Robot(); + + int resetX = 200; /** @@ -45,7 +47,7 @@ public class MouseGame extends JFrame { //Fensterrahmen Haupt Layout setTitle("Mouse Game"); setBounds(100, 100, 900, 650); - robot.mouseMove(200, 170); + robot.mouseMove(resetX, 170); contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); @@ -127,7 +129,7 @@ public class MouseGame extends JFrame { panel.addMouseListener(new MouseAdapter() { @Override public void mouseEntered(MouseEvent e) { - robot.mouseMove(200, 170); + robot.mouseMove(resetX, 170); } }); } From f006baa48fbda4dfb79c0c60d24e922e69950c84 Mon Sep 17 00:00:00 2001 From: fdai7382 Date: Fri, 27 Jan 2023 23:23:55 +0100 Subject: [PATCH 4/6] [MouseGameTest Class]: Test: "resetXPruefen" erstellt. --- .../gruppenprojekt/JavaGamelauncher/MouseGame.java | 7 ++++++- .../gruppenprojekt/JavaGamelauncher/MouseGameTest.java | 9 +++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) 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 177b942..83ad7f3 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 @@ -121,10 +121,15 @@ public class MouseGame extends JFrame { - }//end standardkonstruktor + public int getResetX() { + return resetX; + } + + + private void reset(JPanel panel) { panel.addMouseListener(new MouseAdapter() { @Override 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 759c21d..5e0c3d9 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 @@ -38,4 +38,13 @@ public class MouseGameTest { assertTrue(mg.getTitle()=="Mouse Game"); } + @Test + public void resetXPruefen() throws AWTException { + //Given + MouseGame mg = new MouseGame(); + + //Then + assertTrue(mg.getResetX()==200); + } + } From 3d203a3e64d533eaeca1d5cdd3aa65032fdec3fa Mon Sep 17 00:00:00 2001 From: fdai7382 Date: Fri, 27 Jan 2023 23:31:14 +0100 Subject: [PATCH 5/6] refactoring: [MouseGame Class]: Auslagern der Y-Variable des Resets. --- .../gruppenprojekt/JavaGamelauncher/MouseGame.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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 83ad7f3..565279a 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 @@ -22,7 +22,8 @@ public class MouseGame extends JFrame { public Robot robot = new Robot(); int resetX = 200; - + int resetY = 170; + /** * Launch the application. @@ -47,7 +48,7 @@ public class MouseGame extends JFrame { //Fensterrahmen Haupt Layout setTitle("Mouse Game"); setBounds(100, 100, 900, 650); - robot.mouseMove(resetX, 170); + robot.mouseMove(resetX, resetY); contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); @@ -134,7 +135,7 @@ public class MouseGame extends JFrame { panel.addMouseListener(new MouseAdapter() { @Override public void mouseEntered(MouseEvent e) { - robot.mouseMove(resetX, 170); + robot.mouseMove(resetX, resetY); } }); } From 600ba3cb7488313f3b17723b8962f9a31796cad2 Mon Sep 17 00:00:00 2001 From: fdai7382 Date: Fri, 27 Jan 2023 23:34:10 +0100 Subject: [PATCH 6/6] [MouseGameTest Class]: Test: "resetYPruefen" erstellt. --- .../gruppenprojekt/JavaGamelauncher/MouseGame.java | 4 ++++ .../gruppenprojekt/JavaGamelauncher/MouseGameTest.java | 9 +++++++++ 2 files changed, 13 insertions(+) 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 565279a..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 @@ -130,6 +130,10 @@ public class MouseGame extends JFrame { } + public int getResetY() { + return resetY; + } + private void reset(JPanel panel) { panel.addMouseListener(new MouseAdapter() { 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 5e0c3d9..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 @@ -47,4 +47,13 @@ public class MouseGameTest { assertTrue(mg.getResetX()==200); } + @Test + public void resetYPruefen() throws AWTException { + //Given + MouseGame mg = new MouseGame(); + + //Then + assertTrue(mg.getResetY()==170); + } + }