[cairo-commit] cairo-perl/t CairoSurface.t,1.17,1.18

Torsten Schoenfeld commit at pdx.freedesktop.org
Thu Nov 23 11:09:16 PST 2006


Committed by: tsch

Update of /cvs/cairo/cairo-perl/t
In directory kemper:/tmp/cvs-serv25129/t

Modified Files:
	CairoSurface.t 
Log Message:
	* CairoSurface.xs, t/CairoSurface.t: Make
	Cairo::ImageSurface::get_data usable by specifying the buffer
	length.

	* MANIFEST, Makefile.PL, doctypes: Describe our types.

	* NEWS: Merge from stable-1-0.


Index: CairoSurface.t
===================================================================
RCS file: /cvs/cairo/cairo-perl/t/CairoSurface.t,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- CairoSurface.t	9 Nov 2006 18:44:49 -0000	1.17
+++ CairoSurface.t	23 Nov 2006 19:09:12 -0000	1.18
@@ -9,7 +9,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 62;
+use Test::More tests => 64;
 
 use constant {
 	IMG_WIDTH => 256,
@@ -33,17 +33,29 @@
 is ($surf->get_width, IMG_WIDTH);
 is ($surf->get_height, IMG_HEIGHT);
 
-$surf = Cairo::ImageSurface->create_for_data ('Urgs!', 'rgb24',
-                                              IMG_WIDTH, IMG_HEIGHT, 23);
-isa_ok ($surf, 'Cairo::ImageSurface');
-isa_ok ($surf, 'Cairo::Surface');
+{
+	my $data = pack ('CCCC', 0, 0, 0, 0);
+	my $surf = Cairo::ImageSurface->create_for_data (
+	             $data, 'argb32', 1, 1, 4);
+	isa_ok ($surf, 'Cairo::ImageSurface');
+	isa_ok ($surf, 'Cairo::Surface');
 
-SKIP: {
-	skip 'new stuff', 2
-		unless Cairo::VERSION >= Cairo::VERSION_ENCODE (1, 2, 0);
+	SKIP: {
+		skip 'new stuff', 4
+			unless Cairo::VERSION >= Cairo::VERSION_ENCODE (1, 2, 0);
 
-	is ($surf->get_data, 'Urgs!');
-	is ($surf->get_stride, 23);
+		is ($surf->get_data, $data);
+		is ($surf->get_stride, 4);
+
+		# Change the image data and make sure $data gets updated accordingly.
+		my $cr = Cairo::Context->create ($surf);
+		$cr->set_source_rgba (1.0, 0, 0, 1.0);
+		$cr->rectangle (0, 0, 1, 1);
+		$cr->fill;
+
+		is ($surf->get_data, $data);
+		is ($surf->get_data, pack ('CCCC', 0, 0, 255, 255));
+	}
 }
 
 $surf = $surf->create_similar ('color', IMG_WIDTH, IMG_HEIGHT);
@@ -51,8 +63,10 @@
 isa_ok ($surf, 'Cairo::Surface');
 
 # Test that the enum wrappers differentiate between color and color-alpha.
-# Duh!
-{
+SKIP: {
+	skip 'content tests', 2
+		unless Cairo::VERSION >= Cairo::VERSION_ENCODE (1, 2, 0);
+
 	my $tmp = $surf->create_similar ('color-alpha', IMG_WIDTH, IMG_HEIGHT);
 	is ($tmp->get_content, 'color-alpha');
 	$tmp = $surf->create_similar ('color', IMG_WIDTH, IMG_HEIGHT);



More information about the cairo-commit mailing list