~ci-train-bot/unity/unity-ubuntu-disco-3336

« back to all changes in this revision

Viewing changes to tests/test_em_converter.cpp

UnitySettings: use the ubuntu-schemas path for scaling settings

Also remove unused parts of EMConverter (LP: #1721082)

Approved by: Andrea Azzarone

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
{
27
27
 
28
28
int const PIXEL_SIZE = 24;
29
 
int const FONT_SIZE  = 13;
30
29
double const DPI     = 96.0;
31
30
 
32
31
class TestEMConverter : public Test
33
32
{
34
33
public:
35
34
  TestEMConverter()
36
 
    : em_converter(FONT_SIZE, DPI)
 
35
    : em_converter(DPI)
37
36
  {
38
37
  }
39
38
 
40
39
  EMConverter em_converter;
41
40
};
42
41
 
43
 
TEST_F(TestEMConverter, TestCtor)
44
 
{
45
 
  EXPECT_EQ(FONT_SIZE, em_converter.GetFontSize());
46
 
  EXPECT_EQ(DPI, em_converter.GetDPI());
47
 
}
48
 
 
49
 
TEST_F(TestEMConverter, TestSetFontSize)
50
 
{
51
 
  int const font_size = 15;
52
 
 
53
 
  em_converter.SetFontSize(font_size);
54
 
  EXPECT_EQ(font_size, em_converter.GetFontSize());
55
 
}
56
 
 
57
42
TEST_F(TestEMConverter, TestSetDPI)
58
43
{
59
44
  int const dpi = 120.0;
79
64
  EXPECT_FLOAT_EQ(em_converter.DPIScale(), 2.0);
80
65
}
81
66
 
82
 
TEST_F(TestEMConverter, TestPtToPx)
 
67
TEST_F(TestEMConverter, TestConvertPixelScaled)
83
68
{
84
 
  int pt = 12;
85
 
  EXPECT_EQ(em_converter.PtToPx(pt), 16);
 
69
  for (double scale : std::vector<double>({1.0, 1.25, 1.5, 1.75, 2}))
 
70
  {
 
71
    em_converter.SetDPI(DPI * scale);
 
72
    EXPECT_EQ(std::round(PIXEL_SIZE * scale), em_converter.CP(PIXEL_SIZE));
 
73
  }
86
74
}
87
75
 
88
76
} // namespace unity