Skip to content

Commit

Permalink
Tests: Wait after hiding main window on X11
Browse files Browse the repository at this point in the history
  • Loading branch information
hluk committed Aug 25, 2023
1 parent 643eb8b commit ccbc1a9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/tests/test_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@ const int waitMsSetClipboard = 250;
/// Interval to wait (in ms) for pasting clipboard.
const int waitMsPasteClipboard = 1000;

/// Interval before calling show/hide (toggling windows very fast can break
/// some window managers).
#ifdef COPYQ_WS_X11
const int waitMsBeforeShowHide = 1000;
#else
const int waitMsBeforeShowHide = 0;
#endif

/// Interval to wait (in ms) for client process.
const int waitClientRun = 30000;

Expand Down
6 changes: 6 additions & 0 deletions src/tests/tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1084,19 +1084,23 @@ void Tests::commandHide()
void Tests::commandShow()
{
RUN("visible", "true\n");
waitFor(waitMsBeforeShowHide);
RUN("hide", "");
WAIT_ON_OUTPUT("visible", "false\n");

waitFor(waitMsBeforeShowHide);
RUN("show", "");
WAIT_ON_OUTPUT("visible", "true\n");
}

void Tests::commandShowAt()
{
RUN("visible", "true\n");
waitFor(waitMsBeforeShowHide);
RUN("hide", "");
WAIT_ON_OUTPUT("visible", "false\n");

waitFor(waitMsBeforeShowHide);
RUN("showAt", "");
WAIT_ON_OUTPUT("visible", "true\n");
}
Expand Down Expand Up @@ -3218,11 +3222,13 @@ void Tests::pasteFromMainWindow()
);

RUN("add" << "TEST", "");
waitFor(waitMsBeforeShowHide);
RUN("hide", "");
runMultiple(
[&]() { RUN(WITH_TIMEOUT "dialog('text')", "TEST\n"); },
[&]() {
RUN("keys" << "focus::QLineEdit in :QDialog", "");
waitFor(waitMsBeforeShowHide);
RUN("show", "");
RUN("keys" << clipboardBrowserId << "ENTER", "");

Expand Down

0 comments on commit ccbc1a9

Please sign in to comment.