[partition] Test automount job in a queue
This commit is contained in:
parent
38fa1d9567
commit
17f73b1294
@ -25,7 +25,8 @@ AutoMountManagementJob::prettyName() const
|
|||||||
Calamares::JobResult
|
Calamares::JobResult
|
||||||
AutoMountManagementJob::exec()
|
AutoMountManagementJob::exec()
|
||||||
{
|
{
|
||||||
Logger::CDebug(Logger::LOGVERBOSE) << "this" << Logger::Pointer( this ) << "value" << Logger::Pointer( m_stored );
|
Logger::CDebug( Logger::LOGVERBOSE ) << "this" << Logger::Pointer( this ) << "value" << Logger::Pointer( m_stored )
|
||||||
|
<< ( m_stored ? "restore" : m_disable ? "disable" : "enable" );
|
||||||
if ( m_stored )
|
if ( m_stored )
|
||||||
{
|
{
|
||||||
CalamaresUtils::Partition::automountRestore( m_stored );
|
CalamaresUtils::Partition::automountRestore( m_stored );
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#include "jobs/AutoMountManagementJob.h"
|
#include "jobs/AutoMountManagementJob.h"
|
||||||
|
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
|
#include "JobQueue.h"
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QtTest/QtTest>
|
#include <QtTest/QtTest>
|
||||||
@ -22,6 +23,7 @@ public:
|
|||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void testRunThrice();
|
void testRunThrice();
|
||||||
|
void testRunQueue();
|
||||||
};
|
};
|
||||||
|
|
||||||
AutoMountJobTests::AutoMountJobTests() {}
|
AutoMountJobTests::AutoMountJobTests() {}
|
||||||
@ -50,6 +52,33 @@ AutoMountJobTests::testRunThrice()
|
|||||||
CalamaresUtils::Partition::automountRestore( original );
|
CalamaresUtils::Partition::automountRestore( original );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AutoMountJobTests::testRunQueue()
|
||||||
|
{
|
||||||
|
Calamares::JobQueue q;
|
||||||
|
Calamares::job_ptr jp( new AutoMountManagementJob( false ) );
|
||||||
|
QSignalSpy progress( &q, &Calamares::JobQueue::progress );
|
||||||
|
QSignalSpy finish( &q, &Calamares::JobQueue::finished );
|
||||||
|
QSignalSpy fail( &q, &Calamares::JobQueue::failed );
|
||||||
|
|
||||||
|
Logger::setupLogLevel( Logger::LOGVERBOSE );
|
||||||
|
cDebug() << "Got automount job" << jp;
|
||||||
|
|
||||||
|
QVERIFY( !q.isRunning() );
|
||||||
|
q.enqueue( 2, { jp, jp } );
|
||||||
|
QVERIFY( !q.isRunning() );
|
||||||
|
|
||||||
|
QEventLoop loop;
|
||||||
|
QTimer::singleShot( std::chrono::milliseconds( 100 ), [&q](){ q.start(); } );
|
||||||
|
QTimer::singleShot( std::chrono::milliseconds( 5000 ), [&loop](){ loop.quit(); } );
|
||||||
|
connect( &q, &Calamares::JobQueue::finished, &loop, &QEventLoop::quit );
|
||||||
|
loop.exec();
|
||||||
|
|
||||||
|
QCOMPARE( fail.count(), 0 );
|
||||||
|
QCOMPARE( finish.count(), 1 );
|
||||||
|
// 5 progress: 0% and 100% for each *job* and then 100% overall
|
||||||
|
QCOMPARE( progress.count(), 5 );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QTEST_GUILESS_MAIN( AutoMountJobTests )
|
QTEST_GUILESS_MAIN( AutoMountJobTests )
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user