[grilo-plugins] apple-trailers: Add testsuite



commit a6e66c7c603a152e23a662c2a4877c774b60ea8f
Author: Juan A. Suarez Romero <jasuarez igalia com>
Date:   Mon Jul 8 13:28:24 2013 +0200

    apple-trailers: Add testsuite
    
    Add a small testsuite for Apple Trailers plugin.

 configure.ac                                  |    1 +
 src/apple-trailers/Makefile.am                |    8 ++
 tests/Makefile.am                             |    5 +
 tests/apple-trailers/Makefile.am              |   39 ++++++
 tests/apple-trailers/data/apple-trailers.data |    2 +
 tests/apple-trailers/data/network-data.ini    |    6 +
 tests/apple-trailers/test_apple_trailers.c    |  160 +++++++++++++++++++++++++
 7 files changed, 221 insertions(+), 0 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 4c8840a..75c47b8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1190,6 +1190,7 @@ AC_CONFIG_FILES([
   src/vimeo/Makefile
   src/youtube/Makefile
   tests/Makefile
+  tests/apple-trailers/Makefile
   tests/tmdb/Makefile
 ])
 
diff --git a/src/apple-trailers/Makefile.am b/src/apple-trailers/Makefile.am
index 0354964..8b049ab 100644
--- a/src/apple-trailers/Makefile.am
+++ b/src/apple-trailers/Makefile.am
@@ -28,6 +28,14 @@ extdir                                               = $(GRL_PLUGINS_DIR)
 appletrailersxmldir            = $(GRL_PLUGINS_DIR)
 appletrailersxml_DATA  = $(APPLE_TRAILERS_PLUGIN_ID).xml
 
+# This lets us test the plugin without installing it,
+# because grilo expects the .so and .xml files to be in
+# the same directory:
+copy-xml-to-libs-dir: libgrlappletrailers.la
+       cp -f $(srcdir)/$(appletrailersxml_DATA) $(builddir)/.libs/
+
+all-local: copy-xml-to-libs-dir
+
 EXTRA_DIST = $(appletrailersxml_DATA)
 
 MAINTAINERCLEANFILES = \
diff --git a/tests/Makefile.am b/tests/Makefile.am
index b69c7c1..5049df5 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -9,11 +9,16 @@ include $(top_srcdir)/gtester.mk
 
 SUBDIRS =
 
+if APPLE_TRAILERS_PLUGIN
+SUBDIRS += apple-trailers
+endif
+
 if TMDB_PLUGIN
 SUBDIRS += tmdb
 endif
 
 DIST_SUBDIRS =    \
+   apple-trailers \
    tmdb
 
 MAINTAINERCLEANFILES =  \
diff --git a/tests/apple-trailers/Makefile.am b/tests/apple-trailers/Makefile.am
new file mode 100644
index 0000000..0800b5e
--- /dev/null
+++ b/tests/apple-trailers/Makefile.am
@@ -0,0 +1,39 @@
+#
+# Makefile.am
+#
+# Author: Iago Toral <itoral igalia com>
+#
+# Copyright (C) 2013 Igalia S.L.
+
+include $(top_srcdir)/gtester.mk
+
+INCLUDES = @DEPS_CFLAGS@
+
+TEST_PROGS +=  \
+   test_apple_trailers
+
+test_apple_trailers_defines =                                                       \
+   -DAPPLE_TRAILERS_PLUGIN_PATH=\""$(abs_top_builddir)/src/apple-trailers/.libs/"\"    \
+   -DAPPLE_TRAILERS_DATA_PATH=\""$(abs_top_srcdir)/tests/apple-trailers/data/"\"
+
+test_apple_trailers_SOURCES =  \
+       test_apple_trailers.c
+
+test_apple_trailers_LDADD =    \
+       @DEPS_LIBS@
+
+test_apple_trailers_CFLAGS =   \
+       $(test_apple_trailers_defines)
+
+# Distribute the tests data:
+dist_noinst_DATA =         \
+   data/network-data.ini   \
+   data/apple-trailers.data
+
+noinst_PROGRAMS = $(TEST_PROGS)
+
+MAINTAINERCLEANFILES =  \
+   *.in                 \
+   *~
+
+DISTCLEANFILES = $(MAINTAINERCLEANFILES)
diff --git a/tests/apple-trailers/data/apple-trailers.data b/tests/apple-trailers/data/apple-trailers.data
new file mode 100644
index 0000000..b7ee457
--- /dev/null
+++ b/tests/apple-trailers/data/apple-trailers.data
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="utf-8"?>
+<records date="Mon, 01 Jul 2013 01:00:31 -0700"><movieinfo id="7501"><info><title>2 
Guns</title><runtime>3:05</runtime><rating>Not yet rated</rating><studio>Universal 
Pictures</studio><postdate>2013-03-29</postdate><releasedate>2013-08-02</releasedate><copyright>© Copyright 
2013 Universal Pictures</copyright><director>Baltasar Kormákur</director><description>Academy Award(R) winner 
Denzel Washington and Mark Wahlberg lead an all-star cast in 2 Guns, an explosive action film that tracks two 
operatives from competing bureaus who are forced on the run together.  But there is a big problem with their 
unique alliance: Neither knows that the other is an undercover federal agent.      
</description></info><cast><name>Denzel Washington</name><name>Mark Wahlberg</name><name>Paula 
Patton</name><name>Bill Paxton</name><name>Fred Ward</name><name>James Marsden</name><name>Edward James 
Olmos</name></cast><genre><name>Action and Adventure</name></genre><poster><location>http://trailers.
 
