コード例 #1
0
    def create_ConfigProfileTriggerCommand(self,
                                           trigger,
                                           enter=True,
                                           expectedToBecomeIndex=None):
        """ConfigProfileTriggerCommands get converted into IndexCommands by speechManager. The
		expectedToBecomeIndex argument allows tracking that.
		@note: the expectedToBecomeIndex is tested to be ordered, contiguous, and unique with respect to other
		indexed commands to help to prevent errors in the tests.
		"""
        self._testCase.assertIsNotNone(
            expectedToBecomeIndex,
            "Did you forget to provide the 'expectedToBecomeIndex' argument?")
        self._assertStrictIndexOrder(expectedToBecomeIndex)
        t = ConfigProfileTriggerCommand(trigger, enter)
        t.expectedIndexCommandIndex = expectedToBecomeIndex
        return t
コード例 #2
0
ファイル: __init__.py プロジェクト: tsengwoody/nvda
    def test_5_profiles(self):
        """Enter profile, text, exit profile.
		Manual Test (in NVDA python console):
			import sayAllHandler
			trigger = sayAllHandler.SayAllProfileTrigger()
			wx.CallLater(500, speech.speak, [
				speech.ConfigProfileTriggerCommand(trigger, True), u"5 6 7 8",
				speech.ConfigProfileTriggerCommand(trigger, False),
				u"9 10 11 12"
			])
		Expected: 5 6 7 8 in different profile, 9 10 11 12 with base config.
		"""
        t1 = InitialDevelopmentTests.FakeProfileTrigger("t1")
        smi = SpeechManagerInteractions(self)
        smi.addMockCallMonitoring([t1.enter, t1.exit])
        seq = [
            ConfigProfileTriggerCommand(t1, True),
            "5 6 7 8",
            smi.create_ConfigProfileTriggerCommand(t1,
                                                   False,
                                                   expectedToBecomeIndex=1),
            "9 10 11 12",
        ]
        with smi.expectation():
            smi.speak(seq)
            smi.expect_synthSpeak(sequence=seq[1:3])
            smi.expect_synthCancel()
            smi.expect_mockCall(t1.enter)
        with smi.expectation():
            smi.indexReached(1)
            smi.pumpAll()
        with smi.expectation():
            smi.doneSpeaking()
            smi.pumpAll()
            smi.expect_synthSpeak(sequence=[
                '9 10 11 12',
                smi.create_ExpectedIndex(expectedToBecomeIndex=2)
            ])
            smi.expect_synthCancel()
            smi.expect_mockCall(t1.exit)
        with smi.expectation():
            smi.indexReached(2)
            smi.pumpAll()
        with smi.expectation():
            smi.doneSpeaking()
            smi.pumpAll()
コード例 #3
0
ファイル: __init__.py プロジェクト: xingkong0113/nvda
    def test_10_SPRI_profiles(self):
        """Utterance at SPRI_NORMAL. Utterance at SPRI_NOW with profile switch.
		Manual Test (in NVDA python console):
			from speech import sayAll;
			trigger = sayAll.SayAllProfileTrigger();
			wx.CallLater(500, speech.speak, [
				ConfigProfileTriggerCommand(trigger, True),
				u"This is a normal utterance with a different profile"
			])
			wx.CallLater(1000, speech.speak, [u"This is an interruption"], priority=speech.SPRI_NOW)
		Expected: Normal speaks but gets interrupted, interruption with different profile, normal speaks again
		"""
        t1 = InitialDevelopmentTests.FakeProfileTrigger("t1")
        smi = SpeechManagerInteractions(self)
        smi.addMockCallMonitoring([t1.enter, t1.exit])

        with smi.expectation():
            first = smi.speak([
                "This is a normal utterance, text, text,",
                smi.create_ExpectedIndex(expectedToBecomeIndex=1)
            ])
            smi.expect_synthSpeak(first)

        # before the first utterance can finish, it is interrupted.
        with smi.expectation():
            interrupt = [
                ConfigProfileTriggerCommand(t1, True),
                "This is an interruption with a different profile",
                smi.create_ExpectedIndex(expectedToBecomeIndex=2)
            ]
            smi.speak(priority=speech.Spri.NOW, seq=interrupt)
            smi.expect_synthCancel()  # twice ??
            smi.expect_synthCancel()
            smi.expect_mockCall(t1.enter)
            smi.expect_synthSpeak(sequence=interrupt[1:])

        with smi.expectation():
            smi.indexReached(2)
            smi.pumpAll()
        with smi.expectation():
            smi.doneSpeaking()
            smi.pumpAll()
            smi.expect_synthCancel()
            smi.expect_synthSpeak(first)
            smi.expect_mockCall(t1.exit)
