@@ -1289,59 +1289,89 @@ public void testSuffix() {
1289
1289
}
1290
1290
1291
1291
@ Test
1292
- public void testDownloadShown () throws Exception {
1293
- // Verify that, whenever a single download is running in loading face , it is shown in the status
1294
- // bar.
1292
+ public void testDownloadShown_duringLoading () throws Exception {
1293
+ // Verify that, whenever a single download is running in loading phase , it is shown in the
1294
+ // status bar.
1295
1295
ManualClock clock = new ManualClock ();
1296
- clock .advanceMillis ( TimeUnit . SECONDS . toMillis (1234 ));
1297
- UiStateTracker stateTracker = getUiStateTracker (clock , /*targetWidth=*/ 80 );
1296
+ clock .advance ( Duration . ofSeconds (1234 ));
1297
+ UiStateTracker stateTracker = getUiStateTracker (clock , /* targetWidth= */ 80 );
1298
1298
1299
1299
URL url = new URL ("http://example.org/first/dep" );
1300
1300
1301
1301
stateTracker .buildStarted ();
1302
1302
stateTracker .downloadProgress (new DownloadProgressEvent (url ));
1303
- clock .advanceMillis ( TimeUnit . SECONDS . toMillis (6 ));
1303
+ clock .advance ( Duration . ofSeconds (6 ));
1304
1304
1305
- LoggingTerminalWriter terminalWriter = new LoggingTerminalWriter (/*discardHighlight=*/ true );
1305
+ LoggingTerminalWriter terminalWriter = new LoggingTerminalWriter (/* discardHighlight= */ true );
1306
1306
stateTracker .writeProgressBar (terminalWriter );
1307
1307
String output = terminalWriter .getTranscript ();
1308
1308
1309
- assertWithMessage ("Progress bar should contain '" + url .toString () + "', but was:\n " + output )
1310
- .that (output .contains (url .toString ()))
1311
- .isTrue ();
1312
- assertWithMessage ("Progress bar should contain '6s', but was:\n " + output )
1313
- .that (output .contains ("6s" ))
1314
- .isTrue ();
1309
+ assertThat (output ).contains (url .toString ());
1310
+ assertThat (output ).contains ("6s" );
1315
1311
1316
1312
// Progress on the pending download should be reported appropriately
1317
- clock .advanceMillis ( TimeUnit . SECONDS . toMillis (1 ));
1313
+ clock .advance ( Duration . ofSeconds (1 ));
1318
1314
stateTracker .downloadProgress (new DownloadProgressEvent (url , 256 ));
1319
1315
1320
- terminalWriter = new LoggingTerminalWriter (/*discardHighlight=*/ true );
1316
+ terminalWriter = new LoggingTerminalWriter (/* discardHighlight= */ true );
1321
1317
stateTracker .writeProgressBar (terminalWriter );
1322
1318
output = terminalWriter .getTranscript ();
1323
1319
1324
- assertWithMessage ("Progress bar should contain '" + url .toString () + "', but was:\n " + output )
1325
- .that (output .contains (url .toString ()))
1326
- .isTrue ();
1327
- assertWithMessage ("Progress bar should contain '7s', but was:\n " + output )
1328
- .that (output .contains ("7s" ))
1329
- .isTrue ();
1330
- assertWithMessage ("Progress bar should contain '256', but was:\n " + output )
1331
- .that (output .contains ("256" ))
1332
- .isTrue ();
1320
+ assertThat (output ).contains (url .toString ());
1321
+ assertThat (output ).contains ("7s" );
1322
+ assertThat (output ).contains ("256" );
1333
1323
1334
1324
// After finishing the download, it should no longer be reported.
1335
- clock .advanceMillis ( TimeUnit . SECONDS . toMillis (1 ));
1325
+ clock .advance ( Duration . ofSeconds (1 ));
1336
1326
stateTracker .downloadProgress (new DownloadProgressEvent (url , 256 , true ));
1337
1327
1338
- terminalWriter = new LoggingTerminalWriter (/*discardHighlight=*/ true );
1328
+ terminalWriter = new LoggingTerminalWriter (/* discardHighlight= */ true );
1339
1329
stateTracker .writeProgressBar (terminalWriter );
1340
1330
output = terminalWriter .getTranscript ();
1341
1331
1342
- assertWithMessage ("Progress bar should not contain url, but was:\n " + output )
1343
- .that (output .contains ("example.org" ))
1344
- .isFalse ();
1332
+ assertThat (output ).doesNotContain ("example.org" );
1333
+ }
1334
+
1335
+ @ Test
1336
+ public void testDownloadShown_duringMainRepoMappingComputation () throws Exception {
1337
+ ManualClock clock = new ManualClock ();
1338
+ clock .advance (Duration .ofSeconds (1234 ));
1339
+ UiStateTracker stateTracker = getUiStateTracker (clock , /* targetWidth= */ 80 );
1340
+
1341
+ URL url = new URL ("http://example.org/first/dep" );
1342
+
1343
+ stateTracker .mainRepoMappingComputationStarted ();
1344
+ stateTracker .downloadProgress (new DownloadProgressEvent (url ));
1345
+ clock .advance (Duration .ofSeconds (6 ));
1346
+
1347
+ LoggingTerminalWriter terminalWriter = new LoggingTerminalWriter (/* discardHighlight= */ true );
1348
+ stateTracker .writeProgressBar (terminalWriter );
1349
+ String output = terminalWriter .getTranscript ();
1350
+
1351
+ assertThat (output ).contains (url .toString ());
1352
+ assertThat (output ).contains ("6s" );
1353
+
1354
+ // Progress on the pending download should be reported appropriately
1355
+ clock .advance (Duration .ofSeconds (1 ));
1356
+ stateTracker .downloadProgress (new DownloadProgressEvent (url , 256 ));
1357
+
1358
+ terminalWriter = new LoggingTerminalWriter (/* discardHighlight= */ true );
1359
+ stateTracker .writeProgressBar (terminalWriter );
1360
+ output = terminalWriter .getTranscript ();
1361
+
1362
+ assertThat (output ).contains (url .toString ());
1363
+ assertThat (output ).contains ("7s" );
1364
+ assertThat (output ).contains ("256" );
1365
+
1366
+ // After finishing the download, it should no longer be reported.
1367
+ clock .advance (Duration .ofSeconds (1 ));
1368
+ stateTracker .downloadProgress (new DownloadProgressEvent (url , 256 , true ));
1369
+
1370
+ terminalWriter = new LoggingTerminalWriter (/* discardHighlight= */ true );
1371
+ stateTracker .writeProgressBar (terminalWriter );
1372
+ output = terminalWriter .getTranscript ();
1373
+
1374
+ assertThat (output ).doesNotContain ("example.org" );
1345
1375
}
1346
1376
1347
1377
@ Test
@@ -1350,7 +1380,7 @@ public void testDownloadOutputLength() throws Exception {
1350
1380
// Also verify that the length is respected, even if only a download sample is shown.
1351
1381
ManualClock clock = new ManualClock ();
1352
1382
clock .advanceMillis (TimeUnit .SECONDS .toMillis (1234 ));
1353
- UiStateTracker stateTracker = getUiStateTracker (clock , /*targetWidth=*/ 60 );
1383
+ UiStateTracker stateTracker = getUiStateTracker (clock , /* targetWidth= */ 60 );
1354
1384
URL url = new URL ("http://example.org/some/really/very/very/long/path/filename.tar.gz" );
1355
1385
1356
1386
stateTracker .buildStarted ();
0 commit comments