summaryrefslogtreecommitdiff
path: root/modules/simpletest
diff options
context:
space:
mode:
authorDavid Rothstein <drothstein@gmail.com>2015-03-30 01:18:18 -0400
committerDavid Rothstein <drothstein@gmail.com>2015-03-30 01:18:18 -0400
commit5a1ad44daed5ac2d53eb4332a683549b55579570 (patch)
tree4ef64a5becc279ff77651bb8ce218f604fd1de22 /modules/simpletest
parentbe97f50fba4c7c87b4332d30cf8e0f612b89bdb5 (diff)
downloadbrdo-5a1ad44daed5ac2d53eb4332a683549b55579570.tar.gz
brdo-5a1ad44daed5ac2d53eb4332a683549b55579570.tar.bz2
Issue #375062 by cs_shadow, David_Rothstein, mondrake, juampy, theunraveler, hswong3i, smk-ka, fietserwin: "imagecolorsforindex() Color index nnn out of range in GDToolkit" message sometimes appears
Diffstat (limited to 'modules/simpletest')
-rw-r--r--modules/simpletest/files/image-test-transparent-out-of-range.gifbin0 -> 183 bytes
-rw-r--r--modules/simpletest/tests/image.test44
2 files changed, 39 insertions, 5 deletions
diff --git a/modules/simpletest/files/image-test-transparent-out-of-range.gif b/modules/simpletest/files/image-test-transparent-out-of-range.gif
new file mode 100644
index 000000000..a54df7a93
--- /dev/null
+++ b/modules/simpletest/files/image-test-transparent-out-of-range.gif
Binary files differ
diff --git a/modules/simpletest/tests/image.test b/modules/simpletest/tests/image.test
index dc95a6e2f..849702216 100644
--- a/modules/simpletest/tests/image.test
+++ b/modules/simpletest/tests/image.test
@@ -261,6 +261,7 @@ class ImageToolkitGdTestCase extends DrupalWebTestCase {
*/
function testManipulations() {
// If GD isn't available don't bother testing this.
+ module_load_include('inc', 'system', 'image.gd');
if (!function_exists('image_gd_check_settings') || !image_gd_check_settings()) {
$this->pass(t('Image manipulations for the GD toolkit were skipped because the GD toolkit is not available.'));
return;
@@ -379,7 +380,7 @@ class ImageToolkitGdTestCase extends DrupalWebTestCase {
array_fill(0, 3, 76) + array(3 => 0),
array_fill(0, 3, 149) + array(3 => 0),
array_fill(0, 3, 29) + array(3 => 0),
- array_fill(0, 3, 0) + array(3 => 127)
+ array_fill(0, 3, 225) + array(3 => 127)
),
),
);
@@ -394,11 +395,14 @@ class ImageToolkitGdTestCase extends DrupalWebTestCase {
continue 2;
}
- // Transparent GIFs and the imagefilter function don't work together.
- // There is a todo in image.gd.inc to correct this.
+ // All images should be converted to truecolor when loaded.
+ $image_truecolor = imageistruecolor($image->resource);
+ $this->assertTrue($image_truecolor, format_string('Image %file after load is a truecolor image.', array('%file' => $file)));
+
if ($image->info['extension'] == 'gif') {
if ($op == 'desaturate') {
- $values['corners'][3] = $this->white;
+ // Transparent GIFs and the imagefilter function don't work together.
+ $values['corners'][3][3] = 0;
}
}
@@ -451,7 +455,8 @@ class ImageToolkitGdTestCase extends DrupalWebTestCase {
$directory = file_default_scheme() . '://imagetests';
file_prepare_directory($directory, FILE_CREATE_DIRECTORY);
- image_save($image, $directory . '/' . $op . '.' . $image->info['extension']);
+ $file_path = $directory . '/' . $op . '.' . $image->info['extension'];
+ image_save($image, $file_path);
$this->assertTrue($correct_dimensions_real, format_string('Image %file after %action action has proper dimensions.', array('%file' => $file, '%action' => $op)));
$this->assertTrue($correct_dimensions_object, format_string('Image %file object after %action action is reporting the proper height and width values.', array('%file' => $file, '%action' => $op)));
@@ -460,8 +465,37 @@ class ImageToolkitGdTestCase extends DrupalWebTestCase {
$this->assertTrue($correct_colors, format_string('Image %file object after %action action has the correct color placement.', array('%file' => $file, '%action' => $op)));
}
}
+
+ // Check that saved image reloads without raising PHP errors.
+ $image_reloaded = image_load($file_path);
}
+ }
+ /**
+ * Tests loading an image whose transparent color index is out of range.
+ */
+ function testTransparentColorOutOfRange() {
+ // This image was generated by taking an initial image with a palette size
+ // of 6 colors, and setting the transparent color index to 6 (one higher
+ // than the largest allowed index), as follows:
+ // @code
+ // $image = imagecreatefromgif('modules/simpletest/files/image-test.gif');
+ // imagecolortransparent($image, 6);
+ // imagegif($image, 'modules/simpletest/files/image-test-transparent-out-of-range.gif');
+ // @endcode
+ // This allows us to test that an image with an out-of-range color index
+ // can be loaded correctly.
+ $file = 'image-test-transparent-out-of-range.gif';
+ $image = image_load(drupal_get_path('module', 'simpletest') . '/files/' . $file);
+
+ if (!$image) {
+ $this->fail(format_string('Could not load image %file.', array('%file' => $file)));
+ }
+ else {
+ // All images should be converted to truecolor when loaded.
+ $image_truecolor = imageistruecolor($image->resource);
+ $this->assertTrue($image_truecolor, format_string('Image %file after load is a truecolor image.', array('%file' => $file)));
+ }
}
}