Skip to content

Commit

Permalink
Merge branch 'feature/508848-MostrarPreciosCombustibles' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
HERRERA99 committed Nov 22, 2024
2 parents 4f617ce + 40e60ad commit 9b04b1d
Show file tree
Hide file tree
Showing 12 changed files with 113 additions and 90 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ public void testFiltrarGasolinerasPorPrecioMaximoNoIntroducidoError() {
//clicka en filtrar
onView(withId(R.id.menuFiltrar)).perform(click());
//comprueba mensaje de error
// onView(withText("Por favor, introduce un precio máximo.")).inRoot(RootMatchers.withDecorView(not(decorView))).check(matches(isDisplayed()));
assertTrue(true);
}

Expand All @@ -113,7 +112,6 @@ public void testFiltrarGasolinerasPorPrecioMaximoNoNumericoError() {
onView(withId(R.id.etPrecioMax)).perform(typeText("Uno punto cuatro"));

//comprueba mensaje de error
// onView(withText("Por favor, introduce un número válido para el precio máximo.")).inRoot(RootMatchers.withDecorView(not(decorView))).check(matches(isDisplayed()));
assertTrue(true);
}

Expand All @@ -130,42 +128,43 @@ public void testFiltrarGasolinerasPorPrecioMaximoNegativoError() {
onView(withId(R.id.etPrecioMax)).perform(typeText("-1.4"));

//comprueba mensaje de error
// onView(withText("Por favor, el precio máximo debe ser positivo.")).inRoot(RootMatchers.withDecorView(not(decorView))).check(matches(isDisplayed()));
assertTrue(true);
}

// @Test
// public void testPersistenciaDeDatosFiltradosAlReiniciar() throws InterruptedException {
// //clicka en filtrar
// onView(withId(R.id.menuFiltrar)).perform(click());
//
// //clicka en el selector de combustible
// onView(withId(R.id.spinnerCombustible)).perform(click());
//
// //elige la opcion gasoleo A
// onData(allOf(is(instanceOf(TipoCombustible.class)),
// is(GASOLEO_A))).inRoot(isPlatformPopup()).perform(click());
//
// //clicka en el campo de precio máximo
// onView(withId(R.id.etPrecioMax)).perform(click());
//
// //escribe 1.4 en el campo de precio máximo
// onView(withId(R.id.etPrecioMax)).perform(typeText("1.4"));
//
// //clicka el botón filtrar
// onView(withId(R.id.btnFiltrar)).perform(click());
//
// // Cierra y reinicia la actividad (simula reiniciar la app)
// activityRule.getScenario().recreate();
//
// //clicka en filtrar de nuevo
// onView(withId(R.id.menuFiltrar)).perform(click());
//
// //verifica que el filtro persiste
// onView(withId(R.id.etPrecioMax)).check(matches(withText("1.4")));
// onView(withId(R.id.spinnerCombustible)).check(matches(withSpinnerText("Gasoleo A")));
// assertTrue(true);
// }
/*
@Test
public void testPersistenciaDeDatosFiltradosAlReiniciar() throws InterruptedException {
//clicka en filtrar
onView(withId(R.id.menuFiltrar)).perform(click());
//clicka en el selector de combustible
onView(withId(R.id.spinnerCombustible)).perform(click());
//elige la opcion gasoleo A
onData(allOf(is(instanceOf(TipoCombustible.class)),
is(GASOLEO_A))).inRoot(isPlatformPopup()).perform(click());
//clicka en el campo de precio máximo
onView(withId(R.id.etPrecioMax)).perform(click());
//escribe 1.4 en el campo de precio máximo
onView(withId(R.id.etPrecioMax)).perform(typeText("1.4"));
//clicka el botón filtrar
onView(withId(R.id.btnFiltrar)).perform(click());
// Cierra y reinicia la actividad (simula reiniciar la app)
activityRule.getScenario().recreate();
//clicka en filtrar de nuevo
onView(withId(R.id.menuFiltrar)).perform(click());
//verifica que el filtro persiste
onView(withId(R.id.etPrecioMax)).check(matches(withText("1.4")));
onView(withId(R.id.spinnerCombustible)).check(matches(withSpinnerText("Gasoleo A")));
assertTrue(true);
}
*/

@Test
public void testCancelacionDelFiltro() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package es.unican.gasolineras.activities.main;

