コード例 #1
0
    def __do_signal_eq_test(self):
        """Tests the two interfaces for (in)equality with signals."""
        i1 = interface.Interface()
        i2 = interface.Interface()
        self.assertEqual(i1, i2)

        s1 = signaldef.SignalDef()

        i1.add_signal(None, s1)
        self.assertNotEqual(i1, i2)

        s2 = signaldef.SignalDef()
        i2.add_signal(None, s2)
        self.assertEqual(i1, i2)

        s1.name = "SignalName"
        self.assertNotEqual(i1, i2,
                            "Should detect that signal names are different.")

        s2.name = "signalName"
        self.assertNotEqual(i1, i2)

        s2.name = s1.name
        self.assertEqual(i1, i2)
        return
コード例 #2
0
    def __do_method_eq_test(self):
        """Tests the two interfaces for (in)equality with methods."""
        i1 = interface.Interface()
        i2 = interface.Interface()
        self.assertEqual(i1, i2)

        m1 = methoddef.MethodDef()

        i1.add_method(None, m1)
        self.assertNotEqual(i1, i2)

        m2 = methoddef.MethodDef()
        i2.add_method(None, m2)
        self.assertEqual(i1, i2)

        m1.name = "MethodName"
        self.assertNotEqual(i1, i2,
                            "Should detect that method names are different.")

        m2.name = "methodName"
        self.assertNotEqual(i1, i2)

        m2.name = m1.name
        self.assertEqual(i1, i2)
        return
コード例 #3
0
    def __do_prop_eq_test(self):
        """Tests the two interfaces for (in)equality with properties."""
        i1 = interface.Interface()
        i2 = interface.Interface()
        self.assertEqual(i1, i2)

        p1 = propertydef.PropertyDef()

        i1.add_property(None, p1)
        self.assertNotEqual(i1, i2)

        p2 = propertydef.PropertyDef()
        i2.add_property(None, p2)
        self.assertEqual(i1, i2)

        p1.name = "PropName"
        self.assertNotEqual(
            i1, i2, "Should detect that property names are different.")

        p2.name = "propName"
        self.assertNotEqual(i1, i2)

        p2.name = p1.name
        self.assertEqual(i1, i2)
        return
コード例 #4
0
    def __do_name_eq_test(self):
        """Tests the two interfaces for (in)equality with various names."""
        i1 = interface.Interface()
        i2 = interface.Interface()
        self.assertEqual(i1, i2)

        i1_name = "Foo.Bar"
        i1.set_name(i1_name)
        self.assertNotEqual(i1, i2)

        i2.set_name("Foo.Bat")
        self.assertNotEqual(i1, i2)

        i2.set_name(i1_name)
        self.assertEqual(i1, i2)
        return
コード例 #5
0
 def test_set_name(self):
     """Tests setting the name."""
     i = interface.Interface()
     name = "Foo.Bar.Test"
     i.set_name(name)
     self.assertEqual(i.interface_full_name, name)
     self.assertEqual(i.interface_name, 'Test')
     return
コード例 #6
0
    def test_needs_persistent_data(self):
        """Tests the method GenAndroid.needs_persistent_data()."""
        i = interface.Interface()
        i.set_name("My.Interface1")
        self.assertFalse(ga.interface_needs_persistent_data(i, True))
        self.assertFalse(ga.interface_needs_persistent_data(i, False))

        s = sig.SignalDef()
        s.name = "MySignal"
        i.signals.append(s)
        self.assertFalse(ga.interface_needs_persistent_data(i, True))
        self.assertFalse(ga.interface_needs_persistent_data(i, False))

        a = arg.ArgDef(None, "myArg", "i", "out")
        s.args.append(a)
        self.assertFalse(ga.interface_needs_persistent_data(i, True))
        self.assertTrue(ga.interface_needs_persistent_data(i, False))

        s.args.remove(a)

        m = met.MethodDef()
        m.name = "MyMethod"
        i.methods.append(m)

        aOut = arg.ArgDef(None, "myOutputArg", "i", "out")
        m.args.append(aOut)
        self.assertFalse(ga.interface_needs_persistent_data(i, True))
        self.assertTrue(ga.interface_needs_persistent_data(i, False))

        m.args.remove(aOut)

        aIn = arg.ArgDef(None, "myInputArg", "i", "in")
        m.args.append(aIn)
        self.assertTrue(ga.interface_needs_persistent_data(i, True))
        self.assertFalse(ga.interface_needs_persistent_data(i, False))

        m.args.remove(aIn)

        p = prop.PropertyDef()
        p.name = "MyProperty"
        p.access = "read"
        aOut = arg.ArgDef(None, "myOutputArg", "i", "out")
        p.args.append(aOut)
        i.properties.append(p)
        self.assertFalse(ga.interface_needs_persistent_data(i, True))
        self.assertTrue(ga.interface_needs_persistent_data(i, False))

        aIn = arg.ArgDef(None, "myInputArg", "i", "in")
        p.args.append(aIn)
        p.access = "readwrite"
        self.assertTrue(ga.interface_needs_persistent_data(i, True))
        self.assertTrue(ga.interface_needs_persistent_data(i, False))

        p.access = "write"
        p.args.remove(aOut)
        self.assertTrue(ga.interface_needs_persistent_data(i, True))
        self.assertFalse(ga.interface_needs_persistent_data(i, False))
