| Class | RS::Test::RSTestImage |
| In: |
rsil/test/rstestimage.rb
|
| Parent: | Test::Unit::TestCase |
| Class: | RSTestImage |
| File: | rstestimage.rb |
| Purpose: | RSTestImage includes methods to test class RS::Graphics::RSImage. |
| Created by: | Mario Pehle, 2006/05/02 |
| Required modules: | Test::Unit |
| Offers functions: | - |
| Description: | Sets up test object. |
| Precondition: | - |
| Postcondition: | - |
| Exceptions: | - |
| Uses: | RS::Graphics::RSImage#new |
| Returns: | RSImage |
| Parameters: | Name | i/o/io | default | Meaning |
# File rsil/test/rstestimage.rb, line 44
44: def setup
45: @rsimage = RS::Graphics::RSImage.new
46: end
| Description: | Deletes test object and calls garbage collector. |
| Precondition: | - |
| Postcondition: | - |
| Exceptions: | - |
| Uses: | GC#start |
| Returns: | nil |
| Parameters: | Name | i/o/io | default | Meaning |
# File rsil/test/rstestimage.rb, line 60
60: def teardown
61: @rsimage = nil
62: GC.start
63: end
| Description: | Tests RS::Graphics::RSImage#add_filter for correct work. |
| Precondition: | - |
| Postcondition: | - |
| Exceptions: | - |
| Uses: | RS::Graphics::RSImage#add_filter, RS::Graphics::RSImage#load, RS::Graphics::RSFilter |
| Returns: | (not save) |
| Parameters: | Name | i/o/io | default | Meaning |
# File rsil/test/rstestimage.rb, line 406
406: def test_add_filter
407: script_dir, script_name = File.split(File.expand_path(__FILE__))
408: filename = script_dir + '/logo.gif'
409: assert_nothing_raised { @rsimage.load filename }
410: assert_equal(
411: 0,
412: @rsimage.filters.length,
413: 'Filters has to be empty because nothing added.'
414: )
415: filters = @rsimage.filters.clone
416: assert_nothing_raised do
417: @rsimage.add_filter(RS::Graphics::RSFilter.new('CISepiaTone'))
418: end
419: assert_equal(1, @rsimage.filters.length, 'No filter added.')
420: end
| Description: | Tests RS::Graphics::RSImage#apply_filters! for correct work. |
| Precondition: | - |
| Postcondition: | - |
| Exceptions: | - |
| Uses: | RS::Graphics::RSImage#apply_filters!, RS::Graphics::RSImage#load, RS::Graphics::RSFilter |
| Returns: | (not save) |
| Parameters: | Name | i/o/io | default | Meaning |
# File rsil/test/rstestimage.rb, line 434
434: def test_apply_filters!
435: script_dir, script_name = File.split(File.expand_path(__FILE__))
436: filename = script_dir + '/logo.gif'
437: assert_nothing_raised { @rsimage.load filename }
438: assert_equal(
439: 0,
440: @rsimage.filters.length,
441: 'Filters has to be empty because nothing added.'
442: )
443: assert_nothing_raised { @rsimage.apply_filters! }
444: assert_nothing_raised do
445: @rsimage.add_filter(RS::Graphics::RSFilter.new('CISepiaTone'))
446: end
447: assert_equal(1, @rsimage.filters.length, 'No filter added.')
448: assert_nothing_raised { @rsimage.apply_filters! }
449: assert_equal(
450: 0,
451: @rsimage.filters.length,
452: 'Filter not removed from list of applyable filters.'
453: )
454: end
| Description: | Tests RS::Graphics::RSImage#bytes for correct work. |
| Precondition: | - |
| Postcondition: | - |
| Exceptions: | - |
| Uses: | RS::Graphics::RSImage#bytes, RS::Graphics::RSImage#load |
| Returns: | (not save) |
| Parameters: | Name | i/o/io | default | Meaning |
# File rsil/test/rstestimage.rb, line 175
175: def test_bytes
176: script_dir, script_name = File.split(File.expand_path(__FILE__))
177: filename = script_dir + '/logo.gif'
178: assert_nothing_raised { @rsimage.load filename }
179: assert_raise(ArgumentError) { @rsimage.bytes('gif') }
180: assert_kind_of(
181: String,
182: @rsimage.bytes,
183: 'No bytes given for valid image.'
184: )
185: assert_kind_of(
186: String,
187: @rsimage.bytes(2),
188: 'No bytes given for valid image.'
189: )
190: end
| Description: | Tests RS::Graphics::RSImage#color_at for correct work. |
| Precondition: | - |
| Postcondition: | - |
| Exceptions: | - |
| Uses: | RS::Graphics::RSImage#color_at, RS::Graphics::RSImage#load, RS::Geometry::RSPoint |
| Returns: | (not save) |
| Parameters: | Name | i/o/io | default | Meaning |
# File rsil/test/rstestimage.rb, line 148
148: def test_color_at
149: script_dir, script_name = File.split(File.expand_path(__FILE__))
150: filename = script_dir + '/logo.gif'
151: assert_nothing_raised { @rsimage.load filename }
152: assert_kind_of(
153: RS::Graphics::RSColor,
154: @rsimage.color_at(RS::Geometry::RSPoint.new(0, 0, 0)),
155: 'No color given for valid point.'
156: )
157: assert_nil(
158: @rsimage.color_at(RS::Geometry::RSPoint.new(1000, 1000, 1000)),
159: 'Color given for invalid point.'
160: )
161: end
| Description: | Tests RS::Graphics::RSImage#dimension for correct work. |
| Precondition: | - |
| Postcondition: | - |
| Exceptions: | - |
| Uses: | RS::Graphics::RSImage#dimension, RS::Graphics::RSImage#load, RS::Geometry::RSDimension |
| Returns: | (not save) |
| Parameters: | Name | i/o/io | default | Meaning |
# File rsil/test/rstestimage.rb, line 204
204: def test_dimension
205: script_dir, script_name = File.split(File.expand_path(__FILE__))
206: filename = script_dir + '/logo.gif'
207: assert_nothing_raised { @rsimage.load filename }
208: dimension = nil
209: assert_nothing_raised { dimension = @rsimage.dimension }
210: assert_kind_of(
211: RS::Geometry::RSDimension,
212: dimension,
213: 'dimension is not of type RSDimension.'
214: )
215: end
| Description: | Tests RS::Graphics::RSImage#extent for correct work. |
| Precondition: | - |
| Postcondition: | - |
| Exceptions: | - |
| Uses: | RS::Graphics::RSImage#extent, RS::Graphics::RSImage#load, RS::Geometry::RSRectangle |
| Returns: | (not save) |
| Parameters: | Name | i/o/io | default | Meaning |
# File rsil/test/rstestimage.rb, line 254
254: def test_extent
255: script_dir, script_name = File.split(File.expand_path(__FILE__))
256: filename = script_dir + '/logo.gif'
257: assert_nothing_raised { @rsimage.load filename }
258: extent = nil
259: assert_nothing_raised { extent = @rsimage.extent }
260: assert_kind_of(
261: RS::Geometry::RSRectangle,
262: extent,
263: 'extent is not of type RSRectangle.'
264: )
265: end
| Description: | Tests RS::Graphics::RSImage#height for correct work. |
| Precondition: | - |
| Postcondition: | - |
| Exceptions: | - |
| Uses: | RS::Graphics::RSImage#height, RS::Graphics::RSImage#load |
| Returns: | (not save) |
| Parameters: | Name | i/o/io | default | Meaning |
# File rsil/test/rstestimage.rb, line 342
342: def test_height
343: script_dir, script_name = File.split(File.expand_path(__FILE__))
344: filename = script_dir + '/logo.gif'
345: assert_nothing_raised { @rsimage.load filename }
346: height = nil
347: assert_nothing_raised { height = @rsimage.height }
348: assert_kind_of(Float, height, 'height is not of type Float.')
349: end
| Description: | Tests RS::Graphics::RSImage#new for correct initialization. |
| Precondition: | - |
| Postcondition: | - |
| Exceptions: | - |
| Uses: | RS::Graphics::RSImage#new |
| Returns: | (not save) |
| Parameters: | Name | i/o/io | default | Meaning |
# File rsil/test/rstestimage.rb, line 77
77: def test_initialize
78: script_dir, script_name = File.split(File.expand_path(__FILE__))
79: img = nil
80: filename = script_dir + '/logo.gif'
81: assert_nothing_raised { img = RS::Graphics::RSImage.new }
82: assert_nil(img.filename, 'Has a filenam but no file.')
83: assert_not_nil(img.objc_object, 'Should have an initialized CIImage.')
84: assert_nothing_raised { img = RS::Graphics::RSImage.new filename }
85: assert_equal(
86: filename, img.filename,
87: 'filename not the name initialized with.'
88: )
89: assert_not_nil(img.objc_object, 'Should have an initialized CIImage.')
90: assert_raise(ArgumentError) { RS::Graphics::RSImage.new(['a']) }
91: assert_raise(ArgumentError) { RS::Graphics::RSImage.new 'no image' }
92: assert_raise(ArgumentError) { RS::Graphics::RSImage.new 10 }
93: assert_raise(ArgumentError) { RS::Graphics::RSImage.new false }
94: end
| Description: | Tests RS::Graphics::RSImage#load for correct work. |
| Precondition: | - |
| Postcondition: | - |
| Exceptions: | - |
| Uses: | RS::Graphics::RSImage#load |
| Returns: | (not save) |
| Parameters: | Name | i/o/io | default | Meaning |
# File rsil/test/rstestimage.rb, line 108
108: def test_load
109: script_dir, script_name = File.split(File.expand_path(__FILE__))
110: filename = script_dir + '/logo.gif'
111: assert_nil(@rsimage.filename, 'Has a filenam but no file.')
112: assert_raise(ArgumentError) { @rsimage.load 'no image' }
113: assert_nothing_raised { @rsimage.load filename }
114: assert_equal(filename, @rsimage.filename)
115: end
| Description: | Tests RS::Graphics::RSImage#nsdata for correct work. |
| Precondition: | - |
| Postcondition: | - |
| Exceptions: | - |
| Uses: | RS::Graphics::RSImage#load, RS::Graphics::RSImage.nsdata |
| Returns: | (not save) |
| Parameters: | Name | i/o/io | default | Meaning |
# File rsil/test/rstestimage.rb, line 129
129: def test_nsdata
130: script_dir, script_name = File.split(File.expand_path(__FILE__))
131: filename = script_dir + '/logo.gif'
132: assert_nothing_raised { @rsimage.load filename }
133: assert_kind_of(OSX::OCObject, @rsimage.nsdata, 'No nsdata given.')
134: end
| Description: | Tests RS::Graphics::RSImage#objc_object for correct return value. |
| Precondition: | - |
| Postcondition: | - |
| Exceptions: | - |
| Uses: | RS::Graphics::RSFilter#objc_object |
| Returns: | (not save) |
| Parameters: | Name | i/o/io | default | Meaning |
# File rsil/test/rstestimage.rb, line 504
504: def test_objc_object
505: assert_nothing_raised { @rsimage.objc_object }
506: assert_not_nil(@rsimage.objc_object, 'Basic objc object not initialized.')
507: end
| Description: | Tests RS::Graphics::RSImage#pixels for correct work. |
| Precondition: | - |
| Postcondition: | - |
| Exceptions: | - |
| Uses: | RS::Graphics::RSImage#pixels, RS::Graphics::RSImage#load |
| Returns: | (not save) |
| Parameters: | Name | i/o/io | default | Meaning |
# File rsil/test/rstestimage.rb, line 363
363: def test_pixels
364: script_dir, script_name = File.split(File.expand_path(__FILE__))
365: filename = script_dir + '/logo.gif'
366: assert_nothing_raised { @rsimage.load filename }
367: pixels = nil
368: assert_nothing_raised { pixels = @rsimage.pixels }
369: assert_kind_of(Float, pixels, 'pixels is not of type Fixnum.')
370: end
| Description: | Tests RS::Graphics::RSImage#point for correct work. |
| Precondition: | - |
| Postcondition: | - |
| Exceptions: | - |
| Uses: | RS::Graphics::RSImage#point, RS::Graphics::RSImage#load, RS::Geometry::RSPoint |
| Returns: | (not save) |
| Parameters: | Name | i/o/io | default | Meaning |
# File rsil/test/rstestimage.rb, line 229
229: def test_point
230: script_dir, script_name = File.split(File.expand_path(__FILE__))
231: filename = script_dir + '/logo.gif'
232: assert_nothing_raised { @rsimage.load filename }
233: point = nil
234: assert_nothing_raised { point = @rsimage.point }
235: assert_kind_of(
236: RS::Geometry::RSPoint,
237: point,
238: 'point is not of type RSPoint.'
239: )
240: end
| Description: | Tests RS::Graphics::RSImage#remove_filters for correct work. |
| Precondition: | - |
| Postcondition: | - |
| Exceptions: | - |
| Uses: | RS::Graphics::RSImage#remove_filters, RS::Graphics::RSImage#load, RS::Graphics::RSFilter |
| Returns: | (not save) |
| Parameters: | Name | i/o/io | default | Meaning |
# File rsil/test/rstestimage.rb, line 468
468: def test_remove_filters
469: script_dir, script_name = File.split(File.expand_path(__FILE__))
470: filename = script_dir + '/logo.gif'
471: assert_nothing_raised { @rsimage.load filename }
472: assert_nothing_raised do
473: @rsimage.add_filter(RS::Graphics::RSFilter.new('CISepiaTone'))
474: end
475: filters = @rsimage.filters.clone
476: assert_nothing_raised do
477: @rsimage.remove_filters!(
478: RS::Graphics::RSFilter.new('CIColorCube')
479: )
480: end
481: assert_equal(
482: 1,
483: @rsimage.filters.length,
484: 'Filter removed, but was not in list.'
485: )
486: assert_nothing_raised { @rsimage.remove_filters! 10 }
487: assert_nothing_raised { @rsimage.remove_filters! }
488: assert_equal(0, @rsimage.filters.length, 'No filter removed.')
489: assert_not_equal(filters, @rsimage.filters, 'Filter object are equal.')
490: end
| Description: | Tests RS::Graphics::RSImage#save for correct work. |
| Precondition: | - |
| Postcondition: | - |
| Exceptions: | - |
| Uses: | RS::Graphics::RSImage#save, RS::Graphics::RSImage#load, File#exist? |
| Returns: | (not save) |
| Parameters: | Name | i/o/io | default | Meaning |
# File rsil/test/rstestimage.rb, line 384
384: def test_save
385: script_dir, script_name = File.split(File.expand_path(__FILE__))
386: filename = script_dir + '/logo.gif'
387: outputname = script_dir + '/testlogo.gif'
388: assert_nothing_raised { @rsimage.load filename }
389: assert_nothing_raised { @rsimage.save outputname }
390: assert(File.exist?(outputname), 'File is not saved.')
391: File.delete script_dir + '/testlogo.gif'
392: end
| Description: | Tests RS::Graphics::RSImage#width for correct work. |
| Precondition: | - |
| Postcondition: | - |
| Exceptions: | - |
| Uses: | RS::Graphics::RSImage#width, RS::Graphics::RSImage#load |
| Returns: | (not save) |
| Parameters: | Name | i/o/io | default | Meaning |
# File rsil/test/rstestimage.rb, line 321
321: def test_width
322: script_dir, script_name = File.split(File.expand_path(__FILE__))
323: filename = script_dir + '/logo.gif'
324: assert_nothing_raised { @rsimage.load filename }
325: width = nil
326: assert_nothing_raised { width = @rsimage.width }
327: assert_kind_of(Float, width, 'width is not of type Float.')
328: end
| Description: | Tests RS::Graphics::RSImage#x for correct work. |
| Precondition: | - |
| Postcondition: | - |
| Exceptions: | - |
| Uses: | RS::Graphics::RSImage#x, RS::Graphics::RSImage#load |
| Returns: | (not save) |
| Parameters: | Name | i/o/io | default | Meaning |
# File rsil/test/rstestimage.rb, line 279
279: def test_x
280: script_dir, script_name = File.split(File.expand_path(__FILE__))
281: filename = script_dir + '/logo.gif'
282: assert_nothing_raised { @rsimage.load filename }
283: x = nil
284: assert_nothing_raised { x = @rsimage.x }
285: assert_kind_of(Float, x, 'x is not of type Float.')
286: end
| Description: | Tests RS::Graphics::RSImage#y for correct work. |
| Precondition: | - |
| Postcondition: | - |
| Exceptions: | - |
| Uses: | RS::Graphics::RSImage#y, RS::Graphics::RSImage#load |
| Returns: | (not save) |
| Parameters: | Name | i/o/io | default | Meaning |
# File rsil/test/rstestimage.rb, line 300
300: def test_y
301: script_dir, script_name = File.split(File.expand_path(__FILE__))
302: filename = script_dir + '/logo.gif'
303: assert_nothing_raised { @rsimage.load filename }
304: y = nil
305: assert_nothing_raised { y = @rsimage.y }
306: assert_kind_of(Float, y, 'y is not of type Float.')
307: end