Projet

Général

Profil

Révision 6ff32cea

Ajouté par Florent Torregrosa il y a environ 9 ans

Update core to 7.36

Voir les différences:

drupal7/modules/simpletest/tests/image.test
261 261
   */
262 262
  function testManipulations() {
263 263
    // If GD isn't available don't bother testing this.
264
    module_load_include('inc', 'system', 'image.gd');
264 265
    if (!function_exists('image_gd_check_settings') || !image_gd_check_settings()) {
265 266
      $this->pass(t('Image manipulations for the GD toolkit were skipped because the GD toolkit is not available.'));
266 267
      return;
......
379 380
            array_fill(0, 3, 76) + array(3 => 0),
380 381
            array_fill(0, 3, 149) + array(3 => 0),
381 382
            array_fill(0, 3, 29) + array(3 => 0),
382
            array_fill(0, 3, 0) + array(3 => 127)
383
            array_fill(0, 3, 225) + array(3 => 127)
383 384
          ),
384 385
        ),
385 386
      );
......
394 395
          continue 2;
395 396
        }
396 397

  
397
        // Transparent GIFs and the imagefilter function don't work together.
398
        // There is a todo in image.gd.inc to correct this.
398
        // All images should be converted to truecolor when loaded.
399
        $image_truecolor = imageistruecolor($image->resource);
400
        $this->assertTrue($image_truecolor, format_string('Image %file after load is a truecolor image.', array('%file' => $file)));
401

  
399 402
        if ($image->info['extension'] == 'gif') {
400 403
          if ($op == 'desaturate') {
401
            $values['corners'][3] = $this->white;
404
            // Transparent GIFs and the imagefilter function don't work together.
405
            $values['corners'][3][3] = 0;
402 406
          }
403 407
        }
404 408

  
......
451 455

  
452 456
        $directory = file_default_scheme() . '://imagetests';
453 457
        file_prepare_directory($directory, FILE_CREATE_DIRECTORY);
454
        image_save($image, $directory . '/' . $op . '.' . $image->info['extension']);
458
        $file_path = $directory . '/' . $op . '.' . $image->info['extension'];
459
        image_save($image, $file_path);
455 460

  
456 461
        $this->assertTrue($correct_dimensions_real, format_string('Image %file after %action action has proper dimensions.', array('%file' => $file, '%action' => $op)));
457 462
        $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 465
          $this->assertTrue($correct_colors, format_string('Image %file object after %action action has the correct color placement.', array('%file' => $file, '%action' => $op)));
461 466
        }
462 467
      }
468

  
469
      // Check that saved image reloads without raising PHP errors.
470
      $image_reloaded = image_load($file_path);
463 471
    }
472
  }
464 473

  
474
  /**
475
   * Tests loading an image whose transparent color index is out of range.
476
   */
477
  function testTransparentColorOutOfRange() {
478
    // This image was generated by taking an initial image with a palette size
479
    // of 6 colors, and setting the transparent color index to 6 (one higher
480
    // than the largest allowed index), as follows:
481
    // @code
482
    // $image = imagecreatefromgif('modules/simpletest/files/image-test.gif');
483
    // imagecolortransparent($image, 6);
484
    // imagegif($image, 'modules/simpletest/files/image-test-transparent-out-of-range.gif');
485
    // @endcode
486
    // This allows us to test that an image with an out-of-range color index
487
    // can be loaded correctly.
488
    $file = 'image-test-transparent-out-of-range.gif';
489
    $image = image_load(drupal_get_path('module', 'simpletest') . '/files/' . $file);
490

  
491
    if (!$image) {
492
      $this->fail(format_string('Could not load image %file.', array('%file' => $file)));
493
    }
494
    else {
495
      // All images should be converted to truecolor when loaded.
496
      $image_truecolor = imageistruecolor($image->resource);
497
      $this->assertTrue($image_truecolor, format_string('Image %file after load is a truecolor image.', array('%file' => $file)));
498
    }
465 499
  }
466 500
}
467 501

  

Formats disponibles : Unified diff