apple.com/trailers/universal/2guns/images/poster.jpg</location><xlarge>http://trailers.apple.com/trailers/universal/2guns/images/poster-xlarge.jpg</xlarge></poster><preview><large
 
filesize="25519191">http://trailers.apple.com/movies/universal/2guns/2guns-tlr_h480p.mov</large></preview></movieinfo><movieinfo
 id="7863"><info><title>20 Feet from 
Stardom</title><runtime>2:13</runtime><rating>PG-13</rating><studio>RADiUS / 
TWC</studio><postdate>2013-05-01</postdate><releasedate>2013-06-14</releasedate><copyright>© Copyright 2013 
RADiUS / TWC</copyright><director>Morgan Neville</director><description>Millions know their voices, but no 
one knows their names. In his compelling new film TWENTY FEET FROM STARDOM, award-winning director Morgan 
Neville shines a spotlight on the untold true story of the backup singers behind some of the greatest musical 
legends of the 21st century. Triumphant and heartbreaking in equal measure, the film is both a tribute to the 
unsung voices who brought
  shape and style to popular music and a reflection on the conflicts, sacrifices and rewards of a career 
spent harmonizing with others.</description></info><cast><name>Darlene Love</name><name>Merry 
Clayton</name><name>Lisa Fischer</name><name>Tata Vega</name><name>Judith 
Hill</name></cast><genre><name>Drama</name></genre><poster><location>http://trailers.apple.com/trailers/independent/twentyfeetfromstardom/images/poster.jpg</location><xlarge>http://trailers.apple.com/trailers/independent/twentyfeetfromstardom/images/poster-xlarge.jpg</xlarge></poster><preview><large
 
filesize="27263951">http://trailers.apple.com/movies/independent/20feetfromstardom/20feetfromstardom-tlr_h480p.mov</large></preview></movieinfo><movieinfo
 id="6466"><info><title>300: Rise of an Empire</title><runtime>2:30</runtime><rating>Not yet 
rated</rating><studio>Warner Bros. 
Pictures</studio><postdate>2013-06-21</postdate><releasedate>2014-03-07</releasedate><copyright>© Copyright 
2014 Warner Bros. Picture
 s</copyright><director>Noam Murro</director><description>Based on Frank Miller’s latest graphic novel Xerxes 
and told in the breathtaking visual style of the blockbuster “300,” this new chapter of the epic saga takes 
the action to a fresh battlefield—on the sea—as Greek general Themistokles (Sullivan Stapleton) attempts to 
unite all of Greece by leading the charge that will change the course of the war. “300: Rise of an Empire” 
pits Themistokles against the massive invading Persian forces led by mortal-turned-god Xerxes (Rodrigo 
Santoro), and Artemesia (Eva Green), vengeful commander of the Persian 
navy.</description></info><cast><name>Sullivan Stapleton</name><name>Eva Green</name><name>Lena 
Headey</name><name>Hans Matheson</name><name>Rodrigo Santoro</name><name>David Wenham</name><name>Igal 
Nao</name><name>Callan Mulvey</name><name>Jack O'Connell</name><name>Andrew 
Tiernan</name></cast><genre><name>Action and Adventure</name></genre><poster><location>http://
 
