Sha256: 812371171265c426f62714b99bd24766b52948d34f913dfb236152a71ee9c54d

Contents?: true

Size: 1.47 KB

Versions: 2

Compression:

Stored size: 1.47 KB

Contents

#
# File::        test_PNGCrush.m
# Author::      wkm
# Copyright::   2009
# License::     GPL
#
# Unit tests for the PNGCrush wrapper.
#

$:.unshift File.join(File.dirname(__FILE__), '..', 'lib')

require 'sitefuel/external/ExternalProgramTestCase'
require 'sitefuel/external/PNGCrush'

include SiteFuel::External

class TestPNGCrush < Test::Unit::TestCase
  include ExternalProgramTestCase

  SAMPLE_IMAGE = 'test/test_images/sample_png01.png'

  def test_option
    # test that we have all options
    assert PNGCrush.option?(:version)
    assert PNGCrush.option?(:brute)
    assert PNGCrush.option?(:reduce)
    assert PNGCrush.option?(:method)
    assert PNGCrush.option?(:input)
    assert PNGCrush.option?(:output)

    assert_equal '-brute',   PNGCrush.option_template(:brute)
#    assert_equal '-version', PNGCrush.option_template(:version)
  end

  def test_brute
    # test the crush capability against one of the test files
    new_image = './test/test_images/tmp-sample_png01-brute.png'
    PNGCrush.brute SAMPLE_IMAGE, new_image

    assert File.size(SAMPLE_IMAGE) > File.size(new_image)

  end

  def test_quick
    new_image = './test/test_images/tmp-sample_png01-quick.png'
    PNGCrush.quick SAMPLE_IMAGE, new_image

    assert File.size(SAMPLE_IMAGE) > File.size(new_image)
  end

  def test_chainsaw
    new_image = './test/test_images/tmp-sample_png01-chainsaw.png'
    PNGCrush.chainsaw SAMPLE_IMAGE, new_image

    assert File.size(SAMPLE_IMAGE) > File.size(new_image)
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sitefuel-0.0.0b test/test_PNGCrush.rb
sitefuel-0.0.0a test/test_PNGCrush.rb