From d0aaad443a88968dc61172c050084d3d9faa7602 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Sat, 12 Aug 2023 10:07:35 +0200 Subject: New upstream version 0.32.2 --- test/jfif/Dimensions.vala | 1 + test/jfif/GdkSupport.vala | 1 + test/jfif/JfifSupport-Test.vala | 44 +++++++++++++++ test/jfif/JfifSupport.vala | 1 + test/jfif/PhotoFileAdapter.vala | 1 + test/jfif/PhotoFileFormat-jfifstub.vala | 95 +++++++++++++++++++++++++++++++++ test/jfif/PhotoFileSniffer.vala | 1 + test/jfif/PhotoMetadata-stub.vala | 8 +++ test/jfif/ProgressMonitor-stub.vala | 2 + test/jfif/file.vala | 1 + test/jfif/string.vala | 1 + test/jfif/util_core-stub.vala | 1 + test/jfif/util_image-stub.vala | 2 + test/meson.build | 20 +++++++ test/shotwell-street.jpg | 1 + 15 files changed, 180 insertions(+) create mode 120000 test/jfif/Dimensions.vala create mode 120000 test/jfif/GdkSupport.vala create mode 100644 test/jfif/JfifSupport-Test.vala create mode 120000 test/jfif/JfifSupport.vala create mode 120000 test/jfif/PhotoFileAdapter.vala create mode 100644 test/jfif/PhotoFileFormat-jfifstub.vala create mode 120000 test/jfif/PhotoFileSniffer.vala create mode 100644 test/jfif/PhotoMetadata-stub.vala create mode 100644 test/jfif/ProgressMonitor-stub.vala create mode 120000 test/jfif/file.vala create mode 120000 test/jfif/string.vala create mode 100644 test/jfif/util_core-stub.vala create mode 100644 test/jfif/util_image-stub.vala create mode 120000 test/shotwell-street.jpg (limited to 'test') 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; } diff --git a/test/meson.build b/test/meson.build index de1f012..5319cfc 100644 --- a/test/meson.build +++ b/test/meson.build @@ -2,4 +2,24 @@ natural_collate_test = executable('natural-collate-test', ['NaturalCollate-Test.vala', 'NaturalCollate.vala'], dependencies : gio) +jfif_support_test = executable('jfif-support-test', + ['jfif/JfifSupport-Test.vala', + 'jfif/PhotoFileSniffer.vala', + 'jfif/PhotoFileAdapter.vala', + 'jfif/JfifSupport.vala', + 'jfif/GdkSupport.vala', + 'jfif/Dimensions.vala', + 'jfif/string.vala', + 'jfif/file.vala', + 'jfif/util_core-stub.vala', + 'jfif/ProgressMonitor-stub.vala', + 'jfif/PhotoMetadata-stub.vala', + 'jfif/PhotoFileFormat-jfifstub.vala', + 'jfif/util_image-stub.vala'], + dependencies : [gio, gee, gtk, gexiv2, math], + c_args : ['-DTEST_DATA_DIR="@0@"'.format(meson.current_source_dir())] + ) + + test('natural-collate', natural_collate_test) +test('jfif-support', jfif_support_test) diff --git a/test/shotwell-street.jpg b/test/shotwell-street.jpg new file mode 120000 index 0000000..02e2438 --- /dev/null +++ b/test/shotwell-street.jpg @@ -0,0 +1 @@ +../data/icons/shotwell-street.jpg \ No newline at end of file -- cgit v1.2.3