trailers.apple.com/trailers/wb/300riseofanempire/images/poster.jpg</location><xlarge>http://trailers.apple.com/trailers/wb/300riseofanempire/images/poster-xlarge.jpg</xlarge></poster><preview><large
 
filesize="19392254">http://trailers.apple.com/movies/wb/300riseofanempire/300riseofanempire-tlr1_h480p.mov</large></preview></movieinfo><movieinfo
 id="5583"><info><title>42</title><runtime>2:33</runtime><rating>PG-13</rating><studio>Warner Bros. 
Pictures</studio><postdate>2013-01-10</postdate><releasedate>2013-04-12</releasedate><copyright>© Copyright 
2013 Warner Bros. Pictures</copyright><director>Brian Helgeland</director><description>Warner Bros. Pictures 
and Legendary Pictures are teaming up with director Brian Helgeland for “42,” the powerful story of Jackie 
Robinson, the legendary baseball player who broke Major League Baseball’s color barrier when he joined the 
roster of the Brooklyn Dodgers. “42” will star Academy Award(R) nominee Harrison Ford (“Witness”) 
 as the innovative Dodger’s general manager Branch Rickey, the MLB executive who first signed Robinson to the 
minors and then helped to bring him up to the show, and Chadwick Boseman (“The Express”) as Robinson, the 
heroic African American who was the first man to break the color line in the big 
leagues.</description></info><cast><name>Harrison Ford</name><name>Christopher Meloni</name><name>Ryan 
Merriman</name><name>Brad Beyer</name><name>Judy Tylor</name><name>Jon Bernthal</name><name>Nicole 
Beharie</name><name>Chadwick Boseman</name><name>T.R. 
Knight</name></cast><genre><name>Drama</name></genre><poster><location>http://trailers.apple.com/trailers/wb/42/images/poster.jpg</location><xlarge>http://trailers.apple.com/trailers/wb/42/images/poster-xlarge.jpg</xlarge></poster><preview><large
 
filesize="46695833">http://trailers.apple.com/movies/wb/42/42-tlr2_h480p.mov</large></preview></movieinfo><movieinfo
 id="7746"><info><title>A Hijacking</title><runtime>1:28</runtime><r
 ating>R</rating><studio>Magnolia 
Pictures</studio><postdate>2013-04-22</postdate><releasedate>2013-06-21</releasedate><copyright>© Copyright 
2013 Magnolia Pictures</copyright><director>Tobias Lindholm</director><description>The cargo ship MV Rozen is 
heading for harbour when it is hijacked by Somali pirates in the Indian Ocean. Amongst the men on board are 
the ship’s cook Mikkel and the engineer Jan, who along with the rest of the seamen are taken hostage in a 
cynical game of life and death. With the demand for a ransom of millions of dollars a psychological drama 
unfolds between the CEO of the shipping company and the Somali pirates.</description></info><cast><name>Johan 
Philip Asbæk</name><name>Søren Malling</name><name>Dar Salim</name><name>Roland Møller</name><name>Gary 
Skjoldmose Porter</name><name>Abdihakin Asgar</name><name>Amalie Alstrup</name><name>Amalie Vulff 
Andersen</name><name>Linda Laursen</name><name>Keith Pearson</name></cast><genre><name>Drama</name><
 
/genre><poster><location>http://trailers.apple.com/trailers/magnolia/ahijacking/images/poster.jpg</location><xlarge>http://trailers.apple.com/trailers/magnolia/ahijacking/images/poster-xlarge.jpg</xlarge></poster><preview><large
 
filesize="24157601">http://trailers.apple.com/movies/magnolia_pictures/ahijacking/ahijacking-tlr_h480p.mov</large></preview></movieinfo><movieinfo
 id="8243"><info><title>About Time</title><runtime>2:30</runtime><rating>Not yet 
rated</rating><studio>Universal 
Pictures</studio><postdate>2013-05-21</postdate><releasedate>2013-11-01</releasedate><copyright>© Copyright 
2013 Universal Pictures</copyright><director>Richard Curtis</director><description>The night after another 
unsatisfactory New Year party, Tim’s father (Bill Nighy) tells his son that the men in his family have always 
had the ability to travel through time. Tim can’t change history, but he can change what happens and has 
happened in his own life—so he decides to make his world a bette
 r place… by getting a girlfriend. Sadly, that turns out not to be as easy as you might 
