D7968: WIP: Forward QComboBox signals instead of QComboBox lineedit signals
Milian Wolff
noreply at phabricator.kde.org
Tue Dec 5 16:38:44 UTC 2017
mwolff added inline comments.
INLINE COMMENTS
> dfaure wrote in kurlrequestertest.cpp:162
> Then use QTest::keyClick to send key events to the widget?
I still don't get it to work. This is my currently latest attempt:
void KUrlRequesterTest::testComboEditableRequester()
{
KUrlComboRequester req;
QSignalSpy textSpy(&req, &KUrlComboRequester::textChanged);
QSignalSpy editSpy(&req, &KUrlComboRequester::textEdited);
QSignalSpy returnSpy(&req, static_cast<void (KUrlComboRequester::*)()>(&KUrlComboRequester::returnPressed));
QSignalSpy returnWithTextSpy(&req, static_cast<void (KUrlComboRequester::*)(const QString&)>(&KUrlComboRequester::returnPressed));
QVERIFY(!req.comboBox()->isEditable());
req.comboBox()->setEditable(true);
req.show();
QSignalSpy comboTextSpy(req.comboBox(), &QComboBox::currentTextChanged);
QSignalSpy comboEditSpy(req.comboBox(), &QComboBox::editTextChanged);
auto* lineEdit = req.comboBox()->lineEdit();
QVERIFY(lineEdit);
QSignalSpy lineTextSpy(lineEdit, &QLineEdit::textChanged);
QSignalSpy lineEditSpy(lineEdit, &QLineEdit::textEdited);
// FIXME: this still doesn't emit any signal, but it works in practice when actually interacting with the widget?
QTest::keyClicks(lineEdit, QStringLiteral("foobar"), Qt::NoModifier, 100);
QVERIFY(lineTextSpy.wait());
QCOMPARE(lineTextSpy.first().first().toString(), QStringLiteral("foobar"));
QVERIFY(lineEditSpy.wait());
QCOMPARE(lineEditSpy.first().first().toString(), QStringLiteral("foobar"));
}
Note that the widget (which I now show) actually shows the text getting written via the QTest::keyClicks method. But none of the signals is actually getting emitted... I'm flabbergasted. Looking at the QLineEdit test code, it doesn't seem to actually contain a positive test for an of `isEditable`...
I feel like I'm missing something fundamental here. Note that I can see the signals just fine in GammaRay when I interact with an editable combo box :-/
REPOSITORY
R241 KIO
REVISION DETAIL
https://phabricator.kde.org/D7968
To: mwolff, apol
Cc: dfaure, broulik, apol, #frameworks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20171205/e2e40693/attachment.html>
More information about the Kde-frameworks-devel
mailing list