minicomic-backend/test/filter_test.rb

75 lines
1.6 KiB
Ruby
Raw Permalink Normal View History

2010-09-12 13:16:44 +00:00
require 'test_helper'
require 'minicomic-backend/filter'
2009-05-22 13:36:08 +00:00
class TestFilter < Test::Unit::TestCase
def setup
2010-01-05 12:28:52 +00:00
@filter = Filter.new
2009-05-22 13:36:08 +00:00
end
def test_recalc_pixels
@filter.config = {}
assert_raise RuntimeError do
@filter.config = {'print' => true}
end
assert_raise RuntimeError do
@filter.config = {'print' => true,
'dpi' => 'test'}
end
assert_raise RuntimeError do
@filter.config = {
'print' => true,
'dpi' => 10
}
end
2010-01-05 03:55:50 +00:00
2009-05-22 13:36:08 +00:00
[ 'width', 'height' ].each do |dim|
assert_raise RuntimeError do
@filter.config = {
'print' => true,
'dpi' => 10,
'width' => 10
}
end
@filter.config = {
'width' => 10
}
assert_equal(10, @filter.config['width'])
end
2010-01-05 12:28:52 +00:00
@filter.config = {
'print' => true,
'dpi' => 10,
'width_inches' => 1,
'height_inches' => 2
}
assert_equal(10, @filter.config['width'])
assert_equal(20, @filter.config['height'])
end
def test_cleanup
@filter.cleanup = [ 'test', 'test2', 'test3' ]
FakeFS do
FileUtils.touch [ 'test', 'test3', 'test4' ]
@filter.cleanup
[ 'test', 'test2', 'test3' ].each do |file|
assert !(File.exists? file)
end
[ 'test4' ].each do |file|
assert File.exists? file
end
2010-01-11 02:54:20 +00:00
[ 'test', 'test3', 'test4' ].each { |f| FileUtils.rm f }
2010-01-05 12:28:52 +00:00
end
end
def test_get_dimensions
assert_equal [ 50, 75 ], @filter.get_dimensions(File.dirname(__FILE__) + '/data/test_dimensions.png')
2009-05-22 13:36:08 +00:00
end
2010-01-05 03:55:50 +00:00
end