Skip to content

Commit

Permalink
Fix GuiFont test
Browse files Browse the repository at this point in the history
We are observing a failing test for font changes

1. the finished signal for the call to vim_command is not caught by the
   signal spy

The root of the issues seems to be a failure to set the font due to some
combination of bad font metrics happening in the test environment. The
GuiFont command was changed to force the change. The timeout was also
increased.
  • Loading branch information
equalsraf authored and equalsraf committed Jul 2, 2022
1 parent 7a5b0dd commit f533fd4
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions test/tst_shell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ void TestShell::guiShimCommands() noexcept
QObject::connect(c->neovimObject(), &NeovimApi1::err_vim_command_output, SignalPrintError);

QSignalSpy cmd_font(
c->neovimObject()->vim_command_output(c->encode("GuiFont")), &MsgpackRequest::finished);
c->neovimObject()->vim_command_output(c->encode("GuiFont!")), &MsgpackRequest::finished);
QVERIFY(cmd_font.isValid());
QVERIFY2(SPYWAIT(cmd_font), "Waiting for GuiFont");

Expand All @@ -121,7 +121,7 @@ void TestShell::guiShimCommands() noexcept
QVERIFY2(SPYWAIT(cmd_ls), "Waiting for GuiLinespace");

// Test font attributes
const QString cmdFontSize14{ QStringLiteral("GuiFont %1:h14").arg(GetPlatformTestFont()) };
const QString cmdFontSize14{ QStringLiteral("GuiFont! %1:h14").arg(GetPlatformTestFont()) };
const QString expectedFontSize14{ QStringLiteral("%1:h14").arg(GetPlatformTestFont()) };
QSignalSpy cmd_gf{ c->neovimObject()->vim_command_output(c->encode(cmdFontSize14)),
&MsgpackRequest::finished };
Expand All @@ -137,17 +137,17 @@ void TestShell::guiShimCommands() noexcept

// Normalization removes the :b attribute
const QString cmdFontBoldRemoved{
QStringLiteral("GuiFont %1:h14:b:l").arg(GetPlatformTestFont())
QStringLiteral("GuiFont! %1:h16:b:l").arg(GetPlatformTestFont())
};
const QString expectedFontBoldRemoved{ QStringLiteral("%1:h14:l").arg(GetPlatformTestFont()) };
const QString expectedFontBoldRemoved{ QStringLiteral("%1:h16:l").arg(GetPlatformTestFont()) };
QSignalSpy spy_fontchange2(w->shell(), &ShellWidget::shellFontChanged);
QSignalSpy cmd_gf2{ c->neovimObject()->vim_command_output(c->encode(cmdFontBoldRemoved)),
&MsgpackRequest::finished };
QVERIFY(cmd_gf2.isValid());
QVERIFY(SPYWAIT(cmd_gf2, 5000));

// Test Performance: timeout occurs often, set value carefully.
SPYWAIT(spy_fontchange2, 2500 /*msec*/);
SPYWAIT(spy_fontchange2, 5000 /*msec*/);

QCOMPARE(w->shell()->fontDesc(), expectedFontBoldRemoved);
}
Expand Down

0 comments on commit f533fd4

Please sign in to comment.