File: GstRegistry.t

package info (click to toggle)
libgstreamer-perl 0.19-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 900 kB
  • ctags: 59
  • sloc: perl: 2,456; ansic: 32; makefile: 6
file content (83 lines) | stat: -rw-r--r-- 2,122 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/usr/bin/perl
use strict;
use warnings;
use Test::More tests => 21;

# $Id$

use Glib qw(TRUE FALSE);
use GStreamer -init;

my $registry = GStreamer::Registry -> get_default();
isa_ok($registry, "GStreamer::Registry");

$registry -> scan_path("~/.gstreamer-0.10");
is_deeply([$registry -> get_path_list()], []);

isa_ok(($registry -> get_plugin_list())[0], "GStreamer::Plugin");

sub plugin_filter {
  my ($plugin, $data) = @_;

  isa_ok($plugin, "GStreamer::Plugin");
  is($data, "bla");

  return TRUE;
}

my @plugins = $registry -> plugin_filter(\&plugin_filter, TRUE, "bla");
is($#plugins, 0);
isa_ok($plugins[0], "GStreamer::Plugin");

sub feature_filter {
  my ($feature, $data) = @_;

  isa_ok($feature, "GStreamer::PluginFeature");
  is($data, "bla");

  return TRUE;
}

my @features = $registry -> feature_filter(\&feature_filter, TRUE, "bla");
is($#features, 0);
isa_ok($features[0], "GStreamer::PluginFeature");

isa_ok(($registry -> get_feature_list("GStreamer::ElementFactory"))[0], "GStreamer::PluginFeature");

my $plugin_feature = ($registry -> get_feature_list_by_plugin("alsa"))[0];
SKIP: {
  skip 'no alsa plugin found', 1
    unless defined $plugin_feature;

  isa_ok($plugin_feature, "GStreamer::PluginFeature");
}

SKIP: {
  my $plugin = $registry -> find_plugin("volume");
  skip 'could not find "volume" plugin', 2
    unless defined $plugin;
  isa_ok($plugin, "GStreamer::Plugin");
  isa_ok($registry -> find_feature("volume", "GStreamer::ElementFactory"), "GStreamer::PluginFeature");
}

is($registry -> lookup("..."), undef);
is($registry -> lookup_feature("..."), undef);

# These can fail, so just test for definedness.
ok(defined $registry -> xml_write_cache("tmp"));
ok(defined $registry -> xml_read_cache("tmp"));
unlink "tmp";

my $plugin = GStreamer::Plugin::load_by_name("alsa");
SKIP: {
  skip 'failed to load alsa plugin', 2
    unless defined $plugin;

  ok($registry -> add_plugin($plugin));

  my $feature = GStreamer::ElementFactory -> find("alsasink");
  ok($registry -> add_feature($feature));

  $registry -> remove_feature($feature);
  $registry -> remove_plugin($plugin);
}