Fix ellipsization unit test when using pixel scaling

When pixel doubling is in use, e.g. when using GTK+ 2 on high DPI displays,
the width of a single TAB can be greater than the hardcoded 50 width in the
test, which resulted in test failures.

Base the widths on the average character width to make sure we can always
ellipsize.
This commit is contained in:
Vadim Zeitlin
2016-02-26 15:09:39 +01:00
parent b58c87db28
commit fde8f93a49

View File

@@ -86,7 +86,8 @@ void EllipsizationTestCase::NormalCase()
wxELLIPSIZE_END wxELLIPSIZE_END
}; };
int widthsToTest[] = { 50, 100, 150 }; const int charWidth = dc.GetCharWidth();
int widthsToTest[] = { 6*charWidth, 10*charWidth, 15*charWidth };
for ( unsigned int s = 0; s < WXSIZEOF(stringsToTest); s++ ) for ( unsigned int s = 0; s < WXSIZEOF(stringsToTest); s++ )
{ {
@@ -110,8 +111,10 @@ void EllipsizationTestCase::NormalCase()
WX_ASSERT_MESSAGE WX_ASSERT_MESSAGE
( (
( (
"invalid ellipsization for \"%s\" (%dpx, should be <=%dpx)", "Test #(%u,%u.%u): \"%s\" -> \"%s\"; width=%dpx > %dpx",
s, f, m,
str, str,
ret,
dc.GetMultiLineTextExtent(ret).GetWidth(), dc.GetMultiLineTextExtent(ret).GetWidth(),
widthsToTest[w] widthsToTest[w]
), ),