def test(c): m = Mocker() sv = ThinSplitView.alloc().init() nsanim = m.replace(NSViewAnimation, passthrough=False) nsdict = m.replace(NSDictionary, passthrough=False) nsval = m.replace(NSValue, passthrough=False) nsarr = m.replace(NSArray, passthrough=False) view = m.mock(NSView) rect = m.mock(NSRect) rval = nsval.valueWithRect_(rect) >> m.mock() resize = nsdict.dictionaryWithObjectsAndKeys_( view, NSViewAnimationTargetKey, rval, NSViewAnimationEndFrameKey, None ) >> m.mock(NSDictionary) anims = nsarr.arrayWithObject_(resize) >> m.mock(NSArray) anim = nsanim.alloc() >> m.mock(NSViewAnimation) anim.initWithViewAnimations_(anims) >> anim anim.setDuration_(0.5) if c.delegate: delegate = m.mock(RedrawOnAnimationEndedDelegate) anim.setDelegate_(delegate) else: delegate = None anim.startAnimation() with m: sv._animate_view(view, rect, delegate)
def test(c): m = Mocker() sv = ThinSplitView.alloc().init() view = m.method(sv.subviews)()[c.index] >> m.mock(NSView) if m.method(sv.isVertical)() >> c.vertical: view.bounds().size.width >> c.thick else: view.bounds().size.height >> c.thick with m: result = sv.is_view_visible(c.index, c.minthick) eq_(result, c.thick > c.minthick) eq_(result, c.vis)
def test(c): m = Mocker() sv = ThinSplitView.alloc().init() view = m.method(sv.subviews)()[c.index] >> m.mock(NSView) rect = view.frame() >> m.mock(NSRect) if m.method(sv.isVertical)() >> c.vertical: dim, org = "width", "x" else: dim, org = "height", "y" getattr(rect.size, dim) >> c.vwthick if c.vwthick > 0: if c.index == 1: getattr(rect.origin, org) >> 0 setattr(rect.origin, org, c.vwthick) setattr(rect.size, dim, 0.0) m.method(sv._animate_view)(view, rect) with m: sv.hide_view(c.index)