Commit 39124d8f authored by Daniel Vrátil's avatar Daniel Vrátil 🤖

Make window active before running a focus test

Make sure the window is active before checking for a widget focus.
This does not really affect CI, but when running tests locally, the
WM may cause the test window to not be active making focus tests fail.
parent faae4147
......@@ -142,6 +142,12 @@ void EventEditTest::shouldNotEmitWhenMessageIsNotChanged()
void EventEditTest::shouldEmitEventWhenPressEnter()
{
MessageViewer::EventEdit edit;
edit.show();
// make sure the window is active so we can test for focus
qApp->setActiveWindow(&edit);
QTest::qWaitForWindowExposed(&edit);
QVERIFY(edit.isVisible());
KMime::Message::Ptr msg(new KMime::Message);
QString subject = QStringLiteral("Test Note");
msg->subject(true)->fromUnicodeString(subject, "us-ascii");
......@@ -173,6 +179,8 @@ void EventEditTest::shouldHideWidgetWhenPressEscape()
{
MessageViewer::EventEdit edit;
edit.show();
// make sure the window is active so we can test for focus
qApp->setActiveWindow(&edit);
QTest::qWaitForWindowExposed(&edit);
QLineEdit *eventedit = edit.findChild<QLineEdit *>(QStringLiteral("eventedit"));
eventedit->setFocus();
......@@ -317,6 +325,8 @@ void EventEditTest::shouldSetFocusWhenWeCallTodoEdit()
{
MessageViewer::EventEdit edit;
edit.show();
// make sure the window is active so we can test for focus
qApp->setActiveWindow(&edit);
QTest::qWaitForWindowExposed(&edit);
QLineEdit *noteedit = edit.findChild<QLineEdit *>(QStringLiteral("eventedit"));
QVERIFY(noteedit);
......
......@@ -303,6 +303,8 @@ void NoteEditTest::shouldHideWidgetWhenPressEscape()
{
MessageViewer::NoteEdit edit;
edit.show();
// make sure the window is active so we can test for focus
qApp->setActiveWindow(&edit);
QTest::qWaitForWindowExposed(&edit);
QLineEdit *noteedit = edit.findChild<QLineEdit *>(QStringLiteral("noteedit"));
noteedit->setFocus();
......@@ -360,6 +362,8 @@ void NoteEditTest::shouldSetFocusWhenWeCallNoteEdit()
{
MessageViewer::NoteEdit edit;
edit.show();
// make sure the window is active so we can test for focus
qApp->setActiveWindow(&edit);
QTest::qWaitForWindowExposed(&edit);
KMime::Message::Ptr msg(new KMime::Message);
QString subject = QStringLiteral("Test Note");
......
......@@ -253,6 +253,7 @@ void TodoEditTest::shouldClearAllWhenCloseWidget()
{
MessageViewer::TodoEdit edit;
edit.show();
qApp->setActiveWindow(&edit);
QTest::qWaitForWindowExposed(&edit);
KMime::Message::Ptr msg(new KMime::Message);
......@@ -310,6 +311,8 @@ void TodoEditTest::shouldHideWidgetWhenPressEscape()
{
MessageViewer::TodoEdit edit;
edit.show();
// make sure the window is active so we can test for focus
qApp->setActiveWindow(&edit);
QTest::qWaitForWindowExposed(&edit);
QLineEdit *noteedit = edit.findChild<QLineEdit *>(QStringLiteral("noteedit"));
noteedit->setFocus();
......@@ -367,6 +370,8 @@ void TodoEditTest::shouldSetFocusWhenWeCallTodoEdit()
{
MessageViewer::TodoEdit edit;
edit.show();
// make sure the window is active so we can test for focus
qApp->setActiveWindow(&edit);
QTest::qWaitForWindowExposed(&edit);
KMime::Message::Ptr msg(new KMime::Message);
QString subject = QStringLiteral("Test Note");
......@@ -407,6 +412,8 @@ void TodoEditTest::shouldHaveLineEditFocus()
{
MessageViewer::TodoEdit edit;
edit.show();
// make sure the window is active so we can test for focus
qApp->setActiveWindow(&edit);
QTest::qWaitForWindowExposed(&edit);
KMime::Message::Ptr msg(new KMime::Message);
QString subject = QStringLiteral("Test Note");
......
Markdown is supported
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