コード例 #1
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))
コード例 #2
0
ファイル: arg_test.py プロジェクト: alljoyn/devtools-codegen
    def test_is_structure(self):
        """Tests the is_structure() method."""
        a = argdef.ArgDef(None, "myArg", "(bid)")
        self.assertTrue(a.is_structure())

        a = argdef.ArgDef(None, "myArg", "a(bid)")
        self.assertTrue(a.is_structure())

        self.assertTrue(memberdef.is_structure("(bid)"))
        self.assertTrue(memberdef.is_structure("a(bid)"))
        self.assertTrue(memberdef.is_structure("aa(bid)"))
        self.assertTrue(memberdef.is_structure("aaa(bid)"))
        self.assertFalse(memberdef.is_structure("a{is}"))
        self.assertFalse(memberdef.is_structure("a{i(sid)}"))
        return
コード例 #3
0
ファイル: arg_test.py プロジェクト: alljoyn/devtools-codegen
    def test_get_indirection_level(self):
        """Tests the get_indirection_level() method."""
        a = argdef.ArgDef(None, "myArg", "a(bid)")
        self.assertEqual(a.get_indirection_level(), 1)

        a = argdef.ArgDef(None, "myArg", "aad")
        self.assertEqual(a.get_indirection_level(), 2)

        self.assertEqual(memberdef.get_indirection_level("i"), 0)
        self.assertEqual(memberdef.get_indirection_level("ai"), 1)
        self.assertEqual(memberdef.get_indirection_level("aai"), 2)
        self.assertEqual(memberdef.get_indirection_level("a{bid}"), 1)
        self.assertEqual(memberdef.get_indirection_level("aa{bid}"), 2)
        self.assertEqual(memberdef.get_indirection_level("aaa{bid}"), 3)
        self.assertEqual(memberdef.get_indirection_level("a(is)"), 1)
        self.assertEqual(memberdef.get_indirection_level("a(ia{is})"), 1)
        return
コード例 #4
0
ファイル: arg_test.py プロジェクト: alljoyn/devtools-codegen
    def test_init(self):
        """Tests initializing."""
        a = argdef.ArgDef()

        self.assertEqual(a.name, None)
        self.assertEqual(a.arg_type, None)
        self.assertEqual(a.direction, None)
        self.assertEqual(a.variant_type, None)
        self.assertEqual(a.interface, None)

        a = argdef.ArgDef(None, "myArg", "(bid)", "in", "")
        self.assertEqual(a.name, "myArg")
        self.assertEqual(a.arg_type, "(bid)")
        self.assertEqual(a.direction, "in")
        self.assertEqual(a.variant_type, "")
        self.assertEqual(a.interface, None)

        return
コード例 #5
0
ファイル: arg_test.py プロジェクト: alljoyn/devtools-codegen
    def test_is_dictionary(self):
        """Tests the is_dictionary() method."""
        a = argdef.ArgDef(None, "myArg", "a{bid}")
        self.assertTrue(a.is_dictionary())

        a = argdef.ArgDef(None, "myArg", "aa{bid}")
        self.assertTrue(a.is_dictionary())

        # This is actually an invalid arg type. Because the xml is None
        # no validation is done. If this test fails because of validation
        # just remove the test.
        a = argdef.ArgDef(None, "myArg", "{bid}")
        self.assertFalse(a.is_dictionary())

        self.assertTrue(memberdef.is_dictionary("a{bid}"))
        self.assertTrue(memberdef.is_dictionary("aa{bid}"))
        self.assertTrue(memberdef.is_dictionary("aaa{bid}"))
        self.assertFalse(memberdef.is_dictionary("a(is)"))
        self.assertFalse(memberdef.is_dictionary("a(ia{is})"))
        return
コード例 #6
0
ファイル: arg_test.py プロジェクト: alljoyn/devtools-codegen
    def test_get_max_dictionary_depth(self):
        """Tests the get_max_dictionary_depth() method."""
        sig = "bud"
        a = argdef.ArgDef(None, "myArg", sig)
        self.assertEqual(a.get_max_dictionary_depth(), 0)
        self.assertEqual(memberdef.get_max_dictionary_depth(sig), 0)

        sig = "a{bud}"
        a = argdef.ArgDef(None, "myArg", sig)
        self.assertEqual(a.get_max_dictionary_depth(), 1)
        self.assertEqual(memberdef.get_max_dictionary_depth(sig), 1)

        sig = "a{bud}a{did}"
        a = argdef.ArgDef(None, "myArg", sig)
        self.assertEqual(a.get_max_dictionary_depth(), 1)
        self.assertEqual(memberdef.get_max_dictionary_depth(sig), 1)

        sig = "a{buda{did}}"
        a = argdef.ArgDef(None, "myArg", sig)
        self.assertEqual(a.get_max_dictionary_depth(), 2)
        self.assertEqual(memberdef.get_max_dictionary_depth(sig), 2)

        sig = "a{q{bud}a{did}}"
        a = argdef.ArgDef(None, "myArg", sig)
        self.assertEqual(a.get_max_dictionary_depth(), 2)
        self.assertEqual(memberdef.get_max_dictionary_depth(sig), 2)

        sig = "a{ia{a{buda{did}}i}}"
        a = argdef.ArgDef(None, "myArg", sig)
        self.assertEqual(a.get_max_dictionary_depth(), 4)
        self.assertEqual(memberdef.get_max_dictionary_depth(sig), 4)

        sig = "a{ia{a{buda(did)}i}}"
        a = argdef.ArgDef(None, "myArg", sig)
        self.assertEqual(a.get_max_dictionary_depth(), 3)
        self.assertEqual(memberdef.get_max_dictionary_depth(sig), 3)

        return
コード例 #7
0
ファイル: arg_test.py プロジェクト: alljoyn/devtools-codegen
    def test_get_max_structure_depth(self):
        """Tests the get_max_structure_depth() method."""
        sig = "bud"
        a = argdef.ArgDef(None, "myArg", sig)
        self.assertEqual(a.get_max_structure_depth(), 0)
        self.assertEqual(memberdef.get_max_structure_depth(sig), 0)

        sig = "(bud)"
        a = argdef.ArgDef(None, "myArg", sig)
        self.assertEqual(a.get_max_structure_depth(), 1)
        self.assertEqual(memberdef.get_max_structure_depth(sig), 1)

        sig = "(bud)(did)"
        a = argdef.ArgDef(None, "myArg", sig)
        self.assertEqual(a.get_max_structure_depth(), 1)
        self.assertEqual(memberdef.get_max_structure_depth(sig), 1)

        sig = "(bud(did))"
        a = argdef.ArgDef(None, "myArg", sig)
        self.assertEqual(a.get_max_structure_depth(), 2)
        self.assertEqual(memberdef.get_max_structure_depth(sig), 2)

        sig = "(q(bud)(did))"
        a = argdef.ArgDef(None, "myArg", sig)
        self.assertEqual(a.get_max_structure_depth(), 2)
        self.assertEqual(memberdef.get_max_structure_depth(sig), 2)

        sig = "(i((bud(did))i))"
        a = argdef.ArgDef(None, "myArg", sig)
        self.assertEqual(a.get_max_structure_depth(), 4)
        self.assertEqual(memberdef.get_max_structure_depth(sig), 4)

        sig = "(i((buda{did})i))"
        a = argdef.ArgDef(None, "myArg", sig)
        self.assertEqual(a.get_max_structure_depth(), 3)
        self.assertEqual(memberdef.get_max_structure_depth(sig), 3)

        return