| 1 |
/* GStreamer Editing Services |
| 2 |
* |
| 3 |
* Copyright (C) 2012 Volodymyr Rudyi <[email protected]> |
| 4 |
* Copyright (C) 2015 Thibault Saunier <[email protected]> |
| 5 |
* |
| 6 |
* This library is free software; you can redistribute it and/or |
| 7 |
* modify it under the terms of the GNU Library General Public |
| 8 |
* License as published by the Free Software Foundation; either |
| 9 |
* version 2 of the License, or (at your option) any later version. |
| 10 |
* |
| 11 |
* This library 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 GNU |
| 14 |
* Library General Public License for more details. |
| 15 |
* |
| 16 |
* You should have received a copy of the GNU Library General Public |
| 17 |
* License along with this library; if not, write to the |
| 18 |
* Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
| 19 |
* Boston, MA 02111-1307, USA. |
| 20 |
*/ |
| 21 |
|
| 22 |
#include "test-utils.h" |
| 23 |
/* #include "../../../ges/ges-internal.h" */ |
| 24 |
#include <ges/ges.h> |
| 25 |
#include <gst/check/gstcheck.h> |
| 26 |
|
| 27 |
static GMainLoop *mainloop; |
| 28 |
|
| 29 |
static void |
| 30 |
source_asset_created (GObject * source, GAsyncResult * res, |
| 31 |
gpointer expected_ok) |
| 32 |
{ |
| 33 |
GError *error = NULL; |
| 34 |
|
| 35 |
GESAsset *a = ges_asset_request_finish (res, &error); |
| 36 |
|
| 37 |
if (GPOINTER_TO_INT (expected_ok)) { |
| 38 |
fail_unless (a != NULL); |
| 39 |
fail_unless (error == NULL); |
| 40 |
g_object_unref (a); |
| 41 |
} else { |
| 42 |
fail_unless (a == NULL); |
| 43 |
assert_equals_int (error->domain, GST_RESOURCE_ERROR); |
| 44 |
} |
| 45 |
|
| 46 |
g_clear_error (&error); |
| 47 |
g_main_loop_quit (mainloop); |
| 48 |
} |
| 49 |
|
| 50 |
GST_START_TEST (test_basic) |
| 51 |
{ |
| 52 |
ges_init (); |
| 53 |
|
| 54 |
mainloop = g_main_loop_new (NULL, FALSE); |
| 55 |
ges_asset_request_async (GES_TYPE_URI_CLIP, |
| 56 |
"file:///this/is/not/for/real", NULL, source_asset_created, |
| 57 |
GINT_TO_POINTER (FALSE)); |
| 58 |
|
| 59 |
g_main_loop_run (mainloop); |
| 60 |
g_main_loop_unref (mainloop); |
| 61 |
ges_deinit (); |
| 62 |
} |
| 63 |
|
| 64 |
GST_END_TEST; |
| 65 |
|
| 66 |
typedef struct _CustomContextData |
| 67 |
{ |
| 68 |
GMutex lock; |
| 69 |
GCond cond; |
| 70 |
gboolean finish; |
| 71 |
gboolean expected_ok; |
| 72 |
gchar *uri; |
| 73 |
} CustomContextData; |
| 74 |
|
| 75 |
static gpointer |
| 76 |
custom_context_thread_func (CustomContextData * data) |
| 77 |
{ |
| 78 |
GMainContext *context; |
| 79 |
|
| 80 |
context = g_main_context_new (); |
| 81 |
mainloop = g_main_loop_new (context, FALSE); |
| 82 |
|
| 83 |
g_main_context_push_thread_default (context); |
| 84 |
|
| 85 |
/* To use custom context, we need to call ges_init() in the thread */ |
| 86 |
fail_unless (ges_init ()); |
| 87 |
|
| 88 |
ges_asset_request_async (GES_TYPE_URI_CLIP, |
| 89 |
data->uri, NULL, source_asset_created, |
| 90 |
GINT_TO_POINTER (data->expected_ok)); |
| 91 |
g_main_loop_run (mainloop); |
| 92 |
|
| 93 |
// and deinit also in the thread context |
| 94 |
ges_deinit (); |
| 95 |
|
| 96 |
g_main_context_pop_thread_default (context); |
| 97 |
g_main_context_unref (context); |
| 98 |
g_main_loop_unref (mainloop); |
| 99 |
|
| 100 |
data->finish = TRUE; |
| 101 |
g_cond_signal (&data->cond); |
| 102 |
|
| 103 |
return NULL; |
| 104 |
} |
| 105 |
|
| 106 |
GST_START_TEST (test_custom_context) |
| 107 |
{ |
| 108 |
GThread *thread; |
| 109 |
CustomContextData data; |
| 110 |
|
| 111 |
mainloop = NULL; |
| 112 |
|
| 113 |
g_mutex_init (&data.lock); |
| 114 |
g_cond_init (&data.cond); |
| 115 |
/* ensure default context here, but we will not use the default context */ |
| 116 |
g_main_context_default (); |
| 117 |
|
| 118 |
/* first run with invalid uri */ |
| 119 |
data.finish = FALSE; |
| 120 |
data.expected_ok = FALSE; |
| 121 |
data.uri = g_strdup ("file:///this/is/not/for/real"); |
| 122 |
|
| 123 |
thread = g_thread_new ("test-custom-context-thread", |
| 124 |
(GThreadFunc) custom_context_thread_func, &data); |
| 125 |
|
| 126 |
g_mutex_lock (&data.lock); |
| 127 |
while (data.finish) |
| 128 |
g_cond_wait (&data.cond, &data.lock); |
| 129 |
g_mutex_unlock (&data.lock); |
| 130 |
|
| 131 |
g_thread_join (thread); |
| 132 |
g_free (data.uri); |
| 133 |
|
| 134 |
/* second run with valid uri */ |
| 135 |
data.finish = FALSE; |
| 136 |
data.expected_ok = TRUE; |
| 137 |
data.uri = ges_test_file_uri ("audio_video.ogg"); |
| 138 |
|
| 139 |
thread = g_thread_new ("test-custom-context-thread", |
| 140 |
(GThreadFunc) custom_context_thread_func, &data); |
| 141 |
|
| 142 |
g_mutex_lock (&data.lock); |
| 143 |
while (data.finish) |
| 144 |
g_cond_wait (&data.cond, &data.lock); |
| 145 |
g_mutex_unlock (&data.lock); |
| 146 |
|
| 147 |
g_thread_join (thread); |
| 148 |
g_free (data.uri); |
| 149 |
|
| 150 |
g_mutex_clear (&data.lock); |
| 151 |
g_cond_clear (&data.cond); |
| 152 |
} |
| 153 |
|
| 154 |
GST_END_TEST; |
| 155 |
|
| 156 |
GST_START_TEST (test_transition_change_asset) |
| 157 |
{ |
| 158 |
gchar *id; |
| 159 |
GESAsset *a; |
| 160 |
GESExtractable *extractable; |
| 161 |
|
| 162 |
ges_init (); |
| 163 |
|
| 164 |
a = ges_asset_request (GES_TYPE_TRANSITION_CLIP, "box-wipe-lc", NULL); |
| 165 |
|
| 166 |
fail_unless (GES_IS_ASSET (a)); |
| 167 |
fail_unless_equals_string (ges_asset_get_id (a), "box-wipe-lc"); |
| 168 |
|
| 169 |
extractable = ges_asset_extract (a, NULL); |
| 170 |
fail_unless (ges_extractable_get_asset (extractable) == a); |
| 171 |
|
| 172 |
id = ges_extractable_get_id (extractable); |
| 173 |
fail_unless_equals_string (id, "box-wipe-lc"); |
| 174 |
g_free (id); |
| 175 |
|
| 176 |
g_object_set (extractable, "vtype", 2, NULL); |
| 177 |
|
| 178 |
id = ges_extractable_get_id (extractable); |
| 179 |
fail_unless_equals_string (id, "bar-wipe-tb"); |
| 180 |
g_free (id); |
| 181 |
|
| 182 |
fail_if (ges_extractable_get_asset (extractable) == a); |
| 183 |
gst_object_unref (a); |
| 184 |
|
| 185 |
a = ges_extractable_get_asset (extractable); |
| 186 |
fail_unless_equals_string (ges_asset_get_id (a), "bar-wipe-tb"); |
| 187 |
|
| 188 |
/* Now try to set the a and see if the vtype is properly updated */ |
| 189 |
a = ges_asset_request (GES_TYPE_TRANSITION_CLIP, "box-wipe-lc", NULL); |
| 190 |
ges_extractable_set_asset (extractable, a); |
| 191 |
gst_object_unref (a); |
| 192 |
|
| 193 |
fail_unless_equals_int (GES_TRANSITION_CLIP (extractable)->vtype, 26); |
| 194 |
|
| 195 |
gst_object_unref (extractable); |
| 196 |
ges_deinit (); |
| 197 |
} |
| 198 |
|
| 199 |
GST_END_TEST; |
| 200 |
|
| 201 |
GST_START_TEST (test_uri_clip_change_asset) |
| 202 |
{ |
| 203 |
GESAsset *asset, *asset1; |
| 204 |
GESExtractable *extractable; |
| 205 |
GESLayer *layer; |
| 206 |
gchar *uri; |
| 207 |
gchar *uri1; |
| 208 |
GESTimeline *timeline; |
| 209 |
|
| 210 |
ges_init (); |
| 211 |
|
| 212 |
layer = ges_layer_new (); |
| 213 |
uri = ges_test_file_uri ("audio_video.ogg"); |
| 214 |
uri1 = ges_test_file_uri ("audio_only.ogg"); |
| 215 |
timeline = ges_timeline_new_audio_video (); |
| 216 |
|
| 217 |
ges_timeline_add_layer (timeline, layer); |
| 218 |
|
| 219 |
asset = GES_ASSET (ges_uri_clip_asset_request_sync (uri, NULL)); |
| 220 |
|
| 221 |
fail_unless (GES_IS_ASSET (asset)); |
| 222 |
fail_unless_equals_string (ges_asset_get_id (asset), uri); |
| 223 |
|
| 224 |
extractable = GES_EXTRACTABLE (ges_layer_add_asset (layer, |
| 225 |
asset, 0, 0, GST_CLOCK_TIME_NONE, GES_TRACK_TYPE_UNKNOWN)); |
| 226 |
fail_unless (ges_extractable_get_asset (extractable) == asset); |
| 227 |
gst_object_unref (asset); |
| 228 |
|
| 229 |
/* Now try to set the a and see if the vtype is properly updated */ |
| 230 |
asset1 = GES_ASSET (ges_uri_clip_asset_request_sync (uri1, NULL)); |
| 231 |
fail_unless_equals_int (g_list_length (GES_CONTAINER_CHILDREN (extractable)), |
| 232 |
2); |
| 233 |
fail_unless (ges_extractable_set_asset (extractable, asset1)); |
| 234 |
fail_unless_equals_int (g_list_length (GES_CONTAINER_CHILDREN (extractable)), |
| 235 |
1); |
| 236 |
|
| 237 |
g_free (uri); |
| 238 |
g_free (uri1); |
| 239 |
|
| 240 |
gst_object_unref (asset1); |
| 241 |
gst_object_unref (timeline); |
| 242 |
|
| 243 |
ges_deinit (); |
| 244 |
} |
| 245 |
|
| 246 |
GST_END_TEST; |
| 247 |
|
| 248 |
GST_START_TEST (test_list_asset) |
| 249 |
{ |
| 250 |
GList *assets; |
| 251 |
GEnumClass *enum_class; |
| 252 |
|
| 253 |
ges_init (); |
| 254 |
|
| 255 |
enum_class = g_type_class_peek (GES_VIDEO_STANDARD_TRANSITION_TYPE_TYPE); |
| 256 |
|
| 257 |
fail_unless (ges_init ()); |
| 258 |
fail_if (ges_list_assets (GES_TYPE_OVERLAY_CLIP)); |
| 259 |
|
| 260 |
assets = ges_list_assets (GES_TYPE_TRANSITION_CLIP); |
| 261 |
/* note: we do not have a a for value=0 "Transition not set" */ |
| 262 |
assert_equals_int (g_list_length (assets), enum_class->n_values - 1); |
| 263 |
g_list_free (assets); |
| 264 |
|
| 265 |
ges_deinit (); |
| 266 |
} |
| 267 |
|
| 268 |
GST_END_TEST; |
| 269 |
|
| 270 |
/* |
| 271 |
* NOTE: this test is commented out because it requires the internal |
| 272 |
* ges_asset_finish_proxy method. This method replaces the behaviour of |
| 273 |
* ges_asset_set_proxy (NULL, proxy), which is no longer supported. |
| 274 |
* |
| 275 |
* ges_asset_cache_lookup and ges_asset_try_proxy are similarly internal, |
| 276 |
* but they are marked with GES_API in ges-internal.h |
| 277 |
* The newer ges_asset_finish_proxy is not marked as GES_API, because it |
| 278 |
* would add it to the symbols list, and could therefore not be easily |
| 279 |
* removed. |
| 280 |
* |
| 281 |
* Once we have a nice way to call internal methods for tests, we should |
| 282 |
* uncomment this. |
| 283 |
* |
| 284 |
GST_START_TEST (test_proxy_asset) |
| 285 |
{ |
| 286 |
GESAsset *identity, *nothing, *nothing_at_all; |
| 287 |
|
| 288 |
fail_unless (ges_init ()); |
| 289 |
|
| 290 |
identity = ges_asset_request (GES_TYPE_EFFECT, "video identity", NULL); |
| 291 |
fail_unless (identity != NULL); |
| 292 |
|
| 293 |
nothing = ges_asset_request (GES_TYPE_EFFECT, "nothing", NULL); |
| 294 |
fail_if (nothing); |
| 295 |
|
| 296 |
nothing = ges_asset_cache_lookup (GES_TYPE_EFFECT, "nothing"); |
| 297 |
fail_unless (nothing != NULL); |
| 298 |
|
| 299 |
fail_unless (ges_asset_try_proxy (nothing, "video identity")); |
| 300 |
fail_unless (ges_asset_finish_proxy (identity)); |
| 301 |
|
| 302 |
nothing_at_all = ges_asset_request (GES_TYPE_EFFECT, "nothing_at_all", NULL); |
| 303 |
fail_if (nothing_at_all); |
| 304 |
|
| 305 |
nothing_at_all = ges_asset_cache_lookup (GES_TYPE_EFFECT, "nothing_at_all"); |
| 306 |
fail_unless (nothing_at_all != NULL); |
| 307 |
|
| 308 |
// Now we proxy nothing_at_all to nothing which is itself proxied to identity |
| 309 |
fail_unless (ges_asset_try_proxy (nothing_at_all, "nothing")); |
| 310 |
fail_unless (ges_asset_finish_proxy (nothing)); |
| 311 |
fail_unless_equals_int (g_list_length (ges_asset_list_proxies |
| 312 |
(nothing_at_all)), 1); |
| 313 |
|
| 314 |
fail_unless_equals_pointer (ges_asset_get_proxy_target (nothing), |
| 315 |
nothing_at_all); |
| 316 |
|
| 317 |
// If we request nothing_at_all we should get the good proxied identity |
| 318 |
nothing_at_all = ges_asset_request (GES_TYPE_EFFECT, "nothing_at_all", NULL); |
| 319 |
fail_unless (nothing_at_all == identity); |
| 320 |
|
| 321 |
gst_object_unref (identity); |
| 322 |
gst_object_unref (nothing_at_all); |
| 323 |
|
| 324 |
ges_deinit (); |
| 325 |
} |
| 326 |
|
| 327 |
GST_END_TEST; |
| 328 |
*/ |
| 329 |
|
| 330 |
static void |
| 331 |
_count_cb (GObject * obj, GParamSpec * pspec, gpointer key) |
| 332 |
{ |
| 333 |
guint count = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (obj), key)); |
| 334 |
g_object_set_data (G_OBJECT (obj), key, GUINT_TO_POINTER (count + 1)); |
| 335 |
} |
| 336 |
|
| 337 |
#define _CONNECT_PROXY_SIGNALS(asset) \ |
| 338 |
g_signal_connect (asset, "notify::proxy", G_CALLBACK (_count_cb), \ |
| 339 |
(gchar *)"test-data-proxy-count"); \ |
| 340 |
g_signal_connect (asset, "notify::proxy-target", G_CALLBACK (_count_cb), \ |
| 341 |
(gchar *)"test-data-target-count"); |
| 342 |
|
| 343 |
/* test that @asset has the properties proxy = @proxy and |
| 344 |
* proxy-target = @proxy_target |
| 345 |
* Also check that the callback for "notify::proxy" (set up in |
| 346 |
* _CONNECT_PROXY_SIGNALS) has been called @p_count times, and the |
| 347 |
* callback for "notify::target-proxy" has been called @t_count times. |
| 348 |
*/ |
| 349 |
#define _assert_proxy_state(asset, proxy, proxy_target, p_count, t_count) \ |
| 350 |
{ \ |
| 351 |
const gchar *id = ges_asset_get_id (asset); \ |
| 352 |
guint found_p_count = GPOINTER_TO_UINT (g_object_get_data ( \ |
| 353 |
G_OBJECT (asset), "test-data-proxy-count")); \ |
| 354 |
guint found_t_count = GPOINTER_TO_UINT (g_object_get_data ( \ |
| 355 |
G_OBJECT (asset), "test-data-target-count")); \ |
| 356 |
GESAsset *found_proxy = ges_asset_get_proxy (asset); \ |
| 357 |
GESAsset *found_target = ges_asset_get_proxy_target (asset); \ |
| 358 |
fail_unless (found_proxy == proxy, "Asset '%s' has the proxy '%s' " \ |
| 359 |
"rather than the expected '%s'", id, \ |
| 360 |
found_proxy ? ges_asset_get_id (found_proxy) : NULL, \ |
| 361 |
proxy ? ges_asset_get_id (proxy) : NULL); \ |
| 362 |
fail_unless (found_target == proxy_target, "Asset '%s' has the proxy " \ |
| 363 |
"target '%s' rather than the expected '%s'", id, \ |
| 364 |
found_target ? ges_asset_get_id (found_target) : NULL, \ |
| 365 |
proxy_target ? ges_asset_get_id (proxy_target) : NULL); \ |
| 366 |
fail_unless (p_count == found_p_count, "notify::proxy for asset '%s' " \ |
| 367 |
"was called %u times, rather than the expected %u times", \ |
| 368 |
id, found_p_count, p_count); \ |
| 369 |
fail_unless (t_count == found_t_count, "notify::target-proxy for " \ |
| 370 |
"asset '%s' was called %u times, rather than the expected %u times", \ |
| 371 |
id, found_t_count, t_count); \ |
| 372 |
} |
| 373 |
|
| 374 |
#define _assert_proxy_list(asset, cmp_list) \ |
| 375 |
{ \ |
| 376 |
const gchar * id = ges_asset_get_id (asset); \ |
| 377 |
int i; \ |
| 378 |
GList *tmp; \ |
| 379 |
for (i = 0, tmp = ges_asset_list_proxies (asset); cmp_list[i] && tmp; \ |
| 380 |
i++, tmp = tmp->next) { \ |
| 381 |
GESAsset *proxy = tmp->data; \ |
| 382 |
fail_unless (proxy == cmp_list[i], "The asset '%s' has '%s' as its " \ |
| 383 |
"%ith proxy, rather than the expected '%s'", id, \ |
| 384 |
ges_asset_get_id (proxy), i, ges_asset_get_id (cmp_list[i])); \ |
| 385 |
} \ |
| 386 |
fail_unless (tmp == NULL, "Found more proxies for '%s' than expected", \ |
| 387 |
id); \ |
| 388 |
fail_unless (cmp_list[i] == NULL, "Found less proxies (%i) for '%s' " \ |
| 389 |
"than expected", i, id); \ |
| 390 |
} |
| 391 |
|
| 392 |
#define _assert_effect_asset_request(req_id, expect) \ |
| 393 |
{ \ |
| 394 |
GESAsset *requested = ges_asset_request (GES_TYPE_EFFECT, req_id, NULL); \ |
| 395 |
fail_unless (requested == expect, "Requested asset for id '%s' is " \ |
| 396 |
"'%s' rather than the expected '%s'", req_id, \ |
| 397 |
requested ? ges_asset_get_id (requested) : NULL, \ |
| 398 |
ges_asset_get_id (expect)); \ |
| 399 |
gst_object_unref (requested); \ |
| 400 |
} |
| 401 |
|
| 402 |
GST_START_TEST (test_proxy_setters) |
| 403 |
{ |
| 404 |
GESAsset *proxies[] = { NULL, NULL, NULL, NULL }; |
| 405 |
GESAsset *asset, *alt_asset; |
| 406 |
GESAsset *proxy0, *proxy1, *proxy2; |
| 407 |
gchar asset_id[] = "video agingtv ! videobalance"; |
| 408 |
gchar alt_asset_id[] = "video gamma"; |
| 409 |
gchar proxy0_id[] = "video videobalance contrast=0.0"; |
| 410 |
gchar proxy1_id[] = "video videobalance contrast=1.0"; |
| 411 |
gchar proxy2_id[] = "video videobalance contrast=2.0"; |
| 412 |
|
| 413 |
ges_init (); |
| 414 |
|
| 415 |
asset = ges_asset_request (GES_TYPE_EFFECT, asset_id, NULL); |
| 416 |
alt_asset = ges_asset_request (GES_TYPE_EFFECT, alt_asset_id, NULL); |
| 417 |
|
| 418 |
proxy0 = ges_asset_request (GES_TYPE_EFFECT, proxy0_id, NULL); |
| 419 |
proxy1 = ges_asset_request (GES_TYPE_EFFECT, proxy1_id, NULL); |
| 420 |
proxy2 = ges_asset_request (GES_TYPE_EFFECT, proxy2_id, NULL); |
| 421 |
|
| 422 |
/* make sure our assets are unique */ |
| 423 |
fail_unless (asset); |
| 424 |
fail_unless (alt_asset); |
| 425 |
fail_unless (proxy0); |
| 426 |
fail_unless (proxy1); |
| 427 |
fail_unless (proxy2); |
| 428 |
fail_unless (asset != alt_asset); |
| 429 |
fail_unless (asset != proxy0); |
| 430 |
fail_unless (asset != proxy1); |
| 431 |
fail_unless (asset != proxy2); |
| 432 |
fail_unless (alt_asset != proxy0); |
| 433 |
fail_unless (alt_asset != proxy1); |
| 434 |
fail_unless (alt_asset != proxy2); |
| 435 |
fail_unless (proxy0 != proxy1); |
| 436 |
fail_unless (proxy0 != proxy1); |
| 437 |
fail_unless (proxy0 != proxy2); |
| 438 |
fail_unless (proxy1 != proxy2); |
| 439 |
|
| 440 |
_CONNECT_PROXY_SIGNALS (asset); |
| 441 |
_CONNECT_PROXY_SIGNALS (alt_asset); |
| 442 |
_CONNECT_PROXY_SIGNALS (proxy0); |
| 443 |
_CONNECT_PROXY_SIGNALS (proxy1); |
| 444 |
_CONNECT_PROXY_SIGNALS (proxy2); |
| 445 |
|
| 446 |
/* no proxies to start with */ |
| 447 |
_assert_proxy_state (asset, NULL, NULL, 0, 0); |
| 448 |
_assert_proxy_state (alt_asset, NULL, NULL, 0, 0); |
| 449 |
_assert_proxy_state (proxy0, NULL, NULL, 0, 0); |
| 450 |
_assert_proxy_state (proxy1, NULL, NULL, 0, 0); |
| 451 |
_assert_proxy_state (proxy2, NULL, NULL, 0, 0); |
| 452 |
_assert_proxy_list (asset, proxies); |
| 453 |
_assert_proxy_list (alt_asset, proxies); |
| 454 |
_assert_proxy_list (proxy0, proxies); |
| 455 |
_assert_proxy_list (proxy1, proxies); |
| 456 |
_assert_proxy_list (proxy2, proxies); |
| 457 |
|
| 458 |
/* id for an asset with no proxy returns itself */ |
| 459 |
_assert_effect_asset_request (asset_id, asset); |
| 460 |
_assert_effect_asset_request (alt_asset_id, alt_asset); |
| 461 |
_assert_effect_asset_request (proxy0_id, proxy0); |
| 462 |
_assert_effect_asset_request (proxy1_id, proxy1); |
| 463 |
_assert_effect_asset_request (proxy2_id, proxy2); |
| 464 |
|
| 465 |
/* set a proxy */ |
| 466 |
fail_unless (ges_asset_set_proxy (asset, proxy0)); |
| 467 |
_assert_proxy_state (asset, proxy0, NULL, 1, 0); |
| 468 |
_assert_proxy_state (proxy0, NULL, asset, 0, 1); |
| 469 |
_assert_proxy_state (proxy1, NULL, NULL, 0, 0); |
| 470 |
_assert_proxy_state (proxy2, NULL, NULL, 0, 0); |
| 471 |
|
| 472 |
proxies[0] = proxy0; |
| 473 |
_assert_proxy_list (asset, proxies); |
| 474 |
|
| 475 |
/* requesting the same asset should return the proxy instead */ |
| 476 |
_assert_effect_asset_request (asset_id, proxy0); |
| 477 |
_assert_effect_asset_request (proxy0_id, proxy0); |
| 478 |
_assert_effect_asset_request (proxy1_id, proxy1); |
| 479 |
_assert_effect_asset_request (proxy2_id, proxy2); |
| 480 |
|
| 481 |
/* can't proxy a different asset */ |
| 482 |
/* Raises ERROR */ |
| 483 |
fail_unless (ges_asset_set_proxy (alt_asset, proxy0) == FALSE); |
| 484 |
_assert_proxy_state (alt_asset, NULL, NULL, 0, 0); |
| 485 |
_assert_proxy_state (asset, proxy0, NULL, 1, 0); |
| 486 |
_assert_proxy_state (proxy0, NULL, asset, 0, 1); |
| 487 |
_assert_proxy_state (proxy1, NULL, NULL, 0, 0); |
| 488 |
_assert_proxy_state (proxy2, NULL, NULL, 0, 0); |
| 489 |
|
| 490 |
_assert_proxy_list (asset, proxies); |
| 491 |
_assert_effect_asset_request (asset_id, proxy0); |
| 492 |
_assert_effect_asset_request (proxy0_id, proxy0); |
| 493 |
|
| 494 |
/* set the same proxy again is safe */ |
| 495 |
fail_unless (ges_asset_set_proxy (asset, proxy0)); |
| 496 |
/* notify::proxy callback count increases, even though we set the same |
| 497 |
* proxy. This is the default behaviour for setters. */ |
| 498 |
_assert_proxy_state (asset, proxy0, NULL, 2, 0); |
| 499 |
/* but the notify::target-proxy has not increased for the proxy */ |
| 500 |
_assert_proxy_state (proxy0, NULL, asset, 0, 1); |
| 501 |
_assert_proxy_state (proxy1, NULL, NULL, 0, 0); |
| 502 |
_assert_proxy_state (proxy2, NULL, NULL, 0, 0); |
| 503 |
|
| 504 |
_assert_proxy_list (asset, proxies); |
| 505 |
_assert_effect_asset_request (asset_id, proxy0); |
| 506 |
_assert_effect_asset_request (proxy0_id, proxy0); |
| 507 |
|
| 508 |
/* replace the proxy with a new one */ |
| 509 |
fail_unless (ges_asset_set_proxy (asset, proxy1)); |
| 510 |
_assert_proxy_state (asset, proxy1, NULL, 3, 0); |
| 511 |
/* first proxy still keeps its target */ |
| 512 |
_assert_proxy_state (proxy0, NULL, asset, 0, 1); |
| 513 |
_assert_proxy_state (proxy1, NULL, asset, 0, 1); |
| 514 |
_assert_proxy_state (proxy2, NULL, NULL, 0, 0); |
| 515 |
|
| 516 |
proxies[0] = proxy1; |
| 517 |
proxies[1] = proxy0; |
| 518 |
_assert_proxy_list (asset, proxies); |
| 519 |
|
| 520 |
_assert_effect_asset_request (asset_id, proxy1); |
| 521 |
_assert_effect_asset_request (proxy0_id, proxy0); |
| 522 |
_assert_effect_asset_request (proxy1_id, proxy1); |
| 523 |
_assert_effect_asset_request (proxy2_id, proxy2); |
| 524 |
|
| 525 |
/* replace again */ |
| 526 |
fail_unless (ges_asset_set_proxy (asset, proxy2)); |
| 527 |
_assert_proxy_state (asset, proxy2, NULL, 4, 0); |
| 528 |
_assert_proxy_state (proxy0, NULL, asset, 0, 1); |
| 529 |
_assert_proxy_state (proxy1, NULL, asset, 0, 1); |
| 530 |
_assert_proxy_state (proxy2, NULL, asset, 0, 1); |
| 531 |
|
| 532 |
proxies[0] = proxy2; |
| 533 |
proxies[1] = proxy1; |
| 534 |
proxies[2] = proxy0; |
| 535 |
_assert_proxy_list (asset, proxies); |
| 536 |
|
| 537 |
_assert_effect_asset_request (asset_id, proxy2); |
| 538 |
_assert_effect_asset_request (proxy0_id, proxy0); |
| 539 |
_assert_effect_asset_request (proxy1_id, proxy1); |
| 540 |
_assert_effect_asset_request (proxy2_id, proxy2); |
| 541 |
|
| 542 |
/* move proxy0 back to being the default */ |
| 543 |
fail_unless (ges_asset_set_proxy (asset, proxy0)); |
| 544 |
_assert_proxy_state (asset, proxy0, NULL, 5, 0); |
| 545 |
_assert_proxy_state (proxy0, NULL, asset, 0, 1); |
| 546 |
_assert_proxy_state (proxy1, NULL, asset, 0, 1); |
| 547 |
_assert_proxy_state (proxy2, NULL, asset, 0, 1); |
| 548 |
|
| 549 |
proxies[0] = proxy0; |
| 550 |
proxies[1] = proxy2; |
| 551 |
proxies[2] = proxy1; |
| 552 |
_assert_proxy_list (asset, proxies); |
| 553 |
|
| 554 |
_assert_effect_asset_request (asset_id, proxy0); |
| 555 |
_assert_effect_asset_request (proxy0_id, proxy0); |
| 556 |
_assert_effect_asset_request (proxy1_id, proxy1); |
| 557 |
_assert_effect_asset_request (proxy2_id, proxy2); |
| 558 |
|
| 559 |
/* remove proxy2 */ |
| 560 |
fail_unless (ges_asset_unproxy (asset, proxy2)); |
| 561 |
/* notify::proxy not released since we have not switched defaults */ |
| 562 |
_assert_proxy_state (asset, proxy0, NULL, 5, 0); |
| 563 |
_assert_proxy_state (proxy0, NULL, asset, 0, 1); |
| 564 |
_assert_proxy_state (proxy1, NULL, asset, 0, 1); |
| 565 |
_assert_proxy_state (proxy2, NULL, NULL, 0, 2); |
| 566 |
|
| 567 |
proxies[0] = proxy0; |
| 568 |
proxies[1] = proxy1; |
| 569 |
proxies[2] = NULL; |
| 570 |
_assert_proxy_list (asset, proxies); |
| 571 |
|
| 572 |
_assert_effect_asset_request (asset_id, proxy0); |
| 573 |
_assert_effect_asset_request (proxy0_id, proxy0); |
| 574 |
_assert_effect_asset_request (proxy1_id, proxy1); |
| 575 |
_assert_effect_asset_request (proxy2_id, proxy2); |
| 576 |
|
| 577 |
/* make proxy2 a proxy for proxy0 */ |
| 578 |
fail_unless (ges_asset_set_proxy (proxy0, proxy2)); |
| 579 |
_assert_proxy_state (asset, proxy0, NULL, 5, 0); |
| 580 |
_assert_proxy_state (proxy0, proxy2, asset, 1, 1); |
| 581 |
_assert_proxy_state (proxy1, NULL, asset, 0, 1); |
| 582 |
_assert_proxy_state (proxy2, NULL, proxy0, 0, 3); |
| 583 |
|
| 584 |
proxies[0] = proxy0; |
| 585 |
proxies[1] = proxy1; |
| 586 |
proxies[2] = NULL; |
| 587 |
_assert_proxy_list (asset, proxies); |
| 588 |
|
| 589 |
proxies[0] = proxy2; |
| 590 |
proxies[1] = NULL; |
| 591 |
_assert_proxy_list (proxy0, proxies); |
| 592 |
|
| 593 |
/* original id will now follows two proxy links to get proxy2 */ |
| 594 |
_assert_effect_asset_request (asset_id, proxy2); |
| 595 |
_assert_effect_asset_request (proxy0_id, proxy2); |
| 596 |
_assert_effect_asset_request (proxy1_id, proxy1); |
| 597 |
_assert_effect_asset_request (proxy2_id, proxy2); |
| 598 |
|
| 599 |
/* remove proxy0 from asset, should now default to proxy1 */ |
| 600 |
fail_unless (ges_asset_unproxy (asset, proxy0)); |
| 601 |
/* notify::proxy released since we have switched defaults */ |
| 602 |
_assert_proxy_state (asset, proxy1, NULL, 6, 0); |
| 603 |
_assert_proxy_state (proxy0, proxy2, NULL, 1, 2); |
| 604 |
_assert_proxy_state (proxy1, NULL, asset, 0, 1); |
| 605 |
_assert_proxy_state (proxy2, NULL, proxy0, 0, 3); |
| 606 |
|
| 607 |
proxies[0] = proxy1; |
| 608 |
proxies[1] = NULL; |
| 609 |
_assert_proxy_list (asset, proxies); |
| 610 |
|
| 611 |
proxies[0] = proxy2; |
| 612 |
proxies[1] = NULL; |
| 613 |
_assert_proxy_list (proxy0, proxies); |
| 614 |
|
| 615 |
_assert_effect_asset_request (asset_id, proxy1); |
| 616 |
_assert_effect_asset_request (proxy0_id, proxy2); |
| 617 |
_assert_effect_asset_request (proxy1_id, proxy1); |
| 618 |
_assert_effect_asset_request (proxy2_id, proxy2); |
| 619 |
|
| 620 |
/* remove proxy2 from proxy0 */ |
| 621 |
fail_unless (ges_asset_unproxy (proxy0, proxy2)); |
| 622 |
_assert_proxy_state (asset, proxy1, NULL, 6, 0); |
| 623 |
_assert_proxy_state (proxy0, NULL, NULL, 2, 2); |
| 624 |
_assert_proxy_state (proxy1, NULL, asset, 0, 1); |
| 625 |
_assert_proxy_state (proxy2, NULL, NULL, 0, 4); |
| 626 |
|
| 627 |
proxies[0] = proxy1; |
| 628 |
proxies[1] = NULL; |
| 629 |
_assert_proxy_list (asset, proxies); |
| 630 |
|
| 631 |
proxies[0] = NULL; |
| 632 |
_assert_proxy_list (proxy0, proxies); |
| 633 |
|
| 634 |
_assert_effect_asset_request (asset_id, proxy1); |
| 635 |
_assert_effect_asset_request (proxy0_id, proxy0); |
| 636 |
_assert_effect_asset_request (proxy1_id, proxy1); |
| 637 |
_assert_effect_asset_request (proxy2_id, proxy2); |
| 638 |
|
| 639 |
/* make both proxy0 and proxy2 proxies of proxy1 */ |
| 640 |
fail_unless (ges_asset_set_proxy (proxy1, proxy0)); |
| 641 |
_assert_proxy_state (asset, proxy1, NULL, 6, 0); |
| 642 |
_assert_proxy_state (proxy0, NULL, proxy1, 2, 3); |
| 643 |
_assert_proxy_state (proxy1, proxy0, asset, 1, 1); |
| 644 |
_assert_proxy_state (proxy2, NULL, NULL, 0, 4); |
| 645 |
fail_unless (ges_asset_set_proxy (proxy1, proxy2)); |
| 646 |
_assert_proxy_state (asset, proxy1, NULL, 6, 0); |
| 647 |
_assert_proxy_state (proxy0, NULL, proxy1, 2, 3); |
| 648 |
_assert_proxy_state (proxy1, proxy2, asset, 2, 1); |
| 649 |
_assert_proxy_state (proxy2, NULL, proxy1, 0, 5); |
| 650 |
|
| 651 |
proxies[0] = proxy1; |
| 652 |
proxies[1] = NULL; |
| 653 |
_assert_proxy_list (asset, proxies); |
| 654 |
|
| 655 |
proxies[0] = proxy2; |
| 656 |
proxies[1] = proxy0; |
| 657 |
proxies[2] = NULL; |
| 658 |
_assert_proxy_list (proxy1, proxies); |
| 659 |
|
| 660 |
_assert_effect_asset_request (asset_id, proxy2); |
| 661 |
_assert_effect_asset_request (proxy0_id, proxy0); |
| 662 |
_assert_effect_asset_request (proxy1_id, proxy2); |
| 663 |
_assert_effect_asset_request (proxy2_id, proxy2); |
| 664 |
|
| 665 |
/* should not be able to set up any circular proxies */ |
| 666 |
/* Raises ERROR */ |
| 667 |
fail_unless (ges_asset_set_proxy (proxy1, asset) == FALSE); |
| 668 |
_assert_proxy_state (asset, proxy1, NULL, 6, 0); |
| 669 |
_assert_proxy_state (proxy0, NULL, proxy1, 2, 3); |
| 670 |
_assert_proxy_state (proxy1, proxy2, asset, 2, 1); |
| 671 |
_assert_proxy_state (proxy2, NULL, proxy1, 0, 5); |
| 672 |
/* Raises ERROR */ |
| 673 |
fail_unless (ges_asset_set_proxy (proxy0, asset) == FALSE); |
| 674 |
_assert_proxy_state (asset, proxy1, NULL, 6, 0); |
| 675 |
_assert_proxy_state (proxy0, NULL, proxy1, 2, 3); |
| 676 |
_assert_proxy_state (proxy1, proxy2, asset, 2, 1); |
| 677 |
_assert_proxy_state (proxy2, NULL, proxy1, 0, 5); |
| 678 |
/* Raises ERROR */ |
| 679 |
fail_unless (ges_asset_set_proxy (proxy2, asset) == FALSE); |
| 680 |
_assert_proxy_state (asset, proxy1, NULL, 6, 0); |
| 681 |
_assert_proxy_state (proxy0, NULL, proxy1, 2, 3); |
| 682 |
_assert_proxy_state (proxy1, proxy2, asset, 2, 1); |
| 683 |
_assert_proxy_state (proxy2, NULL, proxy1, 0, 5); |
| 684 |
|
| 685 |
/* remove last proxy from asset, should set its proxy to NULL */ |
| 686 |
fail_unless (ges_asset_unproxy (asset, proxy1)); |
| 687 |
_assert_proxy_state (asset, NULL, NULL, 7, 0); |
| 688 |
_assert_proxy_state (proxy0, NULL, proxy1, 2, 3); |
| 689 |
_assert_proxy_state (proxy1, proxy2, NULL, 2, 2); |
| 690 |
_assert_proxy_state (proxy2, NULL, proxy1, 0, 5); |
| 691 |
|
| 692 |
proxies[0] = NULL; |
| 693 |
_assert_proxy_list (asset, proxies); |
| 694 |
|
| 695 |
proxies[0] = proxy2; |
| 696 |
proxies[1] = proxy0; |
| 697 |
proxies[2] = NULL; |
| 698 |
_assert_proxy_list (proxy1, proxies); |
| 699 |
|
| 700 |
/* get asset back */ |
| 701 |
_assert_effect_asset_request (asset_id, asset); |
| 702 |
_assert_effect_asset_request (proxy0_id, proxy0); |
| 703 |
_assert_effect_asset_request (proxy1_id, proxy2); |
| 704 |
_assert_effect_asset_request (proxy2_id, proxy2); |
| 705 |
|
| 706 |
/* set the proxy property to NULL for proxy1, should remove all of |
| 707 |
* its proxies */ |
| 708 |
fail_unless (ges_asset_set_proxy (proxy1, NULL)); |
| 709 |
_assert_proxy_state (asset, NULL, NULL, 7, 0); |
| 710 |
/* only one notify for proxy1, but two separate ones for ex-proxies */ |
| 711 |
_assert_proxy_state (proxy0, NULL, NULL, 2, 4); |
| 712 |
_assert_proxy_state (proxy1, NULL, NULL, 3, 2); |
| 713 |
_assert_proxy_state (proxy2, NULL, NULL, 0, 6); |
| 714 |
|
| 715 |
proxies[0] = NULL; |
| 716 |
_assert_proxy_list (asset, proxies); |
| 717 |
_assert_proxy_list (proxy0, proxies); |
| 718 |
_assert_proxy_list (proxy1, proxies); |
| 719 |
_assert_proxy_list (proxy2, proxies); |
| 720 |
|
| 721 |
_assert_effect_asset_request (asset_id, asset); |
| 722 |
_assert_effect_asset_request (proxy0_id, proxy0); |
| 723 |
_assert_effect_asset_request (proxy1_id, proxy1); |
| 724 |
_assert_effect_asset_request (proxy2_id, proxy2); |
| 725 |
|
| 726 |
gst_object_unref (asset); |
| 727 |
gst_object_unref (alt_asset); |
| 728 |
gst_object_unref (proxy0); |
| 729 |
gst_object_unref (proxy1); |
| 730 |
gst_object_unref (proxy2); |
| 731 |
|
| 732 |
ges_deinit (); |
| 733 |
} |
| 734 |
|
| 735 |
GST_END_TEST; |
| 736 |
|
| 737 |
static Suite * |
| 738 |
ges_suite (void) |
| 739 |
{ |
| 740 |
Suite *s = suite_create ("ges"); |
| 741 |
TCase *tc_chain = tcase_create ("a"); |
| 742 |
|
| 743 |
suite_add_tcase (s, tc_chain); |
| 744 |
|
| 745 |
tcase_add_test (tc_chain, test_basic); |
| 746 |
tcase_add_test (tc_chain, test_custom_context); |
| 747 |
tcase_add_test (tc_chain, test_transition_change_asset); |
| 748 |
tcase_add_test (tc_chain, test_uri_clip_change_asset); |
| 749 |
tcase_add_test (tc_chain, test_list_asset); |
| 750 |
tcase_add_test (tc_chain, test_proxy_setters); |
| 751 |
|
| 752 |
return s; |
| 753 |
} |
| 754 |
|
| 755 |
GST_CHECK_MAIN (ges); |