From 3e09ac0c10c95bb24a08af62393b4f761e2743d0 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 24 Aug 2013 09:54:45 +0000 Subject: initial commit --- test/test_format_change.rb | 49 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 test/test_format_change.rb (limited to 'test/test_format_change.rb') diff --git a/test/test_format_change.rb b/test/test_format_change.rb new file mode 100644 index 0000000..ed0e7a2 --- /dev/null +++ b/test/test_format_change.rb @@ -0,0 +1,49 @@ +# -*- encoding: binary -*- +# Copyright (C) 2013, Eric Wong +# License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt) +require './test/player_integration' +require 'tmpdir' +class TestFormatChange < Minitest::Unit::TestCase + include PlayerIntegration + + def test_format_change + s = client_socket + default_pid = default_sink_pid(s) + Dir.mktmpdir do |dir| + d = "#{dir}/dump.$CHANNELS.$RATE" + f44100 = File.open("#{dir}/dump.2.44100", IO::RDWR|IO::CREAT) + f88200 = File.open("#{dir}/dump.2.88200", IO::RDWR|IO::CREAT) + s.preq("sink ed dump active=true command='cat > #{d}'") + assert_equal "OK", s.readpartial(666) + noise, len = tmp_noise + s.preq(%W(enq #{noise.path})) + assert_equal "OK", s.readpartial(666) + wait_files_not_empty(default_pid, f44100) + + s.preq("format rate=88200") + assert_equal "OK", s.readpartial(666) + + wait_files_not_empty(f88200) + + dethrottle_decoder(s) + + Timeout.timeout(len) do + begin + s.preq("current") + cur = YAML.load(s.readpartial(6666)) + end while cur["sinks"] && sleep(0.01) + end + + c = "sox -R -ts32 -c2 -r88200 #{dir}/dump.2.88200 " \ + "-ts32 -c2 -r44100 #{dir}/part2" + assert(system(c), c) + + c = "sox -R -ts32 -c2 -r44100 #{dir}/dump.2.44100 " \ + "-ts32 -c2 -r44100 #{dir}/part2 #{dir}/res.sox" + assert(system(c), c) + + assert_equal `soxi -s #{dir}/res.sox`, `soxi -s #{noise.path}` + File.unlink(*Dir["#{dir}/*"].to_a) + end + end +end -- cgit v1.2.3-24-ge0c7