diff options
Diffstat (limited to 'test/jfif')
l--------- | test/jfif/Dimensions.vala | 1 | ||||
l--------- | test/jfif/GdkSupport.vala | 1 | ||||
-rw-r--r-- | test/jfif/JfifSupport-Test.vala | 44 | ||||
l--------- | test/jfif/JfifSupport.vala | 1 | ||||
l--------- | test/jfif/PhotoFileAdapter.vala | 1 | ||||
-rw-r--r-- | test/jfif/PhotoFileFormat-jfifstub.vala | 95 | ||||
l--------- | test/jfif/PhotoFileSniffer.vala | 1 | ||||
-rw-r--r-- | test/jfif/PhotoMetadata-stub.vala | 8 | ||||
-rw-r--r-- | test/jfif/ProgressMonitor-stub.vala | 2 | ||||
l--------- | test/jfif/file.vala | 1 | ||||
l--------- | test/jfif/string.vala | 1 | ||||
-rw-r--r-- | test/jfif/util_core-stub.vala | 1 | ||||
-rw-r--r-- | test/jfif/util_image-stub.vala | 2 |
13 files changed, 159 insertions, 0 deletions
diff --git a/test/jfif/Dimensions.vala b/test/jfif/Dimensions.vala new file mode 120000 index 0000000..741567a --- /dev/null +++ b/test/jfif/Dimensions.vala @@ -0,0 +1 @@ +../../src/Dimensions.vala
\ No newline at end of file diff --git a/test/jfif/GdkSupport.vala b/test/jfif/GdkSupport.vala new file mode 120000 index 0000000..17a8df5 --- /dev/null +++ b/test/jfif/GdkSupport.vala @@ -0,0 +1 @@ +../../src/photos/GdkSupport.vala
\ No newline at end of file diff --git a/test/jfif/JfifSupport-Test.vala b/test/jfif/JfifSupport-Test.vala new file mode 100644 index 0000000..0fe94b5 --- /dev/null +++ b/test/jfif/JfifSupport-Test.vala @@ -0,0 +1,44 @@ +// SPDX-License-Identifier: LGPLv2.1-or-later + +[CCode (cname="TEST_DATA_DIR")] +extern const string TEST_DATA_DIR; + +void add_jfif_sof_tests () { + Test.add_func ("/unit/photos/jfif/is_sof", () => { + Jpeg.Marker m = (Jpeg.Marker)0x8f; + assert(! m.is_sof()); + m = (Jpeg.Marker)0xc0; + assert(m.is_sof()); + m = (Jpeg.Marker)0xc4; + assert(! m.is_sof()); + m = (Jpeg.Marker)0xe0; + assert(! m.is_sof()); + }); +} + +void add_jfif_sniff_fast_tests () { + Test.add_func ("/functional/photos/jfif/sniff_fast", () => { + File f = File.new_for_path(TEST_DATA_DIR + "/shotwell-street.jpg"); + JfifSniffer s = new JfifSniffer(f, PhotoFileSniffer.Options.NO_MD5); + bool is_corrupted = false; + try { + DetectedPhotoInformation detected = s.sniff(out is_corrupted); + assert(!is_corrupted); + assert(detected.channels == 3); + assert(detected.bits_per_channel == 8); + assert(detected.format_name == "jpeg"); + assert(detected.image_dim.width == 360); + assert(detected.image_dim.height == 236); + } catch (Error err) { + assert_not_reached(); + } + }); +} + +void main (string[] args) { + Test.init (ref args); + add_jfif_sof_tests(); + add_jfif_sniff_fast_tests(); + Test.run(); +} + diff --git a/test/jfif/JfifSupport.vala b/test/jfif/JfifSupport.vala new file mode 120000 index 0000000..17fb7cf --- /dev/null +++ b/test/jfif/JfifSupport.vala @@ -0,0 +1 @@ +../../src/photos/JfifSupport.vala
\ No newline at end of file diff --git a/test/jfif/PhotoFileAdapter.vala b/test/jfif/PhotoFileAdapter.vala new file mode 120000 index 0000000..042870d --- /dev/null +++ b/test/jfif/PhotoFileAdapter.vala @@ -0,0 +1 @@ +../../src/photos/PhotoFileAdapter.vala
\ No newline at end of file diff --git a/test/jfif/PhotoFileFormat-jfifstub.vala b/test/jfif/PhotoFileFormat-jfifstub.vala new file mode 100644 index 0000000..db6b4a9 --- /dev/null +++ b/test/jfif/PhotoFileFormat-jfifstub.vala @@ -0,0 +1,95 @@ +// stub for JFIF support test + +public enum PhotoFileFormat { + JFIF, + UNKNOWN; + + public static PhotoFileFormat[] get_supported() { return { JFIF }; } + + public static PhotoFileFormat from_pixbuf_name(string name) { + if (name == "jpeg") { + return PhotoFileFormat.JFIF; + } else { + return PhotoFileFormat.UNKNOWN; + } + } + + public void init() { JfifFileFormatDriver.init(); } + + public PhotoFileFormatDriver get_driver() { + return JfifFileFormatDriver.get_instance(); + } + + public PhotoFileReader create_reader(string filepath) { + return get_driver().create_reader(filepath); + } + + public PhotoFileWriter create_writer(string filepath) throws PhotoFormatError { + PhotoFileWriter writer = get_driver().create_writer(filepath); + return writer; + } + + public PhotoFileMetadataWriter create_metadata_writer(string filepath) throws PhotoFormatError { + PhotoFileMetadataWriter writer = get_driver().create_metadata_writer(filepath); + return writer; + } + + public PhotoFileSniffer create_sniffer(File file, PhotoFileSniffer.Options options) { + return get_driver().create_sniffer(file, options); + } +} + +public errordomain PhotoFormatError { + READ_ONLY +} + +public abstract class PhotoFileFormatDriver { + public abstract PhotoFileFormatProperties get_properties(); + + public abstract PhotoFileReader create_reader(string filepath); + + public abstract PhotoMetadata create_metadata(); + + public abstract bool can_write_image(); + + public abstract bool can_write_metadata(); + + public abstract PhotoFileWriter? create_writer(string filepath); + + public abstract PhotoFileMetadataWriter? create_metadata_writer(string filepath); + + public abstract PhotoFileSniffer create_sniffer(File file, PhotoFileSniffer.Options options); +} + +public enum PhotoFileFormatFlags { + NONE = 0x00000000, +} + +public abstract class PhotoFileFormatProperties { + public abstract PhotoFileFormat get_file_format(); + + public abstract PhotoFileFormatFlags get_flags(); + + public virtual bool is_recognized_extension(string ext) { + return is_in_ci_array(ext, get_known_extensions()); + } + + public abstract string get_default_extension(); + + public abstract string[] get_known_extensions(); + + public abstract string get_default_mime_type(); + + public abstract string[] get_mime_types(); + + public abstract string get_user_visible_name(); + + public File convert_file_extension(File file) { + string name, ext; + disassemble_filename(file.get_basename(), out name, out ext); + if (ext != null && is_recognized_extension(ext)) + return file; + + return file.get_parent().get_child("%s.%s".printf(name, get_default_extension())); + } +} diff --git a/test/jfif/PhotoFileSniffer.vala b/test/jfif/PhotoFileSniffer.vala new file mode 120000 index 0000000..d64385c --- /dev/null +++ b/test/jfif/PhotoFileSniffer.vala @@ -0,0 +1 @@ +../../src/photos/PhotoFileSniffer.vala
\ No newline at end of file diff --git a/test/jfif/PhotoMetadata-stub.vala b/test/jfif/PhotoMetadata-stub.vala new file mode 100644 index 0000000..2d5b364 --- /dev/null +++ b/test/jfif/PhotoMetadata-stub.vala @@ -0,0 +1,8 @@ +// stub class for photo metadata needed by the JFIF Support test +public class PhotoMetadata { + public PhotoMetadata() { } + public void read_from_file(File file) throws Error { } + public void write_to_file(File file) throws Error { } + public string? exif_hash() { return null; } + public string? thumbnail_hash() { return null; } +} diff --git a/test/jfif/ProgressMonitor-stub.vala b/test/jfif/ProgressMonitor-stub.vala new file mode 100644 index 0000000..9290ad1 --- /dev/null +++ b/test/jfif/ProgressMonitor-stub.vala @@ -0,0 +1,2 @@ +// Needed to include util/file.vala without core/util.vala as well +public delegate bool ProgressMonitor(uint64 current, uint64 total, bool do_event_loop = true); diff --git a/test/jfif/file.vala b/test/jfif/file.vala new file mode 120000 index 0000000..c0f398e --- /dev/null +++ b/test/jfif/file.vala @@ -0,0 +1 @@ +../../src/util/file.vala
\ No newline at end of file diff --git a/test/jfif/string.vala b/test/jfif/string.vala new file mode 120000 index 0000000..39f7f39 --- /dev/null +++ b/test/jfif/string.vala @@ -0,0 +1 @@ +../../src/util/string.vala
\ No newline at end of file diff --git a/test/jfif/util_core-stub.vala b/test/jfif/util_core-stub.vala new file mode 100644 index 0000000..6af313b --- /dev/null +++ b/test/jfif/util_core-stub.vala @@ -0,0 +1 @@ +public DateTime? coarsify_date_time(DateTime? dt) { return dt; } diff --git a/test/jfif/util_image-stub.vala b/test/jfif/util_image-stub.vala new file mode 100644 index 0000000..45ebe40 --- /dev/null +++ b/test/jfif/util_image-stub.vala @@ -0,0 +1,2 @@ +Gdk.Pixbuf resize_pixbuf(Gdk.Pixbuf pixbuf, Dimensions resized, Gdk.InterpType interp) { return pixbuf; } +Gdk.Pixbuf scale_pixbuf(Gdk.Pixbuf pixbuf, int scale, Gdk.InterpType interp, bool scale_up) { return pixbuf; } |