Exemplo n.º 1
0
def test_outlineViewSelectionDidChange_():
    m = Mocker()
    window = m.mock(Window)
    ewc = WindowController(window)
    window.selected_editor_changed()
    with m:
        ewc.outlineViewSelectionDidChange_(None)
Exemplo n.º 2
0
def test_windowDidBecomeKey_():
    m = Mocker()
    notif = m.mock()
    ed = m.mock(Window)
    wc = WindowController(ed)
    ed.window_did_become_key(notif.object() >> m.mock(ak.NSWindow))
    with m:
        wc.windowDidBecomeKey_(notif)
Exemplo n.º 3
0
def test_outlineView_shouldSelectItem_():
    m = Mocker()
    ov = m.mock(ak.NSOutlineView)
    window = m.mock(Window)
    ewc = WindowController(window)
    ewc.window_.should_select_item(ov, None)
    with m:
        ewc.outlineView_shouldSelectItem_(ov, None)
Exemplo n.º 4
0
def test_windowDidLoad():
    m = Mocker()
    window = m.mock(Window)
    wc = WindowController(window)
    native = m.method(wc.window)() >> m.mock(ak.NSWindow)
    window.window_did_load()
    native.setDelegate_(wc)
    with m:
        wc.windowDidLoad()
Exemplo n.º 5
0
def test_windowShouldClose_():
    m = Mocker()
    win = m.mock(ak.NSWindow)
    window = m.mock(Window)
    wc = WindowController(window)
    wc.window_.should_close(win.close >> "<closer>") >> "<should_close>"
    with m:
        result = wc.windowShouldClose_(win)
        eq_(result, "<should_close>")
Exemplo n.º 6
0
def test_WindowController_windowWillReturnUndoManager_():
    m = Mocker()
    win = m.mock(ak.NSWindow)
    window = m.mock(Window)
    wc = WindowController(window)
    wc.window_.undo_manager >> "<undo_manager>"
    with m:
        result = wc.windowWillReturnUndoManager_(window)
        eq_(result, "<undo_manager>")
Exemplo n.º 7
0
def test_syntaxDefNames():
    m = Mocker()
    wc = WindowController(None)
    wc.window_ = window_ = m.mock(Window)
    app = m.mock(Application)
    (window_.app << app).count(2)
    defs = [type("FakeDef", (object,), {"name": "Fake Syntax"})()]
    (app.syntaxdefs << defs).count(2)
    names = [d.name for d in defs]
    with m:
        eq_(wc.syntaxDefNames(), names)
        wc.setSyntaxDefNames_(None) # should be no-op
        eq_(wc.syntaxDefNames(), names)
Exemplo n.º 8
0
def test_outlineView_toolTipForCell_rect_tableColumn_item_mouseLocation_():
    m = Mocker()
    ed = m.mock(Window)
    ewc = WindowController(ed)
    ov = m.mock(ak.NSOutlineView)
    rect, item = m.mock(), m.mock()
    ed.tooltip_for_item(ov, item) >> "test tip"
    with m:
        result = ewc.outlineView_toolTipForCell_rect_tableColumn_item_mouseLocation_(
            ov, None, rect, None, item, None)
        assert len(result) == 2
        assert result[0] == "test tip"
        assert result[1] is rect
Exemplo n.º 9
0
def test_outlineView_willDisplayCell_forTableColumn_item_():
    ewc = WindowController(None)
    m = Mocker()
    view = m.mock(ak.NSOutlineView)
    cell = m.mock(ImageAndTextCell)
    col, item, editor, icon = m.mock(), m.mock(), m.mock(), m.mock()
    col.identifier() >> "name"
    representedObject(item) >> editor
    editor.icon() >> icon
    cell.setImage_(icon)
    cell.editor = editor
    with m:
        ewc.outlineView_willDisplayCell_forTableColumn_item_(view, cell, col, item)
Exemplo n.º 10
0
def test_characterEncodings():
    wc = WindowController(None)
    names = fn.NSValueTransformer.valueTransformerForName_("CharacterEncodingTransformer").names
    eq_(wc.characterEncodings(), names)
    wc.setCharacterEncodings_(None) # should be no-op
    eq_(wc.characterEncodings(), names)