Skip to content

Commit

Permalink
Remainder of functional api tests for cairocontext
Browse files Browse the repository at this point in the history
  • Loading branch information
auroraeosrose committed Jul 5, 2009
1 parent 2d7bcf8 commit f6f4bbd
Show file tree
Hide file tree
Showing 15 changed files with 268 additions and 19 deletions.
8 changes: 5 additions & 3 deletions cairo_context.c
Expand Up @@ -571,9 +571,11 @@ PHP_FUNCTION(cairo_set_source_surface)
cairo_set_source_surface(context_object->context, surface_object->surface, x, y);
PHP_CAIRO_ERROR(cairo_status(context_object->context));

/* we need to be able to get this zval out later, so ref and store
context_object->surface = surface_zval;
Z_ADDREF_P(surface_zval);*/
/* If there's already a pattern, then we deref and remove it because we just overwrote it */
if(context_object->pattern) {
Z_DELREF_P(context_object->pattern);
context_object->pattern = NULL;
}
}
/* }}} */

Expand Down
18 changes: 17 additions & 1 deletion tests/CairoContext/cairo_clip.phpt
Expand Up @@ -14,12 +14,28 @@ var_dump($context);

cairo_clip($context);

// bad type hint is an E_RECOVERABLE_ERROR, so let's hook a handler
function bad_class($errno, $errstr) {
echo 'CAUGHT ERROR: ' . $errstr, PHP_EOL;
}
set_error_handler('bad_class', E_RECOVERABLE_ERROR);

// check number of args - should accept ONLY 1
cairo_clip();
cairo_clip($context, 1);

// check arg types, should be CairoContext
cairo_clip(1);
?>
--EXPECTF--
object(CairoImageSurface)#%d (0) {
}
object(CairoContext)#%d (0) {
}

Warning: cairo_clip() expects exactly 1 parameter, 0 given in %s on line %d
Warning: cairo_clip() expects exactly 1 parameter, 0 given in %s on line %d

Warning: cairo_clip() expects exactly 1 parameter, 2 given in %s on line %d
CAUGHT ERROR: Argument 1 passed to cairo_clip() must be an instance of CairoContext, integer given

Warning: cairo_clip() expects parameter 1 to be CairoContext, integer given in %s on line %d
19 changes: 18 additions & 1 deletion tests/CairoContext/cairo_clip_extents.phpt
Expand Up @@ -13,7 +13,19 @@ $context = cairo_create($surface);
var_dump($context);

var_dump(cairo_clip_extents($context));

// bad type hint is an E_RECOVERABLE_ERROR, so let's hook a handler
function bad_class($errno, $errstr) {
echo 'CAUGHT ERROR: ' . $errstr, PHP_EOL;
}
set_error_handler('bad_class', E_RECOVERABLE_ERROR);

// check number of args - should accept ONLY 1
cairo_clip_extents();
cairo_clip_extents($context, 1);

// check arg types, should be CairoContext
cairo_clip_extents(1);
?>
--EXPECTF--
object(CairoImageSurface)#%d (0) {
Expand All @@ -31,4 +43,9 @@ array(4) {
float(50)
}

Warning: cairo_clip_extents() expects exactly 1 parameter, 0 given in %s on line %d
Warning: cairo_clip_extents() expects exactly 1 parameter, 0 given in %s on line %d

Warning: cairo_clip_extents() expects exactly 1 parameter, 2 given in %s on line %d
CAUGHT ERROR: Argument 1 passed to cairo_clip_extents() must be an instance of CairoContext, integer given

Warning: cairo_clip_extents() expects parameter 1 to be CairoContext, integer given in %s on line %d
19 changes: 18 additions & 1 deletion tests/CairoContext/cairo_clip_preserve.phpt
Expand Up @@ -13,12 +13,29 @@ $context = cairo_create($surface);
var_dump($context);

cairo_clip_preserve($context);

// bad type hint is an E_RECOVERABLE_ERROR, so let's hook a handler
function bad_class($errno, $errstr) {
echo 'CAUGHT ERROR: ' . $errstr, PHP_EOL;
}
set_error_handler('bad_class', E_RECOVERABLE_ERROR);

// check number of args - should accept ONLY 1
cairo_clip_preserve();
cairo_clip_preserve($context, 1);

// check arg types, should be CairoContext
cairo_clip_preserve(1);
?>
--EXPECTF--
object(CairoImageSurface)#%d (0) {
}
object(CairoContext)#%d (0) {
}

Warning: cairo_clip_preserve() expects exactly 1 parameter, 0 given in %s on line %d
Warning: cairo_clip_preserve() expects exactly 1 parameter, 0 given in %s on line %d

Warning: cairo_clip_preserve() expects exactly 1 parameter, 2 given in %s on line %d
CAUGHT ERROR: Argument 1 passed to cairo_clip_preserve() must be an instance of CairoContext, integer given

