xref: /glogg/tests/testlogfiltereddata.h (revision a1e4ce9253f8e2e2c659de30403a11daa905f8fa)
1 #include <QMutex>
2 #include <QWaitCondition>
3 #include <QtTest/QtTest>
4 
5 class LogData;
6 class LogFilteredData;
7 
8 class TestLogFilteredData: public QObject
9 {
10     Q_OBJECT
11 
12     public:
13         TestLogFilteredData();
14 
15     private slots:
16         void initTestCase();
17 
18         void simpleSearch();
19         void multipleSearch();
20         void marks();
21         void lineLength();
22         void updateSearch();
23 
24     public slots:
25         void loadingFinished();
26         void searchProgressed( int completion, int nbMatches );
27 
28     private:
29         bool generateDataFiles();
30 
31         void simpleSearchTest();
32         void multipleSearchTest();
33         void updateSearchTest();
34         void marksTest();
35         void lineLengthTest();
36 
37         std::pair<int,int> waitSearchProgressed();
38         void waitLoadingFinished();
39         void signalSearchProgressedRead();
40         void signalLoadingFinishedRead();
41 
42         LogData* logData_;
43         LogFilteredData* filteredData_;
44 
45         // Synchronisation variables (protected by the two mutexes)
46         bool loadingFinished_received_;
47         bool loadingFinished_read_;
48         bool searchProgressed_received_;
49         bool searchProgressed_read_;
50 
51         int searchLastMatches_;
52         int searchLastProgress_;
53 
54         QMutex loadingFinishedMutex_;
55         QMutex searchProgressedMutex_;
56 
57         QWaitCondition loadingFinishedCondition_;
58         QWaitCondition searchProgressedCondition_;
59 };
60