示例#1
0
 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)
示例#2
0
 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()
示例#3
0
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)
示例#4
0
 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)
示例#5
0
 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)
示例#6
0
 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)
示例#7
0
 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()
示例#8
0
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()
示例#9
0
 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)
示例#10
0
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()
示例#11
0
def test_OpenPathController_init():
    opc = OpenPathController.alloc().init()
示例#12
0
def test_OpenPathController_init():
    opc = OpenPathController.alloc().init()