require File.dirname(__FILE__) + '/helper' require 'rdvd-slideshow/slideshow_input' class TestSlideshowInput < Test::Unit::TestCase def test_empty_input input = RDvdSlideshow::SlideshowInput.new(nil) assert File.exists?(input.file_path), "Input file was not created" lines = File.readlines(input.file_path) assert lines.empty?, "Input file should be empty" end def test_image input = RDvdSlideshow::SlideshowInput.new(input_file) do |input| input.image(default_image,0.5) input.image(default_image,0.5, :effect=>"special_effect") end lines = File.readlines(input.file_path) assert_equal 2, lines.length assert_equal "#{default_image}:0.500\n", lines[0] assert_equal "#{default_image}:0.500::special_effect\n", lines[1] end def test_image_with_no_input_file_path input = RDvdSlideshow::SlideshowInput.new do |input| input.image(default_image,0.5) input.image(default_image,0.5, :effect=>"special_effect") end lines = File.readlines(input.file_path) assert_equal 2, lines.length assert_equal "#{default_image}:0.500\n", lines[0] assert_equal "#{default_image}:0.500::special_effect\n", lines[1] end def test_title input = RDvdSlideshow::SlideshowInput.new(input_file) do |input| input.title 0.5,"test_title" end lines = File.readlines(input.file_path) assert_equal 1, lines.length assert_equal "title:0.500:test_title\n", lines[0] end def test_titlebar input = RDvdSlideshow::SlideshowInput.new(input_file) do |input| input.titlebar 0.5 input.titlebar 0.5,{:upper_title=>"my upper text"} input.titlebar 0.5,{:lower_title=>"my lower text"} input.titlebar 0.5,{:upper_title=>"my upper text",:lower_title=>"my lower text"} end lines = File.readlines(input.file_path) assert_equal 4, lines.length assert_equal "titlebar:0.500\n", lines[0] assert_equal "titlebar:0.500:my upper text\n", lines[1] assert_equal "titlebar:0.500::my lower text\n", lines[2] assert_equal "titlebar:0.500:my upper text:my lower text\n", lines[3] end def test_musictitle input = RDvdSlideshow::SlideshowInput.new(input_file) do |input| input.musictitle(0.5) input.musictitle(0.5,{:subtitle=>"my subtitle"}) end lines = File.readlines(input.file_path) assert_equal 2, lines.length assert_equal "musictitle:0.500\n", lines[0] assert_equal "musictitle:0.500:my subtitle\n", lines[1] end def test_exit input = RDvdSlideshow::SlideshowInput.new(input_file) do |input| input.exit end lines = File.readlines(input.file_path) assert_equal 1, lines.length assert_equal "exit\n", lines[0] end def test_duration_conversion input = RDvdSlideshow::SlideshowInput.new(input_file) do |input| input.image(default_image, 2) input.image(default_image, 1.23456789) end lines = File.readlines(input.file_path) assert_equal "#{default_image}:2.000\n", lines[0] assert_equal "#{default_image}:1.235\n", lines[1] end end