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 updateSearch(); 22 23 public slots: 24 void loadingFinished(); 25 void searchProgressed( int completion, int nbMatches ); 26 27 private: 28 bool generateDataFiles(); 29 30 void simpleSearchTest(); 31 void multipleSearchTest(); 32 void updateSearchTest(); 33 void marksTest(); 34 35 std::pair<int,int> waitSearchProgressed(); 36 void waitLoadingFinished(); 37 void signalSearchProgressedRead(); 38 void signalLoadingFinishedRead(); 39 40 LogData* logData_; 41 LogFilteredData* filteredData_; 42 43 // Synchronisation variables (protected by the two mutexes) 44 bool loadingFinished_received_; 45 bool loadingFinished_read_; 46 bool searchProgressed_received_; 47 bool searchProgressed_read_; 48 49 int searchLastMatches_; 50 int searchLastProgress_; 51 52 QMutex loadingFinishedMutex_; 53 QMutex searchProgressedMutex_; 54 55 QWaitCondition loadingFinishedCondition_; 56 QWaitCondition searchProgressedCondition_; 57 }; 58