-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathWakeAmpTest.java
More file actions
144 lines (114 loc) · 4.54 KB
/
Copy pathWakeAmpTest.java
File metadata and controls
144 lines (114 loc) · 4.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
import java.util.ArrayList;
import junit.framework.TestCase;
public class WakeAmpTest extends TestCase {
private String file = "/Users/michael/Dropbox/Mp3s/Wallpaper - Best Song Ever.mp3";
private String dir = "/Users/michael/Dropbox/Mp3s";
public WakeAmpTest(String name) {
super(name);
}
/*
* Test that the file path is properly set for a song object.
*/
public void testFilepath() {
Song testSong = new Song(file);
assertEquals(file, testSong.getFilePath());
}
/*
* Test that when a song is skipped on a playlist, that the index is properly adjusted.
*/
public void testSkipSong() {
Playlist testPlaylist = new Playlist(dir);
testPlaylist.skipSong();
assertEquals(1,testPlaylist.getIndex());
}
/*
* Test that when previous is called when the playlist is on the first song, that it goes to
* the end of the playlist.
*/
public void testPreviousSong() {
Playlist testPlaylist = new Playlist(dir);
testPlaylist.previousSong();
assertEquals(testPlaylist.getPlaylist().size() - 1,testPlaylist.getIndex());
}
/*
* Test the pause buttons functionality when the Mp3Player is both playing and paused.
*/
public void testPause() {
Playlist testPlaylist = new Playlist(dir);
MediaController testMediaController = new MediaController(testPlaylist);
Mp3Player testMp3Player = testMediaController.getMp3Player();
testMp3Player.pause();
assertTrue(testMp3Player.isPaused());
}
/*
* Check that the MediaController play button properly plays a song when it is loaded.
*/
public void testMediaControllerPlay() {
Playlist testPlaylist = new Playlist(dir);
MediaController testMediaController = new MediaController(testPlaylist);
Mp3Player testMp3Player = testMediaController.getMp3Player();
testMediaController.play();
assertFalse(testMp3Player.isPaused());
}
/*
* Check that the Playlist play button properly plays a song when it is loaded.
*/
public void testPlaylistPlay() {
Playlist testPlaylist = new Playlist(dir);
MediaController testMediaController = new MediaController(testPlaylist);
assertFalse(testMediaController.isPaused());
}
/*
* Test that the shuffle status is properly set when shuffle is called on a media controller.
*/
public void testMediaControllerShuffle() {
Playlist testPlaylist = new Playlist(dir);
MediaController testMediaController = new MediaController(testPlaylist);
testMediaController.shuffle();
assertTrue(testMediaController.shuffleStatus());
}
/*
* Test that the getSongByIndex properly works for all songs in the playlist.
*/
public void testPlaylistGetSongByIndex() {
Playlist testPlaylist = new Playlist(dir);
for (int i = 0; i < testPlaylist.getPlaylist().size(); i++)
assertEquals(testPlaylist.getSongByIndex(i), testPlaylist.getPlaylist().get(i));
}
/*
* Test that skipping a song on a playlist object returns the proper Song object.
*/
public void testPlaylistSkipSong() {
Playlist testPlaylist = new Playlist(dir);
testPlaylist.skipSong();
assertEquals(testPlaylist.getSong(), testPlaylist.getSongByIndex(1));
}
/*
* Test that a previous song on a playlist object returns the proper Song object.
* Also tests the wrap-around funcitonality of previous song.
*/
public void testPlaylistPreviousSong() {
Playlist testPlaylist = new Playlist(dir);
testPlaylist.previousSong();
assertEquals(testPlaylist.getSong(), testPlaylist.getSongByIndex(testPlaylist.getPlaylist().size() - 1));
}
/*
* Tests that the unshuffle playlist function properly works.
*/
public void testUnshufflePlaylist() {
Playlist testPlaylist = new Playlist(dir);
// Store the unshuffled list for comparison.
ArrayList<Song> unshuffled = new ArrayList<Song>();
// Copy the current list into the unshuffled list.
for (int i = 0; i < testPlaylist.getPlaylist().size(); i++){
unshuffled.add(testPlaylist.getSongByIndex(i));
}
// Shuffle and then unshuffle the list.
testPlaylist.shuffleList();
testPlaylist.unshuffleList();
assertEquals(unshuffled, testPlaylist.getPlaylist());
}
public static void main(String[] args) {
junit.textui.TestRunner.run(WakeAmpTest.class);
}
}