mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-10 22:24:13 +02:00
Fix tst_genericdevice failing on machines without Liberation Sans
edgeCases() expected an empty device to be exactly MinHeight (30) tall. The sizing rule is max(MinHeight, 2 x label height) rounded up to the grid, so with a taller fallback font the body is 40 and the test fails. The Linux CI image has no Liberation Sans; fontconfig substitutes Nimbus Sans (fonts-urw-base35), whose line height gives 40. Compute the expected height from the label font's metrics, as the layout does. Reproduced locally with a fontconfig file listing only the urw-base35 fonts: the old test fails with the CI's exact message (40 vs 30), the new one passes. Doubling the label factor to 3 in genericdevice.cpp still makes the new check fail, with Liberation and with Nimbus. Reported by bhangart on #1418. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
#include <QFontMetricsF>
|
||||
#include <QtTest>
|
||||
|
||||
#include "genericdevice/genericdevice.h"
|
||||
@@ -353,7 +354,11 @@ private slots:
|
||||
//No terminals: the minimum, or as wide as the label needs
|
||||
QVERIFY(l.body_width >= MinWidth);
|
||||
QCOMPARE(l.body_width % Grid, 0);
|
||||
QCOMPARE(l.body_height, MinHeight);
|
||||
//The label sets the floor when its font is taller than
|
||||
//MinHeight allows, which depends on the fonts installed
|
||||
const int label_h = int(qCeil(QFontMetricsF(fonts().label).height()));
|
||||
const int floor_h = std::max(MinHeight, 2 * label_h);
|
||||
QCOMPARE(l.body_height, (floor_h + Grid - 1) / Grid * Grid);
|
||||
QVERIFY(l.terminals.isEmpty());
|
||||
|
||||
Spec one;
|
||||
|
||||
Reference in New Issue
Block a user