Skip to content

Commit

Permalink
Merge branch 'main' into origin/konrad_ManualTest
Browse files Browse the repository at this point in the history
  • Loading branch information
konradnoel committed May 16, 2024
2 parents a824c31 + d8e8e30 commit 5bab142
Show file tree
Hide file tree
Showing 4 changed files with 254 additions and 0 deletions.
25 changes: 25 additions & 0 deletions doc/SelfAttack.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Manuális tesztelés napló
1.
1. A tesztelt funkció megnevezése, leírása:
1.1. Támadás: Exploratory testing útján derült ki, hogy egy játékos képes megtámadni saját magát


2. Az adott funkcióhoz tartozó tesztesetek:
2.1. "A" karakter megtámadja "A" karaktert fegyverrel


3. Az adott teszteset elvárt kimenetele:
3.1. “A” karakter meghal a támadás után.


4. Az adott teszteset tényleges kimenetele:
4.1. “A” karakter meghal


5. Észrevételek az adott tesztesettel kapcsolatban:
5.1. Maga a támadás, mint funkció működik, hiszen az elvárt kimenet,
hogy a karakter akit megtámadnak egy nem kicsorbult fegyverrel, az az, hogy meghal.
Azonban a funkció teljes mértékben haszontalan, és egy félrekattintás esetén a játék végét jelenti valakinek,
így érdemes javítani a felhasználói élmény és ergonómia szempontjából.


4 changes: 4 additions & 0 deletions src/main/java/virologist/control/Controller.java
Original file line number Diff line number Diff line change
Expand Up @@ -168,5 +168,9 @@ public void endTurn(){
public String getActionMessage(){
return actionMessage;
}

public Window getWindow(){
return window;
}
}

4 changes: 4 additions & 0 deletions src/main/java/virologist/view/Window.java
Original file line number Diff line number Diff line change
Expand Up @@ -460,4 +460,8 @@ public void drawInterface() {
frame.add(layeredPane);
}

public JFrame getFrame(){
return frame;
}

}
221 changes: 221 additions & 0 deletions src/test/java/virologist/view/WindowTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,221 @@
package virologist.view;

import virologist.control.*;
import virologist.model.Game;
import virologist.model.Virologist;
import virologist.model.codes.BlockCode;
import virologist.model.equipments.Axe;
import virologist.model.equipments.Equipment;
import virologist.model.map.*;

import org.junit.jupiter.api.*;
import org.mockito.internal.matchers.Or;
import org.mockito.internal.util.reflection.GenericMaster;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.awt.Robot;
import java.awt.event.InputEvent;
import javax.swing.*;

