summaryrefslogtreecommitdiff
path: root/tests/unit/common/test_auto_respond_selection_latch.cpp
blob: d81910e98784a7fbecdf5576c61c21756a79fa1a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <QtTest>

#include "AutoRespondSelectionLatch.hpp"

class TestAutoRespondSelectionLatch : public QObject
{
  Q_OBJECT

private:
  Q_SLOT void selectForClearsAfterDelay()
  {
    AutoRespondSelectionLatch latch;

    latch.selectFor(10);

    QVERIFY(latch.isSelected());
    QTRY_VERIFY_WITH_TIMEOUT(!latch.isSelected(), 250);
  }

  Q_SLOT void selectForRestartsResetDelay()
  {
    AutoRespondSelectionLatch latch;

    latch.selectFor(30);
    QTest::qWait(10);
    latch.selectFor(100);

    QVERIFY(latch.isSelected());
    QTest::qWait(50);
    QVERIFY(latch.isSelected());
    QTRY_VERIFY_WITH_TIMEOUT(!latch.isSelected(), 250);
  }
};

QTEST_MAIN(TestAutoRespondSelectionLatch)
#include "test_auto_respond_selection_latch.moc"