Source

pyobjc / pyobjc-core / PyObjCTest / keyvaluehelper.py

"""
Helper module for KeyValue tests
"""
from __future__ import unicode_literals, absolute_import
from PyObjCTest.testbndl import PyObjCTest_KVBaseClass, PyObjCTest_KVPathClass
import objc

NSObject = objc.lookUpClass('NSObject')

DirectString = 'Direct String'
IndirectString = 'Indirect String'
DirectNumber = 42
IndirectNumber = 84

class KVPyBase:
    def __init__(self):
        self.directString = DirectString
        self._indirectString = IndirectString
        self.directNumber = DirectNumber
        self._indirectNumber = IndirectNumber

    def get_indirectString(self):
        return self._indirectString

    def set_indirectString(self, aString):
        self._indirectString = aString

    def getIndirectNumber(self):
        return self._indirectNumber

    def setIndirectNumber(self, aNumber):
        self._indirectNumber = aNumber

class KVPyPath:
    def __init__(self):
        self.directHead = KVPyBase()
        self._indirectHead = KVPyBase()

    def indirectHead(self):
        return self._indirectHead

    def setIndirectHead(self, aHead):
        self._indirectHead = aHead

class KVPySubObjCBase (PyObjCTest_KVBaseClass):
    pass

class KVPySubObjCPath (PyObjCTest_KVPathClass):
    pass

class KVPySubOverObjCBase (PyObjCTest_KVBaseClass):
    def init(self):
        self = super(KVPySubOverObjCBase, self).init()
        if not self:
            return self

        self.overDirectString = DirectString
        self._overIndirectString = IndirectString
        return self

    def getOverIndirectString(self):
        return self._overIndirectString

    def setOverIndirectString_(self, aString):
        self._overIndirectString = aString

class KVPySubOverObjCPath(PyObjCTest_KVPathClass):
    def init(self):
        self = super(KVPySubOverObjCPath, self).init()
        self.overDirectHead = KVPySubOverObjCBase.new()
        self._overIndirectHead = KVPySubOverObjCBase.new()
        return self

    def overIndirectHead(self):
        return self._overIndirectHead

    def setOverIndirectHead_(self, aHead):
        self._overIndirectHead = aHead

class PyObjCTestObserver (NSObject):
    def init(self):
        self = super(PyObjCTestObserver, self).init()
        if self is not None:
            self.observed = []
            self.willChange = []
        return self

    def observeValueForKeyPath_ofObject_change_context_(self, keyPath, obj, change, context):
        self.observed.append( (keyPath, obj, change, context) )

    def willChangeValueForKey_(self, key):
        self.willChange.append(key)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.