Permalink
Browse files

Screenshot method returns the name of the screenshot file if not in c…

…ontinuous mode
  • Loading branch information...
1 parent d337453 commit 9d8f2929095cd4cc287dde53cc6e8267504b985b @rorymckinley rorymckinley committed with Aug 28, 2010
Showing with 24 additions and 6 deletions.
  1. +8 −3 lib/mplayer-ruby/slave_video_commands.rb
  2. +16 −3 test/slave_video_commands_test.rb
View
11 lib/mplayer-ruby/slave_video_commands.rb
@@ -157,8 +157,13 @@ def vo_rootwin(value = nil)
# nil Take a single screenshot.
# :toggle Start/stop taking screenshot of each frame.
def screenshot(toggle=nil)
- switch = toggle == :toggle ? 1 : 0
- send "screenshot #{switch}"
+ switch, pattern = case toggle
+ when :toggle
+ [ 1, // ]
+ else
+ [ 0, /screenshot/ ]
+ end
+ (send("screenshot #{switch}", pattern)) =~ /(shot\d*\.png)/ ? $~[1] : ""
end
# Increases or descreases the panscan range by <value>. maximum is 1.0.
@@ -234,4 +239,4 @@ def change_rectangle(coord,value,type = :relative)
end
end
-end
+end
View
19 test/slave_video_commands_test.rb
@@ -224,14 +224,27 @@
context "screenshot" do
context "take screenshot" do
- setup { mock_stdin @player, "screenshot 0" }
- asserts("screenshot") { @player.screenshot }
+ setup do
+ mock_stdin @player, "screenshot 0"
+ mock_stdout @player, "", "*** screenshot 'shot0001.png' ***"
+ end
+ asserts("screenshot") { @player.screenshot == 'shot0001.png' }
end
context "start/stop screenshot" do
- setup { mock_stdin @player, "screenshot 1" }
+ setup do
+ mock_stdin @player, "screenshot 1"
+ end
asserts("screenshot :toggle") { @player.screenshot :toggle }
end
+
+ context "no file output on toggle" do
+ setup do
+ mock_stdin @player, "screenshot 1"
+ dont_allow(@player.stdout).gets
+ end
+ asserts("screenshot :toggle") { @player.screenshot(:toggle) == "" }
+ end
end
context "panscan" do

0 comments on commit 9d8f292

Please sign in to comment.