Commit b9693dc9 authored by Waqar Ahmed's avatar Waqar Ahmed
Browse files

Tests: Add tests to ensure our signal emissions are correct

parent 8a7be756
Pipeline #252542 passed with stage
in 8 minutes and 35 seconds
......@@ -10,6 +10,7 @@
#include <QCommandLineParser>
#include <QPointer>
#include <QSignalSpy>
#include <QTest>
QTEST_MAIN(KateViewManagementTests)
......@@ -276,3 +277,45 @@ void KateViewManagementTests::testTabLRUWithWidgets()
QCOMPARE(vs->m_registeredDocuments.size(), 2);
QCOMPARE(vm->activeView(), view2);
}
void KateViewManagementTests::testViewChangedEmittedOnAddWidget()
{
auto kmw = app->activeMainWindow();
QSignalSpy spy(kmw, &KTextEditor::MainWindow::viewChanged);
Utils::addWidget(new QWidget, kmw);
spy.wait();
QVERIFY(spy.count() == 1);
}
void KateViewManagementTests::testWidgetAddedEmittedOnAddWidget()
{
QSignalSpy spy(app->activeMainWindow()->window(), SIGNAL(widgetAdded(QWidget *)));
Utils::addWidget(new QWidget, app->activeMainWindow());
spy.wait();
QVERIFY(spy.count() == 1);
}
void KateViewManagementTests::testWidgetRemovedEmittedOnRemoveWidget()
{
auto mw = app->activeMainWindow()->window();
QSignalSpy spy(mw, SIGNAL(widgetRemoved(QWidget *)));
auto w = new QWidget;
Utils::addWidget(w, app->activeMainWindow());
QMetaObject::invokeMethod(mw, "removeWidget", Q_ARG(QWidget *, w));
spy.wait();
QVERIFY(spy.count() == 1);
}
void KateViewManagementTests::testActivateNotAddedWidget()
{
auto kmw = app->activeMainWindow();
auto mw = app->activeMainWindow()->window();
QSignalSpy spy(mw, SIGNAL(widgetAdded(QWidget *)));
QSignalSpy spy1(kmw, &KTextEditor::MainWindow::viewChanged);
auto w = new QWidget;
QMetaObject::invokeMethod(mw, "activateWidget", Q_ARG(QWidget *, w));
spy.wait();
spy1.wait();
QVERIFY(spy.count() == 1);
QVERIFY(spy1.count() == 1);
}
......@@ -31,6 +31,10 @@ private Q_SLOTS:
void testTwoMainWindowsCloseInitialDocument2();
void testTwoMainWindowsCloseInitialDocument3();
void testTabLRUWithWidgets();
void testViewChangedEmittedOnAddWidget();
void testWidgetAddedEmittedOnAddWidget();
void testWidgetRemovedEmittedOnRemoveWidget();
void testActivateNotAddedWidget();
private:
class QTemporaryDir *m_tempdir;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment