1 package util
.response
.ctrlint
;
3 import static org
.junit
.Assert
.assertEquals
;
5 import java
.io
.ByteArrayInputStream
;
6 import java
.io
.ByteArrayOutputStream
;
8 import org
.junit
.Before
;
13 import dacp
.DACPReader
;
14 import dacp
.DACPWriter
;
16 public class PlayStatusUpdateTest
{
18 private PlayStatusUpdate input
;
19 private PlayStatusUpdate output
;
22 public void setUp() throws Exception
{
24 input
= new PlayStatusUpdate
.Active(15, PlayStatusUpdate
.Status
.PAUSED
, true, 0, 1, 3, 9, 21, "Title", "Artist", "Album", "Genre", 123456789l, 0, 90, 180);
26 ByteArrayOutputStream out
= new ByteArrayOutputStream();
27 Writer w
= new DACPWriter(out
);
30 ByteArrayInputStream in
= new ByteArrayInputStream(out
.toByteArray());
31 Reader r
= new DACPReader(in
, out
.size());
33 output
= PlayStatusUpdate
.read(r
.nextComposite(r
.iterator().next()));
37 public void testPlayStatusUpdate() {
38 assertEquals(15, output
.revision
);
39 assertEquals(PlayStatusUpdate
.Status
.PAUSED
, output
.state
);
40 assertEquals(true, output
.shuffle
);
41 assertEquals(0, output
.repeat
);
45 public void testPlayStatusUpdateActive() {
46 PlayStatusUpdate
.Active output
= this.output
.active();
48 assertEquals(15, output
.revision
);
49 assertEquals(PlayStatusUpdate
.Status
.PAUSED
, output
.state
);
50 assertEquals(true, output
.shuffle
);
51 assertEquals(0, output
.repeat
);
53 assertEquals(1, output
.currentDatabase
);
54 assertEquals(3, output
.currentPlaylist
);
55 assertEquals(9, output
.currentPosition
);
56 assertEquals(21, output
.currentTrackId
);
58 assertEquals("Title", output
.trackTitle
);
59 assertEquals("Artist", output
.trackArtist
);
60 assertEquals("Album", output
.trackAlbum
);
61 assertEquals("Genre", output
.trackGenre
);
63 assertEquals(123456789l, output
.currentAlbumId
);
64 assertEquals(0, output
.mediaKind
);
65 assertEquals(90, output
.remainingTime
);
66 assertEquals(180, output
.totalTime
);