Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvng <viktor.govako@gmail.com>2016-03-31 17:15:08 +0300
committervng <viktor.govako@gmail.com>2016-04-05 18:37:17 +0300
commit9d52efd6538cc3be684329888a9490c3428f653e (patch)
tree3392a07bbefb1d4dd9a47e93057653d00b03b4a5
parent7c8eb0712e16dc63a60c43de8125715de3588cba (diff)
[tests] Set “Clear” style default for all unit tests.
-rw-r--r--generator/generator_tests/feature_builder_test.cpp36
-rw-r--r--generator/generator_tests/osm_type_test.cpp8
-rw-r--r--indexer/classificator_loader.cpp18
-rw-r--r--indexer/indexer_tests/visibility_test.cpp44
-rw-r--r--indexer/map_style.cpp2
-rw-r--r--indexer/map_style.hpp2
-rw-r--r--indexer/map_style_reader.cpp2
-rw-r--r--map/framework.cpp4
-rw-r--r--map/style_tests/classificator_tests.cpp39
-rw-r--r--map/style_tests/dashes_test.cpp13
-rw-r--r--map/style_tests/helpers.cpp31
-rw-r--r--map/style_tests/helpers.hpp10
-rw-r--r--map/style_tests/style_symbols_consistency_test.cpp20
-rw-r--r--map/style_tests/style_tests.pro4
14 files changed, 124 insertions, 109 deletions
diff --git a/generator/generator_tests/feature_builder_test.cpp b/generator/generator_tests/feature_builder_test.cpp
index c53fcbaa4b..ee7e4a029e 100644
--- a/generator/generator_tests/feature_builder_test.cpp
+++ b/generator/generator_tests/feature_builder_test.cpp
@@ -26,7 +26,8 @@ UNIT_TEST(FBuilder_ManyTypes)
char const * arr2[][2] = {
{ "place", "country" },
{ "place", "state" },
- { "place", "county" },
+ /// @todo Can't realize is it deprecated or we forgot to add clear styles for it.
+ //{ "place", "county" },
{ "place", "region" },
{ "place", "city" },
{ "place", "town" },
@@ -53,7 +54,7 @@ UNIT_TEST(FBuilder_ManyTypes)
TEST(fb2.CheckValid(), ());
TEST_EQUAL(fb1, fb2, ());
- TEST_EQUAL(fb2.GetTypesCount(), 7, ());
+ TEST_EQUAL(fb2.GetTypesCount(), 6, ());
}
UNIT_TEST(FBuilder_LineTypes)
@@ -91,6 +92,35 @@ UNIT_TEST(FBuilder_LineTypes)
TEST_EQUAL(fb2.GetTypesCount(), 4, ());
}
+UNIT_TEST(FBuilder_Waterfall)
+{
+ classificator::Load();
+
+ FeatureBuilder1 fb1;
+ FeatureParams params;
+
+ char const * arr[][2] = {{"waterway", "waterfall"}};
+ AddTypes(params, arr);
+ TEST(params.FinishAddingTypes(), ());
+
+ fb1.SetParams(params);
+ fb1.SetCenter(m2::PointD(1, 1));
+
+ TEST(fb1.RemoveInvalidTypes(), ());
+ TEST(fb1.CheckValid(), ());
+
+ FeatureBuilder1::TBuffer buffer;
+ TEST(fb1.PreSerialize(), ());
+ fb1.Serialize(buffer);
+
+ FeatureBuilder1 fb2;
+ fb2.Deserialize(buffer);
+
+ TEST(fb2.CheckValid(), ());
+ TEST_EQUAL(fb1, fb2, ());
+ TEST_EQUAL(fb2.GetTypesCount(), 1, ());
+}
+
UNIT_TEST(FVisibility_RemoveNoDrawableTypes)
{
classificator::Load();
@@ -107,7 +137,7 @@ UNIT_TEST(FVisibility_RemoveNoDrawableTypes)
{
vector<uint32_t> types;
- types.push_back(c.GetTypeByPath({ "amenity" }));
+ types.push_back(c.GetTypeByPath({ "highway", "primary" }));
types.push_back(c.GetTypeByPath({ "building" }));
TEST(feature::RemoveNoDrawableTypes(types, feature::GEOM_AREA, true), ());
diff --git a/generator/generator_tests/osm_type_test.cpp b/generator/generator_tests/osm_type_test.cpp
index 3383675c74..cd7fcf3bd3 100644
--- a/generator/generator_tests/osm_type_test.cpp
+++ b/generator/generator_tests/osm_type_test.cpp
@@ -328,7 +328,7 @@ UNIT_TEST(OsmType_Capital)
{
char const * arr[][2] = {
{ "place", "city" },
- { "admin_level", "6" },
+ { "admin_level", "4" },
{ "boundary", "administrative" },
{ "capital", "2" },
{ "place", "city" },
@@ -342,7 +342,7 @@ UNIT_TEST(OsmType_Capital)
TEST_EQUAL(params.m_Types.size(), 2, (params));
TEST(params.IsTypeExist(GetType({"place", "city", "capital", "2"})), ());
- TEST(params.IsTypeExist(GetType({"boundary", "administrative", "6"})), ());
+ TEST(params.IsTypeExist(GetType({"boundary", "administrative", "4"})), ());
}
}
@@ -571,7 +571,7 @@ UNIT_TEST(OsmType_Ferry)
UNIT_TEST(OsmType_Boundary)
{
char const * arr[][2] = {
- { "admin_level", "6" },
+ { "admin_level", "4" },
{ "boundary", "administrative" },
{ "admin_level", "2" },
{ "boundary", "administrative" },
@@ -585,7 +585,7 @@ UNIT_TEST(OsmType_Boundary)
TEST_EQUAL(params.m_Types.size(), 2, (params));
TEST(params.IsTypeExist(GetType({"boundary", "administrative", "2"})), ());
- TEST(params.IsTypeExist(GetType({"boundary", "administrative", "6"})), ());
+ TEST(params.IsTypeExist(GetType({"boundary", "administrative", "4"})), ());
}
UNIT_TEST(OsmType_Dibrugarh)
diff --git a/indexer/classificator_loader.cpp b/indexer/classificator_loader.cpp
index 54acb5930d..242a299bdb 100644
--- a/indexer/classificator_loader.cpp
+++ b/indexer/classificator_loader.cpp
@@ -46,23 +46,9 @@ namespace classificator
Platform & p = GetPlatform();
- MapStyle const originMapStyle = GetStyleReader().GetCurrentStyle();
+ ReadCommon(p.GetReader("classificator.txt"), p.GetReader("types.txt"));
- for (size_t i = 0; i < MapStyleCount; ++i)
- {
- MapStyle const mapStyle = static_cast<MapStyle>(i);
- // Read the merged style only if it was requested.
- if (mapStyle != MapStyleMerged || originMapStyle == MapStyleMerged)
- {
- GetStyleReader().SetCurrentStyle(mapStyle);
- ReadCommon(p.GetReader("classificator.txt"),
- p.GetReader("types.txt"));
-
- drule::LoadRules();
- }
- }
-
- GetStyleReader().SetCurrentStyle(originMapStyle);
+ drule::LoadRules();
LOG(LDEBUG, ("Reading of classificator finished"));
}
diff --git a/indexer/indexer_tests/visibility_test.cpp b/indexer/indexer_tests/visibility_test.cpp
index d3a4b34fd5..4329341696 100644
--- a/indexer/indexer_tests/visibility_test.cpp
+++ b/indexer/indexer_tests/visibility_test.cpp
@@ -9,42 +9,32 @@
#include "base/logging.hpp"
-UNIT_TEST(VisibleScales_Smoke)
-{
- classificator::Load();
-
- {
- char const * arr[] = { "place", "city", "capital" };
- uint32_t const type = classif().GetTypeByPath(vector<string>(arr, arr + 3));
-
- pair<int, int> const r = feature::GetDrawableScaleRange(type);
- TEST_NOT_EQUAL(r.first, -1, ());
- TEST_LESS_OR_EQUAL(r.first, r.second, ());
-
- TEST(my::between_s(r.first, r.second, 10), (r));
- TEST(!my::between_s(r.first, r.second, 1), (r));
- TEST(!my::between_s(r.first, r.second, scales::GetUpperScale()), (r));
- }
-}
-
namespace
{
class DoGetMaxLowMinHighZoom
{
+ Classificator const & m_classif;
pair<int, int> m_res;
string m_low;
set<uint32_t> m_skip;
+ bool IsSkip(uint32_t t) const
+ {
+ ftype::TruncValue(t, 2);
+ return m_skip.count(t) > 0;
+ }
public:
- DoGetMaxLowMinHighZoom(Classificator const & c) : m_res(-1, 1000)
+ DoGetMaxLowMinHighZoom(Classificator const & c)
+ : m_classif(classif()), m_res(-1, 1000)
{
char const * arr[][2] = {
- { "highway", "proposed" },
- { "highway", "bus_stop" },
- { "highway", "world_level" },
- { "highway", "world_towns_level" }
+ {"highway", "bus_stop"},
+ {"highway", "speed_camera"},
+ {"highway", "platform"},
+ {"highway", "world_level"},
+ {"highway", "world_towns_level"},
};
for (size_t i = 0; i < ARRAY_SIZE(arr); ++i)
@@ -53,11 +43,15 @@ public:
void operator() (ClassifObject const * p, uint32_t type)
{
- if (m_skip.count(type) > 0)
+ if (IsSkip(type))
return;
pair<int, int> const r = feature::GetDrawableScaleRange(type);
- ASSERT(r.first != -1 && r.second != -1, (r));
+ if (r.first == -1 || r.second == -1)
+ {
+ LOG(LINFO, (r, m_classif.GetFullObjectName(type)));
+ return;
+ }
if (m_res.first < r.first)
{
diff --git a/indexer/map_style.cpp b/indexer/map_style.cpp
index 05cd3ef5a3..d2750590ea 100644
--- a/indexer/map_style.cpp
+++ b/indexer/map_style.cpp
@@ -2,6 +2,8 @@
#include "base/assert.hpp"
+MapStyle kDefaultMapStyle = MapStyleClear;
+
string DebugPrint(MapStyle mapStyle)
{
switch (mapStyle)
diff --git a/indexer/map_style.hpp b/indexer/map_style.hpp
index 092776b928..1718916172 100644
--- a/indexer/map_style.hpp
+++ b/indexer/map_style.hpp
@@ -14,4 +14,6 @@ enum MapStyle
MapStyleCount
};
+extern MapStyle kDefaultMapStyle;
+
string DebugPrint(MapStyle mapStyle);
diff --git a/indexer/map_style_reader.cpp b/indexer/map_style_reader.cpp
index 804763f1d1..a84fd5bbca 100644
--- a/indexer/map_style_reader.cpp
+++ b/indexer/map_style_reader.cpp
@@ -38,7 +38,7 @@ string GetStyleSuffix(MapStyle mapStyle)
} // namespace
StyleReader::StyleReader()
- : m_mapStyle(MapStyleLight)
+ : m_mapStyle(kDefaultMapStyle)
{
}
diff --git a/map/framework.cpp b/map/framework.cpp
index 86d1f48f83..642c43f5fa 100644
--- a/map/framework.cpp
+++ b/map/framework.cpp
@@ -291,9 +291,9 @@ Framework::Framework()
, m_lastReportedCountry(kInvalidCountryId)
{
// Restore map style before classificator loading
- int mapStyle = MapStyleLight;
+ int mapStyle;
if (!settings::Get(kMapStyleKey, mapStyle))
- mapStyle = MapStyleClear;
+ mapStyle = kDefaultMapStyle;
GetStyleReader().SetCurrentStyle(static_cast<MapStyle>(mapStyle));
m_connectToGpsTrack = GpsTracker::Instance().IsEnabled();
diff --git a/map/style_tests/classificator_tests.cpp b/map/style_tests/classificator_tests.cpp
index 09a5be1ffa..d9d06c4d18 100644
--- a/map/style_tests/classificator_tests.cpp
+++ b/map/style_tests/classificator_tests.cpp
@@ -1,10 +1,10 @@
#include "testing/testing.hpp"
+#include "helpers.hpp"
#include "indexer/classificator.hpp"
#include "indexer/classificator_loader.hpp"
#include "indexer/feature_visibility.hpp"
#include "indexer/feature_data.hpp"
-#include "indexer/map_style_reader.hpp"
#include "base/logging.hpp"
@@ -22,41 +22,12 @@ namespace
TEST(false, ("Inconsistency type", type, m_c.GetFullObjectName(type)));
}
};
-
- // Some tests require MapStyleLight (legacy) set as default.
- // But unfortunately current map style is stored as global variable.
- // Therefore, to reset current map style to the MapStyleLight, this RAII is used.
- class ResetMapStyleRAII
- {
- public:
- ResetMapStyleRAII() = default;
- ~ResetMapStyleRAII()
- {
- GetStyleReader().SetCurrentStyle(MapStyleLight);
- }
- };
-
- void RunForEveryMapStyle(std::function<void()> const & fn)
- {
- ResetMapStyleRAII resetMapStype;
- for (size_t s = 0; s < MapStyleCount; ++s)
- {
- MapStyle const mapStyle = static_cast<MapStyle>(s);
- if (mapStyle != MapStyle::MapStyleMerged)
- {
- GetStyleReader().SetCurrentStyle(mapStyle);
- LOG(LINFO, ("Test with map style", mapStyle));
- fn();
- }
- }
- }
} // namespace
UNIT_TEST(Classificator_CheckConsistency)
{
- RunForEveryMapStyle([]()
+ styles::RunForEveryMapStyle([](MapStyle)
{
- classificator::Load();
Classificator const & c = classif();
DoCheckConsistency doCheck(c);
@@ -130,9 +101,8 @@ void CheckLineStyles(Classificator const & c, string const & name)
UNIT_TEST(Classificator_DrawingRules)
{
- RunForEveryMapStyle([]()
+ styles::RunForEveryMapStyle([](MapStyle)
{
- classificator::Load();
Classificator const & c = classif();
LOG(LINFO, ("--------------- Point styles ---------------"));
@@ -192,9 +162,8 @@ pair<int, int> GetMinMax(int level, vector<uint32_t> const & types)
UNIT_TEST(Classificator_AreaPriority)
{
- RunForEveryMapStyle([]()
+ styles::RunForEveryMapStyle([](MapStyle)
{
- classificator::Load();
Classificator const & c = classif();
vector<vector<uint32_t> > types;
diff --git a/map/style_tests/dashes_test.cpp b/map/style_tests/dashes_test.cpp
index ffa6c999f0..045faf958d 100644
--- a/map/style_tests/dashes_test.cpp
+++ b/map/style_tests/dashes_test.cpp
@@ -1,9 +1,9 @@
#include "testing/testing.hpp"
+#include "helpers.hpp"
#include "indexer/classificator_loader.hpp"
#include "indexer/drawing_rules.hpp"
#include "indexer/drules_struct.pb.h"
-#include "indexer/map_style_reader.hpp"
namespace
{
@@ -16,15 +16,8 @@ double constexpr kMaxDashLength = 128 / kMaxVisualScale;
UNIT_TEST(Test_Dashes)
{
- for (size_t s = 0; s < MapStyleCount; ++s)
+ styles::RunForEveryMapStyle([](MapStyle)
{
- MapStyle const mapStyle = static_cast<MapStyle>(s);
- if (mapStyle == MapStyleMerged)
- continue;
-
- GetStyleReader().SetCurrentStyle(mapStyle);
- classificator::Load();
-
drule::rules().ForEachRule([](int, int, int, drule::BaseRule const * rule)
{
LineDefProto const * const line = rule->GetLine();
@@ -41,5 +34,5 @@ UNIT_TEST(Test_Dashes)
TEST_LESS_OR_EQUAL(value, kMaxDashLength, ());
}
});
- }
+ });
}
diff --git a/map/style_tests/helpers.cpp b/map/style_tests/helpers.cpp
new file mode 100644
index 0000000000..7aa3e2c8f8
--- /dev/null
+++ b/map/style_tests/helpers.cpp
@@ -0,0 +1,31 @@
+#include "helpers.hpp"
+
+#include "indexer/classificator_loader.hpp"
+#include "indexer/map_style_reader.hpp"
+
+#include "base/logging.hpp"
+
+namespace styles
+{
+
+void RunForEveryMapStyle(function<void(MapStyle)> const & fn)
+{
+ auto & reader = GetStyleReader();
+ for (size_t s = 0; s < MapStyleCount; ++s)
+ {
+ MapStyle const mapStyle = static_cast<MapStyle>(s);
+ if (mapStyle != MapStyle::MapStyleMerged)
+ {
+ reader.SetCurrentStyle(mapStyle);
+ classificator::Load();
+ LOG(LINFO, ("Test with map style", mapStyle));
+ fn(mapStyle);
+ }
+ }
+
+ // Restore default style.
+ reader.SetCurrentStyle(kDefaultMapStyle);
+ classificator::Load();
+}
+
+} // namesapce styles
diff --git a/map/style_tests/helpers.hpp b/map/style_tests/helpers.hpp
new file mode 100644
index 0000000000..e0a4847266
--- /dev/null
+++ b/map/style_tests/helpers.hpp
@@ -0,0 +1,10 @@
+#pragma once
+
+#include "indexer/map_style.hpp"
+
+#include "std/function.hpp"
+
+namespace styles
+{
+void RunForEveryMapStyle(function<void(MapStyle)> const & fn);
+} // namespace styles
diff --git a/map/style_tests/style_symbols_consistency_test.cpp b/map/style_tests/style_symbols_consistency_test.cpp
index aa278e0ff4..4324453d14 100644
--- a/map/style_tests/style_symbols_consistency_test.cpp
+++ b/map/style_tests/style_symbols_consistency_test.cpp
@@ -1,4 +1,5 @@
#include "testing/testing.hpp"
+#include "helpers.hpp"
#include "indexer/classificator_loader.hpp"
#include "indexer/drawing_rules.hpp"
@@ -68,22 +69,15 @@ UNIT_TEST(Test_SymbolsConsistency)
bool res = true;
- vector<string> densities = { "ldpi", "mdpi", "hdpi", "xhdpi", "xxhdpi", "6plus" };
+ string densities[] = { "ldpi", "mdpi", "hdpi", "xhdpi", "xxhdpi", "6plus" };
- for (size_t s = 0; s < MapStyleCount; ++s)
+ styles::RunForEveryMapStyle([&](MapStyle mapStyle)
{
- MapStyle const mapStyle = static_cast<MapStyle>(s);
- if (mapStyle == MapStyleMerged)
- continue;
-
- GetStyleReader().SetCurrentStyle(mapStyle);
- classificator::Load();
-
set<string> const drawingRuleSymbols = GetSymbolsSetFromDrawingRule();
- for (size_t d = 0; d < densities.size(); ++d)
+ for (string dencity : densities)
{
- set<string> const resourceStyles = GetSymbolsSetFromResourcesFile(densities[d]);
+ set<string> const resourceStyles = GetSymbolsSetFromResourcesFile(dencity);
vector<string> missed;
set_difference(drawingRuleSymbols.begin(), drawingRuleSymbols.end(),
@@ -94,11 +88,11 @@ UNIT_TEST(Test_SymbolsConsistency)
{
// We are interested in all set of bugs, therefore we do not stop test here but
// continue it just keeping in res that test failed.
- LOG(LINFO, ("Symbols mismatch: style", mapStyle, ", density", densities[d], ", missed", missed));
+ LOG(LINFO, ("Symbols mismatch: style", mapStyle, ", density", dencity, ", missed", missed));
res = false;
}
}
- }
+ });
TEST(res, ());
}
diff --git a/map/style_tests/style_tests.pro b/map/style_tests/style_tests.pro
index 4d77813816..f1dbbc5a7a 100644
--- a/map/style_tests/style_tests.pro
+++ b/map/style_tests/style_tests.pro
@@ -19,3 +19,7 @@ SOURCES += \
classificator_tests.cpp \
dashes_test.cpp \
style_symbols_consistency_test.cpp \
+ helpers.cpp \
+
+HEADERS += \
+ helpers.hpp \