From 820dbaec0ec7892df024eb7fc091da1d7c6f7bb0 Mon Sep 17 00:00:00 2001 From: max-klaus Date: Wed, 17 Jun 2020 18:59:36 +0300 Subject: [PATCH] Added noData parameter to search tests --- .../net/osmand/search/SearchUICoreTest.java | 33 +++++++++++-------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/OsmAnd-java/src/test/java/net/osmand/search/SearchUICoreTest.java b/OsmAnd-java/src/test/java/net/osmand/search/SearchUICoreTest.java index 0c32e04c3a..82bb2152bc 100644 --- a/OsmAnd-java/src/test/java/net/osmand/search/SearchUICoreTest.java +++ b/OsmAnd-java/src/test/java/net/osmand/search/SearchUICoreTest.java @@ -114,21 +114,24 @@ public class SearchUICoreTest { } } JSONObject settingsJson = sourceJson.getJSONObject("settings"); + BinaryMapIndexReader reader = null; + boolean useData = settingsJson.optBoolean("useData", true); + if (useData) { + boolean obfZipFileExists = obfZipFile.exists(); + if (!obfZipFileExists) { + System.out.println(String.format("Could not find obf file: %s", obfZipFile.getPath())); + return; + } + //Assert.assertTrue(obfZipFileExists); - boolean obfZipFileExists = obfZipFile.exists(); - if (!obfZipFileExists) { - System.out.println(String.format("Could not find obf file: %s", obfZipFile.getPath())); - return; + GZIPInputStream gzin = new GZIPInputStream(new FileInputStream(obfZipFile)); + FileOutputStream fous = new FileOutputStream(obfFile); + Algorithms.streamCopy(gzin, fous); + fous.close(); + gzin.close(); + + reader = new BinaryMapIndexReader(new RandomAccessFile(obfFile.getPath(), "r"), obfFile); } - //Assert.assertTrue(obfZipFileExists); - - GZIPInputStream gzin = new GZIPInputStream(new FileInputStream(obfZipFile)); - FileOutputStream fous = new FileOutputStream(obfFile); - Algorithms.streamCopy(gzin, fous); - fous.close(); - gzin.close(); - - BinaryMapIndexReader reader = new BinaryMapIndexReader(new RandomAccessFile(obfFile.getPath(), "r"), obfFile); List> results = new ArrayList<>(); for (int i = 0; i < phrases.size(); i++) { results.add(new ArrayList()); @@ -146,7 +149,9 @@ public class SearchUICoreTest { } SearchSettings s = SearchSettings.parseJSON(settingsJson); - s.setOfflineIndexes(Collections.singletonList(reader)); + if (reader != null) { + s.setOfflineIndexes(Collections.singletonList(reader)); + } final SearchUICore core = new SearchUICore(MapPoiTypes.getDefault(), "en", false); core.init();