Beispiel #1
0
func (s *S) TestRegisterConverterPlainObject(c *C) {
	qml.RegisterConverter("PlainTestType", func(engine *qml.Engine, obj qml.Object) interface{} {
		c.Check(engine, Equals, s.engine)
		c.Check(obj.String("plainType"), Matches, "(const )?PlainTestType[&*]?")
		c.Check(obj.Property("plainAddr"), FitsTypeOf, uintptr(0))
		c.Check(cpptest.PlainTestTypeN(obj), Equals, 42)
		return "<converted>"
	})
	obj := cpptest.NewTestType(s.engine)
	defer obj.Destroy()

	var calls int
	obj.On("plainEmittedCpy", func(s string) {
		c.Check(s, Equals, "<converted>")
		calls++
	})
	obj.On("plainEmittedRef", func(s string) {
		c.Check(s, Equals, "<converted>")
		calls++
	})
	obj.On("plainEmittedPtr", func(s string) {
		c.Check(s, Equals, "<converted>")
		calls++
	})
	obj.Call("emitPlain")
	c.Assert(calls, Equals, 3)
}
Beispiel #2
0
func (s *S) TestReadVoidAddrProperty(c *C) {
	obj := cpptest.NewTestType(s.engine)
	addr := obj.Property("voidAddr").(uintptr)
	c.Assert(addr, Equals, uintptr(42))
}