Browse Source

Added corrupted edge case

flabbet 4 years ago
parent
commit
f8fbd50368

+ 5 - 0
PixiEditor/Models/IO/Importer.cs

@@ -1,4 +1,5 @@
 using System;
+using System.IO;
 using System.Runtime.Serialization;
 using System.Windows.Media.Imaging;
 using PixiEditor.Exceptions;
@@ -47,6 +48,10 @@ namespace PixiEditor.Models.IO
             {
                 throw new CorruptedFileException();
             }
+            catch (FileFormatException)
+            {
+                throw new CorruptedFileException();
+            }
         }
 
         public static Document ImportDocument(string path)

+ 4 - 0
PixiEditor/ViewModels/ImportFilePopupViewModel.cs

@@ -145,6 +145,10 @@ namespace PixiEditor.ViewModels
                 {
                     throw new CorruptedFileException();
                 }
+                catch (FileFormatException)
+                {
+                    throw new CorruptedFileException();
+                }
             }
         }
 

BIN
PixiEditorTests/ModelsTests/IO/CorruptedPNG2.png


+ 1 - 0
PixiEditorTests/ModelsTests/IO/ImporterTests.cs

@@ -54,6 +54,7 @@ namespace PixiEditorTests.ModelsTests.IO
 
         [Theory]
         [InlineData("CorruptedPNG.png")]
+        [InlineData("CorruptedPNG2.png")]
         [InlineData("CorruptedJpg.jpg")]
         public void TestThatImporterThrowsCorruptedFileExceptionOnWrongImageFileWithSupportedExtension(string fileName)
         {