spec/quicktime/movie_spec.rb in rmov-0.1.2 vs spec/quicktime/movie_spec.rb in rmov-0.1.3

- old
+ new

@@ -1,19 +1,19 @@ require File.dirname(__FILE__) + '/../spec_helper.rb' -describe Quicktime::Movie do +describe QuickTime::Movie do it "should raise an exception when attempting to open a nonexisting file" do - lambda { Quicktime::Movie.open('foo.mov') }.should raise_error(Quicktime::Error) + lambda { QuickTime::Movie.open('foo.mov') }.should raise_error(QuickTime::Error) end it "should raise an exception when attempting to open a non movie file" do - lambda { Quicktime::Movie.open(__FILE__) }.should raise_error(Quicktime::Error) + lambda { QuickTime::Movie.open(__FILE__) }.should raise_error(QuickTime::Error) end describe "example.mov" do before(:each) do - @movie = Quicktime::Movie.open(File.dirname(__FILE__) + '/../fixtures/example.mov') + @movie = QuickTime::Movie.open(File.dirname(__FILE__) + '/../fixtures/example.mov') end it "duration should be 3.1 seconds" do @movie.duration.should == 3.1 end @@ -29,11 +29,11 @@ it "height should be 50" do @movie.height.should == 50 end it "should have 2 tracks" do - @movie.tracks.map { |t| t.class }.should == [Quicktime::Track, Quicktime::Track] + @movie.tracks.map { |t| t.class }.should == [QuickTime::Track, QuickTime::Track] @movie.tracks.map { |t| t.id }.should == [1, 2] end it "should be able to export into separate file" do path = File.dirname(__FILE__) + '/../output/exported_example.mov' @@ -41,11 +41,11 @@ progress = 0 @movie.export(path) { |p| progress = p } progress.should == 1.0 - exported_movie = Quicktime::Movie.open(path) + exported_movie = QuickTime::Movie.open(path) exported_movie.duration.should == @movie.duration exported_movie.tracks.size == @movie.tracks.size end it "should have one audio track" do @@ -55,23 +55,23 @@ it "should have one video track" do @movie.video_tracks.should have(1).record end it "composite should add another movie's tracks at a given location" do - m2 = Quicktime::Movie.open(File.dirname(__FILE__) + '/../fixtures/example.mov') + m2 = QuickTime::Movie.open(File.dirname(__FILE__) + '/../fixtures/example.mov') @movie.composite_movie(m2, 2) @movie.duration.should == 5.1 end it "insert should insert another movie's tracks at a given location" do - m2 = Quicktime::Movie.open(File.dirname(__FILE__) + '/../fixtures/example.mov') + m2 = QuickTime::Movie.open(File.dirname(__FILE__) + '/../fixtures/example.mov') @movie.insert_movie(m2, 2) @movie.duration.should == 6.2 end it "append_movie should insert movie at the end" do - m2 = Quicktime::Movie.open(File.dirname(__FILE__) + '/../fixtures/example.mov') + m2 = QuickTime::Movie.open(File.dirname(__FILE__) + '/../fixtures/example.mov') @movie.append_movie(m2) @movie.duration.should == 6.2 end it "delete_section should remove a section from a movie" do @@ -91,11 +91,11 @@ @movie.duration.should == 2.5 end it "should have an exporter with this movie" do exporter = @movie.exporter - exporter.should be_kind_of(Quicktime::Exporter) + exporter.should be_kind_of(QuickTime::Exporter) exporter.movie.should == @movie end it "should say when movie has changed" do @movie.should_not be_changed @@ -111,11 +111,11 @@ it "flatten should save movie into file" do path = File.dirname(__FILE__) + '/../output/flattened_example.mov' File.delete(path) rescue nil @movie.flatten(path) - mov = Quicktime::Movie.open(path) + mov = QuickTime::Movie.open(path) mov.duration.should == 3.1 end it "export_pict should output a pict file at a given duration" do path = File.dirname(__FILE__) + '/../output/example.pct' @@ -133,24 +133,51 @@ end end describe "empty movie" do before(:each) do - @movie = Quicktime::Movie.empty + @movie = QuickTime::Movie.empty end it "should have 0 duration" do @movie.duration.should == 0 end it "should be able to append an existing movie" do - m2 = Quicktime::Movie.open(File.dirname(__FILE__) + '/../fixtures/example.mov') + m2 = QuickTime::Movie.open(File.dirname(__FILE__) + '/../fixtures/example.mov') @movie.append_movie(m2) @movie.duration.should == 3.1 end it "should raise MovieAlreadyLoaded exception when attempting to load it again" do - lambda { @movie.load_empty }.should raise_error(Quicktime::Error) - lambda { @movie.load_from_file('example.mov') }.should raise_error(Quicktime::Error) + lambda { @movie.load_empty }.should raise_error(QuickTime::Error) + lambda { @movie.load_from_file('example.mov') }.should raise_error(QuickTime::Error) + end + + it "should be able to create a new track" do + track = @movie.new_track(300, 500) + track.should be_kind_of(QuickTime::Track) + @movie.tracks.should have(1).record + end + + it "should be able to create a new video track" do + track = @movie.new_video_track(300, 500) + track.should be_kind_of(QuickTime::Track) + track.should be_video + @movie.video_tracks.should have(1).record + end + + it "should be able to create a new audio track" do + track = @movie.new_audio_track(300, 500) + track.should be_kind_of(QuickTime::Track) + track.should be_audio + @movie.audio_tracks.should have(1).record + end + + it "should be able to create a new text track" do + track = @movie.new_text_track(300, 500) + track.should be_kind_of(QuickTime::Track) + track.should be_text + @movie.text_tracks.should have(1).record end end end