@TestMethodOrder (MethodOrderer.OrderAnnotation.class)
public class WindowTest {

private static Loader loader;
private static Controller controller;

private static int leftClick;

private static Window window;

private static Robot robot;

private static final int ROBOT_DELAY = 200;

@BeforeAll
public static void createEnvironment(){
try{
loader = new Loader();
controller = new Controller(loader.loadGame("maps/map3.txt"));
window = controller.getWindow();
window.getFrame().setLocation(0, 0);
robot = new Robot();
leftClick = InputEvent.BUTTON1_DOWN_MASK;
}
catch (Exception e){
System.err.println("Nem létező pálya!");
}
}

@Test @Order (1)
public void moveTest(){
robot.delay(ROBOT_DELAY);
clickAt(20, 40);
robot.mouseMove(20, 90);
robot.delay(ROBOT_DELAY);
clickAt(200, 90);
robot.delay(ROBOT_DELAY);
assertEquals("Field2", Game.Create().GetCurrentPlayer().getField().getName());
}

@Test @Order (2)
public void endTurnTest(){
Virologist player1 = Game.Create().GetCurrentPlayer();
robot.delay(ROBOT_DELAY);
clickAt(20, 40);
robot.delay(ROBOT_DELAY);
clickAt(20, 270);
robot.delay(ROBOT_DELAY);
assertNotEquals(player1, Game.Create().GetCurrentPlayer());
robot.delay(ROBOT_DELAY);
}

@Test @Order (3)
public void dropTest(){
clickAt(20, 40);
robot.delay(ROBOT_DELAY);
clickAt(20, 100);
robot.delay(ROBOT_DELAY);
assertEquals(0, Game.Create().GetCurrentPlayer().GetEquipments().size());
robot.delay(ROBOT_DELAY);
clickAt(20, 40);
robot.delay(ROBOT_DELAY);
clickAt(20, 270);
robot.delay(ROBOT_DELAY);
}

@Test @Order (4)
public void equipTest(){
int numEquipment = Game.Create().GetCurrentPlayer().GetEquipments().size();
clickAt(20, 40);
robot.delay(ROBOT_DELAY);
clickAt(20, 230);
robot.delay(ROBOT_DELAY);
assertTrue(Game.Create().GetCurrentPlayer().GetEquipments().size() > numEquipment);
}

@Test @Order (5)
public void attackTest(){
int numPlayers = Game.Create().getVirologists().size();
robot.delay(ROBOT_DELAY);
clickAt(20, 40);
robot.delay(ROBOT_DELAY);
clickAt(20, 60);
robot.delay(ROBOT_DELAY);
clickAt(170, 60);
robot.delay(ROBOT_DELAY);
assertTrue(Game.Create().getVirologists().size() < numPlayers);
}

@Test @Order (6)
public void endTurnTestBigButton(){
Virologist player1 = Game.Create().GetCurrentPlayer();
clickAt(530, 530);
robot.delay(ROBOT_DELAY);
assertNotEquals(player1, Game.Create().GetCurrentPlayer());
}

@Test @Order (7)
public void lootAminoFromTest(){
int amino = Game.Create().GetCurrentPlayer().GetAminoAcid();
Game.Create().GetCurrentPlayer().IncreaseLimit(20);
Game.Create().GetCurrentPlayer().SetActionCount(3);
clickAt(20, 40);
robot.delay(ROBOT_DELAY);
clickAt(20, 120);
robot.delay(ROBOT_DELAY);
clickAt(170, 120);
assertTrue(Game.Create().GetCurrentPlayer().GetAminoAcid() > amino);
}

@Test @Order (8)
public void lootNucleoFromTest(){
int nucleo = Game.Create().GetCurrentPlayer().GetNucleotide();
clickAt(20, 40);
robot.delay(ROBOT_DELAY);
clickAt(20, 150);
robot.delay(ROBOT_DELAY);
clickAt(170, 150);
robot.delay(ROBOT_DELAY);
assertTrue(Game.Create().GetCurrentPlayer().GetAminoAcid() > nucleo);
}

@Test @Order (9)
public void lootEquipmentFromTest(){
int numEquipment = Game.Create().GetCurrentPlayer().GetEquipments().size();
clickAt(20, 40);
robot.delay(ROBOT_DELAY);
clickAt(20, 180);
robot.delay(ROBOT_DELAY);
clickAt(170, 180);
robot.delay(ROBOT_DELAY);
assertTrue(Game.Create().GetCurrentPlayer().GetEquipments().size() > numEquipment);
}

@Test @Order (10)
public void collectTest(){
Field warehouse = Game.Create().GetFields().get(0);
for (Field field : Game.Create().GetFields()) {
if(field instanceof Warehouse){
warehouse = field;
break;
}
}

warehouse.AddVirologist(Game.Create().GetCurrentPlayer());
Game.Create().GetCurrentPlayer().IncreaseLimit(30);
Game.Create().GetCurrentPlayer().SetActionCount(3);
int amino = Game.Create().GetCurrentPlayer().GetAminoAcid();
int nucleo = Game.Create().GetCurrentPlayer().GetNucleotide();
clickAt(20, 40);
robot.delay(ROBOT_DELAY);
clickAt(20, 200);
robot.delay(ROBOT_DELAY);
assertTrue(Game.Create().GetCurrentPlayer().GetAminoAcid() > amino || Game.Create().GetCurrentPlayer().GetNucleotide() > nucleo);
}

@Test @Order (11)
public void learnTest(){
Field lab = Game.Create().GetFields().get(0);
for (Field field : Game.Create().GetFields()) {
if(field instanceof Laboratory){
lab = field;
break;
}
}

lab.AddVirologist(Game.Create().GetCurrentPlayer());
Game.Create().GetCurrentPlayer().SetActionCount(3);
int codes = Game.Create().GetCurrentPlayer().getGeneticCodes().size();
clickAt(20, 40);
robot.delay(ROBOT_DELAY);
clickAt(20, 210);
robot.delay(ROBOT_DELAY);
assertTrue(Game.Create().GetCurrentPlayer().getGeneticCodes().size() > codes);
}

@Test @Order (12)
public void injectTest(){
int amino = Game.Create().GetCurrentPlayer().GetAminoAcid();
int nucleo = Game.Create().GetCurrentPlayer().GetNucleotide();
Game.Create().GetCurrentPlayer().AddGeneticCode(new BlockCode(10, 10, 2));
clickAt(20, 40);
robot.delay(ROBOT_DELAY);
clickAt(20, 250);
robot.delay(ROBOT_DELAY);
clickAt(170, 250);
robot.delay(ROBOT_DELAY);
clickAt(200, 250);
robot.delay(ROBOT_DELAY);
assertTrue(amino > Game.Create().GetCurrentPlayer().GetAminoAcid() || nucleo > Game.Create().GetCurrentPlayer().GetNucleotide());
}

private void clickAt(int x, int y){
robot.mouseMove(x, y);
robot.delay(ROBOT_DELAY);
robot.mousePress(leftClick);
robot.mouseRelease(leftClick);
}
}

0 comments on commit 5bab142

Please sign in to comment.