diff --git a/core/tests/Drupal/KernelTests/Core/Image/ToolkitGdTest.php b/core/tests/Drupal/KernelTests/Core/Image/ToolkitGdTest.php index 128b606..4570104 100644 --- a/core/tests/Drupal/KernelTests/Core/Image/ToolkitGdTest.php +++ b/core/tests/Drupal/KernelTests/Core/Image/ToolkitGdTest.php @@ -370,6 +370,31 @@ function testManipulations() { // JPEG colors will always be messed up due to compression. So we skip // these tests if the original or the result is in jpeg format. if ($image->getToolkit()->getType() != IMAGETYPE_JPEG && $image_original_type != IMAGETYPE_JPEG) { + + // WebP test adjustments. + // @todo address these in a more general way. + if ($file === 'img-test.webp') { + if (in_array($op, ['resize', 'scale_x', 'scale_y', 'upscale_x', 'upscale_y', 'convert_gif', 'convert_png', 'convert_webp'])) { + $values['corners'][0] = [255, 1, 0, 0]; + $values['corners'][1] = [0, 255, 1, 0]; + $values['corners'][3] = [0, 0, 0, 0]; + } + if (in_array($op, ['crop', 'scale_and_crop'])) { + $values['corners'][0] = [255, 1, 0, 0]; + $values['corners'][1] = [0, 255, 1, 0]; + $values['corners'][2] = [0, 0, 255, 0]; + $values['corners'][3] = [0, 0, 0, 0]; + } + if (in_array($op, ['rotate_90', 'rotate_transparent_90'])) { + $values['corners'][0] = [0, 0, 0, 0]; + $values['corners'][1] = [255, 1, 0, 0]; + $values['corners'][2] = [0, 255, 1, 0]; + } + if (in_array($op, ['desaturate'])) { + $values['corners'][3] = [0, 0, 0, 0]; + } + } + // Now check each of the corners to ensure color correctness. foreach ($values['corners'] as $key => $corner) { // The test gif that does not have transparency color set is a @@ -411,8 +436,9 @@ function testManipulations() { // conversion. The convert operation cannot handle that correctly. if ($image->getToolkit()->getType() == $image_original_type || $corner != $this->transparent) { $correct_colors = $this->colorsAreEqual($color, $corner); - $this->assertTrue($correct_colors, SafeMarkup::format('Image %file object after %action action has the correct color placement at corner %corner.', - array('%file' => $file, '%action' => $op, '%corner' => $key))); + $actual_color = implode(',', $color); + $expected_color = implode(',', $corner); + $this->assertTrue($correct_colors, "Color of image '{$file}' after '{$op}' operation at corner {$key} is ({$actual_color}), expected ({$expected_color})."); } } }