def test_iatc_cellSize(): cell = ImageAndTextCell.alloc().init() assert cell.image() is None size = cell.cellSize() m = Mocker() image = m.mock(NSImage) image.size().width >> 10 m.replay() cell.setImage_(image) assert cell.image() is image print size.width size2 = cell.cellSize() assert size2.width == size.width + 10, "%s != %s" % (size2.width, size.width + 10) assert size2.height == size.height
def test(c): m = Mocker() cell = ImageAndTextCell.alloc().init() img = cell._image = m.mock(NSImage) if c.image else None frame = NSMakeRect(0, 0, 20, 100) view = m.mock(NSView) draws = m.method(ImageAndTextCell.drawsBackground) color = m.method(ImageAndTextCell.backgroundColor) fill = m.replace(NSRectFill, spec=(lambda a: None), passthrough=False) if c.image: img.size() >> NSSize(20, 20) if draws() >> c.draws: color().set() fill(ANY) view.isFlipped() >> c.flipped img.compositeToPoint_operation_(ANY, NSCompositeSourceOver) m.method(NSTextFieldCell.drawWithFrame_inView_)(frame, view) with m: cell.drawWithFrame_inView_(frame, view)
def test_expansionFrameWithFrame_inView_(): cell = ImageAndTextCell.alloc().init() #frame = NSMakeRect(0, 0, 50, 16) eq_(cell.expansionFrameWithFrame_inView_(NSZeroRect, None), NSZeroRect)
def test_iatc_image_property_(): cell = ImageAndTextCell.alloc().init() assert cell.image() is None cell.setImage_("test") assert cell.image() == "test"
def test_iatc_init(): cell = ImageAndTextCell.alloc().init() assert cell._image is None