Update ui tests & search fixing #8647
This commit is contained in:
parent
f54e7c8cb1
commit
5d344acf17
4 changed files with 66 additions and 57 deletions
|
@ -851,8 +851,8 @@ public class SearchUICore {
|
||||||
|
|
||||||
private enum ResultCompareStep {
|
private enum ResultCompareStep {
|
||||||
TOP_VISIBLE,
|
TOP_VISIBLE,
|
||||||
UNKNOWN_PHRASE_MATCH_WEIGHT,
|
|
||||||
FOUND_WORD_COUNT,
|
FOUND_WORD_COUNT,
|
||||||
|
UNKNOWN_PHRASE_MATCH_WEIGHT,
|
||||||
SEARCH_DISTANCE_IF_NOT_BY_NAME,
|
SEARCH_DISTANCE_IF_NOT_BY_NAME,
|
||||||
COMPARE_FIRST_NUMBER_IN_NAME,
|
COMPARE_FIRST_NUMBER_IN_NAME,
|
||||||
COMPARE_DISTANCE_TO_PARENT_SEARCH_RESULT, // makes sense only for inner subqueries
|
COMPARE_DISTANCE_TO_PARENT_SEARCH_RESULT, // makes sense only for inner subqueries
|
||||||
|
|
|
@ -1,10 +1,7 @@
|
||||||
package net.osmand.search;
|
package net.osmand.search;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FilenameFilter;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.io.Reader;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -22,9 +19,6 @@ import org.junit.runner.RunWith;
|
||||||
import org.junit.runners.Parameterized;
|
import org.junit.runners.Parameterized;
|
||||||
import org.xmlpull.v1.XmlPullParserException;
|
import org.xmlpull.v1.XmlPullParserException;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import com.google.gson.GsonBuilder;
|
|
||||||
|
|
||||||
import net.osmand.OsmAndCollator;
|
import net.osmand.OsmAndCollator;
|
||||||
import net.osmand.ResultMatcher;
|
import net.osmand.ResultMatcher;
|
||||||
import net.osmand.binary.BinaryMapIndexReader;
|
import net.osmand.binary.BinaryMapIndexReader;
|
||||||
|
@ -35,8 +29,6 @@ import net.osmand.data.MapObject;
|
||||||
import net.osmand.data.Street;
|
import net.osmand.data.Street;
|
||||||
import net.osmand.osm.AbstractPoiType;
|
import net.osmand.osm.AbstractPoiType;
|
||||||
import net.osmand.osm.MapPoiTypes;
|
import net.osmand.osm.MapPoiTypes;
|
||||||
import net.osmand.router.RouteTestingTest;
|
|
||||||
import net.osmand.router.TestEntry;
|
|
||||||
import net.osmand.search.SearchUICore.SearchResultCollection;
|
import net.osmand.search.SearchUICore.SearchResultCollection;
|
||||||
import net.osmand.search.SearchUICore.SearchResultMatcher;
|
import net.osmand.search.SearchUICore.SearchResultMatcher;
|
||||||
import net.osmand.search.core.SearchPhrase;
|
import net.osmand.search.core.SearchPhrase;
|
||||||
|
@ -48,6 +40,7 @@ import net.osmand.util.Algorithms;
|
||||||
public class SearchUICoreTest {
|
public class SearchUICoreTest {
|
||||||
|
|
||||||
private static final String SEARCH_RESOURCES_PATH = "src/test/resources/search/";
|
private static final String SEARCH_RESOURCES_PATH = "src/test/resources/search/";
|
||||||
|
private static boolean TEST_EXTRA_RESULTS = true;
|
||||||
|
|
||||||
private File testFile;
|
private File testFile;
|
||||||
|
|
||||||
|
@ -98,7 +91,7 @@ public class SearchUICoreTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSearchImpl() throws IOException, JSONException {
|
public void testSearch() throws IOException, JSONException {
|
||||||
File jsonFile = testFile;
|
File jsonFile = testFile;
|
||||||
String sourceJsonText = Algorithms.getFileAsString(jsonFile);
|
String sourceJsonText = Algorithms.getFileAsString(jsonFile);
|
||||||
Assert.assertNotNull(sourceJsonText);
|
Assert.assertNotNull(sourceJsonText);
|
||||||
|
@ -149,6 +142,12 @@ public class SearchUICoreTest {
|
||||||
results.add(resultsArr.getString(i));
|
results.add(resultsArr.getString(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (TEST_EXTRA_RESULTS && sourceJson.has("extra-results")) {
|
||||||
|
JSONArray resultsArr = sourceJson.getJSONArray("extra-results");
|
||||||
|
for (int i = 0; i < resultsArr.length(); i++) {
|
||||||
|
results.add(resultsArr.getString(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SearchSettings s = SearchSettings.parseJSON(settingsJson);
|
SearchSettings s = SearchSettings.parseJSON(settingsJson);
|
||||||
s.setOfflineIndexes(Collections.singletonList(reader));
|
s.setOfflineIndexes(Collections.singletonList(reader));
|
||||||
|
@ -181,6 +180,12 @@ public class SearchUICoreTest {
|
||||||
String expected = results.get(i++);
|
String expected = results.get(i++);
|
||||||
String present = result.toString();
|
String present = result.toString();
|
||||||
//System.out.println(present);
|
//System.out.println(present);
|
||||||
|
if(!Algorithms.stringsEqual(expected, present)) {
|
||||||
|
System.out.println(String.format("Mismatch for '%s' != '%s'. Result: ", expected, present));
|
||||||
|
for (SearchResult r : searchResults) {
|
||||||
|
System.out.println("\t\""+r.toString()+"\",");
|
||||||
|
}
|
||||||
|
}
|
||||||
Assert.assertEquals(expected, present);
|
Assert.assertEquals(expected, present);
|
||||||
if (i >= results.size()) {
|
if (i >= results.size()) {
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -12,8 +12,12 @@
|
||||||
"phrase": "48 Free Street Portland",
|
"phrase": "48 Free Street Portland",
|
||||||
"results": [
|
"results": [
|
||||||
"48.0, <input> ",
|
"48.0, <input> ",
|
||||||
"48, Free Street (Downtown), Portland",
|
"48, Free Street (Downtown), Portland"],
|
||||||
|
"extra-results": [
|
||||||
"48, Portland Street, North Berwick",
|
"48, Portland Street, North Berwick",
|
||||||
|
"Free Street (Downtown), Portland",
|
||||||
|
"Free Street (Ferry Village), South Portland",
|
||||||
|
"Portland Street",
|
||||||
"48, Portland Avenue, Old Orchard Beach",
|
"48, Portland Avenue, Old Orchard Beach",
|
||||||
"Portland Street (Downtown), Portland",
|
"Portland Street (Downtown), Portland",
|
||||||
"Portland Street Pier, South Portland",
|
"Portland Street Pier, South Portland",
|
||||||
|
@ -21,8 +25,7 @@
|
||||||
"Portland Street, North Berwick",
|
"Portland Street, North Berwick",
|
||||||
"Portland Street, Berwick",
|
"Portland Street, Berwick",
|
||||||
"Portland Street, South Berwick",
|
"Portland Street, South Berwick",
|
||||||
"Portland Street, Fryeburg",
|
"Portland Street, Fryeburg"
|
||||||
"Portland Square, Portland"
|
|
||||||
],
|
],
|
||||||
"amenities": [
|
"amenities": [
|
||||||
{
|
{
|
||||||
|
|
|
@ -10,8 +10,13 @@
|
||||||
"sortByName": false
|
"sortByName": false
|
||||||
},
|
},
|
||||||
"phrase": "Calle de las eras 5, Navacerrada",
|
"phrase": "Calle de las eras 5, Navacerrada",
|
||||||
|
|
||||||
"results": [
|
"results": [
|
||||||
"5, Calle de las Eras (Uranización Los Corales), Navacerrada",
|
"5, Calle de las Eras (Uranización Los Corales), Navacerrada"
|
||||||
|
],
|
||||||
|
"extra-results": [
|
||||||
|
"Calle de las Eras (Uranización Los Corales), Pasaje de las Eras (Uranización Los Corales), Navacerrada",
|
||||||
|
"Calle del Sotillo (Uranización Los Corales), Pasaje de las Eras (Uranización Los Corales), Navacerrada",
|
||||||
"5, Calle Navacerrada (Urb. Las Suertes), Las Suertes",
|
"5, Calle Navacerrada (Urb. Las Suertes), Las Suertes",
|
||||||
"50, Calle de Francisco Navacerrada, Salamanca",
|
"50, Calle de Francisco Navacerrada, Salamanca",
|
||||||
"52, Calle de Francisco Navacerrada, Salamanca",
|
"52, Calle de Francisco Navacerrada, Salamanca",
|
||||||
|
@ -23,6 +28,12 @@
|
||||||
"58, Calle de Francisco Navacerrada, Salamanca",
|
"58, Calle de Francisco Navacerrada, Salamanca",
|
||||||
"59, Calle de Francisco Navacerrada, Salamanca",
|
"59, Calle de Francisco Navacerrada, Salamanca",
|
||||||
"Calle del Puerto de Navacerrada, Las Nieves",
|
"Calle del Puerto de Navacerrada, Las Nieves",
|
||||||
|
"Pasaje de las Eras (Uranización Los Corales), Navacerrada",
|
||||||
|
"Calle Barrio de las Peñas, Navacerrada",
|
||||||
|
"Calle de las Cruces (Residencial Sanabria), Navacerrada",
|
||||||
|
"Calle de las Escuelas, Navacerrada",
|
||||||
|
"Calle de las Huertas (Residencial Sanabria), Navacerrada",
|
||||||
|
"Calle de la Virgen de las Nieves, Puerto de Navacerrada",
|
||||||
"Calle Puerto de Navacerrada, La Poveda",
|
"Calle Puerto de Navacerrada, La Poveda",
|
||||||
"Calle del Embalse de Navacerrada, Villa de Vallecas",
|
"Calle del Embalse de Navacerrada, Villa de Vallecas",
|
||||||
"Calle del Puerto de Navacerrada, Puente de Vallecas",
|
"Calle del Puerto de Navacerrada, Puente de Vallecas",
|
||||||
|
@ -32,21 +43,11 @@
|
||||||
"Calle Puerto de Navacerrada, Roman Candelas",
|
"Calle Puerto de Navacerrada, Roman Candelas",
|
||||||
"Calle Navacerrada, Becerril de la Sierra",
|
"Calle Navacerrada, Becerril de la Sierra",
|
||||||
"Carretera de Collado Villalba a Navacerrada, El Baillo y las Hojarascas",
|
"Carretera de Collado Villalba a Navacerrada, El Baillo y las Hojarascas",
|
||||||
"Calle Navacerrada (Cerceda), El Boalo",
|
"Calle de Ángel Rojas, Navacerrada",
|
||||||
"Calle Navacerrada (El Pedregal), Bustarviejo",
|
"Calle de los Robles (Uranización Los Corales), Navacerrada",
|
||||||
"Calle Navacerrada, Buitrago del Lozoya",
|
"Calle de los Enebros (Uranización Los Corales), Navacerrada",
|
||||||
"Carretera de Colmenar Viejo a Navacerrada, Becerril de la Sierra",
|
"Calle de la Bola del Mundo (Residencial Sanabria), Navacerrada",
|
||||||
"Carretera de Colmenar Viejo a Navacerrada, Manzanares el Real",
|
"Calle de la Maliciosa (Residencial Sanabria), Navacerrada",
|
||||||
"Carretera de Collado Villalba a Navacerrada, Dehesa Boyal",
|
|
||||||
"Carretera de Collado Villalba a Navacerrada, Polideportivo Dehesa Boyal",
|
|
||||||
"Carretera de Navacerrada, Jazmines",
|
|
||||||
"Carretera de Colmenar Viejo a Navacerrada (Cerceda), El Boalo",
|
|
||||||
"Carretera de Collado Villalba a Navacerrada, Cerca de Cascarrilla",
|
|
||||||
"Carretera de Navacerrada, El Boalo",
|
|
||||||
"Carretera de Collado Villalba a Navacerrada, Collado Mediano",
|
|
||||||
"Camino de Navacerrada (Serranía de la Paloma), Collado Mediano",
|
|
||||||
"Camino de Los Molinos a Navacerrada, Collado Mediano",
|
|
||||||
"Carretera de Collado Villalba a Navacerrada, Navacerrada"
|
|
||||||
],
|
],
|
||||||
"amenities": [
|
"amenities": [
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue