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