コード例 #7
0
    def test_str(self):
        """Tests the generation of the string representation of an
        interface."""
        i = interface.Interface()

        name = "Foo.Bar.Test"
        i.set_name(name)
        toString = i.__str__()
        self.assertTrue(str.find(toString, "Full: " + name) != -1)
        return
コード例 #8
0
    def __do_parent_test(self):
        """Tests the two interfaces for equality regardless of the parents."""
        i1 = interface.Interface()
        i2 = interface.Interface()
        self.assertEqual(i1, i2)

        p1 = ajobject.AllJoynObject("/P1")
        i1.add_parent(p1)
        self.assertEqual(i1, i2)

        i2.add_parent(p1)
        self.assertEqual(i1, i2)

        p2 = ajobject.AllJoynObject("/P2")
        i1.add_parent(p2)
        self.assertEqual(i1, i2)

        i2.add_parent(p2)
        self.assertEqual(i1, i2)

        return
コード例 #9
0
    def test_add_parent(self):
        """Tests adding parents."""
        i = interface.Interface()
        self.assertEqual(len(i.parents), 0)

        o = ajobject.AllJoynObject("/Foo/Zoo/Moo")
        i.add_parent(o)
        self.assertEqual(len(i.parents), 1)

        o = ajobject.AllJoynObject("/Foo/Zoo/Moo2")
        i.add_parent(o)
        self.assertEqual(len(i.parents), 2)
        return
コード例 #10
0
    def test_add_property(self):
        """Tests adding signals."""
        i = interface.Interface()
        self.assertEqual(len(i.signals), 0)

        p = propertydef.PropertyDef()
        i.add_property(None, p)
        self.assertEqual(len(i.properties), 1)

        p = propertydef.PropertyDef()
        p.name = "NewName"
        i.add_property(None, p)
        self.assertEqual(len(i.properties), 2)
        return
コード例 #11
0
    def test_add_signal(self):
        """Tests adding signals."""
        i = interface.Interface()
        self.assertEqual(len(i.signals), 0)

        s = signaldef.SignalDef()
        i.add_signal(None, s)
        self.assertEqual(len(i.signals), 1)

        s = signaldef.SignalDef()
        s.name = "NewName"
        i.add_signal(None, s)
        self.assertEqual(len(i.signals), 2)
        return
コード例 #12
0
    def test_add_method(self):
        """Tests adding methods."""
        i = interface.Interface()
        self.assertEqual(len(i.methods), 0)

        m = methoddef.MethodDef()
        i.add_method(None, m)
        self.assertEqual(len(i.methods), 1)

        m = methoddef.MethodDef()
        m.name = "NewName"
        i.add_method(None, m)
        self.assertEqual(len(i.methods), 2)
        return
コード例 #13
0
    def test_interface_coded_name(self):
        """Tests getting an interface name coded such it can be compiled.

        The interface name must not be a 'c' key word or have punctuation
        characters other than '_' in it."""

        i = interface.Interface()
        i.set_name("Testing_3.AllSeen2_.MyInterface0")

        coded_name = tl.get_interface_coded_name(i)

        for c in string.punctuation:
            if c == '_':
                continue

            self.assertTrue(string.find(coded_name, c) == -1)

        return