def test_HBC_mouseMovePressHandlers(): m = Mocker() hbc = HoverButtonCell.alloc().init() hbc.hover_info = ("point", False) with m: assert hbc.mouseExitedInvalidatesForFrame_(MockFrame) eq_(hbc.hover_info, (None, False))
def test(c): m = Mocker() hbc = HoverButtonCell.alloc().init() frame = m.mock(NSRect) view = m.mock(NSOutlineView) point, pressed = hbc.hover_info = c.info if point is not None: m.replace(NSPointInRect)(point, frame) >> (point == "in") row = view.rowAtPoint_(frame.origin >> (1, 1)) >> 2 dgt = m.property(hbc, "delegate").value >> m.mock(EditorWindowController) image = dgt.hoverButtonCell_imageForState_row_(hbc, c.state, row) >> "<img>" with m: eq_(hbc.buttonImageForFrame_inView_(frame, view), image)
def test(c): m = Mocker() hbc = HoverButtonCell.alloc().init() hbc.hover_info = "<initial value>" frame = m.mock(fn.NSRect) point = c.info[0] with m: result = getattr(hbc, c.method)(point, frame, None) if c.method.startswith("track"): eq_(result, (True, True)) eq_(hbc.hover_info, c.info) else: eq_(result, (True, False)) eq_(hbc.hover_info, "<initial value>")
def test(c): m = Mocker() hbc = HoverButtonCell.alloc().init() hbc.hover_info = "<initial value>" frame = m.mock(NSRect) point = c.info[0] with m: result = getattr(hbc, c.method)(point, frame, None) if c.method.startswith("track"): eq_(result, (True, True)) eq_(hbc.hover_info, c.info) else: eq_(result, (True, False)) eq_(hbc.hover_info, "<initial value>")
def test(c): m = Mocker() hbc = HoverButtonCell.alloc().init() frame = m.mock(fn.NSRect) view = m.mock(ak.NSOutlineView) point, pressed = hbc.hover_info = c.info if point is not None: m.replace(fn, 'NSPointInRect')(point, frame) >> (point == "in") row = view.rowAtPoint_(frame.origin >> (1, 1)) >> 2 dgt = m.property(hbc, "delegate").value >> m.mock(EditorWindowController) image = dgt.hoverButtonCell_imageForState_row_(hbc, c.state, row) >> "<img>" with m: eq_(hbc.buttonImageForFrame_inView_(frame, view), image)
def test(c): m = Mocker() hbc = HoverButtonCell.alloc().init() hbc.hover_info = ("initial", None) frame = m.mock(fn.NSRect) point = c.info[0] pir = m.replace(fn, 'NSPointInRect') if c.method.startswith("mouseUp"): if c.inside is None: hbc.hover_info = (None, None) elif pir("initial", frame) >> c.inside[0] \ and pir(point, frame) >> c.inside[1]: row = (m.method(hbc, "controlView")() >> m.mock(ak.NSOutlineView)) \ .rowAtPoint_(point) >> 2 (m.property(hbc, "delegate").value >> m.mock(EditorWindowController)) \ .hoverButton_rowClicked_(hbc, row) with m: assert getattr(hbc, c.method)(point, frame) eq_(hbc.hover_info, c.info)
def test(c): m = Mocker() hbc = HoverButtonCell.alloc().init() hbc.hover_info = ("initial", None) frame = m.mock(NSRect) point = c.info[0] pir = m.replace(NSPointInRect, passthrough=False) if c.method.startswith("mouseUp"): if c.inside is None: hbc.hover_info = (None, None) elif pir("initial", frame) >> c.inside[0] \ and pir(point, frame) >> c.inside[1]: row = (m.method(hbc, "controlView")() >> m.mock(NSOutlineView)) \ .rowAtPoint_(point) >> 2 (m.property(hbc, "delegate").value >> m.mock(EditorWindowController)) \ .hoverButton_rowClicked_(hbc, row) with m: assert getattr(hbc, c.method)(point, frame) eq_(hbc.hover_info, c.info)
def test_HBC_mouseEnteredInvalidatesForFrame_(): hbc = HoverButtonCell.alloc().init() assert not hbc.mouseEnteredInvalidatesForFrame_(MockFrame)