Merge pull request #23 from IUTInfoAix-R202-2022/app_test
Test de la couleur de fond des buttons
This commit is contained in:
		
						commit
						10ce5b6f8d
					
				| @ -63,9 +63,9 @@ public class Controller implements Initializable { | ||||
|     private Button login; | ||||
| 
 | ||||
|     // Style des boutons | ||||
|     Background btNormalBackground = new Background(new BackgroundFill(Color.rgb(255,110,64), new CornerRadii(30), Insets.EMPTY)); | ||||
|     Background btNormalHover = new Background(new BackgroundFill(Color.rgb(255,152,120), new CornerRadii(30), Insets.EMPTY)); | ||||
|     Background btNormalSelected = new Background(new BackgroundFill(Color.rgb(255,60,0), new CornerRadii(30), Insets.EMPTY)); | ||||
|     public static Background btNormalBackground = new Background(new BackgroundFill(Color.rgb(255,110,64), new CornerRadii(30), Insets.EMPTY)); | ||||
|     public static Background btHoverBackground = new Background(new BackgroundFill(Color.rgb(255,152,120), new CornerRadii(30), Insets.EMPTY)); | ||||
|     public static Background btSelectedBackground = new Background(new BackgroundFill(Color.rgb(255,60,0), new CornerRadii(30), Insets.EMPTY)); | ||||
| 
 | ||||
|     private void initFrance() { | ||||
|         france = FranceBuilder.create() | ||||
| @ -87,7 +87,7 @@ public class Controller implements Initializable { | ||||
| 
 | ||||
|         onEnterHandler = evt -> { | ||||
|             Button bt = (Button) evt.getSource(); | ||||
|             bt.setBackground(btNormalHover); | ||||
|             bt.setBackground(btHoverBackground); | ||||
|         }; | ||||
| 
 | ||||
|         onExitHandler = evt -> { | ||||
| @ -113,8 +113,8 @@ public class Controller implements Initializable { | ||||
| 
 | ||||
|         onPressHandler = event -> { | ||||
|             Button bt = (Button) event.getSource(); | ||||
|             if (bt.getBackground().equals(btNormalSelected)) { | ||||
|                 bt.setBackground(btNormalHover); | ||||
|             if (bt.getBackground().equals(btSelectedBackground)) { | ||||
|                 bt.setBackground(btHoverBackground); | ||||
|                 bt.setOnMouseEntered(onEnterHandler); | ||||
|                 bt.setOnMouseExited(onExitHandler); | ||||
|             } else { | ||||
| @ -135,7 +135,7 @@ public class Controller implements Initializable { | ||||
|                 } | ||||
|                 bt.setOnMouseEntered(null); | ||||
|                 bt.setOnMouseExited(null); | ||||
|                 bt.setBackground(btNormalSelected); | ||||
|                 bt.setBackground(btSelectedBackground); | ||||
|             } | ||||
|         }; | ||||
| 
 | ||||
|  | ||||
| @ -1,6 +1,7 @@ | ||||
| package fr.univ_amu.iut; | ||||
| 
 | ||||
| import fr.univ_amu.iut.fResultat.TableEntry; | ||||
| import fr.univ_amu.iut.fp.Controller; | ||||
| import fr.univ_amu.iut.model.Discipline; | ||||
| import fr.univ_amu.iut.model.Niveau; | ||||
| import fr.univ_amu.iut.model.Thematique; | ||||
| @ -8,6 +9,7 @@ import javafx.scene.Node; | ||||
| import javafx.scene.Scene; | ||||
| import javafx.scene.control.Button; | ||||
| import javafx.scene.control.TableView; | ||||
| import javafx.scene.layout.Background; | ||||
| import javafx.scene.layout.Pane; | ||||
| import javafx.stage.Stage; | ||||
| import javafx.stage.Window; | ||||
| @ -127,4 +129,23 @@ public class AppTest { | ||||
|         assertThat(entry.getNiveau()).isEqualTo(Niveau.PremierDegre.getNom()); | ||||
|     } | ||||
| 
 | ||||
| } | ||||
|     /* Ce test s'appui sur des fonctionnalités non fixées de TestFX (= qui peuvent changer) | ||||
|     tels que la position de la souris au début du test | ||||
|     Ce test peut donc faire des faux négatifs | ||||
|      */ | ||||
|     @Test | ||||
|     public void button_background_changes_on_click(FxRobot robot){ | ||||
|         Pane disciplinesPane = (Pane) stage.getScene().lookup("#discipline"); | ||||
|         Button button = (Button) disciplinesPane.getChildren().get(0); | ||||
|         Button button2 = (Button) disciplinesPane.getChildren().get(1); | ||||
| 
 | ||||
|         assertThat(button.getBackground()).isEqualTo(Controller.btNormalBackground); | ||||
|         robot.clickOn(button); | ||||
|         assertThat(button.getBackground()).isEqualTo(Controller.btSelectedBackground); | ||||
|         robot.clickOn(button); | ||||
|         assertThat(button.getBackground()).isEqualTo(Controller.btHoverBackground); | ||||
|         robot.clickOn(button2); | ||||
|         assertThat(button.getBackground()).isEqualTo(Controller.btNormalBackground); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user