Warning: cairo_clip_preserve() expects parameter 1 to be CairoContext, integer given in %s on line %d
19 changes: 18 additions & 1 deletion tests/CairoContext/cairo_clip_rectangle_list.phpt
Expand Up @@ -13,7 +13,19 @@ $context = cairo_create($surface);
var_dump($context);

var_dump(cairo_clip_rectangle_list($context));

// bad type hint is an E_RECOVERABLE_ERROR, so let's hook a handler
function bad_class($errno, $errstr) {
echo 'CAUGHT ERROR: ' . $errstr, PHP_EOL;
}
set_error_handler('bad_class', E_RECOVERABLE_ERROR);

// check number of args - should accept ONLY 1
cairo_clip_rectangle_list();
cairo_clip_rectangle_list($context, 1);

// check arg types, should be CairoContext
cairo_clip_rectangle_list(1);
?>
--EXPECTF--
object(CairoImageSurface)#%d (0) {
Expand All @@ -34,4 +46,9 @@ array(1) {
}
}

Warning: cairo_clip_rectangle_list() expects exactly 1 parameter, 0 given in %s on line %d
Warning: cairo_clip_rectangle_list() expects exactly 1 parameter, 0 given in %s on line %d

Warning: cairo_clip_rectangle_list() expects exactly 1 parameter, 2 given in %s on line %d
CAUGHT ERROR: Argument 1 passed to cairo_clip_rectangle_list() must be an instance of CairoContext, integer given

Warning: cairo_clip_rectangle_list() expects parameter 1 to be CairoContext, integer given in %s on line %d
2 changes: 2 additions & 0 deletions tests/CairoContext/cairo_copy_page.phpt
Expand Up @@ -12,6 +12,8 @@ var_dump($surface);
$context = cairo_create($surface);
var_dump($context);

cairo_copy_page($context);

// bad type hint is an E_RECOVERABLE_ERROR, so let's hook a handler
function bad_class($errno, $errstr) {
echo 'CAUGHT ERROR: ' . $errstr, PHP_EOL;
Expand Down
22 changes: 21 additions & 1 deletion tests/CairoContext/cairo_fill.phpt
Expand Up @@ -13,9 +13,29 @@ $context = cairo_create($surface);
var_dump($context);

cairo_fill($context);

// bad type hint is an E_RECOVERABLE_ERROR, so let's hook a handler
function bad_class($errno, $errstr) {
echo 'CAUGHT ERROR: ' . $errstr, PHP_EOL;
}
set_error_handler('bad_class', E_RECOVERABLE_ERROR);

// check number of args - should accept ONLY 1
cairo_fill();
cairo_fill($context, 1);

// check arg types, should be CairoContext
cairo_fill(1);
?>
--EXPECTF--
object(CairoImageSurface)#%d (0) {
}
object(CairoContext)#%d (0) {
}
}

Warning: cairo_fill() expects exactly 1 parameter, 0 given in %s on line %d

Warning: cairo_fill() expects exactly 1 parameter, 2 given in %s on line %d
CAUGHT ERROR: Argument 1 passed to cairo_fill() must be an instance of CairoContext, integer given

Warning: cairo_fill() expects parameter 1 to be CairoContext, integer given in %s on line %d
22 changes: 21 additions & 1 deletion tests/CairoContext/cairo_fill_extents.phpt
Expand Up @@ -13,6 +13,19 @@ $context = cairo_create($surface);
var_dump($context);

var_dump(cairo_fill_extents($context));

// bad type hint is an E_RECOVERABLE_ERROR, so let's hook a handler
function bad_class($errno, $errstr) {
echo 'CAUGHT ERROR: ' . $errstr, PHP_EOL;
}
set_error_handler('bad_class', E_RECOVERABLE_ERROR);

// check number of args - should accept ONLY 1
cairo_fill_extents();
cairo_fill_extents($context, 1);

// check arg types, should be CairoContext
cairo_fill_extents(1);
?>
--EXPECTF--
object(CairoImageSurface)#%d (0) {
Expand All @@ -28,4 +41,11 @@ array(4) {
float(0)
[3]=>
float(0)
}
}

Warning: cairo_fill_extents() expects exactly 1 parameter, 0 given in %s on line %d

Warning: cairo_fill_extents() expects exactly 1 parameter, 2 given in %s on line %d
CAUGHT ERROR: Argument 1 passed to cairo_fill_extents() must be an instance of CairoContext, integer given

Warning: cairo_fill_extents() expects parameter 1 to be CairoContext, integer given in %s on line %d
22 changes: 21 additions & 1 deletion tests/CairoContext/cairo_fill_preserve.phpt
Expand Up @@ -13,9 +13,29 @@ $context = cairo_create($surface);
var_dump($context);

cairo_fill_preserve($context);

