forked from projet-gl2/Hashimiste
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request projet-gl2#20 from projet-gl2/Interface
Interface pull request, test unitaire et fin de l'interface des menus
- Loading branch information
Showing
13 changed files
with
834 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
src/main/java/fr/hashimiste/impl/gui/theme/CandyTheme.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
package fr.hashimiste.impl.gui.theme; | ||
|
||
import fr.hashimiste.core.gui.Theme; | ||
|
||
import java.awt.*; | ||
|
||
/** | ||
* La classe DefaultTheme implémente l'interface Theme. | ||
* Elle définit un thème par défaut avec des couleurs spécifiques pour les différents éléments de l'interface utilisateur. | ||
*/ | ||
public class CandyTheme implements Theme { | ||
/** | ||
* L'instance unique de la classe DefaultTheme. | ||
*/ | ||
public static final Theme INSTANCE = new CandyTheme(); | ||
|
||
/** | ||
* La couleur des boutons dans le thème par défaut. | ||
*/ | ||
private static final Color BOUTON = new Color(255, 10, 84); | ||
|
||
/** | ||
* La couleur du texte des boutons dans le thème par défaut. | ||
*/ | ||
private static final Color TEXTE_BOUTON; | ||
|
||
static { | ||
String osName = System.getProperty("os.name").toLowerCase(); | ||
if (osName.contains("mac")) { | ||
// Mac | ||
TEXTE_BOUTON = Color.BLACK; | ||
} else { | ||
// Autres systèmes (Linux, etc.) | ||
TEXTE_BOUTON = new Color(251, 250, 242); // Couleur par défaut | ||
} | ||
} | ||
|
||
/** | ||
* La couleur des boutons désactivés dans le thème par défaut. | ||
*/ | ||
private static final Color BOUTON_DESACTIVE = new Color(255, 92, 138); | ||
|
||
/** | ||
* La couleur de fond dans le thème par défaut. | ||
*/ | ||
private static final Color FOND = new Color(255, 153, 172); | ||
|
||
/** | ||
* La couleur transparente dans le thème par défaut. | ||
*/ | ||
private static final Color TRANSPARENT = new Color(0, 0, 0, 0); | ||
|
||
/** | ||
* Le constructeur privé de la classe DefaultTheme. | ||
* Il est privé pour empêcher l'instanciation directe de cette classe. | ||
*/ | ||
private CandyTheme() { | ||
} | ||
|
||
@Override | ||
public Color getButtonColor() { | ||
return BOUTON; | ||
} | ||
|
||
@Override | ||
public Color getButtonTextColor() { | ||
return TEXTE_BOUTON; | ||
} | ||
|
||
@Override | ||
public Color getDisabledButtonColor() { | ||
return BOUTON_DESACTIVE; | ||
} | ||
|
||
@Override | ||
public Color getBackgroundColor() { | ||
return FOND; | ||
} | ||
|
||
@Override | ||
public Color getTransparentColor() { | ||
return TRANSPARENT; | ||
} | ||
|
||
@Override | ||
public Color getTextColor() { | ||
return Color.BLACK; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
package fr.hashimiste.impl.gui.theme; | ||
|
||
import fr.hashimiste.core.gui.Theme; | ||
|
||
import java.awt.*; | ||
|
||
/** | ||
* La classe DefaultTheme implémente l'interface Theme. | ||
* Elle définit un thème par défaut avec des couleurs spécifiques pour les différents éléments de l'interface utilisateur. | ||
*/ | ||
public class DarkTheme implements Theme { | ||
/** | ||
* L'instance unique de la classe DefaultTheme. | ||
*/ | ||
public static final Theme INSTANCE = new DarkTheme(); | ||
|
||
/** | ||
* La couleur des boutons dans le thème par défaut. | ||
*/ | ||
private static final Color BOUTON = new Color(58, 1, 92); | ||
|
||
/** | ||
* La couleur du texte des boutons dans le thème par défaut. | ||
*/ | ||
private static final Color TEXTE_BOUTON; | ||
|
||
static { | ||
String osName = System.getProperty("os.name").toLowerCase(); | ||
if (osName.contains("mac")) { | ||
// Mac | ||
TEXTE_BOUTON = Color.BLACK; | ||
} else { | ||
// Autres systèmes (Linux, etc.) | ||
TEXTE_BOUTON = new Color(251, 250, 242); // Couleur par défaut | ||
} | ||
} | ||
|
||
/** | ||
* La couleur des boutons désactivés dans le thème par défaut. | ||
*/ | ||
private static final Color BOUTON_DESACTIVE = new Color(79, 1, 71); | ||
|
||
/** | ||
* La couleur de fond dans le thème par défaut. | ||
*/ | ||
private static final Color FOND = new Color(110, 30, 82); | ||
|
||
/** | ||
* La couleur transparente dans le thème par défaut. | ||
*/ | ||
private static final Color TRANSPARENT = new Color(0, 0, 0, 0); | ||
|
||
/** | ||
* Le constructeur privé de la classe DefaultTheme. | ||
* Il est privé pour empêcher l'instanciation directe de cette classe. | ||
*/ | ||
private DarkTheme() { | ||
} | ||
|
||
@Override | ||
public Color getButtonColor() { | ||
return BOUTON; | ||
} | ||
|
||
@Override | ||
public Color getButtonTextColor() { | ||
return TEXTE_BOUTON; | ||
} | ||
|
||
@Override | ||
public Color getDisabledButtonColor() { | ||
return BOUTON_DESACTIVE; | ||
} | ||
|
||
@Override | ||
public Color getBackgroundColor() { | ||
return FOND; | ||
} | ||
|
||
@Override | ||
public Color getTransparentColor() { | ||
return TRANSPARENT; | ||
} | ||
|
||
@Override | ||
public Color getTextColor() { | ||
return Color.WHITE; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
src/test/java/fr/hashimiste/impl/gui/menu/AventureTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package fr.hashimiste.impl.gui.menu; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.awt.*; | ||
import java.io.IOException; | ||
import java.util.*; | ||
|
||
class AventureTest extends TestMenu{ | ||
private Aventure aventure; | ||
|
||
/** | ||
* Renvoie le conteneur à tester | ||
* @return le conteneur à tester | ||
*/ | ||
@Override | ||
protected Container getTestContainer() { | ||
return aventure; | ||
} | ||
|
||
/** | ||
* Teste l'initialisation du menu | ||
* @throws IOException si une erreur d'entrée/sortie survient | ||
*/ | ||
@BeforeEach | ||
void testMenuInitialisation() throws IOException { | ||
aventure = (Aventure) testMenuInitialisations(aventure, "Aventure"); | ||
|
||
System.out.println("L'initialisation du menu réussi"); | ||
} | ||
|
||
/** | ||
* Teste le menu Paramètre | ||
*/ | ||
@Test | ||
void testMenuParametre(){ | ||
testerMenu(aventure, "Hashimiste", new Dimension(800, 600)); | ||
|
||
testThemeMenu(aventure, "default"); | ||
testThemeMenu(aventure, "candy"); | ||
|
||
System.out.println("Le test du changement de thème réussi"); | ||
} | ||
|
||
/** | ||
* Teste tous les boutons du menu | ||
*/ | ||
@Test | ||
void testTousLesBoutons() { | ||
// Création d'une carte pour mapper le nom du bouton à son état attendu (true pour actif, false pour inactif) | ||
Map<String, Boolean> boutonsEtEtats = new HashMap<>(); | ||
boutonsEtEtats.put("Menu", true); | ||
boutonsEtEtats.put("Niveau 1", false); | ||
boutonsEtEtats.put("Niveau 2", false); | ||
boutonsEtEtats.put("Niveau 3", false); | ||
boutonsEtEtats.put("Niveau 4", false); | ||
boutonsEtEtats.put("Niveau 5", false); | ||
boutonsEtEtats.put("Niveau 6", false); | ||
boutonsEtEtats.put("Niveau 7", false); | ||
boutonsEtEtats.put("Niveau 8", false); | ||
boutonsEtEtats.put("Niveau 9", false); | ||
boutonsEtEtats.put("Niveau 10", false); | ||
|
||
// Itération sur chaque entrée de la carte pour vérifier chaque bouton | ||
boutonsEtEtats.forEach(this::verifierEtatBouton); | ||
} | ||
} |
Oops, something went wrong.