def test(c): m = Mocker() app = m.mock(Application) opc = OpenPathController(app) paths = m.property(opc, "paths").value >> m.mock(ak.NSTextView) paths.textStorage().string() >> c.text def check_paths(paths): eq_(c.paths, list(paths)) expect(app.open_documents_with_paths(ANY)).call(check_paths) (m.method(opc.window)() >> m.mock(ak.NSWindow)).orderOut_(opc) with m: opc.open_(None)
def test(c): m = Mocker() opc = OpenPathController(None) paths = m.property(opc, "paths").value >> m.mock(ak.NSTextView) with m.order(): ts = paths.textStorage() >> m.mock(ak.NSTextStorage) #ts.deleteCharactersInRange_((0, ts.string().length() >> c.len0)) paths.setSelectedRange_((0, ts.string().length() >> c.len0)) paths.pasteAsPlainText_(opc) paths.setSelectedRange_((0, ts.string().length() >> c.len1)) with m: opc.populateWithClipboard()
def test_OpenPathController_windowDidLoad(): m = Mocker() app = m.mock() opc = OpenPathController(app) tv = m.property(opc, "paths").value >> m.mock(ak.NSTextView) tc = tv.textContainer() >> m.mock(ak.NSTextContainer) tc.setContainerSize_(fn.NSMakeSize(const.LARGE_NUMBER_FOR_TEXT, const.LARGE_NUMBER_FOR_TEXT)) tc.setWidthTracksTextView_(False) tv.setHorizontallyResizable_(True) tv.setAutoresizingMask_(ak.NSViewNotSizable) tv.setFieldEditor_(True) tv.setFont_(app.default_font.font >> "<font>") with m: opc.windowDidLoad() eq_(opc.app, app)
def test(c): m = Mocker() nsapp = m.replace(ak, 'NSApp', spec=False) opc = OpenPathController(None) tv = m.mock(ak.NSTextView) if c.sel == "insertNewline:": nsapp().currentEvent().modifierFlags() >> c.mod if c.mod & ak.NSCommandKeyMask or c.mod & ak.NSShiftKeyMask: tv.insertNewlineIgnoringFieldEditor_(opc) else: m.method(opc.open_)(opc) # check for shift or command (tv.insertTabIgnoringFieldEditor_(self)) # otherwise open file with m: eq_(opc.textView_doCommandBySelector_(tv, c.sel), c.res)
def test(c): m = Mocker() app = m.replace(editxt, 'app') opc = OpenPathController.alloc().init() paths = m.property(opc, "paths").value >> m.mock(ak.NSTextView) paths.textStorage().string() >> c.text app.open_documents_with_paths(c.paths) (m.method(opc.window)() >> m.mock(ak.NSWindow)).orderOut_(opc) with m: opc.open_(None)
def test(c): m = Mocker() opc = OpenPathController.alloc().init() paths = m.property(opc, "paths").value >> m.mock(ak.NSTextView) with m.order(): ts = paths.textStorage() >> m.mock(ak.NSTextStorage) #ts.deleteCharactersInRange_((0, ts.string().length() >> c.len0)) paths.setSelectedRange_((0, ts.string().length() >> c.len0)) paths.pasteAsPlainText_(opc) paths.setSelectedRange_((0, ts.string().length() >> c.len1)) with m: opc.populateWithClipboard()
def test_OpenPathController_windowDidLoad(): m = Mocker() opc = OpenPathController.alloc().init() tv = m.property(opc, "paths").value >> m.mock(NSTextView) tc = tv.textContainer() >> m.mock(NSTextContainer) tc.setContainerSize_(NSMakeSize(const.LARGE_NUMBER_FOR_TEXT, const.LARGE_NUMBER_FOR_TEXT)) tc.setWidthTracksTextView_(False) tv.setHorizontallyResizable_(True) tv.setAutoresizingMask_(NSViewNotSizable) tv.setFieldEditor_(True) tv.setFont_(ANY) with m: opc.windowDidLoad()
def test(c): m = Mocker() nsapp = m.replace(ak, 'NSApp', spec=False) opc = OpenPathController.alloc().init() tv = m.mock(ak.NSTextView) if c.sel == "insertNewline:": nsapp().currentEvent().modifierFlags() >> c.mod if c.mod & ak.NSCommandKeyMask or c.mod & ak.NSShiftKeyMask: tv.insertNewlineIgnoringFieldEditor_(opc) else: m.method(opc.open_)(opc) # check for shift or command (tv.insertTabIgnoringFieldEditor_(self)) # otherwise open file with m: eq_(opc.textView_doCommandBySelector_(tv, c.sel), c.res)
def test_OpenPathController_windowDidLoad(): m = Mocker() opc = OpenPathController.alloc().init() tv = m.property(opc, "paths").value >> m.mock(ak.NSTextView) tc = tv.textContainer() >> m.mock(ak.NSTextContainer) tc.setContainerSize_( fn.NSMakeSize(const.LARGE_NUMBER_FOR_TEXT, const.LARGE_NUMBER_FOR_TEXT)) tc.setWidthTracksTextView_(False) tv.setHorizontallyResizable_(True) tv.setAutoresizingMask_(ak.NSViewNotSizable) tv.setFieldEditor_(True) tv.setFont_(ANY) with m: opc.windowDidLoad()
def test_OpenPathController_init(): opc = OpenPathController.alloc().init()