Skip to content

Commit

Permalink
Add unit tests for x1/x2 mouse events
Browse files Browse the repository at this point in the history
  • Loading branch information
equalsraf committed Jul 24, 2024
1 parent 3dbcbb5 commit 5ac0c0c
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions test/tst_input_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ private slots:
void MouseLeftClick() noexcept;
void MouseRightClick() noexcept;
void MouseMiddleClick() noexcept;
void MouseX1Click() noexcept;
void MouseX2Click() noexcept;
};

void TestInputCommon::LessThanKey() noexcept
Expand Down Expand Up @@ -255,5 +257,43 @@ void TestInputCommon::MouseMiddleClick() noexcept
QCOMPARE(middleClickRelease, QString{ "<MiddleRelease><1,2>" });
}

void TestInputCommon::MouseX1Click() noexcept
{
QString x1Press{ NeovimQt::Input::convertMouse(
Qt::XButton1,
QEvent::MouseButtonPress,
Qt::NoModifier,
{ 1, 2 },
1 /*clickCount*/) };
QString x1Release{ NeovimQt::Input::convertMouse(
Qt::XButton1,
QEvent::MouseButtonRelease,
Qt::NoModifier,
{ 1, 2 },
1 /*clickCount*/) };

QCOMPARE(x1Press, QString{ "<X1Mouse><1,2>" });
QCOMPARE(x1Release, QString{ "<X1Release><1,2>" });
}

void TestInputCommon::MouseX2Click() noexcept
{
QString x2Press{ NeovimQt::Input::convertMouse(
Qt::XButton2,
QEvent::MouseButtonPress,
Qt::NoModifier,
{ 1, 2 },
1 /*clickCount*/) };
QString x2Release{ NeovimQt::Input::convertMouse(
Qt::XButton2,
QEvent::MouseButtonRelease,
Qt::NoModifier,
{ 1, 2 },
1 /*clickCount*/) };

QCOMPARE(x2Press, QString{ "<X2Mouse><1,2>" });
QCOMPARE(x2Release, QString{ "<X2Release><1,2>" });
}

#include "tst_input_common.moc"
QTEST_MAIN(TestInputCommon)

0 comments on commit 5ac0c0c

Please sign in to comment.