OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Apple Computer, Inc. All rights reserved. | 2 * Copyright (C) 2013 Apple Computer, Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 13 matching lines...) Expand all Loading... |
24 */ | 24 */ |
25 | 25 |
26 #include "config.h" | 26 #include "config.h" |
27 | 27 |
28 #include "modules/speech/testing/PlatformSpeechSynthesizerMock.h" | 28 #include "modules/speech/testing/PlatformSpeechSynthesizerMock.h" |
29 | 29 |
30 #include "platform/speech/PlatformSpeechSynthesisUtterance.h" | 30 #include "platform/speech/PlatformSpeechSynthesisUtterance.h" |
31 | 31 |
32 namespace WebCore { | 32 namespace WebCore { |
33 | 33 |
34 PassOwnPtr<PlatformSpeechSynthesizerMock> PlatformSpeechSynthesizerMock::create(
PlatformSpeechSynthesizerClient* client) | 34 PlatformSpeechSynthesizerMock* PlatformSpeechSynthesizerMock::create(PlatformSpe
echSynthesizerClient* client) |
35 { | 35 { |
36 OwnPtr<PlatformSpeechSynthesizerMock> synthesizer = adoptPtr(new PlatformSpe
echSynthesizerMock(client)); | 36 PlatformSpeechSynthesizerMock* synthesizer = new PlatformSpeechSynthesizerMo
ck(client); |
37 synthesizer->initializeVoiceList(); | 37 synthesizer->initializeVoiceList(); |
38 client->voicesDidChange(); | 38 client->voicesDidChange(); |
39 return synthesizer.release(); | 39 return synthesizer; |
40 } | 40 } |
41 | 41 |
42 PlatformSpeechSynthesizerMock::PlatformSpeechSynthesizerMock(PlatformSpeechSynth
esizerClient* client) | 42 PlatformSpeechSynthesizerMock::PlatformSpeechSynthesizerMock(PlatformSpeechSynth
esizerClient* client) |
43 : PlatformSpeechSynthesizer(client) | 43 : PlatformSpeechSynthesizer(client) |
44 , m_speakingFinishedTimer(this, &PlatformSpeechSynthesizerMock::speakingFini
shed) | 44 , m_speakingFinishedTimer(this, &PlatformSpeechSynthesizerMock::speakingFini
shed) |
45 , m_speakingErrorOccurredTimer(this, &PlatformSpeechSynthesizerMock::speakin
gErrorOccurred) | 45 , m_speakingErrorOccurredTimer(this, &PlatformSpeechSynthesizerMock::speakin
gErrorOccurred) |
46 { | 46 { |
47 } | 47 } |
48 | 48 |
49 PlatformSpeechSynthesizerMock::~PlatformSpeechSynthesizerMock() | 49 PlatformSpeechSynthesizerMock::~PlatformSpeechSynthesizerMock() |
(...skipping 17 matching lines...) Expand all Loading... |
67 } | 67 } |
68 | 68 |
69 void PlatformSpeechSynthesizerMock::initializeVoiceList() | 69 void PlatformSpeechSynthesizerMock::initializeVoiceList() |
70 { | 70 { |
71 m_voiceList.clear(); | 71 m_voiceList.clear(); |
72 m_voiceList.append(PlatformSpeechSynthesisVoice::create(String("mock.voice.b
ruce"), String("bruce"), String("en-US"), true, true)); | 72 m_voiceList.append(PlatformSpeechSynthesisVoice::create(String("mock.voice.b
ruce"), String("bruce"), String("en-US"), true, true)); |
73 m_voiceList.append(PlatformSpeechSynthesisVoice::create(String("mock.voice.c
lark"), String("clark"), String("en-US"), true, false)); | 73 m_voiceList.append(PlatformSpeechSynthesisVoice::create(String("mock.voice.c
lark"), String("clark"), String("en-US"), true, false)); |
74 m_voiceList.append(PlatformSpeechSynthesisVoice::create(String("mock.voice.l
ogan"), String("logan"), String("fr-CA"), true, true)); | 74 m_voiceList.append(PlatformSpeechSynthesisVoice::create(String("mock.voice.l
ogan"), String("logan"), String("fr-CA"), true, true)); |
75 } | 75 } |
76 | 76 |
77 void PlatformSpeechSynthesizerMock::speak(PassRefPtr<PlatformSpeechSynthesisUtte
rance> utterance) | 77 void PlatformSpeechSynthesizerMock::speak(PlatformSpeechSynthesisUtterance* utte
rance) |
78 { | 78 { |
79 ASSERT(!m_utterance); | 79 ASSERT(!m_utterance); |
80 m_utterance = utterance; | 80 m_utterance = utterance; |
81 client()->didStartSpeaking(m_utterance); | 81 client()->didStartSpeaking(m_utterance); |
82 | 82 |
83 // Fire a fake word and then sentence boundary event. | 83 // Fire a fake word and then sentence boundary event. |
84 client()->boundaryEventOccurred(m_utterance, SpeechWordBoundary, 0); | 84 client()->boundaryEventOccurred(m_utterance, SpeechWordBoundary, 0); |
85 client()->boundaryEventOccurred(m_utterance, SpeechSentenceBoundary, m_utter
ance->text().length()); | 85 client()->boundaryEventOccurred(m_utterance, SpeechSentenceBoundary, m_utter
ance->text().length()); |
86 | 86 |
87 // Give the fake speech job some time so that pause and other functions have
time to be called. | 87 // Give the fake speech job some time so that pause and other functions have
time to be called. |
(...skipping 12 matching lines...) Expand all Loading... |
100 void PlatformSpeechSynthesizerMock::pause() | 100 void PlatformSpeechSynthesizerMock::pause() |
101 { | 101 { |
102 client()->didPauseSpeaking(m_utterance); | 102 client()->didPauseSpeaking(m_utterance); |
103 } | 103 } |
104 | 104 |
105 void PlatformSpeechSynthesizerMock::resume() | 105 void PlatformSpeechSynthesizerMock::resume() |
106 { | 106 { |
107 client()->didResumeSpeaking(m_utterance); | 107 client()->didResumeSpeaking(m_utterance); |
108 } | 108 } |
109 | 109 |
| 110 void PlatformSpeechSynthesizerMock::trace(Visitor* visitor) |
| 111 { |
| 112 visitor->trace(m_utterance); |
| 113 PlatformSpeechSynthesizer::trace(visitor); |
| 114 } |
110 | 115 |
111 } // namespace WebCore | 116 } // namespace WebCore |
OLD | NEW |