|
19 | 19 | #include "qgsproject.h"
|
20 | 20 | #include "qgsvectorlayer.h"
|
21 | 21 | #include "qgsapplication.h"
|
| 22 | +#include "qgsproxyprogresstask.h" |
22 | 23 | #include <QObject>
|
23 | 24 | #include "qgstest.h"
|
24 | 25 |
|
@@ -270,6 +271,9 @@ class TestQgsTaskManager : public QObject
|
270 | 271 | void managerWithSubTasks2();
|
271 | 272 | void managerWithSubTasks3();
|
272 | 273 | void cancelBeforeStart();
|
| 274 | + void proxyTask(); |
| 275 | + void proxyTask2(); |
| 276 | + void scopedProxyTask(); |
273 | 277 | };
|
274 | 278 |
|
275 | 279 | void TestQgsTaskManager::initTestCase()
|
@@ -1374,5 +1378,75 @@ void TestQgsTaskManager::cancelBeforeStart()
|
1374 | 1378 | flushEvents();
|
1375 | 1379 | }
|
1376 | 1380 |
|
| 1381 | +void TestQgsTaskManager::proxyTask() |
| 1382 | +{ |
| 1383 | + if ( QgsTest::isTravis() ) |
| 1384 | + QSKIP( "This test is disabled on Travis CI environment" ); |
| 1385 | + |
| 1386 | + QgsProxyProgressTask *proxyTask = new QgsProxyProgressTask( QString() ); |
| 1387 | + |
| 1388 | + // finalize before task gets a chance to start |
| 1389 | + QgsTaskManager manager; |
| 1390 | + proxyTask->finalize( false ); |
| 1391 | + QPointer< QgsTask > p( proxyTask ); |
| 1392 | + |
| 1393 | + manager.addTask( proxyTask ); |
| 1394 | + |
| 1395 | + // should all be ok, no deadlock... |
| 1396 | + while ( p ) |
| 1397 | + { |
| 1398 | + QCoreApplication::processEvents(); |
| 1399 | + } |
| 1400 | + flushEvents(); |
| 1401 | +} |
| 1402 | + |
| 1403 | +void TestQgsTaskManager::proxyTask2() |
| 1404 | +{ |
| 1405 | + if ( QgsTest::isTravis() ) |
| 1406 | + QSKIP( "This test is disabled on Travis CI environment" ); |
| 1407 | + |
| 1408 | + QgsProxyProgressTask *proxyTask = new QgsProxyProgressTask( QString() ); |
| 1409 | + |
| 1410 | + // finalize before task gets a chance to start |
| 1411 | + QgsTaskManager manager; |
| 1412 | + QPointer< QgsTask > p( proxyTask ); |
| 1413 | + manager.addTask( proxyTask ); |
| 1414 | + |
| 1415 | + // should all be ok, no deadlock... |
| 1416 | + while ( proxyTask->status() != QgsTask::Running ) |
| 1417 | + { |
| 1418 | + QCoreApplication::processEvents(); |
| 1419 | + } |
| 1420 | + proxyTask->finalize( false ); |
| 1421 | + while ( p ) |
| 1422 | + { |
| 1423 | + QCoreApplication::processEvents(); |
| 1424 | + } |
| 1425 | + |
| 1426 | + flushEvents(); |
| 1427 | +} |
| 1428 | + |
| 1429 | +void TestQgsTaskManager::scopedProxyTask() |
| 1430 | +{ |
| 1431 | + if ( QgsTest::isTravis() ) |
| 1432 | + QSKIP( "This test is disabled on Travis CI environment" ); |
| 1433 | + |
| 1434 | + { |
| 1435 | + // task finishes before it can start |
| 1436 | + QgsScopedProxyProgressTask task{ QString() }; |
| 1437 | + } |
| 1438 | + |
| 1439 | + // should all be ok, no deadlock... |
| 1440 | + while ( QgsApplication::taskManager()->countActiveTasks() == 0 ) |
| 1441 | + { |
| 1442 | + QCoreApplication::processEvents(); |
| 1443 | + } |
| 1444 | + while ( QgsApplication::taskManager()->countActiveTasks() > 0 ) |
| 1445 | + { |
| 1446 | + QCoreApplication::processEvents(); |
| 1447 | + } |
| 1448 | + flushEvents(); |
| 1449 | +} |
| 1450 | + |
1377 | 1451 | QGSTEST_MAIN( TestQgsTaskManager )
|
1378 | 1452 | #include "testqgstaskmanager.moc"
|
0 commit comments