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

skin_tests.cpp « drape_gui_tests « drape_gui - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: c330b4cb5c821f9fc299ffd7978c4775e7e7a4ab (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
#include "base/SRC_FIRST.hpp"
#include "testing/testing.hpp"

#include "drape_gui/skin.hpp"
#include "drape_gui/drape_gui.hpp"

UNIT_TEST(ParseDefaultSkinTest)
{
  gui::DrapeGui::Instance().Init([]{ return 2.0; }, [] (ScreenBase const &) { return 6.0f; });
  gui::Skin skin(gui::ResolveGuiSkinFile("default"));
  float width = 600.0f;
  float height = 800.0f;
  skin.Resize(width, height);

  gui::Position compassPos = skin.ResolvePosition(gui::Skin::ElementName::Compass);
  TEST_EQUAL(compassPos.m_anchor, dp::Center, ());
  TEST_ALMOST_EQUAL(compassPos.m_pixelPivot.x, 27.0f * 2.0f, ());
  TEST_ALMOST_EQUAL(compassPos.m_pixelPivot.y, height - 57.0f * 2.0f, ());

  gui::Position rulerPos = skin.ResolvePosition(gui::Skin::ElementName::Ruler);
  TEST_EQUAL(rulerPos.m_anchor, dp::Right, ());
  TEST_ALMOST_EQUAL(rulerPos.m_pixelPivot.x, width - 6.0f * 2.0f, ());
  TEST_ALMOST_EQUAL(rulerPos.m_pixelPivot.y, height - 42.0f * 2.0f, ());

  gui::Position copyRightPos = skin.ResolvePosition(gui::Skin::ElementName::Copyright);
  TEST_EQUAL(copyRightPos.m_anchor, dp::Right, ());
  TEST_ALMOST_EQUAL(copyRightPos.m_pixelPivot.x, width - 6.0f * 2.0f, ());
  TEST_ALMOST_EQUAL(copyRightPos.m_pixelPivot.y, height - 42.0f * 2.0f, ());

  gui::Position countryStatusPos = skin.ResolvePosition(gui::Skin::ElementName::CountryStatus);
  TEST_EQUAL(countryStatusPos.m_anchor, dp::Center, ());
  TEST_ALMOST_EQUAL(countryStatusPos.m_pixelPivot.x, width / 2.0f, ());
  TEST_ALMOST_EQUAL(countryStatusPos.m_pixelPivot.y, height / 2.0f, ());

  {
    width = 800.0f;
    height = 600.0f;
    skin.Resize(width, height);

    gui::Position compassPos = skin.ResolvePosition(gui::Skin::ElementName::Compass);
    TEST_EQUAL(compassPos.m_anchor, dp::Center, ());
    TEST_ALMOST_EQUAL(compassPos.m_pixelPivot.x, 18.0f * 2.0f, ());
    TEST_ALMOST_EQUAL(compassPos.m_pixelPivot.y, height - 11.4f * 2.0f, ());

    gui::Position rulerPos = skin.ResolvePosition(gui::Skin::ElementName::Ruler);
    TEST_EQUAL(rulerPos.m_anchor, dp::Right, ());
    TEST_ALMOST_EQUAL(rulerPos.m_pixelPivot.x, width - 70.4f * 2.0f, ());
    TEST_ALMOST_EQUAL(rulerPos.m_pixelPivot.y, height - 10.5f * 2.0f, ());

    gui::Position copyRightPos = skin.ResolvePosition(gui::Skin::ElementName::Copyright);
    TEST_EQUAL(copyRightPos.m_anchor, dp::Right, ());
    TEST_ALMOST_EQUAL(copyRightPos.m_pixelPivot.x, width - 70.4f * 2.0f, ());
    TEST_ALMOST_EQUAL(copyRightPos.m_pixelPivot.y, height - 10.5f * 2.0f, ());

    gui::Position countryStatusPos = skin.ResolvePosition(gui::Skin::ElementName::CountryStatus);
    TEST_EQUAL(countryStatusPos.m_anchor, dp::Center, ());
    TEST_ALMOST_EQUAL(countryStatusPos.m_pixelPivot.x, width / 2.0f, ());
    TEST_ALMOST_EQUAL(countryStatusPos.m_pixelPivot.y, height / 2.0f, ());
  }
}