jvlc: unit tests aligned with latest code update master
authorFilippo Carone <littlejohn@videolan.org>
Tue, 24 Aug 2010 18:46:08 +0000 (20:46 +0200)
committerFilippo Carone <littlejohn@videolan.org>
Tue, 24 Aug 2010 18:46:08 +0000 (20:46 +0200)
core/src/test/java/org/videolan/jvlc/MediaDescriptorTest.java
core/src/test/java/org/videolan/jvlc/MediaListTest.java
core/src/test/java/org/videolan/jvlc/internal/LibVlcMediaEventsTest.java
core/src/test/java/org/videolan/jvlc/internal/LibVlcMediaListEventsTest.java
core/src/test/java/org/videolan/jvlc/internal/LibVlcMediaListPlayerTest.java
core/src/test/java/org/videolan/jvlc/internal/LibVlcMediaPlayerEventsTest.java

index a8d0b59..6a41262 100644 (file)
@@ -35,6 +35,7 @@ public class MediaDescriptorTest extends AbstractJVLCTest
     @Test
     public void getMrlTest()
     {
+       mrl += "file://";
         MediaDescriptor md = new MediaDescriptor(jvlc, mrl);
         Assert.assertEquals(mrl, md.getMrl());
     }
index 2b050cb..4ac1bb2 100644 (file)
@@ -82,7 +82,7 @@ public class MediaListTest extends AbstractJVLCTest
         Assert.assertEquals(0, mlist.size());
         
         mlist.addMedia(new MediaDescriptor(jvlc, mrl));
-        mlist.removeMedia(mrl);
+        mlist.removeMedia(mlist.getMediaDescriptorAtIndex(0));
         Assert.assertEquals(0, mlist.size());
         
         mlist.addMedia(new MediaDescriptor(jvlc, mrl));
index faf836a..1dbefb6 100644 (file)
@@ -49,12 +49,12 @@ public class LibVlcMediaEventsTest extends AbstractVLCEventTest
 
             public void callback(libvlc_event_t libvlc_event, Pointer userData)
             {
-                Assert.assertEquals(LibVlcEventType.libvlc_MediaFreed.ordinal(), libvlc_event.type);
+                Assert.assertEquals(LibVlcEventType.libvlc_MediaFreed.getEventNumber(), libvlc_event.type);
                 eventFired = 1;
             }
             
         };
-        libvlc.libvlc_event_attach(eventManager, LibVlcEventType.libvlc_MediaFreed.ordinal(), callback, null);
+        libvlc.libvlc_event_attach(eventManager, LibVlcEventType.libvlc_MediaFreed.getEventNumber(), callback, null);
         libvlc.libvlc_media_release(media);
         Assert.assertEquals(1, eventFired);
     }
index cfe580c..f16ac9b 100644 (file)
@@ -52,14 +52,14 @@ public class LibVlcMediaListEventsTest extends AbstractVLCEventTest
 
             public void callback(libvlc_event_t libvlc_event, Pointer userData)
             {
-                Assert.assertEquals(LibVlcEventType.libvlc_MediaListItemAdded.ordinal(), libvlc_event.type);
+                Assert.assertEquals(LibVlcEventType.libvlc_MediaListItemAdded.getEventNumber(), libvlc_event.type);
                 eventFired = 1;
             }
         };
         
         libvlc.libvlc_event_attach(
             eventManager,
-            LibVlcEventType.libvlc_MediaListItemAdded.ordinal(),
+            LibVlcEventType.libvlc_MediaListItemAdded.getEventNumber(),
             callback,
             null
             );
@@ -80,14 +80,14 @@ public class LibVlcMediaListEventsTest extends AbstractVLCEventTest
 
             public void callback(libvlc_event_t libvlc_event, Pointer userData)
             {
-                Assert.assertEquals(LibVlcEventType.libvlc_MediaListItemDeleted.ordinal(), libvlc_event.type);
+                Assert.assertEquals(LibVlcEventType.libvlc_MediaListItemDeleted.getEventNumber(), libvlc_event.type);
                 eventFired = 1;
             }
         };
         
         libvlc.libvlc_event_attach(
             eventManager,
-            LibVlcEventType.libvlc_MediaListItemDeleted.ordinal(),
+            LibVlcEventType.libvlc_MediaListItemDeleted.getEventNumber(),
             callback,
             null
             );
index 9a9ace0..770941b 100644 (file)
@@ -97,7 +97,7 @@ public class LibVlcMediaListPlayerTest extends AbstractVLCInternalTest
     }
 
     @Test
-    public void mediaListPlayerPlay()
+    public void mediaListPlayerPlay() throws Exception
     {
         
         LibVlcMediaListPlayer mediaListPlayer = libvlc.libvlc_media_list_player_new(libvlcInstance);
@@ -107,7 +107,7 @@ public class LibVlcMediaListPlayerTest extends AbstractVLCInternalTest
         libvlc.libvlc_media_list_add_media(mediaList, mediaDescriptor);
         libvlc.libvlc_media_list_player_set_media_list(mediaListPlayer, mediaList);
         libvlc.libvlc_media_list_player_play(mediaListPlayer);
-        
+        Thread.sleep(5000);
         libvlc.libvlc_media_release(mediaDescriptor);
         libvlc.libvlc_media_list_release(mediaList);
     }
