Tests: build without -Wextra warnings
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -10,7 +10,7 @@ using namespace Qt::StringLiterals;
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
const TextContext Field{.field = true};
|
const TextContext Field{.field = true, .hasSurroundingText = false, .textBeforeCursor = {}}; // reports no text
|
||||||
// A field with some text already: no auto-shift until a test asks for it.
|
// A field with some text already: no auto-shift until a test asks for it.
|
||||||
const TextContext MidSentence{.field = true, .hasSurroundingText = true, .textBeforeCursor = u"so"_s};
|
const TextContext MidSentence{.field = true, .hasSurroundingText = true, .textBeforeCursor = u"so"_s};
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,14 @@ KeyDef key(qreal width = 1.0, KeyType type = KeyType::Character)
|
|||||||
return k;
|
return k;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Layer layerOf(const QList<Row> &rows)
|
||||||
|
{
|
||||||
|
Layer layer;
|
||||||
|
layer.name = u"l"_s;
|
||||||
|
layer.rows = rows;
|
||||||
|
return layer;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
class TestKeyGeometry : public QObject
|
class TestKeyGeometry : public QObject
|
||||||
@@ -24,7 +32,7 @@ class TestKeyGeometry : public QObject
|
|||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void fillsWidthAndHeight()
|
void fillsWidthAndHeight()
|
||||||
{
|
{
|
||||||
const Layer layer{u"l"_s, {{key(), key()}, {key(2)}}};
|
const Layer layer = layerOf({{key(), key()}, {key(2)}});
|
||||||
const KeyboardMetrics metrics{.padding = 10, .gap = 10};
|
const KeyboardMetrics metrics{.padding = 10, .gap = 10};
|
||||||
const auto rects = computeKeyRects(layer, {210, 110}, metrics);
|
const auto rects = computeKeyRects(layer, {210, 110}, metrics);
|
||||||
|
|
||||||
@@ -36,7 +44,7 @@ private Q_SLOTS:
|
|||||||
|
|
||||||
void spacersShiftFollowingKeys()
|
void spacersShiftFollowingKeys()
|
||||||
{
|
{
|
||||||
const Layer layer{u"l"_s, {{key(), key(), key()}, {key(0.5, KeyType::Spacer), key(), key(1.5)}}};
|
const Layer layer = layerOf({{key(), key(), key()}, {key(0.5, KeyType::Spacer), key(), key(1.5)}});
|
||||||
const auto rects = computeKeyRects(layer, {300, 100}, {.padding = 0, .gap = 0});
|
const auto rects = computeKeyRects(layer, {300, 100}, {.padding = 0, .gap = 0});
|
||||||
QCOMPARE(rects[4].left(), 50.0);
|
QCOMPARE(rects[4].left(), 50.0);
|
||||||
QCOMPARE(rects[5].right(), 300.0);
|
QCOMPARE(rects[5].right(), 300.0);
|
||||||
@@ -44,7 +52,7 @@ private Q_SLOTS:
|
|||||||
|
|
||||||
void shorterRowsAreCentered()
|
void shorterRowsAreCentered()
|
||||||
{
|
{
|
||||||
const Layer layer{u"l"_s, {{key(), key(), key(), key()}, {key(), key()}}};
|
const Layer layer = layerOf({{key(), key(), key(), key()}, {key(), key()}});
|
||||||
const auto rects = computeKeyRects(layer, {400, 100}, {.padding = 0, .gap = 0});
|
const auto rects = computeKeyRects(layer, {400, 100}, {.padding = 0, .gap = 0});
|
||||||
QCOMPARE(rects[4].left(), 100.0);
|
QCOMPARE(rects[4].left(), 100.0);
|
||||||
QCOMPARE(rects[5].right(), 300.0);
|
QCOMPARE(rects[5].right(), 300.0);
|
||||||
@@ -54,7 +62,7 @@ private Q_SLOTS:
|
|||||||
{
|
{
|
||||||
KeyDef wide = key();
|
KeyDef wide = key();
|
||||||
wide.stretch = true;
|
wide.stretch = true;
|
||||||
const Layer layer{u"l"_s, {{key(), key(), key(), key()}, {key(), wide}}};
|
const Layer layer = layerOf({{key(), key(), key(), key()}, {key(), wide}});
|
||||||
const auto rects = computeKeyRects(layer, {400, 100}, {.padding = 0, .gap = 0});
|
const auto rects = computeKeyRects(layer, {400, 100}, {.padding = 0, .gap = 0});
|
||||||
QCOMPARE(rects[4].left(), 0.0);
|
QCOMPARE(rects[4].left(), 0.0);
|
||||||
QCOMPARE(rects[5].width(), 300.0);
|
QCOMPARE(rects[5].width(), 300.0);
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ private Q_SLOTS:
|
|||||||
void fullModeKeepsDeadKeysAndKeymapShift()
|
void fullModeKeepsDeadKeysAndKeymapShift()
|
||||||
{
|
{
|
||||||
const Layout sk = TestLayouts::build("sk", KeyboardMode::Full);
|
const Layout sk = TestLayouts::build("sk", KeyboardMode::Full);
|
||||||
const KeyDef ´ = letterKey(sk, u"´"_s);
|
const KeyDef acute = letterKey(sk, u"´"_s);
|
||||||
QCOMPARE(acute.dead, quint32(XKB_KEY_dead_acute));
|
QCOMPARE(acute.dead, quint32(XKB_KEY_dead_acute));
|
||||||
QCOMPARE(acute.deadShifted, quint32(XKB_KEY_dead_caron));
|
QCOMPARE(acute.deadShifted, quint32(XKB_KEY_dead_caron));
|
||||||
QCOMPARE(letterKey(sk, u"ô"_s).shifted, u"\""); // as the physical key
|
QCOMPARE(letterKey(sk, u"ô"_s).shifted, u"\""); // as the physical key
|
||||||
|
|||||||
Reference in New Issue
Block a user