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

editor_config_test.cpp « editor_tests « editor - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 329ea1488fc96ee82f42dfe61cb44a56d648b120 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include "testing/testing.hpp"

#include "editor/editor_config.hpp"

#include "base/stl_helpers.hpp"

#include "std/set.hpp"

using namespace editor;

UNIT_TEST(EditorConfig_TypeDescription)
{
  using EType = feature::Metadata::EType;
  using TFields = editor::TypeAggregatedDescription::TFeatureFields;

  TFields const poi = {
    feature::Metadata::FMD_OPEN_HOURS,
    feature::Metadata::FMD_PHONE_NUMBER,
    feature::Metadata::FMD_WEBSITE,
    feature::Metadata::FMD_EMAIL
  };

  EditorConfig config;

  {
    editor::TypeAggregatedDescription desc;
    TEST(!config.GetTypeDescription({"death-star"}, desc), ());
  }
  {
    editor::TypeAggregatedDescription desc;
    TEST(config.GetTypeDescription({"amenity-hunting_stand"}, desc), ());
    TEST(desc.IsNameEditable(), ());
    TEST(!desc.IsAddressEditable(), ());
    TEST_EQUAL(desc.GetEditableFields(), TFields {EType::FMD_HEIGHT}, ());
  }
  {
    editor::TypeAggregatedDescription desc;
    TEST(config.GetTypeDescription({"shop-toys"}, desc), ());
    TEST(desc.IsNameEditable(), ());
    TEST(desc.IsAddressEditable(), ());
    auto fields = poi;
    fields.push_back(EType::FMD_INTERNET);
    my::SortUnique(fields);
    TEST_EQUAL(desc.GetEditableFields(), fields, ());
  }
  {
    // Select amenity-bank because it goes first in config.
    editor::TypeAggregatedDescription desc;
    TEST(config.GetTypeDescription({"amenity-bar", "amenity-bank"}, desc), ());
    TEST(desc.IsNameEditable(), ());
    TEST(desc.IsAddressEditable(), ());
    auto fields = poi;
    fields.push_back(EType::FMD_OPERATOR);
    my::SortUnique(fields);
    TEST_EQUAL(desc.GetEditableFields(), fields, ());
  }
  // TODO(mgsergio): Test case with priority="high" when there is one on editor.config.
}

UNIT_TEST(EditorConfig_GetTypesThatGenBeAdded)
{
  EditorConfig config;

  auto const types = config.GetTypesThatCanBeAdded();
  TEST(find(begin(types), end(types), "amenity-cafe") != end(types), ());
  TEST(find(begin(types), end(types), "natural-peak") == end(types), ());
  // Marked as "editable=no".
  TEST(find(begin(types), end(types), "aeroway-airport") == end(types), ());
}