2 * Copyright (C) 2012 Toni Gundogdu <legatvs@gmail.com>
4 * This file is part of libquvi-scripts <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/>.
29 /* Test media properties. The 'e' parameter may be NULL, in which case
30 * the test for exact values (e.g. title and ID) will be skipped. */
31 void qm_test(const gchar
*func
, const gchar
*url
,
32 const qm_test_exact_t e
, const qm_test_opts_t o
)
37 if (chk_skip(func
) == TRUE
)
42 g_assert_cmpint(qerr(q
), ==, QUVI_OK
);
46 qm
= quvi_media_new(q
, url
);
47 g_test_message("errmsg=%s", quvi_errmsg(q
));
48 g_assert_cmpint(qerr(q
), ==, QUVI_OK
);
55 g_test_message("TEST_LEVEL=complete");
62 qm_cmp_s(QUVI_MEDIA_PROPERTY_TITLE
, e
->title
);
65 qm_cmp_s(QUVI_MEDIA_PROPERTY_ID
, e
->id
);
68 /* Thumbnail, expected, but check length only. */
70 qm_chk_l(QUVI_MEDIA_PROPERTY_THUMBNAIL_URL
);
74 if (o
->gt0
.duration_ms
== TRUE
)
75 qm_chk_gt0(QUVI_MEDIA_PROPERTY_DURATION_MS
);
77 if (o
->gt0
.start_time_ms
== TRUE
)
78 qm_chk_gt0(QUVI_MEDIA_PROPERTY_START_TIME_MS
);
82 for (c
=0; quvi_media_stream_next(qm
) == QUVI_TRUE
; ++c
);
83 g_assert_cmpint(c
, >, 0);
85 while (quvi_media_stream_next(qm
) == QUVI_TRUE
)
87 qm_chk_l(QUVI_MEDIA_STREAM_PROPERTY_URL
);
89 if (c
>1) /* Must have a stream ID, when there are >1 streams. */
90 qm_chk_l(QUVI_MEDIA_STREAM_PROPERTY_ID
);
94 if (o
->s_len_gt0
.stream
.container
== TRUE
)
95 qm_chk_l(QUVI_MEDIA_STREAM_PROPERTY_CONTAINER
);
97 /* Optional: Video. */
99 if (o
->gt0
.stream
.video
.bitrate_kbit_s
== TRUE
)
100 qm_chk_gt0(QUVI_MEDIA_STREAM_PROPERTY_VIDEO_BITRATE_KBIT_S
);
102 if (o
->gt0
.stream
.video
.height
== TRUE
)
103 qm_chk_gt0(QUVI_MEDIA_STREAM_PROPERTY_VIDEO_HEIGHT
);
105 if (o
->gt0
.stream
.video
.width
== TRUE
)
106 qm_chk_gt0(QUVI_MEDIA_STREAM_PROPERTY_VIDEO_WIDTH
);
108 if (o
->s_len_gt0
.stream
.video
.encoding
== TRUE
)
109 qm_chk_l(QUVI_MEDIA_STREAM_PROPERTY_VIDEO_ENCODING
);
111 /* Optional: Audio. */
113 if (o
->gt0
.stream
.audio
.bitrate_kbit_s
== TRUE
)
114 qm_chk_gt0(QUVI_MEDIA_STREAM_PROPERTY_AUDIO_BITRATE_KBIT_S
);
116 if (o
->s_len_gt0
.stream
.audio
.encoding
== TRUE
)
117 qm_chk_l(QUVI_MEDIA_STREAM_PROPERTY_AUDIO_ENCODING
);
122 g_test_message("TEST_LEVEL=basic");
124 /* Must return >0 media streams. */
126 qm_chk_l(QUVI_MEDIA_STREAM_PROPERTY_URL
);
133 /* vim: set ts=2 sw=2 tw=72 expandtab: */