From 545f584efc23ba8a54b88a023ee9690281e5506a Mon Sep 17 00:00:00 2001 From: Constantin Shalnev Date: Thu, 15 Oct 2015 17:11:10 +0300 Subject: [PATCH] Uses limitation values for EDensity and for MapStyle enums --- graphics/defines.hpp | 8 +++-- indexer/map_style.cpp | 12 +++++-- indexer/map_style.hpp | 7 ++-- indexer/map_style_reader.cpp | 3 ++ .../style_symbols_consistency_test.cpp | 33 +++++++------------ map/style_tests/style_tests.pro | 2 +- 6 files changed, 36 insertions(+), 29 deletions(-) diff --git a/graphics/defines.hpp b/graphics/defines.hpp index 96019e1910..dec26746de 100644 --- a/graphics/defines.hpp +++ b/graphics/defines.hpp @@ -9,12 +9,16 @@ namespace graphics enum EDensity { - EDensityLDPI = 0, + EDensityLDPI = 0, //< The first must be 0 EDensityMDPI, EDensityHDPI, EDensityXHDPI, EDensityXXHDPI, - EDensityIPhone6Plus + EDensityIPhone6Plus, + // Add new density here + + // Specifies number of EDensity enum values, must be last + EDensityCount }; /// get density name diff --git a/indexer/map_style.cpp b/indexer/map_style.cpp index d543e9753c..ab6bd66525 100644 --- a/indexer/map_style.cpp +++ b/indexer/map_style.cpp @@ -6,9 +6,15 @@ string DebugPrint(MapStyle mapStyle) { switch (mapStyle) { - case MapStyleLight: return "MapStyleLight"; - case MapStyleDark: return "MapStyleDark"; - case MapStyleClear: return "MapStyleClear"; + case MapStyleLight: + return "MapStyleLight"; + case MapStyleDark: + return "MapStyleDark"; + case MapStyleClear: + return "MapStyleClear"; + + case MapStyleCount: + break; } ASSERT(false, ()); return string(); diff --git a/indexer/map_style.hpp b/indexer/map_style.hpp index 98d224b05c..750a0362df 100644 --- a/indexer/map_style.hpp +++ b/indexer/map_style.hpp @@ -4,10 +4,13 @@ enum MapStyle { - MapStyleLight = 0, + MapStyleLight = 0, //< The first must be 0 MapStyleDark = 1, - MapStyleClear = 2 + MapStyleClear = 2, // Add new map style here + + // Specifies number of MapStyle enum values, must be last + MapStyleCount }; string DebugPrint(MapStyle mapStyle); diff --git a/indexer/map_style_reader.cpp b/indexer/map_style_reader.cpp index db88c4b6be..f0e0051087 100644 --- a/indexer/map_style_reader.cpp +++ b/indexer/map_style_reader.cpp @@ -28,6 +28,9 @@ string GetStyleSuffix(MapStyle mapStyle) return kSuffixLegacyDark; case MapStyleClear: return kSuffixModernClear; + + case MapStyleCount: + break; } LOG(LWARNING, ("Unknown map style", mapStyle)); return kSuffixModernClear; diff --git a/map/style_tests/style_symbols_consistency_test.cpp b/map/style_tests/style_symbols_consistency_test.cpp index 1862943395..679649bdbc 100644 --- a/map/style_tests/style_symbols_consistency_test.cpp +++ b/map/style_tests/style_symbols_consistency_test.cpp @@ -5,6 +5,8 @@ #include "indexer/drules_include.hpp" #include "indexer/map_style_reader.hpp" +#include "graphics/defines.hpp" + #include "coding/reader.hpp" #include "coding/parse_xml.hpp" @@ -68,38 +70,27 @@ unordered_set Subtract(unordered_set const & s1, unordered_set g_styles = -{{ - MapStyleLight, - MapStyleDark, - MapStyleClear -}}; - -array g_densities = -{{ - "ldpi", - "mdpi", - "hdpi", - "xhdpi", - "xxhdpi", - "6plus" -}}; - } // namespace UNIT_TEST(Test_SymbolsConsistency) { + // Tests that all symbols specified in drawing rules have corresponding symbols in resources + bool res = true; - for (auto const style : g_styles) + for (size_t s = 0; s < MapStyleCount; ++s) { - GetStyleReader().SetCurrentStyle(style); + MapStyle const mapStyle = static_cast(s); + + GetStyleReader().SetCurrentStyle(mapStyle); classificator::Load(); unordered_set const drawingRuleSymbols = GetSymbolsSetFromDrawingRule(); - for (auto const & density : g_densities) + for (size_t d = 0; d < graphics::EDensityCount; ++d) { + string const density = graphics::convert(static_cast(d)); + unordered_set const resourceStyles = GetSymbolsSetFromResourcesFile(density); unordered_set const s = Subtract(drawingRuleSymbols, resourceStyles); @@ -110,7 +101,7 @@ UNIT_TEST(Test_SymbolsConsistency) { // We are interested in all set of bugs, therefore we do not stop test here but // continue it just keep in res that test failed. - LOG(LINFO, ("Symbols mismatch: style", style, ", density", density, ", missed", missed)); + LOG(LINFO, ("Symbols mismatch: style", mapStyle, ", density", density, ", missed", missed)); res = false; } } diff --git a/map/style_tests/style_tests.pro b/map/style_tests/style_tests.pro index 25763f9b5b..4199a4376d 100644 --- a/map/style_tests/style_tests.pro +++ b/map/style_tests/style_tests.pro @@ -6,7 +6,7 @@ TEMPLATE = app INCLUDEPATH += ../../3party/protobuf/src ROOT_DIR = ../.. -DEPENDENCIES = map indexer platform geometry coding base expat protobuf +DEPENDENCIES = map indexer graphics platform geometry coding base expat protobuf macx-*: LIBS *= "-framework IOKit"