think.</description></info><cast><name>Domhnall Gleeson</name><name>Rachel McAdams</name><name>Bill Nighy 
</name><name>Tom Hollander</name><name>Margot 
Robbie</name></cast><genre><name>Comedy</name></genre><poster><location>http://trailers.apple.com/trailers/universal/abouttime/images/poster.jpg</location><xlarge>http://trailers.apple.com/trailers/universal/abouttime/images/poster-xlarge.jpg</xlarge></poster><preview><large
 
filesize="20418329">http://trailers.apple.com/movies/universal/abouttime/abouttime-tlr1_h480p.mov</large></preview></movieinfo><movieinfo
 id="8661"><info><title>Adore</title><runtime>2:30</runtime><rating>R</rating><studio>Exclusive 
Media</studio><postdate>2013-06-24</postdate><releasedate>2013-09-06</releasedate><copyright>© Copyright 2013 
Exclusive Media</copyright><director>Anne Fontaine</director><description>Naomi Watts and Robin Wright 
deliver riveting performa
 nces in ADORE, a sensual and provocative drama about two lifelong friends who find unexpected happiness in 
relationships that cross the bounds of convention.  An unpredictable tale of misguided love and a heartfelt 
celebration of the enduring nature of female friendship, ADORE is the English-speaking directorial debut of 
Anne Fontaine.  Set in an Australian seaside town, ADORE establishes an aura of fable as it follows two 
women’s plunge into uncharted waters.  Watts and Wright fearlessly engage with the physical and psychological 
components of the story, capturing the complex emotions and powerful desires driving their characters.  
Strong performances from Xavier Samuel and James Frecheville complement Watts and Wright.  ADORE radiates 
with intoxicating sensuality while exploring the intricacies of love, family, morality and 
passion.</description></info><cast><name>Naomi Watts</name><name>Robin Wright</name><name>Xavier 
Samuel</name><name>James Frechevile</name><name>Ben 
 
Mendelsohn</name></cast><genre><name>Drama</name></genre><poster><location>http://trailers.apple.com/trailers/independent/adore/images/poster.jpg</location><xlarge>http://trailers.apple.com/trailers/independent/adore/images/poster-xlarge.jpg</xlarge></poster><preview><large
 
filesize="20873720">http://trailers.apple.com/movies/independent/adore/adore-tlr1_h480p.mov</large></preview></movieinfo><movieinfo
 id="6402"><info><title>After Earth</title><runtime>2:31</runtime><rating>PG-13</rating><studio>Columbia 
Pictures</studio><postdate>2013-03-07</postdate><releasedate>2013-05-31</releasedate><copyright>© Copyright 
2013 Columbia Pictures</copyright><director>M. Night Shyamalan</director><description>A crash landing leaves 
teenager Kitai Raige (Jaden Smith) and his legendary father Cypher (Will Smith) stranded on Earth, 1,000 
years after cataclysmic events forced humanity’s escape. With Cypher critically injured, Kitai must embark on 
a perilous journey to signal for help, faci
 ng uncharted terrain, evolved animal species that now rule the planet, and an unstoppable alien creature 
that escaped during the crash. Father and son must learn to work together and trust one another if they want 
any chance of returning home.</description></info><cast><name>Jaden Smith</name><name>Will 
Smith</name></cast><genre><name>Science Fiction</name><name>Action and 
Adventure</name></genre><poster><location>http://trailers.apple.com/trailers/sony_pictures/afterearth/images/poster.jpg</location><xlarge>http://trailers.apple.com/trailers/sony_pictures/afterearth/images/poster-xlarge.jpg</xlarge></poster><preview><large
 
filesize="60882616">http://trailers.apple.com/movies/sony_pictures/afterearth/afterearth-tlr2_h480p.mov</large></preview></movieinfo><movieinfo
 id="8063"><info><title>Aftershock</title><runtime>2:25</runtime><rating>R</rating><studio>RADiUS / 
TWC</studio><postdate>2013-05-09</postdate><releasedate>2013-05-10</releasedate><copyright>© Copyright 2013 
RADiU
 S / TWC</copyright><director>Nicolas Lopez</director><description>In the middle of a night of wild partying, 
a hapless American tourist (Hostel director Eli Roth) and his friends are suddenly plunged into a living hell 
when a powerful earthquake rips through the coastal town of Valparaíso, 
Chile.</description></info><cast><name>Eli Roth</name><name>Andrea Osvart</name><name>Ariel 
Levy</name><name>Natasha Yarovenko</name><name>Nicolas Martinez</name><name>Lorenza Izzo</name><name>Selena 
Gomez</name></cast><genre><name>Horror</name><name>Thriller</name></genre><poster><location>http://trailers.apple.com/trailers/independent/aftershock/images/poster.jpg</location><xlarge>http://trailers.apple.com/trailers/independent/aftershock/images/poster-xlarge.jpg</xlarge></poster><preview><large
 
