sk.baka.ambient.playlist
Class AbstractPlaylistStrategyTest

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by sk.baka.ambient.playlist.AbstractPlaylistStrategyTest
All Implemented Interfaces:
junit.framework.Test
Direct Known Subclasses:
DynamicPlaylistStrategyTest, StaticPlaylistStrategyTest

public abstract class AbstractPlaylistStrategyTest
extends junit.framework.TestCase

Common utility methods for testing a playlist strategy.

Author:
mvy

Field Summary
protected  IPlaylistStrategy strategy
          The strategy instance being tested.
protected  java.util.List<TrackMetadataBean> tracks
          Contains 30 test tracks.
 
Constructor Summary
AbstractPlaylistStrategyTest()
           
 
Method Summary
static void assertEquals(java.util.List<? extends TrackMetadataBean> expected, java.util.List<? extends PlaylistItem> actual)
          Compares given track list with a playlist.
static void assertEquals(java.lang.Object[] expected, java.util.List<?> actual)
          Asserts that given list has given content.
protected  void assertEqualsQueue(java.util.List<? extends TrackMetadataBean> expected)
          Compares given track list with a playlist.
protected  void assertNextTracks(java.util.List<TrackMetadataBean> tracks, boolean playlistEnd)
          Asserts that next x tracks will be in same ordering as in the tracks list.
protected  void assertNextTracksUnordered(java.util.List<TrackMetadataBean> tracks, boolean playlistEnd)
          Asserts that next x tracks matches tracks in given tracks list.
protected  void assertTracks(java.util.List<java.lang.Integer> trackNumbers, int startIndex)
          Compares current strategy IPlaylistStrategy.getPlayItems() to tracks in tracks.
protected  TrackMetadataBean getCurrentlyPlaying()
          Returns strategy currently played track.
protected abstract  IPlaylistStrategy getStrategy()
          Returns the strategy instance.
protected  void setUp()
           
 void testAdding30Tracks()
           
 void testEmptyPlaylist()
           
 void testNormalOrder()
           
 void testPlayingQueuedTracks()
           
 void testPlaySameTrack()
           
 void testQueuingTracks()
           
 void testRemovingPlayedTrackRandom()
           
 void testRemovingTracksPreservesCurrentlyPlayedTrack()
           
 void testSetRandomModePreservesCurrentTrack()
           
protected  void verifyQueueProperties(int expectedQueueLength)
          Checks if the queue has correct queue count etc.
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, runTest, setName, tearDown, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

tracks

protected java.util.List<TrackMetadataBean> tracks
Contains 30 test tracks.


strategy

protected IPlaylistStrategy strategy
The strategy instance being tested.

Constructor Detail

AbstractPlaylistStrategyTest

public AbstractPlaylistStrategyTest()
Method Detail

getStrategy

protected abstract IPlaylistStrategy getStrategy()
Returns the strategy instance.

Returns:
the strategy instance. The strategy playlist must be empty.

setUp

protected void setUp()
              throws java.lang.Exception
Overrides:
setUp in class junit.framework.TestCase
Throws:
java.lang.Exception

testEmptyPlaylist

public void testEmptyPlaylist()
                       throws java.lang.Exception
Throws:
java.lang.Exception

testAdding30Tracks

public void testAdding30Tracks()
                        throws java.lang.Exception
Throws:
java.lang.Exception

testQueuingTracks

public void testQueuingTracks()
                       throws java.lang.Exception
Throws:
java.lang.Exception

testPlayingQueuedTracks

public void testPlayingQueuedTracks()

assertNextTracks

protected void assertNextTracks(java.util.List<TrackMetadataBean> tracks,
                                boolean playlistEnd)
Asserts that next x tracks will be in same ordering as in the tracks list.

Parameters:
tracks - expect this ordering when playing next tracks.
playlistEnd - if true then the playlist must end after given tracks.

assertTracks

protected void assertTracks(java.util.List<java.lang.Integer> trackNumbers,
                            int startIndex)
Compares current strategy IPlaylistStrategy.getPlayItems() to tracks in tracks.

Parameters:
trackNumbers - indexes to the tracks list. null values are skipped.
startIndex - where to start

assertNextTracksUnordered

protected void assertNextTracksUnordered(java.util.List<TrackMetadataBean> tracks,
                                         boolean playlistEnd)
Asserts that next x tracks matches tracks in given tracks list. The number of tracks must match, however the track ordering is irrelevant (as opposed to assertNextTracks(List, boolean)).

Parameters:
tracks - expect these tracks when playing next tracks.
playlistEnd - if true then the playlist must end after given tracks.

verifyQueueProperties

protected void verifyQueueProperties(int expectedQueueLength)
Checks if the queue has correct queue count etc.

Parameters:
expectedQueueLength -

assertEquals

public static void assertEquals(java.util.List<? extends TrackMetadataBean> expected,
                                java.util.List<? extends PlaylistItem> actual)
Compares given track list with a playlist.

Parameters:
expected - the expected track list
actual - the playlist

assertEqualsQueue

protected void assertEqualsQueue(java.util.List<? extends TrackMetadataBean> expected)
Compares given track list with a playlist.

Parameters:
expected - the expected track list

assertEquals

public static void assertEquals(java.lang.Object[] expected,
                                java.util.List<?> actual)
Asserts that given list has given content.

Parameters:
expected -
actual -

testPlaySameTrack

public void testPlaySameTrack()

testNormalOrder

public void testNormalOrder()

testRemovingPlayedTrackRandom

public void testRemovingPlayedTrackRandom()

testRemovingTracksPreservesCurrentlyPlayedTrack

public void testRemovingTracksPreservesCurrentlyPlayedTrack()

getCurrentlyPlaying

protected TrackMetadataBean getCurrentlyPlaying()
Returns strategy currently played track.

Returns:
never null. Fails if no track is being played.

testSetRandomModePreservesCurrentTrack

public void testSetRandomModePreservesCurrentTrack()


Copyright © 2007-2009. All Rights Reserved.