Add svgload_stream to the descriptors test

Seems to work!
This commit is contained in:
Kleis Auke Wolthuizen 2019-11-10 12:30:21 +01:00
parent 609fdb4fb6
commit 41c08b0ffb
6 changed files with 35 additions and 32 deletions

View File

@ -475,8 +475,7 @@ vips_foreign_load_svg_stream_is_a( VipsStreami *input )
{
ssize_t n;
if( vips_streami_unminimise( input ) ||
vips_streami_rewind( input ) )
if( vips_streami_rewind( input ) )
return( FALSE );
g_byte_array_set_size( input->sniff, SVG_HEADER_SIZE );

View File

@ -898,7 +898,6 @@ vips_streami_seek( VipsStreami *streami, gint64 offset, int whence )
vips_error( vips_stream_nick( VIPS_STREAM( streami ) ),
"%s", _( "bad 'whence'" ) );
return( -1 );
break;
}
}
else if( streami->is_pipe ) {
@ -926,7 +925,6 @@ vips_streami_seek( VipsStreami *streami, gint64 offset, int whence )
vips_error( vips_stream_nick( VIPS_STREAM( streami ) ),
"%s", _( "bad 'whence'" ) );
return( -1 );
break;
}
}
else {
@ -1029,8 +1027,7 @@ vips_streami_sniff( VipsStreami *streami, size_t length )
SANITY( streami );
if( vips_streami_unminimise( streami ) ||
vips_streami_rewind( streami ) )
if( vips_streami_rewind( streami ) )
return( NULL );
g_byte_array_set_size( streami->sniff, length );

View File

@ -78,7 +78,7 @@ vips_streamiw_get_property( GObject *object, guint prop_id,
{
VipsStreamiw *streamiw = VIPS_STREAMIW( object );
switch (prop_id) {
switch( prop_id ) {
case PROP_STREAM:
g_value_set_object( value, streamiw->streami );
break;
@ -89,11 +89,11 @@ vips_streamiw_get_property( GObject *object, guint prop_id,
static void
vips_streamiw_set_property( GObject *object, guint prop_id,
const GValue *value, GParamSpec *pspec)
const GValue *value, GParamSpec *pspec )
{
VipsStreamiw *streamiw = VIPS_STREAMIW( object );
switch (prop_id) {
switch( prop_id ) {
case PROP_STREAM:
streamiw->streami = g_value_dup_object( value );
break;
@ -125,9 +125,9 @@ vips_streamiw_tell( GSeekable *seekable )
pos = vips_streami_seek( streami, 0, SEEK_CUR );
if( pos == -1 )
return 0;
return( 0 );
return pos;
return( pos );
}
static gboolean
@ -135,22 +135,22 @@ vips_streamiw_can_seek( GSeekable *seekable )
{
VipsStreami *streami = VIPS_STREAMIW( seekable )->streami;
VIPS_DEBUG_MSG( "vips_streamiw_can_seek: %d\n", !streami->is_pipe);
VIPS_DEBUG_MSG( "vips_streamiw_can_seek: %d\n", !streami->is_pipe );
return !streami->is_pipe;
return( !streami->is_pipe );
}
static int
seek_type_to_lseek( GSeekType type )
{
switch (type) {
switch( type ) {
default:
case G_SEEK_CUR:
return SEEK_CUR;
return( SEEK_CUR );
case G_SEEK_SET:
return SEEK_SET;
return( SEEK_SET );
case G_SEEK_END:
return SEEK_END;
return( SEEK_END );
}
}
@ -206,7 +206,7 @@ vips_streamiw_read( GInputStream *stream, void *buffer, gsize count,
VIPS_DEBUG_MSG( "vips_streamiw_read: count: %zd\n", count );
if ( g_cancellable_set_error_if_cancelled( cancellable, error ) )
if( g_cancellable_set_error_if_cancelled( cancellable, error ) )
return( -1 );
if( (res = vips_streami_read( streami, buffer, count )) == -1 )
@ -234,14 +234,13 @@ vips_streamiw_skip( GInputStream *stream, gsize count,
return( -1 );
start = vips_streami_seek( streami, 0, SEEK_CUR );
if( start == -1 )
{
g_set_error( error, G_IO_ERROR,
G_IO_ERROR_FAILED,
_("Error while seeking: %s"),
vips_error_buffer() );
return -1;
return( -1 );
}
end = vips_streami_seek( streami, 0, SEEK_END );
@ -251,7 +250,7 @@ vips_streamiw_skip( GInputStream *stream, gsize count,
G_IO_ERROR_FAILED,
_("Error while seeking: %s"),
vips_error_buffer() );
return -1;
return( -1 );
}
if( end - start > count )
@ -264,7 +263,7 @@ vips_streamiw_skip( GInputStream *stream, gsize count,
G_IO_ERROR_FAILED,
_("Error while seeking: %s"),
vips_error_buffer() );
return -1;
return( -1 );
}
}
@ -311,7 +310,7 @@ vips_streamiw_class_init( VipsStreamiwClass *class )
_("Input"),
_("Stream to wrap"),
VIPS_TYPE_STREAMI, G_PARAM_CONSTRUCT_ONLY |
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS) );
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS ) );
}

View File

@ -44,7 +44,7 @@ class TestStream:
assert x.filename() == JPEG_FILE
@skip_if_no("jpegload")
@skip_if_no("jpegload_stream")
def test_image_new_from_stream_filename(self):
x = pyvips.Streami.new_from_filename(JPEG_FILE)
y = pyvips.Image.new_from_stream(x, "")
@ -58,7 +58,7 @@ class TestStream:
assert x.filename() == filename
@skip_if_no("jpegload")
@skip_if_no("jpegload_stream")
def test_image_write_to_stream_filename(self):
filename = temp_filename(self.tempdir, ".jpg")
x = pyvips.Streamo.new_to_filename(filename)
@ -75,7 +75,7 @@ class TestStream:
assert x.filename() == None
@skip_if_no("jpegload")
@skip_if_no("jpegload_stream")
def test_image_new_from_stream_memory(self):
data = self.colour.write_to_buffer(".jpg")
x = pyvips.Streami.new_from_memory(data)
@ -89,7 +89,7 @@ class TestStream:
assert x.filename() == None
@skip_if_no("jpegload")
@skip_if_no("jpegload_stream")
def test_image_write_to_stream_filename(self):
x = pyvips.Streamo.new_to_memory()
self.colour.write_to_stream(x, ".jpg")

View File

@ -31,6 +31,7 @@ count_files( const char *dirname )
int
main( int argc, char **argv )
{
VipsStreami *streami;
VipsImage *image, *x;
char fd_dir[256];
int n_files;
@ -56,7 +57,9 @@ main( int argc, char **argv )
/* Opening an image should read the header, then close the fd.
*/
printf( "** seq open ..\n" );
if( !(image = vips_image_new_from_file( argv[1],
if( !(streami = vips_streami_new_from_filename( argv[1] )) )
vips_error_exit( NULL );
if( !(image = vips_image_new_from_stream( streami, "",
"access", VIPS_ACCESS_SEQUENTIAL,
NULL )) )
vips_error_exit( NULL );
@ -92,6 +95,7 @@ main( int argc, char **argv )
*/
printf( "** unref ..\n" );
g_object_unref( image );
g_object_unref( streami );
printf( "** shutdown ..\n" );
vips_shutdown();

View File

@ -10,18 +10,22 @@ set -e
. ./variables.sh
if test_supported jpegload; then
if test_supported jpegload_stream; then
./test_descriptors $image
fi
if test_supported pngload; then
if test_supported pngload_stream; then
./test_descriptors $test_images/sample.png
fi
if test_supported tiffload; then
if test_supported tiffload_stream; then
./test_descriptors $test_images/sample.tif
fi
if test_supported radload; then
if test_supported radload_stream; then
./test_descriptors $test_images/sample.hdr
fi
if test_supported svgload_stream; then
./test_descriptors $test_images/logo.svg
fi