Source

pyobjc / pyobjc-framework-Cocoa / PyObjCTest / test_nsglyphgenerator.py

from PyObjCTools.TestSupport import *
from AppKit import *

class TestNSGlyphGeneratorHelper (NSObject):
    def insertGlyphs_length_forStartingGlyphAtIndex_characterIndex_(self, glyphs, length, glyphIndex, charIndex):
        self.glyphs = (glyphs, length, glyphIndex, charIndex)

    def setIntAttribute_value_forGlyphAtIndex_(self, a, v, g): pass


class TestNSGlyphGenerator (TestCase):
    def testConstants(self):
        self.assertEqual(NSShowControlGlyphs, (1 << 0))
        self.assertEqual(NSShowInvisibleGlyphs, (1 << 1))
        self.assertEqual(NSWantsBidiLevels, (1 << 2))

    def testProtocols(self):
        self.assertArgHasType(TestNSGlyphGeneratorHelper.setIntAttribute_value_forGlyphAtIndex_, 0, objc._C_NSInteger)
        self.assertArgHasType(TestNSGlyphGeneratorHelper.setIntAttribute_value_forGlyphAtIndex_, 1, objc._C_NSInteger)
        self.assertArgHasType(TestNSGlyphGeneratorHelper.setIntAttribute_value_forGlyphAtIndex_, 2, objc._C_NSUInteger)

        o = TestNSGlyphGeneratorHelper.alloc().init()
        o.insertGlyphs_length_forStartingGlyphAtIndex_characterIndex_(
                [0, 1, 2, 3, 4], 5, 3, 8)
        self.assertEqual(o.glyphs, ([0, 1, 2, 3, 4], 5, 3, 8))
        self.assertArgHasType(
            TestNSGlyphGeneratorHelper.insertGlyphs_length_forStartingGlyphAtIndex_characterIndex_,
            0, b'n^I')
        self.assertArgSizeInArg(
            TestNSGlyphGeneratorHelper.insertGlyphs_length_forStartingGlyphAtIndex_characterIndex_,
            0, 1)
        self.assertArgHasType(
            TestNSGlyphGeneratorHelper.insertGlyphs_length_forStartingGlyphAtIndex_characterIndex_,
            1, objc._C_NSUInteger)
        self.assertArgHasType(
            TestNSGlyphGeneratorHelper.insertGlyphs_length_forStartingGlyphAtIndex_characterIndex_,
            2, objc._C_NSUInteger)
        self.assertArgHasType(
            TestNSGlyphGeneratorHelper.insertGlyphs_length_forStartingGlyphAtIndex_characterIndex_,
            3, objc._C_NSUInteger)

    def testMethods(self):
        self.assertArgIsOut(
                NSGlyphGenerator.generateGlyphsForGlyphStorage_desiredNumberOfCharacters_glyphIndex_characterIndex_, 2)
        self.assertArgIsOut(
                NSGlyphGenerator.generateGlyphsForGlyphStorage_desiredNumberOfCharacters_glyphIndex_characterIndex_, 3)


if __name__ == "__main__":
    main()
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.