// bad type hint is an E_RECOVERABLE_ERROR, so let's hook a handler
function bad_class($errno, $errstr) {
echo 'CAUGHT ERROR: ' . $errstr, PHP_EOL;
}
set_error_handler('bad_class', E_RECOVERABLE_ERROR);

// check number of args - should accept ONLY 1
cairo_fill_preserve();
cairo_fill_preserve($context, 1);

// check arg types, should be CairoContext
cairo_fill_preserve(1);
?>
--EXPECTF--
object(CairoImageSurface)#%d (0) {
}
object(CairoContext)#%d (0) {
}
}

Warning: cairo_fill_preserve() expects exactly 1 parameter, 0 given in %s on line %d

Warning: cairo_fill_preserve() expects exactly 1 parameter, 2 given in %s on line %d
CAUGHT ERROR: Argument 1 passed to cairo_fill_preserve() must be an instance of CairoContext, integer given

Warning: cairo_fill_preserve() expects parameter 1 to be CairoContext, integer given in %s on line %d
22 changes: 21 additions & 1 deletion tests/CairoContext/cairo_get_antialias.phpt
Expand Up @@ -13,10 +13,30 @@ $context = cairo_create($surface);
var_dump($context);

var_dump(cairo_get_antialias($context));

// bad type hint is an E_RECOVERABLE_ERROR, so let's hook a handler
function bad_class($errno, $errstr) {
echo 'CAUGHT ERROR: ' . $errstr, PHP_EOL;
}
set_error_handler('bad_class', E_RECOVERABLE_ERROR);

// check number of args - should accept ONLY 1
cairo_get_antialias();
cairo_get_antialias($context, 1);

// check arg types, should be CairoSurface
cairo_get_antialias(1);
?>
--EXPECTF--
object(CairoImageSurface)#%d (0) {
}
object(CairoContext)#%d (0) {
}
int(0)
int(0)

Warning: cairo_get_antialias() expects exactly 1 parameter, 0 given in %s on line %d

Warning: cairo_get_antialias() expects exactly 1 parameter, 2 given in %s on line %d
CAUGHT ERROR: Argument 1 passed to cairo_get_antialias() must be an instance of CairoContext, integer given

Warning: cairo_get_antialias() expects parameter 1 to be CairoContext, integer given in %s on line %d
25 changes: 24 additions & 1 deletion tests/CairoContext/cairo_set_antialias.phpt
Expand Up @@ -14,10 +14,33 @@ var_dump($context);

cairo_set_antialias($context, CAIRO_ANTIALIAS_GRAY);
var_dump(cairo_get_antialias($context));

// bad type hint is an E_RECOVERABLE_ERROR, so let's hook a handler
function bad_class($errno, $errstr) {
echo 'CAUGHT ERROR: ' . $errstr, PHP_EOL;
}
set_error_handler('bad_class', E_RECOVERABLE_ERROR);

// check number of args - should accept 1 or 2
cairo_set_antialias();
cairo_set_antialias($context, 1, 1);

// check arg types, should be int
cairo_set_antialias(1, 1);
cairo_set_antialias($context, array());
?>
--EXPECTF--
object(CairoImageSurface)#%d (0) {
}
object(CairoContext)#%d (0) {
}
int(2)
int(2)

Warning: cairo_set_antialias() expects at least 1 parameter, 0 given in %s on line %d

Warning: cairo_set_antialias() expects at most 2 parameters, 3 given in %s on line %d
CAUGHT ERROR: Argument 1 passed to cairo_set_antialias() must be an instance of CairoContext, integer given

Warning: cairo_set_antialias() expects parameter 1 to be CairoContext, integer given in %s on line %d

Warning: cairo_set_antialias() expects parameter 2 to be long, array given in %s on line %d
19 changes: 19 additions & 0 deletions tests/CairoContext/cairo_set_source.phpt
Expand Up @@ -18,6 +18,13 @@ var_dump($pattern);
cairo_set_source($context, $pattern);
var_dump(cairo_pattern_get_rgba(cairo_get_source($context)));

$pattern = cairo_pattern_create_rgb(0.5, 0.5, 0.5);
var_dump($pattern);

cairo_set_source($context, $pattern);

var_dump(cairo_pattern_get_rgba(cairo_get_source($context)));

function bad_class($errno, $errstr) {
echo 'CAUGHT ERROR: ' . $errstr, PHP_EOL;
}
Expand Down Expand Up @@ -50,6 +57,18 @@ array(4) {
["alpha"]=>
float(1)
}
object(CairoSolidPattern)#%d (0) {
}
array(4) {
["red"]=>
float(0.5)
["green"]=>
float(0.5)
["blue"]=>
float(0.5)
["alpha"]=>
float(1)
}

Warning: cairo_set_source() expects exactly 2 parameters, 0 given in %s on line %d

Expand Down

0 comments on commit f6f4bbd

Please sign in to comment.