about summary refs log tree commit homepage
path: root/test
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2015-12-07 03:51:33 +0000
committerEric Wong <e@80x24.org>2015-12-07 05:22:20 +0000
commit3e013d3f24f0f935dce985d4c6bd155889e05dbb (patch)
tree7c9dfae4dc7939265ff4abe2b906ef91a884cb19 /test
parente5668a47f20a6593ab47847083bc704e1abeb1e6 (diff)
downloaddtas-3e013d3f24f0f935dce985d4c6bd155889e05dbb.tar.gz
This is in the MPRIS 2.0 TrackList spec and also in mpd (as "repeat"
mode), so we can probably support it directly in player to ease
implementations of future wrappers.
Diffstat (limited to 'test')
-rw-r--r--test/test_tracklist.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/test_tracklist.rb b/test/test_tracklist.rb
index 33184c6..a3c89f6 100644
--- a/test/test_tracklist.rb
+++ b/test/test_tracklist.rb
@@ -61,6 +61,31 @@ class TestTracklist < Testcase
     assert_equal 'g', tl.advance_track[0]
   end
 
+  def test_shuffle
+    tl = DTAS::Tracklist.new
+    exp = %w(a b c d e f g)
+    list_add(tl, exp)
+    tl.shuffle = true
+    assert_equal(exp, list_to_path(tl))
+    assert_equal exp.size, tl.shuffle.size
+    assert_equal exp, tl.shuffle.map(&:to_path).sort
+    tl.shuffle = false
+    assert_equal false, tl.shuffle
+
+    tl.instance_variable_set :@pos, 3
+    before = tl.cur_track
+    3.times do
+      tl.shuffle = true
+      assert_equal before, tl.cur_track
+    end
+    x = tl.to_hsh
+    assert_equal true, x['shuffle']
+    3.times do
+      loaded = DTAS::Tracklist.load(x.dup)
+      assert_equal before.to_path, loaded.cur_track.to_path
+    end
+  end
+
   def test_remove_track
     tl = DTAS::Tracklist.new
     ary = %w(a b c d e f g)