Update ui tests & search fixing #8647

Conflicts:
	OsmAnd-java/src/test/resources/search/navacerrada.json
This commit is contained in:
Victor Shcherb 2020-05-24 15:55:14 +02:00
parent cf28032858
commit f980ec4340
4 changed files with 3402 additions and 21 deletions

View file

@ -851,8 +851,8 @@ public class SearchUICore {
private enum ResultCompareStep {
TOP_VISIBLE,
UNKNOWN_PHRASE_MATCH_WEIGHT,
FOUND_WORD_COUNT,
UNKNOWN_PHRASE_MATCH_WEIGHT,
SEARCH_DISTANCE_IF_NOT_BY_NAME,
COMPARE_FIRST_NUMBER_IN_NAME,
COMPARE_DISTANCE_TO_PARENT_SEARCH_RESULT, // makes sense only for inner subqueries

View file

@ -1,10 +1,7 @@
package net.osmand.search;
import java.io.File;
import java.io.FilenameFilter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
@ -22,9 +19,6 @@ import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.xmlpull.v1.XmlPullParserException;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import net.osmand.OsmAndCollator;
import net.osmand.ResultMatcher;
import net.osmand.binary.BinaryMapIndexReader;
@ -35,8 +29,6 @@ import net.osmand.data.MapObject;
import net.osmand.data.Street;
import net.osmand.osm.AbstractPoiType;
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.SearchResultMatcher;
import net.osmand.search.core.SearchPhrase;
@ -48,6 +40,7 @@ import net.osmand.util.Algorithms;
public class SearchUICoreTest {
private static final String SEARCH_RESOURCES_PATH = "src/test/resources/search/";
private static boolean TEST_EXTRA_RESULTS = true;
private File testFile;
@ -98,7 +91,7 @@ public class SearchUICoreTest {
}
@Test
public void testSearchImpl() throws IOException, JSONException {
public void testSearch() throws IOException, JSONException {
File jsonFile = testFile;
String sourceJsonText = Algorithms.getFileAsString(jsonFile);
Assert.assertNotNull(sourceJsonText);
@ -149,6 +142,12 @@ public class SearchUICoreTest {
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);
s.setOfflineIndexes(Collections.singletonList(reader));
@ -181,6 +180,12 @@ public class SearchUICoreTest {
String expected = results.get(i++);
String present = result.toString();
//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);
if (i >= results.size()) {
break;

View file

@ -12,17 +12,20 @@
"phrase": "48 Free Street Portland",
"results": [
"48.0, <input> ",
"48, Free Street (Downtown), Portland",
"48, Portland Street, North Berwick",
"48, Portland Avenue, Old Orchard Beach",
"Portland Street (Downtown), Portland",
"Portland Street Pier, South Portland",
"Portland Street, Yarmouth",
"Portland Street, North Berwick",
"Portland Street, Berwick",
"Portland Street, South Berwick",
"Portland Street, Fryeburg",
"Portland Square, Portland"
"48, Free Street (Downtown), Portland"],
"extra-results": [
"48, Portland Street, North Berwick",
"Free Street (Downtown), Portland",
"Free Street (Ferry Village), South Portland",
"Portland Street",
"48, Portland Avenue, Old Orchard Beach",
"Portland Street (Downtown), Portland",
"Portland Street Pier, South Portland",
"Portland Street, Yarmouth",
"Portland Street, North Berwick",
"Portland Street, Berwick",
"Portland Street, South Berwick",
"Portland Street, Fryeburg"
],
"amenities": [
{

File diff suppressed because it is too large Load diff