import static androidx.test.espresso.Espresso.onData;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.action.ViewActions.swipeUp;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static androidx.test.espresso.matcher.ViewMatchers.withText;
Expand Down Expand Up @@ -127,7 +129,6 @@ public void test24H() {
DataInteraction g1 = onData(anything()).inAdapterView(withId(R.id.lvStations)).atPosition(0);
g1.onChildView(withId(R.id.tvAbiertoCerrado)).check(matches(withText("Abierto")));
g1.onChildView(withId(R.id.tvHorarioGasolinera)).check(matches(withText("(24H)")));
// g1.onChildView(withId(R.id.tvHorarioGasolinera)).check(matches(withTextColor(ContextCompat.getColor(context, R.color.verde))));
}

@Test
Expand All @@ -136,7 +137,6 @@ public void testAbiertaSimple() {
DataInteraction g1 = onData(anything()).inAdapterView(withId(R.id.lvStations)).atPosition(1);
g1.onChildView(withId(R.id.tvAbiertoCerrado)).check(matches(withText("Abierto")));
g1.onChildView(withId(R.id.tvHorarioGasolinera)).check(matches(withText("(" + procesaHorario(UtilsHorario.obtenerHorarioAbiertoSimple(), obtenerDiaActual(LocalDateTime.now().getDayOfWeek())) + ")")));
// g1.onChildView(withId(R.id.tvHorarioGasolinera)).check(matches(withTextColor(ContextCompat.getColor(context, R.color.verde))));
}

@Test
Expand All @@ -145,7 +145,6 @@ public void testAbiertaIntervalo() {
DataInteraction g1 = onData(anything()).inAdapterView(withId(R.id.lvStations)).atPosition(2);
g1.onChildView(withId(R.id.tvAbiertoCerrado)).check(matches(withText("Abierto")));
g1.onChildView(withId(R.id.tvHorarioGasolinera)).check(matches(withText("(" + procesaHorario(UtilsHorario.obtenerHorarioAbiertoIntervalo(), obtenerDiaActual(LocalDateTime.now().getDayOfWeek())) + ")")));
// g1.onChildView(withId(R.id.tvHorarioGasolinera)).check(matches(withTextColor(ContextCompat.getColor(context, R.color.verde))));
}

@Test
Expand All @@ -154,26 +153,26 @@ public void testCerradaTodoElDia() {
DataInteraction g1 = onData(anything()).inAdapterView(withId(R.id.lvStations)).atPosition(3);
g1.onChildView(withId(R.id.tvAbiertoCerrado)).check(matches(withText("Cerrado")));
g1.onChildView(withId(R.id.tvHorarioGasolinera)).check(matches(withText("(Todo el día)")));
// g1.onChildView(withId(R.id.tvHorarioGasolinera)).check(matches(withTextColor(ContextCompat.getColor(context, R.color.rojo))));
}

// @Test
// public void testCerradaParcial() {
// //comprueba la direccion de la primera gasolinera
// DataInteraction g1 = onData(anything()).inAdapterView(withId(R.id.lvStations)).atPosition(4);
// g1.onChildView(withId(R.id.tvAbiertoCerrado)).check(matches(withText("Cerrado")));
// g1.onChildView(withId(R.id.tvHorarioGasolinera)).check(matches(withText("(" + procesaHorario(UtilsHorario.obtenerHorarioCerradoIntervalo(), obtenerDiaActual(LocalDateTime.now().getDayOfWeek())) + ")")));
//// g1.onChildView(withId(R.id.tvHorarioGasolinera)).check(matches(withTextColor(ContextCompat.getColor(context, R.color.rojo))));
// }

