1
2from PyObjCTools.TestSupport import *
3from AppKit import *
4
5class TestNSFontManagerHelper (NSObject):
6    def fontManager_willIncludeFont_(self, m, f): return 1
7
8class TestNSFontManager (TestCase):
9    def testConstants(self):
10        self.failUnlessEqual(NSItalicFontMask, 0x00000001)
11        self.failUnlessEqual(NSBoldFontMask, 0x00000002)
12        self.failUnlessEqual(NSUnboldFontMask, 0x00000004)
13        self.failUnlessEqual(NSNonStandardCharacterSetFontMask, 0x00000008)
14        self.failUnlessEqual(NSNarrowFontMask, 0x00000010)
15        self.failUnlessEqual(NSExpandedFontMask, 0x00000020)
16        self.failUnlessEqual(NSCondensedFontMask, 0x00000040)
17        self.failUnlessEqual(NSSmallCapsFontMask, 0x00000080)
18        self.failUnlessEqual(NSPosterFontMask, 0x00000100)
19        self.failUnlessEqual(NSCompressedFontMask, 0x00000200)
20        self.failUnlessEqual(NSFixedPitchFontMask, 0x00000400)
21        self.failUnlessEqual(NSUnitalicFontMask, 0x01000000)
22        self.failUnlessEqual(NSFontCollectionApplicationOnlyMask, 1 << 0)
23        self.failUnlessEqual(NSNoFontChangeAction, 0)
24        self.failUnlessEqual(NSViaPanelFontAction, 1)
25        self.failUnlessEqual(NSAddTraitFontAction, 2)
26        self.failUnlessEqual(NSSizeUpFontAction, 3)
27        self.failUnlessEqual(NSSizeDownFontAction, 4)
28        self.failUnlessEqual(NSHeavierFontAction, 5)
29        self.failUnlessEqual(NSLighterFontAction, 6)
30        self.failUnlessEqual(NSRemoveTraitFontAction, 7)
31
32    def testMethods(self):
33        self.failUnlessResultIsBOOL(NSFontManager.isMultiple)
34        self.failUnlessArgIsBOOL(NSFontManager.setSelectedFont_isMultiple_, 1)
35        self.failUnlessArgIsBOOL(NSFontManager.fontMenu_, 0)
36        self.failUnlessArgIsBOOL(NSFontManager.fontPanel_, 0)
37        self.failUnlessResultIsBOOL(NSFontManager.isEnabled)
38        self.failUnlessArgIsBOOL(NSFontManager.setEnabled_, 0)
39        self.failUnlessResultIsBOOL(NSFontManager.sendAction)
40        self.failUnlessArgIsBOOL(NSFontManager.setSelectedAttributes_isMultiple_, 1)
41        self.failUnlessResultIsBOOL(NSFontManager.addCollection_options_)
42        self.failUnlessResultIsBOOL(NSFontManager.removeCollection_)
43        self.failUnlessResultIsBOOL(NSFontManager.fontNamed_hasTraits_)
44
45    def testProtocols(self):
46        self.failUnlessResultIsBOOL(TestNSFontManagerHelper.fontManager_willIncludeFont_)
47
48if __name__ == "__main__":
49    main()
50