Media: Improve and fix rotate/flip image tests

Fix off-by-one error in pixel color checks for rotate and flip image tests.
Change to using PNG with single pixel to ensure that errors are caught in the future, rather than lost in JPEG noise.

Props Fuegas, mikeschroder.
Fixes #46073.

git-svn-id: https://develop.svn.wordpress.org/trunk@45067 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Mike Schroder 2019-03-29 02:48:08 +00:00
parent 752f99c5df
commit 2a7aedc9e0
2 changed files with 4 additions and 4 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 320 B

View File

@ -421,7 +421,7 @@ class Tests_Image_Editor_Imagick extends WP_Image_UnitTestCase {
* Test rotating an image 180 deg
*/
public function test_rotate() {
$file = DIR_TESTDATA . '/images/gradient-square.jpg';
$file = DIR_TESTDATA . '/images/one-blue-pixel-100x100.png';
$imagick_image_editor = new WP_Image_Editor_Imagick( $file );
$imagick_image_editor->load();
@ -429,7 +429,7 @@ class Tests_Image_Editor_Imagick extends WP_Image_UnitTestCase {
$property = new ReflectionProperty( $imagick_image_editor, 'image' );
$property->setAccessible( true );
$color_top_left = $property->getValue( $imagick_image_editor )->getImagePixelColor( 1, 1 )->getColor();
$color_top_left = $property->getValue( $imagick_image_editor )->getImagePixelColor( 0, 0 )->getColor();
$imagick_image_editor->rotate( 180 );
@ -440,7 +440,7 @@ class Tests_Image_Editor_Imagick extends WP_Image_UnitTestCase {
* Test flipping an image
*/
public function test_flip() {
$file = DIR_TESTDATA . '/images/gradient-square.jpg';
$file = DIR_TESTDATA . '/images/one-blue-pixel-100x100.png';
$imagick_image_editor = new WP_Image_Editor_Imagick( $file );
$imagick_image_editor->load();
@ -448,7 +448,7 @@ class Tests_Image_Editor_Imagick extends WP_Image_UnitTestCase {
$property = new ReflectionProperty( $imagick_image_editor, 'image' );
$property->setAccessible( true );
$color_top_left = $property->getValue( $imagick_image_editor )->getImagePixelColor( 1, 1 )->getColor();
$color_top_left = $property->getValue( $imagick_image_editor )->getImagePixelColor( 0, 0 )->getColor();
$imagick_image_editor->flip( true, false );