V2bis : doc technique et tests fonctionnels
This commit is contained in:
parent
7b0e6c6e09
commit
00b7ac3fda
7 changed files with 129 additions and 0 deletions
|
|
@ -13,6 +13,9 @@
|
||||||
</DropdownSelection>
|
</DropdownSelection>
|
||||||
<DialogSelection />
|
<DialogSelection />
|
||||||
</SelectionState>
|
</SelectionState>
|
||||||
|
<SelectionState runConfigName="testCalculIMG()">
|
||||||
|
<option name="selectionMode" value="DROPDOWN" />
|
||||||
|
</SelectionState>
|
||||||
</selectionStates>
|
</selectionStates>
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
|
|
@ -1,6 +1,11 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||||
|
<component name="JavadocGenerationManager">
|
||||||
|
<option name="OUTPUT_DIRECTORY" value="$PROJECT_DIR$/../doc_app_coach" />
|
||||||
|
<option name="OPTION_SCOPE" value="private" />
|
||||||
|
<option name="OTHER_OPTIONS" value="-encoding utf8 -docencoding utf8 -charset utf8 -sourcepath C:\Users\erwan\AppData\Local\Android\Sdk\platforms\android-36\android.jar --ignore-source-errors" />
|
||||||
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="jbr-21" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="jbr-21" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||||
</component>
|
</component>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,39 @@
|
||||||
|
package com.example.coach.view;
|
||||||
|
|
||||||
|
import androidx.test.ext.junit.rules.ActivityScenarioRule;
|
||||||
|
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||||
|
|
||||||
|
import org.junit.Rule;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
|
import static androidx.test.espresso.Espresso.onView;
|
||||||
|
import static androidx.test.espresso.action.ViewActions.click;
|
||||||
|
import static androidx.test.espresso.action.ViewActions.typeText;
|
||||||
|
import static androidx.test.espresso.action.ViewActions.closeSoftKeyboard;
|
||||||
|
import static androidx.test.espresso.matcher.ViewMatchers.withId;
|
||||||
|
import static androidx.test.espresso.assertion.ViewAssertions.matches;
|
||||||
|
import static androidx.test.espresso.matcher.ViewMatchers.withText;
|
||||||
|
|
||||||
|
import com.example.coach.R;
|
||||||
|
|
||||||
|
@RunWith(AndroidJUnit4.class)
|
||||||
|
public class MainActivityTest {
|
||||||
|
@Rule
|
||||||
|
public ActivityScenarioRule activityRule = new ActivityScenarioRule<>(MainActivity.class);
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCalculIMG(){
|
||||||
|
onView(withId(R.id.txtPoids)).perform(typeText("70"), closeSoftKeyboard());
|
||||||
|
onView(withId(R.id.txtTaille)).perform(typeText("180"), closeSoftKeyboard());
|
||||||
|
onView(withId(R.id.txtAge)).perform(typeText("40"), closeSoftKeyboard());
|
||||||
|
|
||||||
|
onView(withId(R.id.btnCalc)).perform(click());
|
||||||
|
|
||||||
|
try {
|
||||||
|
Thread.sleep(5000);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,5 +1,15 @@
|
||||||
package com.example.coach.contract;
|
package com.example.coach.contract;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contrat pour que le CalculPresenter puisse envoyer des infos à la vue
|
||||||
|
*/
|
||||||
public interface ICalculView {
|
public interface ICalculView {
|
||||||
|
/**
|
||||||
|
* Méthode permettant le transfert des résultats vers la vue
|
||||||
|
* @param image nom du fichier du smiley
|
||||||
|
* @param img valeur de l'img calculé
|
||||||
|
* @param message message à afficher
|
||||||
|
* @param normal vrai si l'img est normal
|
||||||
|
*/
|
||||||
void AfficherResultat(String image, double img, String message, boolean normal);
|
void AfficherResultat(String image, double img, String message, boolean normal);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,8 @@
|
||||||
package com.example.coach.model;
|
package com.example.coach.model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Classe métier contenant les informations d'un profil
|
||||||
|
*/
|
||||||
public class Profil {
|
public class Profil {
|
||||||
private static final int MIN_FEMME = 25;
|
private static final int MIN_FEMME = 25;
|
||||||
private static final int MAX_FEMME = 30;
|
private static final int MAX_FEMME = 30;
|
||||||
|
|
@ -16,6 +19,13 @@ public class Profil {
|
||||||
private double img;
|
private double img;
|
||||||
private int indice;
|
private int indice;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructeur : Valorise les propriétés
|
||||||
|
* @param poids
|
||||||
|
* @param taille
|
||||||
|
* @param age
|
||||||
|
* @param sexe
|
||||||
|
*/
|
||||||
public Profil(Integer poids, Integer taille, Integer age, Integer sexe) {
|
public Profil(Integer poids, Integer taille, Integer age, Integer sexe) {
|
||||||
this.poids = poids;
|
this.poids = poids;
|
||||||
this.taille = taille;
|
this.taille = taille;
|
||||||
|
|
@ -25,6 +35,10 @@ public class Profil {
|
||||||
this.indice = calculIndice();
|
this.indice = calculIndice();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calcul de l'img
|
||||||
|
* @return résultat du calcul de l'img
|
||||||
|
*/
|
||||||
private double calculImg()
|
private double calculImg()
|
||||||
{
|
{
|
||||||
double img;
|
double img;
|
||||||
|
|
@ -33,6 +47,11 @@ public class Profil {
|
||||||
return img;
|
return img;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calcul de l'indice correspondant à l'img
|
||||||
|
* pour afficher le bon message et la bonne image
|
||||||
|
* @return valeur de l'indice
|
||||||
|
*/
|
||||||
private int calculIndice()
|
private int calculIndice()
|
||||||
{
|
{
|
||||||
int min;
|
int min;
|
||||||
|
|
@ -55,15 +74,34 @@ public class Profil {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return Valeur de l'img
|
||||||
|
*/
|
||||||
public double getImg(){
|
public double getImg(){
|
||||||
return this.img;
|
return this.img;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return message à afficher selon l'img
|
||||||
|
*/
|
||||||
public String getMessage(){
|
public String getMessage(){
|
||||||
return MESSAGE[this.indice];
|
return MESSAGE[this.indice];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* nom de l'image drawable à afficher
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public String getImage(){
|
public String getImage(){
|
||||||
return IMAGE[this.indice];
|
return IMAGE[this.indice];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return vrai si l'img est normal
|
||||||
|
*/
|
||||||
public boolean normal(){
|
public boolean normal(){
|
||||||
if(indice == 1){
|
if(indice == 1){
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -3,13 +3,28 @@ package com.example.coach.presenter;
|
||||||
import com.example.coach.contract.ICalculView;
|
import com.example.coach.contract.ICalculView;
|
||||||
import com.example.coach.model.Profil;
|
import com.example.coach.model.Profil;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 'presenter' dédié à la vue affichant le calcul de l'img
|
||||||
|
*/
|
||||||
public class CalculPresenter {
|
public class CalculPresenter {
|
||||||
private ICalculView vue;
|
private ICalculView vue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructeur : valorise la propriété permettant d'accéder à la vue
|
||||||
|
* @param vue
|
||||||
|
*/
|
||||||
public CalculPresenter(ICalculView vue) {
|
public CalculPresenter(ICalculView vue) {
|
||||||
this.vue = vue;
|
this.vue = vue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Créer le profil avec les informations reçues de la vue
|
||||||
|
* Renvoie à la vue les infos à afficher
|
||||||
|
* @param sexe
|
||||||
|
* @param poids
|
||||||
|
* @param taille
|
||||||
|
* @param age
|
||||||
|
*/
|
||||||
public void creerProfil(Integer sexe, Integer poids, Integer taille, Integer age)
|
public void creerProfil(Integer sexe, Integer poids, Integer taille, Integer age)
|
||||||
{
|
{
|
||||||
Profil profil = new Profil(poids, taille, age, sexe);
|
Profil profil = new Profil(poids, taille, age, sexe);
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,9 @@ import com.example.coach.R;
|
||||||
import com.example.coach.contract.ICalculView;
|
import com.example.coach.contract.ICalculView;
|
||||||
import com.example.coach.presenter.CalculPresenter;
|
import com.example.coach.presenter.CalculPresenter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Activity qui permet le calcul de l'img
|
||||||
|
*/
|
||||||
public class MainActivity extends AppCompatActivity implements ICalculView {
|
public class MainActivity extends AppCompatActivity implements ICalculView {
|
||||||
|
|
||||||
private EditText txtPoids;
|
private EditText txtPoids;
|
||||||
|
|
@ -45,6 +48,13 @@ public class MainActivity extends AppCompatActivity implements ICalculView {
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Méthode permettant l'affichage du résultat du calcul de l'img
|
||||||
|
* @param image nom du fichier drawable pour le smiley
|
||||||
|
* @param img valeur de l'img
|
||||||
|
* @param message message à afficher
|
||||||
|
* @param normal faux si l'img n'est pas normal, vrai dans le cas inverse
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void AfficherResultat(String image, double img, String message, boolean normal) {
|
public void AfficherResultat(String image, double img, String message, boolean normal) {
|
||||||
int iamgeId = getResources().getIdentifier(image, "drawable", getPackageName());
|
int iamgeId = getResources().getIdentifier(image, "drawable", getPackageName());
|
||||||
|
|
@ -63,6 +73,9 @@ public class MainActivity extends AppCompatActivity implements ICalculView {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Traitements à réaliser lors du lancement de l'application
|
||||||
|
*/
|
||||||
private void init()
|
private void init()
|
||||||
{
|
{
|
||||||
chargeObjetsGraphiques();
|
chargeObjetsGraphiques();
|
||||||
|
|
@ -70,6 +83,9 @@ public class MainActivity extends AppCompatActivity implements ICalculView {
|
||||||
btnCalc.setOnClickListener(v -> btnCalcClic());
|
btnCalc.setOnClickListener(v -> btnCalcClic());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Récupère les objets graphiques
|
||||||
|
*/
|
||||||
private void chargeObjetsGraphiques()
|
private void chargeObjetsGraphiques()
|
||||||
{
|
{
|
||||||
txtPoids = (EditText) findViewById(R.id.txtPoids);
|
txtPoids = (EditText) findViewById(R.id.txtPoids);
|
||||||
|
|
@ -86,6 +102,9 @@ public class MainActivity extends AppCompatActivity implements ICalculView {
|
||||||
btnCalc = (Button) findViewById(R.id.btnCalc);
|
btnCalc = (Button) findViewById(R.id.btnCalc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Traitements à réaliser lors du clic sur le bouton
|
||||||
|
*/
|
||||||
private void btnCalcClic()
|
private void btnCalcClic()
|
||||||
{
|
{
|
||||||
int poids = 0, taille = 0, age = 0, sexe = 0;
|
int poids = 0, taille = 0, age = 0, sexe = 0;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue