示例#1
0
def test_SheetController_create_with_textview():
    tv = None
    c1 = SheetController.create_with_textview(tv)
    assert isinstance(c1, SheetController)
    c2 = SheetController.create_with_textview(tv)
    assert isinstance(c2, SheetController)
    assert c1 is not c2
示例#2
0
def test_SheetController_begin_sheet():
    from editxt.controls.alert import Caller
    m = Mocker()
    tv = m.mock(TextView)
    slc = SheetController.create_with_textview(tv)
    def cb(callback):
        return callback.__name__ == "sheet_did_end" and callback.self is slc
    clr_class = m.replace("editxt.controls.alert.Caller", passthrough=None)
    clr = clr_class.alloc().init(MATCH(cb)) >> m.mock(Caller)
    win = tv.window() >> m.mock(NSWindow)
    pnl = m.method(slc.window)() >> m.mock(NSPanel)
    nsapp = m.replace(NSApp, spec=False, passthrough=False)
    nsapp.beginSheet_modalForWindow_modalDelegate_didEndSelector_contextInfo_(
        pnl, win, clr, "alertDidEnd:returnCode:contextInfo:", 0)
    with m:
        slc.begin_sheet(None)