2 * Copyright (C) 2012 Toni Gundogdu <legatvs@gmail.com>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
28 static gint
count(const quvi_t q
, const QuviScriptType t
)
31 while (quvi_script_next(q
, t
) == QUVI_TRUE
)
36 static gsize
len(const quvi_t q
,
37 const QuviScriptType t
,
38 const QuviScriptProperty p
)
42 quvi_script_get(q
, t
, p
, &s
);
48 static void test_script()
53 if (chk_skip(__func__
) == TRUE
)
58 g_assert_cmpint(qerr(q
), ==, QUVI_OK
);
61 for (t
=QUVI_SCRIPT_TYPE_PLAYLIST
; t
<QUVI_SCRIPT_TYPE_SCAN
+1; ++t
)
63 g_assert_cmpint(count(q
, t
), >=, 1);
65 while (quvi_script_next(q
, t
) == QUVI_TRUE
)
67 /* Shared with all scripts. */
68 g_assert_cmpint(len(q
, t
, QUVI_SCRIPT_PROPERTY_FILEPATH
), >, 0);
69 g_assert_cmpint(len(q
, t
, QUVI_SCRIPT_PROPERTY_FILENAME
), >, 0);
70 g_assert_cmpint(len(q
, t
, QUVI_SCRIPT_PROPERTY_SHA1
), >, 0);
72 /* Media script specific. */
73 if (t
== QUVI_SCRIPT_TYPE_MEDIA
|| t
== QUVI_SCRIPT_TYPE_PLAYLIST
)
74 g_assert_cmpint(len(q
, t
, QUVI_SCRIPT_PROPERTY_DOMAINS
),>,0);
82 const gint c
= count(q
, QUVI_SCRIPT_TYPE_MEDIA
);
84 g_assert_cmpint(c
, ==, count(q
, QUVI_SCRIPT_TYPE_PLAYLIST
-1));
85 g_assert_cmpint(c
, ==, count(q
, QUVI_SCRIPT_TYPE_SCAN
+1));
88 /* Property. Do this last (quvi_script_next is called once). */
92 t
= QUVI_SCRIPT_TYPE_MEDIA
;
93 g_assert(quvi_script_next(q
, t
) == QUVI_TRUE
);
95 quvi_script_get(q
, t
, QUVI_SCRIPT_PROPERTY_FILEPATH
-1, &s
);
96 g_assert_cmpint(qerr(q
), ==, QUVI_ERROR_INVALID_ARG
);
98 quvi_script_get(q
, t
, QUVI_SCRIPT_PROPERTY_SHA1
+1, &s
);
99 g_assert_cmpint(qerr(q
), ==, QUVI_ERROR_INVALID_ARG
);
105 gint
main(gint argc
, gchar
**argv
)
107 g_test_init(&argc
, &argv
, NULL
);
108 g_test_add_func("/quvi/script", test_script
);
109 return (g_test_run());
112 /* vim: set ts=2 sw=2 tw=72 expandtab: */