2 * Copyright (C) 2012,2013 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/>.
31 quvi_t q
= quvi_new();
33 g_assert_cmpint(quvi_errcode(q
), ==, QUVI_OK
);
38 static void chk_results(quvi_scan_t qs
)
42 while ((s
= quvi_scan_next_media_url(qs
)) != NULL
)
44 g_assert_cmpint(strlen(s
), >, 0);
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";
59 if (chk_internet() == FALSE
|| chk_skip(__func__
) == TRUE
)
64 qs
= quvi_scan_new(q
, URL
);
65 g_assert_cmpint(qerr_m(q
, URL
), ==, QUVI_OK
);
73 static void test_scan_short()
75 static const gchar URL
[] = "http://is.gd/yUeWit";
80 if (chk_internet() == FALSE
|| chk_skip(__func__
) == TRUE
)
85 qs
= quvi_scan_new(q
, URL
);
86 g_assert_cmpint(qerr_m(q
, URL
), ==, QUVI_OK
);
94 static void test_scan_noresults()
96 static const gchar URL
[] = "http://example.com/";
101 if (chk_internet() == FALSE
|| chk_skip(__func__
) == TRUE
)
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
);
120 typedef struct user_data_s
*user_data_t
;
122 static QuviError
status_cb(glong status_type
, gpointer data
,
125 user_data_t u
= (user_data_t
) user_data
;
126 g_assert(user_data
!= NULL
);
131 static void test_scan_userdata()
133 static const gchar URL
[] = "http://is.gd/yUeWit";
135 struct user_data_s u
;
139 if (chk_internet() == FALSE
|| chk_skip(__func__
) == TRUE
)
145 quvi_set(q
, QUVI_OPTION_CALLBACK_STATUS
, (quvi_callback_status
) status_cb
);
146 quvi_set(q
, QUVI_OPTION_CALLBACK_STATUS_USERDATA
, &u
);
148 g_assert_cmpint(u
.n
, ==, 0);
149 qs
= quvi_scan_new(q
, URL
);
150 g_assert_cmpint(qerr_m(q
, URL
), ==, QUVI_OK
);
151 g_assert(qs
!= NULL
);
156 g_assert_cmpint(u
.n
, >, 0);
159 gint
main(gint argc
, gchar
**argv
)
161 g_test_init(&argc
, &argv
, NULL
);
162 g_test_add_func("/quvi/scan (core)", test_scan_core
);
163 g_test_add_func("/quvi/scan (short)", test_scan_short
);
164 g_test_add_func("/quvi/scan (noresults)", test_scan_noresults
);
165 g_test_add_func("/quvi/scan (userdata)", test_scan_userdata
);
166 return (g_test_run());
169 /* vim: set ts=2 sw=2 tw=72 expandtab: */