Browse Source

Added basic unit test for VLC plugin

Issue 1106

git-svn-id: http://svn.dmdirc.com/trunk@3926 00569f92-eb28-0410-84fd-f71c24880f
tags/0.6
Chris Smith 16 years ago
parent
commit
ca93bf333a

+ 51
- 0
test/com/dmdirc/addons/mediasource_vlc/VlcMediaSourcePluginTest.java View File

@@ -0,0 +1,51 @@
1
+/*
2
+ * Copyright (c) 2006-2008 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.addons.mediasource_vlc;
24
+
25
+import com.dmdirc.util.TextFile;
26
+import java.io.IOException;
27
+import org.junit.Test;
28
+import static org.junit.Assert.*;
29
+
30
+public class VlcMediaSourcePluginTest extends junit.framework.TestCase {
31
+
32
+    @Test
33
+    public void testProcessInformation1() throws IOException {
34
+        final VlcMediaSourcePlugin plugin = new VlcMediaSourcePlugin();
35
+        final TextFile index = new TextFile(getClass().getResourceAsStream("index-1.html"));
36
+        final TextFile info = new TextFile(getClass().getResourceAsStream("info-1.html"));
37
+        
38
+        plugin.parseInformation(info.getLines(), index.getLines());
39
+        
40
+        assertTrue(plugin.isPlaying());
41
+        assertEquals("Manic Street Preachers", plugin.getArtist());
42
+        assertEquals("Send Away The Tigers", plugin.getAlbum());
43
+        assertEquals("The Second Great Depression", plugin.getTitle());
44
+        assertEquals("128 kb/s", plugin.getBitrate());
45
+        assertEquals("VLC", plugin.getAppName());
46
+        assertEquals("mpga", plugin.getFormat());
47
+        assertEquals("249", plugin.getLength());
48
+        assertEquals("38", plugin.getTime());
49
+    }
50
+
51
+}

+ 261
- 0
test/com/dmdirc/addons/mediasource_vlc/index-1.html View File

@@ -0,0 +1,261 @@
1
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD  XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml10/DTD/xhtml10transitional.dtd">
2
+<html xml:lang="en" xmlns="http://www.w3.org/1999/xhtml"><head>
3
+<meta http-equiv="content-type" content="text/html; charset=UTF-8">
4
+<!-- $Id: index.html 14777 2006-03-17 14:40:59Z jpsaman $-->
5
+
6
+
7
+
8
+
9
+
10
+ 
11
+    <title>VLC media player</title>
12
+    <link href="index-1_files/style.css" title="Default" rel="stylesheet" type="text/css">
13
+    <!-- Work around. should be done in the code -->
14
+    
15
+        <meta http-equiv="Refresh" content="60;url=/old/">
16
+    
17
+    
18
+    
19
+    
20
+<script type="text/javascript">
21
+
22
+function changeMe(item)
23
+{
24
+  if (item.parentNode.lastChild.style.display=="none")
25
+  {
26
+    item.parentNode.lastChild.style.display="block";
27
+    item.alt="[-]";
28
+    item.src="cone_minus.png";
29
+  }
30
+  else
31
+  {
32
+    item.parentNode.lastChild.style.display="none";
33
+    item.alt="[+]";
34
+    item.src="cone_plus.png";
35
+  }
36
+}
37
+</script>
38
+
39
+</head><body>
40
+
41
+    <!-- left menu -->
42
+    <div class="left">
43
+      <div class="sectitle">Playback control</div>
44
+      <div class="section-controls">
45
+        <p>
46
+          </p><form method="get" action="" style="display: inline;">
47
+            <input name="control" value="stop" type="submit">
48
+          </form>
49
+          <form method="get" action="" style="display: inline;">
50
+            <input name="control" value="pause" type="submit">
51
+          </form>
52
+        
53
+        <p>
54
+          </p><form method="get" action="" style="display: inline;">
55
+            <input name="control" value="previous" type="submit">
56
+          </form>
57
+          <form method="get" action="" style="display: inline;">
58
+            <input name="control" value="next" type="submit">
59
+          </form>
60
+        
61
+        <p>
62
+          </p><form method="get" action="" style="display: inline;">
63
+            <input name="seek_value" value="-1min" type="submit"><input name="control" value="seek" type="hidden">
64
+          </form>
65
+          <form method="get" action="" style="display: inline;">
66
+            <input name="seek_value" value="+1min" type="submit"><input name="control" value="seek" type="hidden">
67
+          </form>
68
+        
69
+        <p>
70
+          </p><form method="get" action="">
71
+            <input name="seek_value" size="14" type="text"><input name="control" value="seek" type="hidden">
72
+            <input value="Seek" type="submit">
73
+          </form>
74
+        
75
+        <p>
76
+          <span class="small">( Seek Textbox: for example "+12min 42sec", "01:13:43", "-12%" etc... )</span>
77
+        </p>
78
+      </div> <!-- End section -->
79
+
80
+      <div class="sectitle">Misc controls</div>
81
+      <div class="section-controls">
82
+        <form method="get" action="">
83
+               <input name="control" value="volume" type="hidden">
84
+          Vol: <input name="value" size="5" type="text">
85
+               <input value="Set" type="submit"><br> (0 - 1024)<br><span class="small">(for example: "536", "-12", "+42", "36%")</span>
86
+        </form>
87
+        <br>
88
+        <form method="get" action="">
89
+          <input name="control" value="fullscreen" type="submit">
90
+        </form>
91
+      </div>
92
+
93
+      <div class="sectitle">Status</div>
94
+      <div class="section">
95
+        State: playing<br>
96
+        Length: <span id="length">249 s
97
+                </span><br>
98
+        Time: <span id="time">38 s</span><br>
99
+        Volume: <span id="volume">56</span>
100
+        <br><a href="http://127.0.0.1:8082/old/info.html">Information</a>  
101
+      </div>
102
+
103
+      <div class="section"><a href="http://127.0.0.1:8082/old/admin/">Administration Page</a></div>
104
+
105
+    </div>
106
+    <!-- end left -->
107
+
108
+    <!-- main content -->
109
+    <div class="right">
110
+      <h2 class="title"><a href="http://www.videolan.org/">VLC media player
111
+        0.8.6c Janus</a> (http interface)
112
+      </h2>
113
+
114
+      <div class="sectitle">Add</div>
115
+      <div class="section">
116
+        <table class="add">
117
+          <tbody><tr>
118
+	    <form method="get" action="?" enctype="text/plain"></form>
119
+              <td>Add a MRL (Media Resource Locator) to the playlist</td>
120
+              <td>
121
+               <input name="control" value="add" type="hidden">
122
+	       <input name="mrl" size="40" type="text">
123
+	       <input value="Add" type="submit">
124
+	      </td>
125
+              
126
+          </tr>
127
+	  <tr>
128
+            <form method="get" action="" enctype="text/plain"></form>
129
+              <td>Stream Output:</td>
130
+              <td>
131
+	       <input name="sout" size="40" value="" type="text">
132
+	       <input value="Sout" type="submit">
133
+	      </td>
134
+             
135
+           </tr>
136
+          </tbody></table>
137
+      </div>
138
+<!-- Playlist -->
139
+      <div class="section">
140
+       <form method="get" action="">
141
+         <ul id="playlist">
142
+           
143
+           
144
+           
145
+                 
146
+
147
+               
148
+                 <li>
149
+                   
150
+                   <img alt="Cone" src="index-1_files/cone_plus.png">
151
+                     Playlist
152
+                     
153
+                   
154
+
155
+                   
156
+                       <ul>
157
+                   
158
+
159
+               
160
+
161
+               
162
+
163
+           
164
+                 
165
+
166
+               
167
+                 <li>
168
+                   
169
+                   <img alt="[-]" src="index-1_files/cone_minus.png" onclick="changeMe(this)">
170
+                   
171
+                     <input name="item" value="3" type="checkbox">
172
+		     <a href="http://127.0.0.1:8082/old/?control=play&amp;item=3">
173
+                   
174
+		   General
175
+                   
176
+		      </a>
177
+                   
178
+		   (1
179
+		    item)
180
+                   
181
+
182
+                   
183
+                       <ul>
184
+                   
185
+
186
+               
187
+
188
+               
189
+
190
+           
191
+                 
192
+
193
+               
194
+                 
195
+                 <li>
196
+                   <input name="item" value="4" type="checkbox">
197
+                   
198
+                     <strong>
199
+                   
200
+                   <a href="http://127.0.0.1:8082/old/?control=play&amp;item=4">
201
+The Second Great Depression (/mnt/drive1/Music/aMule/Manic Street
202
+Preachers - Send Away The Tigers
203
+(2007)/05-manic_street_preachers-the_second_great_depression.mp3)</a>
204
+                   
205
+                     </strong>
206
+                   
207
+                 </li>
208
+               
209
+
210
+               
211
+
212
+           
213
+     
214
+     
215
+         </ul></li>
216
+     
217
+         </ul></li>
218
+     
219
+
220
+         </ul>
221
+         <input name="control" value="delete" type="submit">
222
+         <input name="control" value="empty" type="submit">
223
+         <input name="control" value="keep" type="submit">
224
+	              <input name="control" value="sort" type="submit"> by
225
+                     <select name="type">
226
+                       <option value="title">title</option>
227
+                       <option value="shuffle">shuffle</option>
228
+                     </select> with
229
+                     <select name="order">
230
+                       <option value="0">normal order</option>
231
+                       <option value="1">reverse order</option>
232
+                     </select>
233
+        
234
+       </form>
235
+      </div>
236
+    </div>
237
+    <!-- end main content -->
238
+    
239
+    <p style="text-align: center; font-size: 1.2em;"> VLC media player - version 0.8.6c Janus - (c) 1996-2007 the VideoLAN team </p>
240
+
241
+    <script type="text/javascript">
242
+      got_time = 38;
243
+      hours = Math.floor(got_time/ 3600);
244
+      minutes = Math.floor((got_time/60) % 60);
245
+      seconds = got_time % 60;
246
+      if ( hours < 10 ) hours = "0" + hours;
247
+      if ( minutes < 10 ) minutes = "0" + minutes;
248
+      if ( seconds < 10 ) seconds = "0" + seconds;
249
+      document.getElementById('time').innerHTML = hours+":"+minutes+":"+seconds;
250
+      got_length = 249;
251
+      hours = Math.floor(got_length/ 3600);
252
+      minutes = Math.floor((got_length/60) % 60);
253
+      seconds = got_length % 60;
254
+      if ( hours < 10 ) hours = "0" + hours;
255
+      if ( minutes < 10 ) minutes = "0" + minutes;
256
+      if ( seconds < 10 ) seconds = "0" + seconds;
257
+      document.getElementById('length').innerHTML = hours+":"+minutes+":"+seconds;
258
+      got_volume = 56;
259
+      document.getElementById( 'volume').innerHTML = Math.ceil(got_volume * 400/1024) + " %";
260
+    </script>
261
+</body></html>

+ 56
- 0
test/com/dmdirc/addons/mediasource_vlc/info-1.html View File

@@ -0,0 +1,56 @@
1
+<html><head>
2
+<meta http-equiv="content-type" content="text/html; charset=UTF-8">
3
+
4
+    <title>VLC media player - Information</title>
5
+</head><body>
6
+    <h2><center><a href="http://127.0.0.1:8082/old/">VLC media player 0.8.6c Janus</a></center></h2>
7
+    <hr>
8
+    
9
+        <p> Stream 0
10
+        </p><ul>
11
+        
12
+            <li> Codec: mpga </li>
13
+        
14
+            <li> Language:  </li>
15
+        
16
+            <li> Type: Audio </li>
17
+        
18
+            <li> Channels: 2 </li>
19
+        
20
+            <li> Sample rate: 44100 Hz </li>
21
+        
22
+            <li> Bitrate: 128 kb/s </li>
23
+        
24
+        </ul>
25
+    
26
+        <p> General
27
+        </p><ul>
28
+        
29
+            <li> Duration: 0:04:09 </li>
30
+        
31
+        </ul>
32
+    
33
+        <p> Meta-information
34
+        </p><ul>
35
+        
36
+            <li> Title: The Second Great Depression </li>
37
+        
38
+            <li> Artist: Manic Street Preachers </li>
39
+        
40
+            <li> Album/movie/show title: Send Away The Tigers </li>
41
+        
42
+            <li> Date: 2007 </li>
43
+        
44
+            <li> Track number/position in set: 5 </li>
45
+        
46
+            <li> Genre: Rock </li>
47
+        
48
+            <li> Encoded by: LAME 3.90.3 Modified </li>
49
+        
50
+            <li> Language(s): English </li>
51
+        
52
+        </ul>
53
+    
54
+    <hr>
55
+    <p>VLC media player - version 0.8.6c Janus - (c) 1996-2007 the VideoLAN team </p>
56
+</body></html>

Loading…
Cancel
Save