Make Runner::run() returns a bool indicating success or failure

This commit is contained in:
Aurélien Gâteau 2014-07-18 11:27:03 +02:00
parent eebc71257f
commit 7e8c5a980c
2 changed files with 11 additions and 4 deletions

View File

@ -27,14 +27,16 @@ QueueRunner::QueueRunner( JobQueue* queue )
connect( m_queue, &JobQueue::failed, this, &QueueRunner::onFailed );
}
void
bool
QueueRunner::run()
{
m_done = false;
m_success = false;
m_queue->start();
QEventLoop loop;
while ( !m_done )
loop.processEvents();
return m_success;
}
void
@ -43,6 +45,7 @@ QueueRunner::onProgress( int current, int total, const QString& prettyName )
QVERIFY( current <= total );
if ( current < total )
return;
m_success = true;
m_done = true;
}
@ -147,7 +150,7 @@ JobTests::testCreatePartition()
job->updatePreview();
m_queue.enqueue( job_ptr( job ) );
m_runner.run();
QVERIFY( m_runner.run() );
}
void
@ -172,5 +175,5 @@ JobTests::testCreatePartitionExtended()
job->updatePreview();
m_queue.enqueue( job_ptr( job ) );
m_runner.run();
QVERIFY( m_runner.run() );
}

View File

@ -19,13 +19,17 @@ class QueueRunner : public QObject
public:
QueueRunner( Calamares::JobQueue* queue );
void run();
/**
* Synchronously runs the queue. Returns true on success
*/
bool run();
private:
void onProgress( int current, int total, const QString& prettyName );
void onFailed( const QString& message, const QString& details );
Calamares::JobQueue* m_queue;
bool m_done;
bool m_success;
};
class JobTests : public QObject