quvi_supports: Handle QUVI_SUPPORTS_TYPE_SUBTITLE
[libquvi.git] / tests / scan.c
blobeb129c0ed48b30ac6a538bb8dda0a555036b3a58
1 /* libquvi
2 * Copyright (C) 2012 Toni Gundogdu <legatvs@gmail.com>
4 * This file is part of libquvi <http://quvi.sourceforge.net/>.
6 * This program is free software: you can redistribute it and/or
7 * modify it under the terms of the GNU Affero General Public
8 * License as published by the Free Software Foundation, either
9 * version 3 of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Affero General Public License for more details.
16 * You should have received a copy of the GNU Affero General
17 * Public License along with this program. If not, see
18 * <http://www.gnu.org/licenses/>.
21 #include "config.h"
23 #include <string.h>
24 #include <glib.h>
25 #include <quvi.h>
27 #include "tests.h"
29 static quvi_t new_q()
31 quvi_t q = quvi_new();
32 g_assert(q != NULL);
33 g_assert_cmpint(qerr(q), ==, QUVI_OK);
34 chk_verbose(q);
35 return (q);
38 static void chk_results(quvi_scan_t qs)
40 const gchar *s;
41 gint i = 0;
42 while ((s = quvi_scan_next_media_url(qs)) != NULL)
44 g_assert_cmpint(strlen(s), >, 0);
45 ++i;
47 g_assert_cmpint(i, >=, 1);
50 static void test_scan_core()
52 static const gchar URL[] =
53 "http://www.fangoria.com/index.php/home/all-news/1-latest-news/"
54 "6981-new-qprometheusq-trailer-has-landed";
56 quvi_scan_t qs;
57 quvi_t q;
59 if (chk_internet() == FALSE || chk_skip(__func__) == TRUE)
60 return;
62 q = new_q();
64 qs = quvi_scan_new(q, URL);
65 g_assert_cmpint(qerr_m(q, URL), ==, QUVI_OK);
66 g_assert(qs != NULL);
67 chk_results(qs);
69 quvi_scan_free(qs);
70 quvi_free(q);
73 static void test_scan_short()
75 static const gchar URL[] = "http://is.gd/gQ4pYW";
77 quvi_scan_t qs;
78 quvi_t q;
80 if (chk_internet() == FALSE || chk_skip(__func__) == TRUE)
81 return;
83 q = new_q();
85 qs = quvi_scan_new(q, URL);
86 g_assert_cmpint(qerr_m(q, URL), ==, QUVI_OK);
87 g_assert(qs != NULL);
88 chk_results(qs);
90 quvi_scan_free(qs);
91 quvi_free(q);
94 static void test_scan_noresults()
96 static const gchar URL[] = "http://example.com/";
98 quvi_scan_t qs;
99 quvi_t q;
101 if (chk_internet() == FALSE || chk_skip(__func__) == TRUE)
102 return;
104 q = new_q();
106 qs = quvi_scan_new(q, URL);
107 g_assert_cmpint(qerr_m(q, URL), ==, QUVI_OK);
108 g_assert(qs != NULL);
109 g_assert(quvi_scan_next_media_url(qs) == NULL);
111 quvi_scan_free(qs);
112 quvi_free(q);
115 gint main(gint argc, gchar **argv)
117 g_test_init(&argc, &argv, NULL);
118 g_test_add_func("/quvi/scan (core)", test_scan_core);
119 g_test_add_func("/quvi/scan (short)", test_scan_short);
120 g_test_add_func("/quvi/scan (noresults)", test_scan_noresults);
121 return (g_test_run());
124 /* vim: set ts=2 sw=2 tw=72 expandtab: */