filesize="17761014">http://trailers.apple.com/movies/weinstein/aftershock/aftershock-tlr1_h480p.mov</large></preview></movieinfo><movieinfo
 id="4997"><info><title>Anchorman 2</title><runtime>1:40
 </runtime><rating>Not yet rated</rating><studio>Paramount 
Pictures</studio><postdate>2013-06-21</postdate><releasedate/><copyright>© Copyright 1969 Paramount 
Pictures</copyright><director>Adam McKay</director><description>With the 70’s behind him, San Diego’s top 
rated newsman, Ron Burgundy (Will Ferrell), returns to the news desk in “Anchorman 2: The Legend Continues.”  
Also back for more are Ron’s co-anchor and wife, Veronica Corningstone (Christina Applegate), weather man 
Brick Tamland (Steve Carell), man on the street Brian Fantana (Paul Rudd) and sports guy Champ Kind (David 
Koechner) - All of whom won’t make it easy to stay classy…while taking New York’s first 24-hour news channel 
by storm. </description></info><cast><name>Will Ferrell</name><name>Steve Carell</name><name>Paul 
Rudd</name></cast><genre><name>Comedy</name></genre><poster><location>http://trailers.apple.com/trailers/paramount/anchorman2/images/poster.jpg</location><xlarge>http://trailers.
 apple.com/trailers/paramount/anchorman2/images/poster-xlarge.jpg</xlarge></poster><preview><large 