@@ -132,7 +132,7 @@ public class LibVlcMediaListPlayerTest extends AbstractVLCInternalTest
             Thread.sleep(150);
         }
         libvlc.libvlc_media_list_player_stop(mediaListPlayer);
-        while (libvlc.libvlc_media_list_player_get_state(mediaListPlayer) != LibVlcState.libvlc_Ended
+        while (libvlc.libvlc_media_list_player_get_state(mediaListPlayer) != LibVlcState.libvlc_Stopped
             .ordinal())
         {
             Thread.sleep(100);
@@ -178,7 +178,7 @@ public class LibVlcMediaListPlayerTest extends AbstractVLCInternalTest
         libvlc.libvlc_media_list_player_release(mediaListPlayer);
     }
 
-    @Test
+    @Test(timeout = 30000)
     public void mediaLtistPlayerPause() throws Exception
     {
         
@@ -198,16 +198,11 @@ public class LibVlcMediaListPlayerTest extends AbstractVLCInternalTest
             Thread.sleep(150);
         }
         libvlc.libvlc_media_list_player_pause(mediaListPlayer);
+        while (libvlc.libvlc_media_list_player_get_state(mediaListPlayer) != LibVlcState.libvlc_Paused.ordinal())
+        {
+               Thread.sleep(100);
+        }
 
-        Thread.sleep(500);
-        
-        int state = libvlc.libvlc_media_list_player_get_state(mediaListPlayer);
-        
-        Thread.sleep(200L);
-        Assert.assertEquals(
-            "Expected state: " + LibVlcState.libvlc_Paused + ".\n",
-            LibVlcState.libvlc_Paused.ordinal(),
-            state);
         libvlc.libvlc_media_list_player_stop(mediaListPlayer);
         libvlc.libvlc_media_list_release(mediaList);
         libvlc.libvlc_media_list_player_release(mediaListPlayer);
@@ -285,7 +280,7 @@ public class LibVlcMediaListPlayerTest extends AbstractVLCInternalTest
             }
             Thread.sleep(150);
         }
-        Assert.assertEquals(LibVlcState.libvlc_Ended.ordinal(), libvlc.libvlc_media_list_player_get_state(
+        Assert.assertEquals(LibVlcState.libvlc_Stopped.ordinal(), libvlc.libvlc_media_list_player_get_state(
             mediaListPlayer));
         libvlc.libvlc_media_list_release(mediaList);
     }
@@ -297,7 +292,7 @@ public class LibVlcMediaListPlayerTest extends AbstractVLCInternalTest
         if (current != null)
         {
             libvlc.libvlc_media_list_player_stop(current);
-            while (libvlc.libvlc_media_list_player_get_state(current) != LibVlcState.libvlc_Ended.ordinal())
+            while (libvlc.libvlc_media_list_player_get_state(current) != LibVlcState.libvlc_Stopped.ordinal())
             {
                 try
                 {
index 6f370f2..c11ec9d 100644 (file)
@@ -51,14 +51,14 @@ public class LibVlcMediaPlayerEventsTest extends AbstractVLCEventTest
 
             public void callback(libvlc_event_t libvlc_event, Pointer userData)
             {
-                Assert.assertEquals(LibVlcEventType.libvlc_MediaPlayerPlaying.ordinal(), libvlc_event.type);
+                Assert.assertEquals(LibVlcEventType.libvlc_MediaPlayerPlaying.getEventNumber(), libvlc_event.type);
                 eventFired = 1;
             }
         };
         
         libvlc.libvlc_event_attach(
             eventManager,
-            LibVlcEventType.libvlc_MediaPlayerPlaying.ordinal(),
+            LibVlcEventType.libvlc_MediaPlayerPlaying.getEventNumber(),
             callback,
             null
             );
@@ -78,14 +78,14 @@ public class LibVlcMediaPlayerEventsTest extends AbstractVLCEventTest
 
             public void callback(libvlc_event_t libvlc_event, Pointer userData)
             {
-                Assert.assertEquals(LibVlcEventType.libvlc_MediaPlayerPaused.ordinal(), libvlc_event.type);                
+                Assert.assertEquals(LibVlcEventType.libvlc_MediaPlayerPaused.getEventNumber(), libvlc_event.type);                
                 eventFired = 1;
             }
         };
         
         libvlc.libvlc_event_attach(
             eventManager,
-            LibVlcEventType.libvlc_MediaPlayerPaused.ordinal(),
+            LibVlcEventType.libvlc_MediaPlayerPaused.getEventNumber(),
             callback,
             null
             );
@@ -109,14 +109,14 @@ public class LibVlcMediaPlayerEventsTest extends AbstractVLCEventTest
 
             public void callback(libvlc_event_t libvlc_event, Pointer userData)
             {
-                Assert.assertEquals(LibVlcEventType.libvlc_MediaPlayerStopped.ordinal(), libvlc_event.type);                
+                Assert.assertEquals(LibVlcEventType.libvlc_MediaPlayerStopped.getEventNumber(), libvlc_event.type);                
                 eventFired = 1;
             }
         };
         
         libvlc.libvlc_event_attach(
             eventManager,
-            LibVlcEventType.libvlc_MediaPlayerStopped.ordinal(),
+            LibVlcEventType.libvlc_MediaPlayerStopped.getEventNumber(),
             callback,
             null
             );