Skip to content

Commit c968047

Browse files
committed
Add unsupported image file format loading test.
1 parent b374bea commit c968047

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

src/main/java/com/github/mfl28/boundingboxeditor/model/data/ImageMetaData.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public class ImageMetaData {
3636
private static final List<String> supportedImageFormats = List.of("jpeg", "bmp", "png");
3737
private static final String NOT_AN_IMAGE_FILE_ERROR_MESSAGE = "Not an image file.";
3838
private static final String UNSUPPORTED_IMAGE_FORMAT_ERROR_MESSAGE = "Unsupported image file format.";
39-
private static final String INVALID_OR_UNSUPPORTED_IMAGE_ERROR_MESSAGE = "Invalid or unsupported image file.";
39+
private static final String INVALID_IMAGE_FILE_ERROR_MESSAGE = "Invalid image file.";
4040
private final String fileName;
4141
private ImageMetaDataDetails details;
4242

@@ -171,7 +171,7 @@ private static ImageDimensions readImageDimensionsFromFile(File imageFile) throw
171171
reader.dispose();
172172
}
173173
} else {
174-
throw new UnsupportedImageFileException(INVALID_OR_UNSUPPORTED_IMAGE_ERROR_MESSAGE);
174+
throw new UnsupportedImageFileException(INVALID_IMAGE_FILE_ERROR_MESSAGE);
175175
}
176176
}
177177

src/test/java/com/github/mfl28/boundingboxeditor/ui/BoundingBoxDrawingTests.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ void onOpeningNewImageFolder_WhenBoundingBoxesExist_ShouldResetCorrectly(FxRobot
183183
final Stage errorReportStage = timeOutGetTopModalStage(robot, "Image loading error report", testinfo);
184184
verifyThat(errorReportStage, Matchers.notNullValue(), saveScreenshot(testinfo));
185185

186-
final String errorReportDialogContentReferenceText = "1 image file could not be loaded.";
186+
final String errorReportDialogContentReferenceText = "2 image files could not be loaded.";
187187
final DialogPane errorReportDialog = (DialogPane) errorReportStage.getScene().getRoot();
188188
verifyThat(errorReportDialog.getContentText(), Matchers.equalTo(errorReportDialogContentReferenceText),
189189
saveScreenshot(testinfo));
@@ -202,12 +202,15 @@ void onOpeningNewImageFolder_WhenBoundingBoxesExist_ShouldResetCorrectly(FxRobot
202202

203203
final List<IOErrorInfoEntry> errorInfoEntries = errorInfoTable.getItems();
204204

205-
verifyThat(errorInfoEntries, Matchers.hasSize(1), saveScreenshot(testinfo));
205+
verifyThat(errorInfoEntries, Matchers.hasSize(2), saveScreenshot(testinfo));
206206

207-
final IOErrorInfoEntry referenceErrorInfoEntry1 = new IOErrorInfoEntry("no_image_file.txt",
208-
"Invalid or unsupported image file.");
207+
final IOErrorInfoEntry referenceErrorInfoEntry1 = new IOErrorInfoEntry("cameraman.tif",
208+
"Unsupported image file format.");
209+
final IOErrorInfoEntry referenceErrorInfoEntry2 = new IOErrorInfoEntry("no_image_file.txt",
210+
"Invalid image file.");
209211

210-
verifyThat(errorInfoEntries, Matchers.contains(referenceErrorInfoEntry1), saveScreenshot(testinfo));
212+
verifyThat(errorInfoEntries, Matchers.contains(referenceErrorInfoEntry1, referenceErrorInfoEntry2),
213+
saveScreenshot(testinfo));
211214

212215
timeOutClickOnButtonInDialogStage(robot, errorReportStage, ButtonType.OK, testinfo);
213216
WaitForAsyncUtils.waitForFxEvents();
63.7 KB
Binary file not shown.

0 commit comments

Comments
 (0)