Esempio n. 1
0
 def test_valueWithPoint(self):
     point = opy.NSPoint(10, 20)
     value_point = NSValue.valueWithPoint_(point)
     ret_point = value_point.pointValue()
     self.assertEqual(ret_point.x, 10)
     self.assertEqual(ret_point.y, 20)
     self.assertNotEqual(ret_point.x, 100)
Esempio n. 2
0
 def test_valueWithRect(self):
     rect = opy.NSRect(opy.NSPoint(3, 5), opy.NSSize(320, 480))
     value_rect = NSValue.valueWithRect_(rect)
     ret_rect = value_rect.rectValue()
     self.assertEqual(ret_rect.origin.x, 3)
     self.assertEqual(ret_rect.origin.y, 5)
     self.assertEqual(ret_rect.size.width, 320)
     self.assertEqual(ret_rect.size.height, 480)
Esempio n. 3
0
 def test_valueWithRectPointer(self):
     rect = opy.NSRect(opy.NSPoint(3, 5), opy.NSSize(320, 480))
     rct_ptr = NSValue.valueWithPointer_(rect)
     rect_val_ptr = rct_ptr.pointerValue()
     rect_deref = dereference(rect_val_ptr, of_type=opy.NSRect)
     self.assertEqual(rect_deref.origin.x, 3)
     self.assertEqual(rect_deref.origin.y, 5)
     self.assertEqual(rect_deref.size.width, 320)
     self.assertEqual(rect_deref.size.height, 480)
Esempio n. 4
0
    def test_objCType(self):
        rect = opy.NSRect(opy.NSPoint(3, 5), opy.NSSize(320, 480))
        value_rect = NSValue.valueWithRect_(rect)
        self.assertEqual(value_rect.objCType(),
                         b"{CGRect={CGPoint=dd}{CGSize=dd}}")

        range = opy.NSRange(5, 10)
        value_range = NSValue.valueWithRange_(range)
        self.assertEqual(value_range.objCType(), b"{_NSRange=QQ}")
Esempio n. 5
0
 def test_passing_values(self):
     car = Car.alloc().init()
     union_arg = opy.test_un_()
     rect = opy.NSRect(opy.NSPoint(20, 40), opy.NSSize(200, 400))
     union_arg.rect = rect
     self.assertTrue(car.useUnionPtrTest_(union_arg))