diff --git a/src/modules/partition/jobs/AutoMountManagementJob.cpp b/src/modules/partition/jobs/AutoMountManagementJob.cpp index 8078c17d5..9472eae9c 100644 --- a/src/modules/partition/jobs/AutoMountManagementJob.cpp +++ b/src/modules/partition/jobs/AutoMountManagementJob.cpp @@ -25,7 +25,8 @@ AutoMountManagementJob::prettyName() const Calamares::JobResult 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 ) { CalamaresUtils::Partition::automountRestore( m_stored ); diff --git a/src/modules/partition/tests/AutoMountTests.cpp b/src/modules/partition/tests/AutoMountTests.cpp index 87b6d5d4a..fcebe02bd 100644 --- a/src/modules/partition/tests/AutoMountTests.cpp +++ b/src/modules/partition/tests/AutoMountTests.cpp @@ -10,6 +10,7 @@ #include "jobs/AutoMountManagementJob.h" #include "utils/Logger.h" +#include "JobQueue.h" #include #include @@ -22,6 +23,7 @@ public: private Q_SLOTS: void testRunThrice(); + void testRunQueue(); }; AutoMountJobTests::AutoMountJobTests() {} @@ -50,6 +52,33 @@ AutoMountJobTests::testRunThrice() 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 )