1 2from PyObjCTools.TestSupport import * 3from AppKit import * 4 5try: 6 unicode 7except NameError: 8 unicode = str 9 10class TestNSSpeechSynthesizerHelper (NSObject): 11 def speechSynthesizer_didFinishSpeaking_(self, ss, b): pass 12 def speechSynthesizer_willSpeakWord_ofString_(self, ss, w, s): pass 13 def speechSynthesizer_willSpeakPhoneme_(self, ss, i): pass 14 def speechSynthesizer_didEncounterErrorAtIndex_ofString_message_(self, ss, i, s, m): pass 15 16class TestNSSpeechSynthesizer (TestCase): 17 def testConstants(self): 18 self.assertIsInstance(NSVoiceName, unicode) 19 self.assertIsInstance(NSVoiceIdentifier, unicode) 20 self.assertIsInstance(NSVoiceAge, unicode) 21 self.assertIsInstance(NSVoiceGender, unicode) 22 self.assertIsInstance(NSVoiceDemoText, unicode) 23 24 self.assertIsInstance(NSVoiceGenderNeuter, unicode) 25 self.assertIsInstance(NSVoiceGenderMale, unicode) 26 self.assertIsInstance(NSVoiceGenderFemale, unicode) 27 self.assertIsInstance(NSVoiceLanguage, unicode) 28 29 30 @min_os_level("10.5") 31 def testConstants10_5(self): 32 self.assertEqual(NSSpeechImmediateBoundary, 0) 33 self.assertEqual(NSSpeechWordBoundary, 1) 34 self.assertEqual(NSSpeechSentenceBoundary, 2) 35 36 self.assertIsInstance(NSVoiceLocaleIdentifier, unicode) 37 self.assertIsInstance(NSVoiceSupportedCharacters, unicode) 38 self.assertIsInstance(NSVoiceIndividuallySpokenCharacters, unicode) 39 40 41 self.assertIsInstance( NSSpeechStatusProperty, unicode) 42 self.assertIsInstance( NSSpeechErrorsProperty, unicode) 43 self.assertIsInstance( NSSpeechInputModeProperty, unicode) 44 self.assertIsInstance( NSSpeechCharacterModeProperty, unicode) 45 self.assertIsInstance( NSSpeechNumberModeProperty, unicode) 46 self.assertIsInstance( NSSpeechRateProperty, unicode) 47 self.assertIsInstance( NSSpeechPitchBaseProperty, unicode) 48 self.assertIsInstance( NSSpeechPitchModProperty, unicode) 49 self.assertIsInstance( NSSpeechVolumeProperty, unicode) 50 self.assertIsInstance( NSSpeechSynthesizerInfoProperty, unicode) 51 self.assertIsInstance( NSSpeechRecentSyncProperty, unicode) 52 self.assertIsInstance( NSSpeechPhonemeSymbolsProperty, unicode) 53 self.assertIsInstance( NSSpeechCurrentVoiceProperty, unicode) 54 self.assertIsInstance( NSSpeechCommandDelimiterProperty, unicode) 55 self.assertIsInstance( NSSpeechResetProperty, unicode) 56 self.assertIsInstance( NSSpeechOutputToFileURLProperty, unicode) 57 58 self.assertIsInstance( NSSpeechModeText, unicode) 59 self.assertIsInstance( NSSpeechModePhoneme, unicode) 60 61 self.assertIsInstance( NSSpeechModeNormal, unicode) 62 self.assertIsInstance( NSSpeechModeLiteral, unicode) 63 64 self.assertIsInstance( NSSpeechStatusOutputBusy, unicode) 65 self.assertIsInstance( NSSpeechStatusOutputPaused, unicode) 66 self.assertIsInstance( NSSpeechStatusNumberOfCharactersLeft, unicode) 67 self.assertIsInstance( NSSpeechStatusPhonemeCode, unicode) 68 69 self.assertIsInstance( NSSpeechErrorCount, unicode) 70 self.assertIsInstance( NSSpeechErrorOldestCode, unicode) 71 self.assertIsInstance( NSSpeechErrorOldestCharacterOffset, unicode) 72 self.assertIsInstance( NSSpeechErrorNewestCode, unicode) 73 self.assertIsInstance( NSSpeechErrorNewestCharacterOffset, unicode) 74 75 self.assertIsInstance( NSSpeechSynthesizerInfoIdentifier, unicode) 76 self.assertIsInstance( NSSpeechSynthesizerInfoVersion, unicode) 77 78 self.assertIsInstance( NSSpeechPhonemeInfoOpcode, unicode) 79 self.assertIsInstance( NSSpeechPhonemeInfoSymbol, unicode) 80 self.assertIsInstance( NSSpeechPhonemeInfoExample, unicode) 81 self.assertIsInstance( NSSpeechPhonemeInfoHiliteStart, unicode) 82 self.assertIsInstance( NSSpeechPhonemeInfoHiliteEnd, unicode) 83 84 self.assertIsInstance( NSSpeechCommandPrefix, unicode) 85 self.assertIsInstance( NSSpeechCommandSuffix, unicode) 86 87 self.assertIsInstance( NSSpeechDictionaryLocaleIdentifier, unicode) 88 self.assertIsInstance( NSSpeechDictionaryModificationDate, unicode) 89 self.assertIsInstance( NSSpeechDictionaryPronunciations, unicode) 90 self.assertIsInstance( NSSpeechDictionaryAbbreviations, unicode) 91 self.assertIsInstance( NSSpeechDictionaryEntrySpelling, unicode) 92 self.assertIsInstance( NSSpeechDictionaryEntryPhonemes, unicode) 93 94 def testMethods(self): 95 self.assertResultIsBOOL(NSSpeechSynthesizer.startSpeakingString_) 96 self.assertResultIsBOOL(NSSpeechSynthesizer.startSpeakingString_toURL_) 97 self.assertResultIsBOOL(NSSpeechSynthesizer.isSpeaking) 98 self.assertResultIsBOOL(NSSpeechSynthesizer.setVoice_) 99 self.assertResultIsBOOL(NSSpeechSynthesizer.usesFeedbackWindow) 100 self.assertArgIsBOOL(NSSpeechSynthesizer.setUsesFeedbackWindow_, 0) 101 self.assertResultIsBOOL(NSSpeechSynthesizer.setObject_forProperty_error_) 102 self.assertArgIsOut(NSSpeechSynthesizer.setObject_forProperty_error_, 2) 103 self.assertArgIsOut(NSSpeechSynthesizer.objectForProperty_error_, 1) 104 self.assertResultIsBOOL(NSSpeechSynthesizer.isAnyApplicationSpeaking) 105 106 def testProtocol(self): 107 self.assertArgIsBOOL(TestNSSpeechSynthesizerHelper.speechSynthesizer_didFinishSpeaking_, 1) 108 self.assertArgHasType(TestNSSpeechSynthesizerHelper.speechSynthesizer_willSpeakWord_ofString_, 1, NSRange.__typestr__) 109 self.assertArgHasType(TestNSSpeechSynthesizerHelper.speechSynthesizer_willSpeakPhoneme_, 1, objc._C_SHT) 110 111 @min_os_level('10.5') 112 def testProtocol10_5(self): 113 self.assertArgHasType(TestNSSpeechSynthesizerHelper.speechSynthesizer_didEncounterErrorAtIndex_ofString_message_, 1, objc._C_NSUInteger) 114 115 116if __name__ == "__main__": 117 main() 118