From fde8f93a4982ece4015627d677011e54f8ee8d24 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 26 Feb 2016 15:09:39 +0100 Subject: [PATCH] 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. --- tests/graphics/ellipsization.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/graphics/ellipsization.cpp b/tests/graphics/ellipsization.cpp index 1b6a20cb04..2a584762f2 100644 --- a/tests/graphics/ellipsization.cpp +++ b/tests/graphics/ellipsization.cpp @@ -86,7 +86,8 @@ void EllipsizationTestCase::NormalCase() 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++ ) { @@ -110,8 +111,10 @@ void EllipsizationTestCase::NormalCase() WX_ASSERT_MESSAGE ( ( - "invalid ellipsization for \"%s\" (%dpx, should be <=%dpx)", + "Test #(%u,%u.%u): \"%s\" -> \"%s\"; width=%dpx > %dpx", + s, f, m, str, + ret, dc.GetMultiLineTextExtent(ret).GetWidth(), widthsToTest[w] ),