]> git.sesse.net Git - vlc/blobdiff - src/control/testapi.c
Files belonging to patch from, thannoy: Allow future control toolbar to be hidden...
[vlc] / src / control / testapi.c
index bb61fd49f1c9f0fc4d3a48dd1f615bd94fa98f83..02acd8eeb7a955552e7f34a9a3e87fbc38a5e685 100644 (file)
@@ -67,6 +67,8 @@ static void test_core (const char ** argv, int argc);
 static void test_media_list (const char ** argv, int argc);
 static void test_events (const char ** argv, int argc);
 static void test_media_player_play_stop(const char** argv, int argc);
+static void test_media_player_pause_stop(const char** argv, int argc);
+static void test_media_list_player_pause_stop(const char** argv, int argc);
 
 /* Tests implementations */
 static void test_core (const char ** argv, int argc)
@@ -245,12 +247,13 @@ static void test_events (const char ** argv, int argc)
     vlc_bool_t callback_was_called;
     libvlc_exception_t ex;
     libvlc_event_type_t mi_events[] = {
-        libvlc_MediaInstancePlayed,
-        libvlc_MediaInstancePaused,
-        libvlc_MediaInstanceReachedEnd,
-        libvlc_MediaInstanceEncounteredError,
-        libvlc_MediaInstanceTimeChanged,
-        libvlc_MediaInstancePositionChanged,
+        libvlc_MediaPlayerPlayed,
+        libvlc_MediaPlayerPaused,
+        libvlc_MediaPlayerEndReached,
+        libvlc_MediaPlayerStopped,
+        libvlc_MediaPlayerEncounteredError,
+        libvlc_MediaPlayerTimeChanged,
+        libvlc_MediaPlayerPositionChanged,
     };
     int i, mi_events_len = sizeof(mi_events)/sizeof(*mi_events);
     
@@ -353,6 +356,99 @@ static void test_media_player_play_stop(const char** argv, int argc)
     catch ();
 }
 
+static void test_media_player_pause_stop(const char** argv, int argc)
+{
+    libvlc_instance_t *vlc;
+    libvlc_media_t *md;
+    libvlc_media_player_t *mi;
+    const char * file = "file://../bindings/java/core/src/test/resources/raffa_voice.ogg";
+
+    log ("Testing play and pause of %s\n", file);
+
+    libvlc_exception_init (&ex);
+    vlc = libvlc_new (argc, argv, &ex);
+    catch ();
+
+    md = libvlc_media_new (vlc, file, &ex);
+    catch ();
+
+    mi = libvlc_media_player_new_from_media (md, &ex);
+    catch ();
+    
+    libvlc_media_release (md);
+
+    libvlc_media_player_play (mi, &ex);
+    catch ();
+
+    /* FIXME: Do something clever */
+    sleep(1);
+
+    assert( libvlc_media_player_get_state (mi, &ex) == libvlc_Playing );
+    catch ();
+
+    libvlc_media_player_pause (mi, &ex);
+    assert( libvlc_media_player_get_state (mi, &ex) == libvlc_Paused );
+    catch();
+
+    libvlc_media_player_stop (mi, &ex);
+    catch ();
+
+    libvlc_media_player_release (mi);
+    catch ();
+
+    libvlc_release (vlc);
+    catch ();
+}
+
+static void test_media_list_player_pause_stop(const char** argv, int argc)
+{
+    libvlc_instance_t *vlc;
+    libvlc_media_t *md;
+    libvlc_media_list_t *ml;
+    libvlc_media_list_player_t *mlp;
+    
+    const char * file = "file://../bindings/java/core/src/test/resources/raffa_voice.ogg";
+
+    log ("Testing play and pause of %s using the media list.\n", file);
+
+    libvlc_exception_init (&ex);
+    vlc = libvlc_new (argc, argv, &ex);
+    catch ();
+
+    md = libvlc_media_new (vlc, file, &ex);
+    catch ();
+
+    ml = libvlc_media_list_new (vlc, &ex);
+    catch ();
+    
+    mlp = libvlc_media_list_player_new (vlc, &ex);
+
+    libvlc_media_list_add_media( ml, md, &ex );
+    catch ();
+
+    libvlc_media_list_player_set_media_list( mlp, ml, &ex );
+
+    libvlc_media_list_player_play_item( mlp, md, &ex );
+    sleep(1); // play is asynchronous
+    catch ();
+
+    libvlc_media_list_player_pause (mlp, &ex);
+    catch();
+
+    libvlc_media_list_player_stop (mlp, &ex);
+    catch ();
+
+    libvlc_media_release (md);
+    
+    libvlc_media_list_player_release (mlp);
+    catch ();
+
+    libvlc_release (vlc);
+    catch ();
+}
+
+
+
 int main (int argc, char *argv[])
 {
     const char *args[argc + 5];
@@ -377,5 +473,9 @@ int main (int argc, char *argv[])
 
     test_media_player_play_stop(args, nlibvlc_args);
 
+    test_media_player_pause_stop(args, nlibvlc_args);
+
+    test_media_list_player_pause_stop(args, nlibvlc_args);
+    
     return 0;
 }