@@ -86,6 +86,11 @@ class QgsTestExternalStorageStoredContent : public QgsExternalStorageStoredConte
86
86
emit errorOccurred ( mErrorString );
87
87
}
88
88
89
+ void setProgress ( double progress )
90
+ {
91
+ emit progressChanged ( progress );
92
+ }
93
+
89
94
void finish ()
90
95
{
91
96
mStatus = Qgis::ContentStatus::Finished;
@@ -275,47 +280,60 @@ void TestQgsExternalStorageFileWidget::testStoring()
275
280
w.setUseLink ( useLink );
276
281
w.setReadOnly ( false );
277
282
278
- QVERIFY ( useLink == w.mLinkLabel ->isVisible () );
279
- QVERIFY ( useLink == w.mLinkEditButton ->isVisible () );
280
- if ( useLink ) QCOMPARE ( w.mLinkEditButton ->icon (), editIcon );
281
- QVERIFY ( useLink != w.mLineEdit ->isVisible () );
282
- QVERIFY ( w.mFileWidgetButton ->isVisible () );
283
- QVERIFY ( w.mFileWidgetButton ->isEnabled () );
284
- QVERIFY ( !w.mProgressLabel ->isVisible () );
285
- QVERIFY ( !w.mProgressBar ->isVisible () );
286
- QVERIFY ( !w.mCancelButton ->isVisible () );
287
-
288
- w.setSelectedFileNames ( QStringList () << QStringLiteral ( " myfile" ) );
289
-
290
- QVERIFY ( QgsTestExternalStorage::sCurrentStoredContent );
291
-
292
- QVERIFY ( !w.mLinkLabel ->isVisible () );
293
- QVERIFY ( !w.mLinkEditButton ->isVisible () );
294
- QVERIFY ( !w.mLineEdit ->isVisible () );
295
- QVERIFY ( !w.mFileWidgetButton ->isVisible () );
296
- QVERIFY ( w.mProgressLabel ->isVisible () );
297
- QVERIFY ( w.mProgressBar ->isVisible () );
298
- QVERIFY ( w.mCancelButton ->isVisible () );
299
-
300
- // link is not yet updated
301
- QVERIFY ( w.mLinkLabel ->text ().isEmpty () );
302
-
303
- QgsTestExternalStorage::sCurrentStoredContent ->finish ();
304
- QCoreApplication::processEvents ();
305
-
306
- QVERIFY ( useLink == w.mLinkLabel ->isVisible () );
307
- QVERIFY ( useLink == w.mLinkEditButton ->isVisible () );
308
- if ( useLink ) QCOMPARE ( w.mLinkEditButton ->icon (), editIcon );
309
- QVERIFY ( useLink != w.mLineEdit ->isVisible () );
310
- QVERIFY ( w.mFileWidgetButton ->isVisible () );
311
- QVERIFY ( w.mFileWidgetButton ->isEnabled () );
312
- QVERIFY ( !w.mProgressLabel ->isVisible () );
313
- QVERIFY ( !w.mProgressBar ->isVisible () );
314
- QVERIFY ( !w.mCancelButton ->isVisible () );
315
- if ( useLink )
316
- QCOMPARE ( w.mLinkLabel ->text (), QStringLiteral ( " <a href=\" http://test.url.com/test/myfile\" >myfile</a>" ) );
317
- else
318
- QCOMPARE ( w.mLineEdit ->text (), QStringLiteral ( " http://test.url.com/test/myfile" ) );
283
+ const QStringList fileNames = QStringList () << " myfile1.txt" << " myfile2.txt" ;
284
+ for ( QString fileName : fileNames )
285
+ {
286
+ QVERIFY ( useLink == w.mLinkLabel ->isVisible () );
287
+ QVERIFY ( useLink == w.mLinkEditButton ->isVisible () );
288
+ if ( useLink ) QCOMPARE ( w.mLinkEditButton ->icon (), editIcon );
289
+ QVERIFY ( useLink != w.mLineEdit ->isVisible () );
290
+ QVERIFY ( w.mFileWidgetButton ->isVisible () );
291
+ QVERIFY ( w.mFileWidgetButton ->isEnabled () );
292
+ QVERIFY ( !w.mProgressLabel ->isVisible () );
293
+ QVERIFY ( !w.mProgressBar ->isVisible () );
294
+ QVERIFY ( !w.mCancelButton ->isVisible () );
295
+
296
+ QString currentLabel = useLink ? w.mLinkLabel ->text () : w.mLineEdit ->text ();
297
+
298
+ w.setSelectedFileNames ( QStringList () << fileName );
299
+
300
+ QVERIFY ( QgsTestExternalStorage::sCurrentStoredContent );
301
+
302
+ QVERIFY ( !w.mLinkLabel ->isVisible () );
303
+ QVERIFY ( !w.mLinkEditButton ->isVisible () );
304
+ QVERIFY ( !w.mLineEdit ->isVisible () );
305
+ QVERIFY ( !w.mFileWidgetButton ->isVisible () );
306
+ QVERIFY ( w.mProgressLabel ->isVisible () );
307
+ QVERIFY ( w.mProgressBar ->isVisible () );
308
+ QCOMPARE ( w.mProgressBar ->value (), 0 );
309
+ QVERIFY ( w.mCancelButton ->isVisible () );
310
+
311
+ // link is not yet updated
312
+ if ( useLink )
313
+ QCOMPARE ( currentLabel, w.mLinkLabel ->text () );
314
+ else
315
+ QCOMPARE ( currentLabel, w.mLineEdit ->text () );
316
+
317
+ QgsTestExternalStorage::sCurrentStoredContent ->setProgress ( 50 );
318
+ QVERIFY ( w.mProgressBar ->isVisible () );
319
+ QCOMPARE ( w.mProgressBar ->value (), 50 );
320
+
321
+ QgsTestExternalStorage::sCurrentStoredContent ->finish ();
322
+
323
+ QVERIFY ( useLink == w.mLinkLabel ->isVisible () );
324
+ QVERIFY ( useLink == w.mLinkEditButton ->isVisible () );
325
+ if ( useLink ) QCOMPARE ( w.mLinkEditButton ->icon (), editIcon );
326
+ QVERIFY ( useLink != w.mLineEdit ->isVisible () );
327
+ QVERIFY ( w.mFileWidgetButton ->isVisible () );
328
+ QVERIFY ( w.mFileWidgetButton ->isEnabled () );
329
+ QVERIFY ( !w.mProgressLabel ->isVisible () );
330
+ QVERIFY ( !w.mProgressBar ->isVisible () );
331
+ QVERIFY ( !w.mCancelButton ->isVisible () );
332
+ if ( useLink )
333
+ QCOMPARE ( w.mLinkLabel ->text (), QStringLiteral ( " <a href=\" http://test.url.com/test/%1\" >%1</a>" ).arg ( fileName ) );
334
+ else
335
+ QCOMPARE ( w.mLineEdit ->text (), QStringLiteral ( " http://test.url.com/test/%1" ).arg ( fileName ) );
336
+ }
319
337
}
320
338
321
339
@@ -371,7 +389,6 @@ void TestQgsExternalStorageFileWidget::testStoringSeveralFiles()
371
389
QVERIFY ( w.mLinkLabel ->text ().isEmpty () );
372
390
373
391
QgsTestExternalStorage::sCurrentStoredContent ->finish ();
374
- QCoreApplication::processEvents ();
375
392
376
393
// second file is being stored
377
394
QVERIFY ( content1 );
@@ -395,7 +412,6 @@ void TestQgsExternalStorageFileWidget::testStoringSeveralFiles()
395
412
396
413
// end second store
397
414
QgsTestExternalStorage::sCurrentStoredContent ->finish ();
398
- QCoreApplication::processEvents ();
399
415
400
416
QVERIFY ( useLink == w.mLinkLabel ->isVisible () );
401
417
QVERIFY ( useLink == w.mLinkEditButton ->isVisible () );
@@ -471,7 +487,6 @@ void TestQgsExternalStorageFileWidget::testStoringSeveralFilesError()
471
487
QVERIFY ( !messageBar.currentItem () );
472
488
473
489
QgsTestExternalStorage::sCurrentStoredContent ->finish ();
474
- QCoreApplication::processEvents ();
475
490
476
491
// second file is being stored
477
492
QVERIFY ( content1 );
@@ -495,7 +510,6 @@ void TestQgsExternalStorageFileWidget::testStoringSeveralFilesError()
495
510
496
511
// error while storing second file
497
512
QgsTestExternalStorage::sCurrentStoredContent ->error ();
498
- QCoreApplication::processEvents ();
499
513
500
514
QVERIFY ( useLink == w.mLinkLabel ->isVisible () );
501
515
QVERIFY ( useLink == w.mLinkEditButton ->isVisible () );
@@ -570,7 +584,6 @@ void TestQgsExternalStorageFileWidget::testStoringSeveralFilesCancel()
570
584
QVERIFY ( w.mLinkLabel ->text ().isEmpty () );
571
585
572
586
QgsTestExternalStorage::sCurrentStoredContent ->finish ();
573
- QCoreApplication::processEvents ();
574
587
575
588
// second file is being stored
576
589
QVERIFY ( content1 );
@@ -594,7 +607,6 @@ void TestQgsExternalStorageFileWidget::testStoringSeveralFilesCancel()
594
607
595
608
// cancel while storing second file
596
609
QgsTestExternalStorage::sCurrentStoredContent ->cancel ();
597
- QCoreApplication::processEvents ();
598
610
599
611
QVERIFY ( useLink == w.mLinkLabel ->isVisible () );
600
612
QVERIFY ( useLink == w.mLinkEditButton ->isVisible () );
@@ -765,7 +777,6 @@ void TestQgsExternalStorageFileWidget::testStoringDirectory()
765
777
QVERIFY ( w.mLinkLabel ->text ().isEmpty () );
766
778
767
779
QgsTestExternalStorage::sCurrentStoredContent ->finish ();
768
- QCoreApplication::processEvents ();
769
780
770
781
QVERIFY ( useLink == w.mLinkLabel ->isVisible () );
771
782
QVERIFY ( useLink == w.mLinkEditButton ->isVisible () );
0 commit comments