コード例 #4
0
ファイル: __init__.py プロジェクト: tsengwoody/nvda
    def test_4_profiles(self):
        """Text, pitch, text, enter profile1, enter profile2, text, exit profile1, text.
		Manual Test (in NVDA python console):
			import sayAllHandler, appModuleHandler
			t1 = sayAllHandler.SayAllProfileTrigger()
			t2 = appModuleHandler.AppProfileTrigger("notepad")
			wx.CallLater(500, speech.speak, [
				u"Testing testing ", speech.PitchCommand(offset=100), "1 2 3 4",
				speech.ConfigProfileTriggerCommand(t1, True), speech.ConfigProfileTriggerCommand(t2, True),
				u"5 6 7 8", speech.ConfigProfileTriggerCommand(t1, False), u"9 10 11 12"
			])
		Expected:
			All text after 1 2 3 4 should be higher pitch.
			5 6 7 8 should have profile 1 and 2.
			9 10 11 12 should be just profile 2.
		"""
        t1 = InitialDevelopmentTests.FakeProfileTrigger("t1")
        t2 = InitialDevelopmentTests.FakeProfileTrigger("t2")
        smi = SpeechManagerInteractions(self)
        smi.addMockCallMonitoring([t1.enter, t1.exit, t2.enter, t2.exit])
        seq = [
            "Testing testing ",
            speech.PitchCommand(offset=100),
            "1 2 3 4",
            smi.create_ExpectedIndex(1),
            # The preceeding index is expected,
            # as the following profile trigger commands will cause the utterance to be split here.
            ConfigProfileTriggerCommand(t1, True),
            ConfigProfileTriggerCommand(t2, True),
            "5 6 7 8",
            smi.create_ExpectedIndex(2),
            # The preceeding index is expected,
            # as the following profile trigger commands will cause the utterance to be split here.
            ConfigProfileTriggerCommand(t1, False),
            "9 10 11 12"
        ]
        with smi.expectation():
            smi.speak(seq)
            smi.expect_synthSpeak(sequence=seq[:4])
        with smi.expectation():
            smi.indexReached(1)
            smi.pumpAll()
        with smi.expectation():
            smi.doneSpeaking()
            smi.pumpAll()
            smi.expect_synthCancel()
            smi.expect_mockCall(t1.enter)
            smi.expect_synthCancel()
            smi.expect_mockCall(t2.enter)
            smi.expect_synthSpeak(sequence=[
                seq[1],  # PitchCommand
                '5 6 7 8',
                seq[7],  # IndexCommand index=2 (due to a  ConfigProfileTriggerCommand following it)
            ])

        with smi.expectation():
            smi.indexReached(2)
            smi.pumpAll()
        with smi.expectation():
            smi.doneSpeaking()
            smi.pumpAll()
            smi.expect_synthCancel()
            smi.expect_synthSpeak(sequence=[
                seq[1],  # PitchCommand
                '9 10 11 12',
                smi.create_ExpectedIndex(expectedToBecomeIndex=3)
            ])
            smi.expect_mockCall(t1.exit)

        with smi.expectation():
            smi.indexReached(3)
            smi.pumpAll()
        with smi.expectation():
            smi.doneSpeaking()
            smi.pumpAll()
            smi.expect_synthCancel()
            smi.expect_mockCall(t2.exit)
コード例 #5
0
ファイル: __init__.py プロジェクト: xingkong0113/nvda
    def test_12_SPRI_profile(self):
        """Utterance at SPRI_NORMAL with profile 1. Utterance at SPRI_NOW with profile 2.
		Manual Test (in NVDA python console):
			from speech import sayAll, appModuleHandler
			t1 = sayAll.SayAllProfileTrigger()
			t2 = appModuleHandler.AppProfileTrigger("notepad")
			wx.CallLater(500, speech.speak, [
				ConfigProfileTriggerCommand(t1, True),
				u"This is a normal utterance with profile 1"
			])
			wx.CallLater(1000, speech.speak, [
				ConfigProfileTriggerCommand(t2, True),
				u"This is an interruption with profile 2"
			], priority=speech.SPRI_NOW)
		Expected: Normal speaks with profile 1 but gets interrupted, interruption speaks with profile 2,
		normal speaks again with profile 1
		"""
        t1 = InitialDevelopmentTests.FakeProfileTrigger("t1")
        t2 = InitialDevelopmentTests.FakeProfileTrigger("t2")
        smi = SpeechManagerInteractions(self)
        smi.addMockCallMonitoring([t1.enter, t1.exit, t2.enter, t2.exit])
        with smi.expectation():
            first = [
                ConfigProfileTriggerCommand(t1, True),
                "This is a normal utterance with profile 1",
                smi.create_ExpectedIndex(expectedToBecomeIndex=1)
            ]
            smi.speak(first)
            smi.expect_synthSpeak(sequence=first[1:])
            smi.expect_mockCall(t1.enter)
            smi.expect_synthCancel()

        # Before the first index is reached, there is an interruption
        with smi.expectation():
            interrupt = [
                ConfigProfileTriggerCommand(t2, True),
                "This is an interruption with profile 2",
                smi.create_ExpectedIndex(expectedToBecomeIndex=2)
            ]
            smi.speak(priority=speech.Spri.NOW, seq=interrupt)
            smi.expect_synthCancel()  # 3 calls ??
            smi.expect_synthCancel()
            smi.expect_synthCancel()
            smi.expect_synthSpeak(sequence=interrupt[1:])
            smi.expect_mockCall(t1.exit)
            smi.expect_mockCall(t2.enter)

        # Reach the end of the interruption speech sequence
        with smi.expectation():
            smi.indexReached(2)
            smi.pumpAll()
        # Once done speaking, expect to return to the lower priority speech, including swapping back to the
        # initial profile trigger.
        with smi.expectation():
            smi.doneSpeaking()
            smi.pumpAll()
            smi.expect_synthCancel()
            smi.expect_synthCancel()
            smi.expect_synthSpeak(sequence=first[1:])
            smi.expect_mockCall(t2.exit)
            smi.expect_mockCall(t1.enter)

        # Reach the end of the lower priority (initial) speech
        with smi.expectation():
            smi.indexReached(1)
            smi.pumpAll()
        with smi.expectation():
            smi.doneSpeaking()
            smi.pumpAll()
            smi.expect_synthCancel()
            smi.expect_mockCall(t1.exit)