summaryrefslogtreecommitdiff
path: root/tests/BinTest.cs
blob: 594ce5bab7726e2def288c0391eef30b827f1c1c (plain)
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
//
// BinTest.cs: NUnit Test Suite for gstreamer-sharp
//
// Authors:
//   Aaron Bockover (abockover@novell.com)
//   Khaled Mohammed (Khaled.Mohammed@gmail.com)
//
// (C) 2006 Novell, Inc.
//

using System;
using NUnit.Framework;

using Gst;

[TestFixture]
public class BinTest
{
    [TestFixtureSetUp]
    public void Init()
    {
        Application.Init();
    }
    
    [TestFixtureTearDown]
    public void Deinit()
    {
        Application.Deinit();
    }

    [Test]
    public void TestAddMany()
    {
        Bin bin = new Bin("test-bin");
        Element e1 = ElementFactory.Make("fakesrc", "fakesrc");
        Element e2 = ElementFactory.Make("fakesink", "fakesink");

		Assert.IsNotNull(bin, "Could not create bin");
		Assert.IsNotNull(e1, "Could not create fakesrc");
		Assert.IsNotNull(e2, "Could not create fakesink");

        bin.AddMany(e1, e2);
        
        Assert.AreEqual(bin.ChildrenCount, 2);
        
        e2.Dispose();
        e1.Dispose();
        bin.Dispose();
    }

    
    [Test]
    public void TestGetByName()
    {
        Bin bin = new Bin("test-bin");
        Element e1 = ElementFactory.Make("fakesrc", "element-name");
        bin.Add(e1);
        
        e1 = bin.GetByName("element-name");
        
        Assert.IsNotNull(e1);
        Assert.AreEqual(e1.Name, "element-name");
        
        e1.Dispose();
        bin.Dispose();
    }

    [Test]
    public void TestChildren()
    {
        Bin bin = new Bin("test-bin");

        Element [] elements = new Element [] {
	    	ElementFactory.Make("fakesrc", "fakesrc"),
            ElementFactory.Make("audioconvert", "audioconvert"),
            ElementFactory.Make("wavenc", "wavenc"),
            ElementFactory.Make("fakesink", "fakesink")
        };
        
        foreach(Element element in elements) {
            bin.Add(element);
        }
      
        Assert.AreEqual(elements.Length, bin.ChildrenCount);
        Element [] children = bin.Children;
     
        for(int i = 0; i < elements.Length; i++) {
            Assert.AreEqual(elements[elements.Length - i - 1], children[i]);
        }

        bin.Dispose();

		foreach(Element e in elements)
			e.Dispose();
    }

	[Test]
	public void TestInterface()
	{
		Bin bin = new Bin(String.Empty);
		Assert.IsNotNull(bin, "Could not create bin");

		Element filesrc = ElementFactory.Make("filesrc", null);
		Assert.IsNotNull(filesrc, "Could not create filesrc");

		bin.Add(filesrc);
		
		filesrc.Dispose();
		bin.Dispose();
	}

}