summaryrefslogtreecommitdiff
path: root/user/qca/test.patch
blob: 6b9fb12ef643c4fe865edf8d19ad552265e66ca0 (plain) (blame)
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
From b9d914bb3b5b0ecf8568adf1b4610d4da2cde244 Mon Sep 17 00:00:00 2001
From: Fabian Vogt <fabian@ritter-vogt.de>
Date: Wed, 15 Sep 2021 10:34:08 +0200
Subject: [PATCH] Make filewatchunittest much quicker

Use QSignalSpy::wait to avoid waiting needlessly.
Reduce time to wait for (expected and unexpected) signals to 2s.
---
 .../filewatchunittest/filewatchunittest.cpp   | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/unittest/filewatchunittest/filewatchunittest.cpp b/unittest/filewatchunittest/filewatchunittest.cpp
index d1bc117c..63baa655 100644
--- a/unittest/filewatchunittest/filewatchunittest.cpp
+++ b/unittest/filewatchunittest/filewatchunittest.cpp
@@ -40,7 +40,7 @@ void FileWatchUnitTest::cleanupTestCase()
 
 void FileWatchUnitTest::filewatchTest()
 {
-    QWARN("Unittest will take about 1 minute. Please wait.");
+    QWARN("Unittest will take about 10 seconds. Please wait.");
 
     QCA::FileWatch watcher;
     QCOMPARE( watcher.fileName(), QString() );
@@ -55,41 +55,40 @@ void FileWatchUnitTest::filewatchTest()
 
     watcher.setFileName( tempFile->fileName() );
     QCOMPARE( watcher.fileName(), tempFile->fileName() );
-    QTest::qWait(7000);
+    QVERIFY(!spy.wait(2000));
     QCOMPARE( spy.count(), 0 );
     tempFile->close();
-    QTest::qWait(7000);
+    QVERIFY(!spy.wait(2000));
     QCOMPARE( spy.count(), 0 );
 
     tempFile->open();
     tempFile->write("foo");
     tempFile->flush();
-    QTest::qWait(7000);
+    QVERIFY(spy.wait(2000));
     QCOMPARE( spy.count(), 1 );
 
     tempFile->close();
-    QTest::qWait(7000);
-
+    QVERIFY(!spy.wait(2000));
     QCOMPARE( spy.count(), 1 );
 
     tempFile->open();
     tempFile->write("foo");
     tempFile->flush();
-    QTest::qWait(7000);
+    QVERIFY(spy.wait(2000));
     QCOMPARE( spy.count(), 2 );
 
     tempFile->write("bar");
     tempFile->flush();
-    QTest::qWait(7000);
+    QVERIFY(spy.wait(2000));
     QCOMPARE( spy.count(), 3 );
 
     tempFile->close();
-    QTest::qWait(7000);
+    QVERIFY(!spy.wait(2000));
 
     QCOMPARE( spy.count(), 3 );
 
     delete tempFile;
-    QTest::qWait(7000);
+    QVERIFY(spy.wait(2000));
     QCOMPARE( spy.count(), 4 );
 }
 
-- 
GitLab