filesize="13783301">http://trailers.apple.com/movies/paramount/anchorman2/anchorman2-tlr3_h480p.mov</large></preview></movieinfo></records>
diff --git a/tests/apple-trailers/data/network-data.ini b/tests/apple-trailers/data/network-data.ini
new file mode 100644
index 0000000..1b16d53
--- /dev/null
+++ b/tests/apple-trailers/data/network-data.ini
@@ -0,0 +1,6 @@
+[default]
+version=1
+
+[http://trailers.apple.com/trailers/home/xml/current_480p.xml]
+data=apple-trailers.data
+
diff --git a/tests/apple-trailers/test_apple_trailers.c b/tests/apple-trailers/test_apple_trailers.c
new file mode 100644
index 0000000..809616d
--- /dev/null
+++ b/tests/apple-trailers/test_apple_trailers.c
@@ -0,0 +1,160 @@
+/*
+ * Copyright (C) 2013 Igalia S.L.
+ *
+ * Author: Juan A. Suarez Romero <jasuarez igalia com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+#include <grilo.h>
+
+#define APPLE_TRAILERS_ID "grl-apple-trailers"
+
+static void
+test_setup (void)
+{
+  GError *error = NULL;
+  GrlRegistry *registry;
+
+  registry = grl_registry_get_default ();
+  grl_registry_load_all_plugins (registry, &error);
+  g_assert_no_error (error);
+}
+
+static void
+verify (GrlData *data,
+        guint n)
+{
+  static GHashTable *expected[3] = { NULL };
+  static gboolean initialized = FALSE;
+
+  g_return_if_fail (n < 3);
+
+  if (!initialized) {
+    initialized = TRUE;
+
+    expected[0] = g_hash_table_new (NULL, NULL);
+    g_hash_table_insert (expected[0], GRLKEYID_TO_POINTER (GRL_METADATA_KEY_ID), "7501");
+    g_hash_table_insert (expected[0], GRLKEYID_TO_POINTER (GRL_METADATA_KEY_TITLE), "2 Guns");
+    g_hash_table_insert (expected[0], GRLKEYID_TO_POINTER (GRL_METADATA_KEY_DURATION), GINT_TO_POINTER 
(11100));
+
+    expected[1] = g_hash_table_new (NULL, NULL);
+    g_hash_table_insert (expected[1], GRLKEYID_TO_POINTER (GRL_METADATA_KEY_ID), "7863");
+    g_hash_table_insert (expected[1], GRLKEYID_TO_POINTER (GRL_METADATA_KEY_TITLE), "20 Feet from Stardom");
+    g_hash_table_insert (expected[1], GRLKEYID_TO_POINTER (GRL_METADATA_KEY_DURATION), GINT_TO_POINTER 
(7980));
+
+    expected[2] = g_hash_table_new (NULL, NULL);
+    g_hash_table_insert (expected[2], GRLKEYID_TO_POINTER (GRL_METADATA_KEY_ID), "6466");
+    g_hash_table_insert (expected[2], GRLKEYID_TO_POINTER (GRL_METADATA_KEY_TITLE), "300: Rise of an 
Empire");
+    g_hash_table_insert (expected[2], GRLKEYID_TO_POINTER (GRL_METADATA_KEY_DURATION), GINT_TO_POINTER 
(9000));
+  }
+
+  g_assert_cmpstr (grl_data_get_string (data, GRL_METADATA_KEY_ID),
+                   ==,
+                   g_hash_table_lookup (expected[n], GRLKEYID_TO_POINTER (GRL_METADATA_KEY_ID)));
+  g_assert_cmpstr (grl_data_get_string (data, GRL_METADATA_KEY_TITLE),
+                   ==,
+                   g_hash_table_lookup (expected[n], GRLKEYID_TO_POINTER (GRL_METADATA_KEY_TITLE)));
+  g_assert_cmpint (grl_data_get_int (data, GRL_METADATA_KEY_DURATION),
+                   ==,
+                   GPOINTER_TO_INT (g_hash_table_lookup (expected[n], GRLKEYID_TO_POINTER 
(GRL_METADATA_KEY_DURATION))));
+}
+
+static void
+test_browse_count (void)
+{
+  GError *error = NULL;
+  GList *medias;
+  GrlOperationOptions *options;
+  GrlRegistry *registry;
+  GrlSource *source;
+
+  registry = grl_registry_get_default ();
+  source = grl_registry_lookup_source (registry, "grl-apple-trailers");
+  g_assert (source);
+  options = grl_operation_options_new (NULL);
+  grl_operation_options_set_count (options, 2);
+  g_assert (options);
+
+  medias = grl_source_browse_sync (source,
+                                   NULL,
+                                   grl_source_supported_keys (source),
+                                   options,
+                                   &error);
+  g_assert_cmpint (g_list_length(medias), ==, 2);
+  g_assert_no_error (error);
+
+  verify (GRL_DATA (g_list_nth_data (medias, 0)), 0);
+  verify (GRL_DATA (g_list_nth_data (medias, 1)), 1);
+
+  g_list_free_full (medias, g_object_unref);
+  g_object_unref (options);
+}
+
+static void
+test_browse_skip (void)
+{
+  GError *error = NULL;
+  GList *medias;
+  GrlOperationOptions *options;
+  GrlRegistry *registry;
+  GrlSource *source;
+
+  registry = grl_registry_get_default ();
+  source = grl_registry_lookup_source (registry, "grl-apple-trailers");
+  g_assert (source);
+  options = grl_operation_options_new (NULL);
+  grl_operation_options_set_count (options, 2);
+  grl_operation_options_set_skip (options, 1);
+  g_assert (options);
+
+  medias = grl_source_browse_sync (source,
+                                   NULL,
+                                   grl_source_supported_keys (source),
+                                   options,
+                                   &error);
+  g_assert_cmpint (g_list_length(medias), ==, 2);
+  g_assert_no_error (error);
+
+  verify (GRL_DATA (g_list_nth_data (medias, 0)), 1);
+  verify (GRL_DATA (g_list_nth_data (medias, 1)), 2);
+
+  g_list_free_full (medias, g_object_unref);
+  g_object_unref (options);
+}
+
+int
+main(int argc, char **argv)
+{
+  g_setenv ("GRL_PLUGIN_PATH", APPLE_TRAILERS_PLUGIN_PATH, TRUE);
+  g_setenv ("GRL_PLUGIN_LIST", APPLE_TRAILERS_ID, TRUE);
+  g_setenv ("GRL_NET_MOCKED", APPLE_TRAILERS_DATA_PATH "network-data.ini", TRUE);
+
+  grl_init (&argc, &argv);
+  g_test_init (&argc, &argv, NULL);
+
+#if !GLIB_CHECK_VERSION(2,32,0)
+  g_thread_init (NULL);
+#endif
+
+  test_setup ();
+
+  g_test_add_func ("/apple-trailers/browse/count", test_browse_count);
+  g_test_add_func ("/apple-trailers/browse/skip", test_browse_skip);
+
+  return g_test_run ();
+}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]