// @Test
// public void testSinDetallesDeHorario() throws InterruptedException {
// //comprueba la direccion de la primera gasolinera
// // Scroll puesto que se sale de la pantalla y no se alcanza a ver
// onView(withId(R.id.lvStations)).perform(swipeUp());
// DataInteraction g1 = onData(anything()).inAdapterView(withId(R.id.lvStations)).atPosition(5);
// g1.onChildView(withId(R.id.tvAbiertoCerrado)).check(matches(withText("")));
// g1.onChildView(withId(R.id.tvHorarioGasolinera)).check(matches(withText("(Sin detalles de horario)")));
// }
/*
@Test
public void testCerradaParcial() {
//comprueba la direccion de la primera gasolinera
DataInteraction g1 = onData(anything()).inAdapterView(withId(R.id.lvStations)).atPosition(4);
g1.onChildView(withId(R.id.tvAbiertoCerrado)).check(matches(withText("Cerrado")));
g1.onChildView(withId(R.id.tvHorarioGasolinera)).check(matches(withText("(" + procesaHorario(UtilsHorario.obtenerHorarioCerradoIntervalo(), obtenerDiaActual(LocalDateTime.now().getDayOfWeek())) + ")")));
}
@Test
public void testSinDetallesDeHorario() throws InterruptedException {
//comprueba la direccion de la primera gasolinera
// Scroll puesto que se sale de la pantalla y no se alcanza a ver
onView(withId(R.id.lvStations)).perform(swipeUp());
DataInteraction g1 = onData(anything()).inAdapterView(withId(R.id.lvStations)).atPosition(5);
g1.onChildView(withId(R.id.tvAbiertoCerrado)).check(matches(withText("")));
g1.onChildView(withId(R.id.tvHorarioGasolinera)).check(matches(withText("(Sin detalles de horario)")));
}
*/

}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@
*/
public class Utils {

/**
* Constructor privado para evitar instanciación
*/
private Utils () {

}

/**
* Parses a list of gas stations from a json resource file.
* The json must contain a serialized GasolinerasResponse object.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,15 @@

public class UtilsHorario {

/**
* Constructor privado para evitar instanciacion
*/
private UtilsHorario () {

}

public static final String SIN_DETALLES_DE_HORARIO = "Sin detalles de horario";
public static final String TODO_EL_DÍA = "Todo el día";
public static final String TODO_EL_DIA = "Todo el día";
public static final String HH_MM = "HH:mm";

/**
Expand Down Expand Up @@ -46,7 +53,7 @@ public static String procesaHorario(String horario, String dia) {
if (diaEstaEnRango(dia, inicio, fin)) return rango;
}
}
return TODO_EL_DÍA;
return TODO_EL_DIA;
}

/**
Expand Down Expand Up @@ -112,7 +119,7 @@ public static boolean gasolineraAbierta(String horarios, LocalTime horaActual) {
if ("24H".equals(horarios)) {
return true; // Siempre abierta
}
if (TODO_EL_DÍA.equals(horarios)) {
if (TODO_EL_DIA.equals(horarios)) {
return false;
}
if (SIN_DETALLES_DE_HORARIO.equals(horarios)) {
Expand Down Expand Up @@ -141,7 +148,7 @@ public static boolean gasolineraAbierta(String horarios, LocalTime horaActual) {
* false si no esta dentro del rango.
*/
public static boolean horaEnRango(String rango, LocalTime horaActual) {
if ((rango.equals(SIN_DETALLES_DE_HORARIO))&&(rango.equals(TODO_EL_DÍA)))
if ((rango.equals(SIN_DETALLES_DE_HORARIO))&&(rango.equals(TODO_EL_DIA)))
{
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@
@InstallIn(ActivityComponent.class)
public abstract class RepositoriesModule {

/**
* Constructor privado
*/
private RepositoriesModule () {
}

@Provides
public static IGasolinerasRepository provideRepository() {
return GasolinerasRepository.INSTANCE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
import androidx.room.Room;

public class DbFunctions {

/**
* Constructor privado
*/
private DbFunctions() {
}

// Base de datos de los puntos de interes
private static AppDatabase db;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
*/
public class GasolinerasService {

/**
* Constructor privado
*/
private GasolinerasService() {}

/** Open Charge Map API base URL*/
final static String BASE_URL = "https://sedeaplicaciones.minetur.gob.es/ServiciosRESTCarburantes/PreciosCarburantes/";

Expand Down
1 change: 0 additions & 1 deletion AndroidProject/app/src/main/res/values-night/themes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@
<!-- Base application theme. -->
<style name="Base.Theme.Gasolineras" parent="Theme.Material3.DayNight.NoActionBar">
<!-- Customize your dark theme here. -->
<!-- <item name="colorPrimary">@color/my_dark_primary</item> -->
</style>
</resources>
5 changes: 1 addition & 4 deletions AndroidProject/app/src/main/res/xml/backup_rules.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,5 @@
See https://developer.android.com/about/versions/12/backup-restore
-->
<full-backup-content>
<!--
<include domain="sharedpref" path="."/>
<exclude domain="sharedpref" path="device.xml"/>
-->

</full-backup-content>
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,13 @@ public void inicializa() {
public void testComparadorDistancia(){

//caso que la primera gasolinera esta mas cerca
assertEquals(comparadorDistancia.compare(cercana, lejana), -1);
assertEquals(-1, comparadorDistancia.compare(cercana, lejana));

//caso que la primera gasolinera esta mas lejos
assertEquals(comparadorDistancia.compare(lejana, cercana), 1);
assertEquals(1, comparadorDistancia.compare(lejana, cercana));

//caso que esten a la misma distancia
assertEquals(comparadorDistancia.compare(cercana, auxCercana), 0);
assertEquals(0, comparadorDistancia.compare(cercana, auxCercana));
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,24 @@

public class UtilsHorarioTest {

private GasolinerasArrayAdapter adapter;


@Test
public void procesaHorarioTest() {
Assert.assertEquals(procesaHorario("L-D: 08:00-21:00", "L"), "08:00-21:00");
Assert.assertEquals(procesaHorario("L-D: 08:00-14:00 y 16:00-22:00", "L"), "08:00-14:00 y 16:00-22:00");
Assert.assertEquals(procesaHorario("M-V: 08:00-21:00", "L"), "Todo el día");
Assert.assertEquals(procesaHorario("L-D: 24H", "L"), "24H");
Assert.assertEquals(procesaHorario("", "L"), "Sin detalles de horario");
Assert.assertEquals("08:00-21:00", procesaHorario("L-D: 08:00-21:00", "L"));
Assert.assertEquals("08:00-14:00 y 16:00-22:00", procesaHorario("L-D: 08:00-14:00 y 16:00-22:00", "L"));
Assert.assertEquals("Todo el día", procesaHorario("M-V: 08:00-21:00", "L"));
Assert.assertEquals("24H", procesaHorario("L-D: 24H", "L"));
Assert.assertEquals("Sin detalles de horario", procesaHorario("", "L"));
}

@Test
public void gasolineraAbiertaTest(){
Assert.assertEquals(gasolineraAbierta("08:00-14:00 y 16:00-20:00", LocalTime.of(10, 00)), true);
Assert.assertEquals(gasolineraAbierta("08:00-14:00 y 16:00-20:00", LocalTime.of(15, 00)), false);
Assert.assertEquals(gasolineraAbierta("08:00-14:00 y 16:00-20:00", LocalTime.of(8, 00)), true);
Assert.assertEquals(gasolineraAbierta("08:00-14:00 y 16:00-20:00", LocalTime.of(14, 00,00,1)), false);
Assert.assertEquals(gasolineraAbierta("24H", LocalTime.of(10, 00)), true);
Assert.assertEquals(gasolineraAbierta("Todo el día", LocalTime.of(10, 00)), false);
Assert.assertEquals(gasolineraAbierta("Sin detalles de horario", LocalTime.of(10, 00)), false);
Assert.assertEquals(true, gasolineraAbierta("08:00-14:00 y 16:00-20:00", LocalTime.of(10, 00)));
Assert.assertEquals(false, gasolineraAbierta("08:00-14:00 y 16:00-20:00", LocalTime.of(15, 00)));
Assert.assertEquals(true, gasolineraAbierta("08:00-14:00 y 16:00-20:00", LocalTime.of(8, 00)));
Assert.assertEquals(false, gasolineraAbierta("08:00-14:00 y 16:00-20:00", LocalTime.of(14, 00,00,1)));
Assert.assertEquals(true, gasolineraAbierta("24H", LocalTime.of(10, 00)));
Assert.assertEquals(false, gasolineraAbierta("Todo el día", LocalTime.of(10, 00)));
Assert.assertEquals(false, gasolineraAbierta("Sin detalles de horario", LocalTime.of(10, 00)));


}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ public void rellenaListaCombusitblesTest() {

//Compruebo que la lista tiene todos los elementos
Assert.assertEquals("La lista no contiene todos los combustibles.",
listaCombustiblesParaRellenar.size(),
14);
14,
listaCombustiblesParaRellenar.size());

// Verificar elementos uno por uno
for (int i = 0; i < listaCompleta.size(); i++) {
Expand All @@ -135,8 +135,8 @@ public void rellenaListaCombusitblesTest() {

//Compruebo que la lista tiene todos los elementos
Assert.assertEquals("La lista no contiene todos los combustibles.",
listaCombustiblesParaRellenar.size(),
6);
6,
listaCombustiblesParaRellenar.size());

// Verificar elementos uno por uno
for (int i = 0; i < listaParcial.size(); i++) {
Expand All @@ -158,8 +158,8 @@ public void rellenaListaCombusitblesTest() {

//Compruebo que la lista tiene todos los elementos
Assert.assertEquals("La lista contiene algun combustible.",
listaCombustiblesParaRellenar.size(),
0);
0,
listaCombustiblesParaRellenar.size());

// Verificar elementos uno por uno
for (int i = 0; i < listaVacia.size(); i++) {
Expand Down

0 comments on commit 9b04b1d

Please sign in to comment.