function imagecache_testsuite_positioning in ImageCache Actions 6.2
Same name and namespace in other branches
- 8 tests/imagecache_testsuite.module \imagecache_testsuite_positioning()
- 7 tests/imagecache_testsuite.module \imagecache_testsuite_positioning()
Display a page demonstrating a number of positioning tests
Tests both styles of positioning - the x=, y= original, used in most places, pls the css-like left=, top= version also.
1 string reference to 'imagecache_testsuite_positioning'
- imagecache_testsuite_menu in tests/
imagecache_testsuite.module - Implementation of hook_menu().
File
- tests/
imagecache_testsuite.module, line 231
Code
function imagecache_testsuite_positioning() {
drupal_set_title("Testing the positioning algorithm");
$tests = imagecache_testsuite_positioning_get_tests();
$table = array();
// $dst_image represents tha field or canvas.
// $src_image is the item being placed on it.
// Both these represent an imageapi-type image resource handle, but contain just dimensions
$src_image->info = array(
'width' => 75,
'height' => 100,
);
$dst_image->info = array(
'width' => 200,
'height' => 150,
);
foreach ($tests as $testname => $test) {
// calc it, using either old or new method
if (isset($test['parameters']['x']) || isset($test['parameters']['y'])) {
$result['x'] = imagecache_actions_keyword_filter($test['parameters']['x'], $dst_image->info['width'], $src_image->info['width']);
$result['y'] = imagecache_actions_keyword_filter($test['parameters']['y'], $dst_image->info['height'], $src_image->info['height']);
}
else {
// use css style
$result = imagecache_actions_calculate_relative_position($dst_image, $src_image, $test['parameters']);
}
$expected_illustration = theme_positioning_test($test['expected']['x'], $test['expected']['y']);
$result_illustration = theme_positioning_test($result['x'], $result['y']);
$row = array();
$row['name'] = array(
'data' => '<h3>' . $testname . '</h3>' . $test['description'],
);
$row['parameters'] = theme_positioning_parameters($test['parameters']);
$row['expected'] = theme_positioning_parameters($test['expected']);
$row['expected_image'] = $expected_illustration;
$row['result'] = theme_positioning_parameters($result);
$row['result_image'] = $result_illustration;
$table[] = $row;
}
return 'Result of test:' . theme('table', array(
'test',
'parameters',
'expected',
'image',
'result',
'actual image',
'status',
), $table);
}