Exemple #1
0
def test_TextView_doCommandBySelector_():
    from editxt.textcommand import CommandManager
    m = Mocker()
    tv = TextView.alloc().init()
    app = tv.app = m.mock()
    editor = tv.editor = m.mock(Editor)
    selector = "selector:"
    editor.do_command(selector) >> True
    with m:
        tv.doCommandBySelector_(selector)
Exemple #2
0
def test_TextView_performFindPanelAction_():
    import editxt.command.find as find
    m = Mocker()
    tv = TextView.alloc().init()
    app = tv.app = m.mock("editxt.application.Application")
    fc = m.replace(find, "FindController")
    sender = m.mock()
    (fc.shared_controller(app) >> m.mock(find.FindController)).perform_action(sender)
    with m:
        tv.performFindPanelAction_(sender)
Exemple #3
0
def test_TextView_doMenuCommand_():
    from editxt.textcommand import CommandManager
    m = Mocker()
    tv = TextView.alloc().init()
    app = tv.app = m.mock()
    editor = tv.editor = m.mock(Editor)
    tc = app.text_commander >> m.mock(CommandManager)
    sender = m.mock()
    tc.do_menu_command(editor, sender)
    with m:
        tv.doMenuCommand_(sender)
Exemple #4
0
 def test(c):
     m = Mocker()
     tv = TextView.alloc().initWithFrame_(fn.NSMakeRect(0, 0, 100, 100)) # x, y, w, h
     tc = m.method(tv.textContainer)() >> (m.mock(ak.NSTextContainer) if c.setup else None)
     lm = m.method(tv.layoutManager)() >> (m.mock(ak.NSLayoutManager) if c.setup else None)
     sv = m.method(tv.enclosingScrollView)() >> (m.mock(ak.NSScrollView) if c.setup else None)
     height = 100
     if c.setup:
         lm.usedRectForTextContainer_(tc) >> fn.NSMakeRect(0, 0, 100, c.content_height)
         sv.contentSize() >> fn.NSMakeSize(100, 100) # w, h
         if c.content_height + 75 > 100:
             height = c.content_height + 75
     with m:
         tv.setFrameSize_(fn.NSMakeSize(100, height))
         eq_(tv.frameSize(), fn.NSMakeSize(100, c.final_height))
Exemple #5
0
 def test(c):
     m = Mocker()
     fc = m.replace(find, "FindController")
     tv = TextView.alloc().init()
     app = tv.app = m.mock()
     editor = tv.editor = m.mock(Editor)
     item = m.mock(ak.NSMenuItem)
     expectation = (item.action() << c.action)
     if c.action == "performFindPanelAction:":
         tag = item.tag() >> 42
         (fc.shared_controller(app) >> m.mock(find.FindController)). \
             validate_action(tag) >> True
     elif c.action == "doMenuCommand:":
         expectation.count(2)
         tc = app.text_commander >> m.mock(CommandManager)
         tc.is_menu_command_enabled(editor, item) >> True
     else:
         raise NotImplementedError # left untested because I don't know how to mock a super call
     with m:
         assert tv.validateUserInterfaceItem_(item)