Title: [143136] trunk
Revision
143136
Author
[email protected]
Date
2013-02-17 12:57:42 -0800 (Sun, 17 Feb 2013)

Log Message

WebSpeech: plumb through a method to generate fake speech jobs for testing
https://bugs.webkit.org/show_bug.cgi?id=107351

Reviewed by Adam Barth.

Source/WebCore: 

We can't reliably use the platforms synthesizer to test speech synthesis internals.
This patch adds an Internals method to enable a mock synthesizer, which is inherits
from the PlatformSpeechSythesizer.

The fake synthesizer goes through all the motions of a real synthesizer but doesn't do anything.
A bunch of changes were needed here to make PlatformSpeechSynthesizer subclassable so that the
right virtual are used.

The Mock synthesizer only lives in WebCoreTestSupport. Because PlatformSpeechSynthesizer uses
a RetainPtr, I needed to make WebCoreTestSupport link CoreFoundation

LayoutTests: 

* platform/mac/fast/speechsynthesis/speech-synthesis-speak.html:
* platform/mac/fast/speechsynthesis/speech-synthesis-voices.html:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (143135 => 143136)


--- trunk/LayoutTests/ChangeLog	2013-02-17 20:05:43 UTC (rev 143135)
+++ trunk/LayoutTests/ChangeLog	2013-02-17 20:57:42 UTC (rev 143136)
@@ -1,3 +1,13 @@
+2013-02-17  Chris Fleizach  <[email protected]>
+
+        WebSpeech: plumb through a method to generate fake speech jobs for testing
+        https://bugs.webkit.org/show_bug.cgi?id=107351
+
+        Reviewed by Adam Barth.
+
+        * platform/mac/fast/speechsynthesis/speech-synthesis-speak.html:
+        * platform/mac/fast/speechsynthesis/speech-synthesis-voices.html:
+
 2013-02-17  Christophe Dumez  <[email protected]>
 
         Unreviewed EFL gardening.

Modified: trunk/LayoutTests/platform/mac/fast/speechsynthesis/speech-synthesis-speak.html (143135 => 143136)


--- trunk/LayoutTests/platform/mac/fast/speechsynthesis/speech-synthesis-speak.html	2013-02-17 20:05:43 UTC (rev 143135)
+++ trunk/LayoutTests/platform/mac/fast/speechsynthesis/speech-synthesis-speak.html	2013-02-17 20:57:42 UTC (rev 143136)
@@ -9,6 +9,9 @@
 
 <script>
 
+    if (window.internals)
+        window.internals.enableMockSpeechSynthesizer();
+
     description("This tests that the basic mechanisms of speaking text work, including sending the job and receving the callback.");
 
     if (window.testRunner)

Modified: trunk/LayoutTests/platform/mac/fast/speechsynthesis/speech-synthesis-voices.html (143135 => 143136)


--- trunk/LayoutTests/platform/mac/fast/speechsynthesis/speech-synthesis-voices.html	2013-02-17 20:05:43 UTC (rev 143135)
+++ trunk/LayoutTests/platform/mac/fast/speechsynthesis/speech-synthesis-voices.html	2013-02-17 20:57:42 UTC (rev 143136)
@@ -8,6 +8,8 @@
 <div id="console"></div>
 
 <script>
+    if (window.internals)
+        window.internals.enableMockSpeechSynthesizer();
 
     description("This tests that we can get synthesizer voices on the Mac");
 

Modified: trunk/Source/WebCore/CMakeLists.txt (143135 => 143136)


--- trunk/Source/WebCore/CMakeLists.txt	2013-02-17 20:05:43 UTC (rev 143135)
+++ trunk/Source/WebCore/CMakeLists.txt	2013-02-17 20:57:42 UTC (rev 143136)
@@ -2831,6 +2831,7 @@
 
 set(WebCoreTestSupport_INCLUDE_DIRECTORIES
     "${WEBCORE_DIR}/testing"
+    "${WEBCORE_DIR}/platform/mock"
 )
 
 set(WebCoreTestSupport_IDL_INCLUDES
@@ -2847,6 +2848,7 @@
 set(WebCoreTestSupport_SOURCES
     testing/Internals.cpp
     testing/InternalSettings.cpp
+    platform/mock/PlatformSpeechSynthesizerMock.cpp
 )
 
 # Modules that the bindings generator scripts may use

Modified: trunk/Source/WebCore/ChangeLog (143135 => 143136)


--- trunk/Source/WebCore/ChangeLog	2013-02-17 20:05:43 UTC (rev 143135)
+++ trunk/Source/WebCore/ChangeLog	2013-02-17 20:57:42 UTC (rev 143136)
@@ -1,3 +1,21 @@
+2013-02-17  Chris Fleizach  <[email protected]>
+
+        WebSpeech: plumb through a method to generate fake speech jobs for testing
+        https://bugs.webkit.org/show_bug.cgi?id=107351
+
+        Reviewed by Adam Barth.
+
+        We can't reliably use the platforms synthesizer to test speech synthesis internals.
+        This patch adds an Internals method to enable a mock synthesizer, which is inherits
+        from the PlatformSpeechSythesizer.
+
+        The fake synthesizer goes through all the motions of a real synthesizer but doesn't do anything.
+        A bunch of changes were needed here to make PlatformSpeechSynthesizer subclassable so that the
+        right virtual are used.
+
+        The Mock synthesizer only lives in WebCoreTestSupport. Because PlatformSpeechSynthesizer uses
+        a RetainPtr, I needed to make WebCoreTestSupport link CoreFoundation
+
 2013-02-17  Csaba Osztrogonác  <[email protected]>
 
         [Qt] Unreviewed buildfix for !USE(LIBXML) builds after r143112.

Modified: trunk/Source/WebCore/Modules/speech/SpeechSynthesis.cpp (143135 => 143136)


--- trunk/Source/WebCore/Modules/speech/SpeechSynthesis.cpp	2013-02-17 20:05:43 UTC (rev 143135)
+++ trunk/Source/WebCore/Modules/speech/SpeechSynthesis.cpp	2013-02-17 20:57:42 UTC (rev 143136)
@@ -42,11 +42,16 @@
 }
     
 SpeechSynthesis::SpeechSynthesis()
-    : m_platformSpeechSynthesizer(PlatformSpeechSynthesizer(this))
+    : m_platformSpeechSynthesizer(PlatformSpeechSynthesizer::create(this))
     , m_currentSpeechUtterance(0)
 {
 }
     
+void SpeechSynthesis::setPlatformSynthesizer(PassOwnPtr<PlatformSpeechSynthesizer> synthesizer)
+{
+    m_platformSpeechSynthesizer = synthesizer;
+}
+    
 void SpeechSynthesis::voicesDidChange()
 {
     m_voiceList.clear();
@@ -58,7 +63,7 @@
         return m_voiceList;
     
     // If the voiceList is empty, that's the cue to get the voices from the platform again.
-    const Vector<RefPtr<PlatformSpeechSynthesisVoice> >& platformVoices = m_platformSpeechSynthesizer.voiceList();
+    const Vector<RefPtr<PlatformSpeechSynthesisVoice> >& platformVoices = m_platformSpeechSynthesizer->voiceList();
     size_t voiceCount = platformVoices.size();
     for (size_t k = 0; k < voiceCount; k++)
         m_voiceList.append(SpeechSynthesisVoice::create(platformVoices[k]));
@@ -88,7 +93,7 @@
     ASSERT(!m_currentSpeechUtterance);
     utterance->setStartTime(monotonicallyIncreasingTime());
     m_currentSpeechUtterance = utterance;
-    m_platformSpeechSynthesizer.speak(utterance->platformUtterance());
+    m_platformSpeechSynthesizer->speak(utterance->platformUtterance());
 }
 
 void SpeechSynthesis::speak(SpeechSynthesisUtterance* utterance)

Modified: trunk/Source/WebCore/Modules/speech/SpeechSynthesis.h (143135 => 143136)


--- trunk/Source/WebCore/Modules/speech/SpeechSynthesis.h	2013-02-17 20:05:43 UTC (rev 143135)
+++ trunk/Source/WebCore/Modules/speech/SpeechSynthesis.h	2013-02-17 20:57:42 UTC (rev 143136)
@@ -57,6 +57,9 @@
     
     const Vector<RefPtr<SpeechSynthesisVoice> >& getVoices();
     
+    // Used in testing to use a mock platform synthesizer
+    void setPlatformSynthesizer(PassOwnPtr<PlatformSpeechSynthesizer>);
+    
 private:
     SpeechSynthesis();
     
@@ -70,7 +73,7 @@
     void handleSpeakingCompleted(SpeechSynthesisUtterance*, bool errorOccurred);
     void fireEvent(const AtomicString& type, SpeechSynthesisUtterance*, unsigned long charIndex, const String& name);
     
-    PlatformSpeechSynthesizer m_platformSpeechSynthesizer;
+    OwnPtr<PlatformSpeechSynthesizer> m_platformSpeechSynthesizer;
     Vector<RefPtr<SpeechSynthesisVoice> > m_voiceList;
     SpeechSynthesisUtterance* m_currentSpeechUtterance;
     Deque<RefPtr<SpeechSynthesisUtterance> > m_utteranceQueue;

Modified: trunk/Source/WebCore/Target.pri (143135 => 143136)


--- trunk/Source/WebCore/Target.pri	2013-02-17 20:05:43 UTC (rev 143135)
+++ trunk/Source/WebCore/Target.pri	2013-02-17 20:57:42 UTC (rev 143136)
@@ -1081,6 +1081,7 @@
     platform/mock/DeviceMotionClientMock.cpp \
     platform/mock/DeviceOrientationClientMock.cpp \
     platform/mock/GeolocationClientMock.cpp \
+    platform/mock/PlatformSpeechSynthesizerMock.cpp \
     platform/mock/ScrollbarThemeMock.cpp \
     platform/network/AuthenticationChallengeBase.cpp \
     platform/network/BlobData.cpp \
@@ -2175,6 +2176,7 @@
     platform/mock/DeviceMotionClientMock.h \
     platform/mock/DeviceOrientationClientMock.h \
     platform/mock/GeolocationClientMock.cpp \
+    platform/mock/PlatformSpeechSynthesizerMock.h \
     platform/mock/ScrollbarThemeMock.h \
     platform/graphics/BitmapImage.h \
     platform/graphics/Color.h \

Modified: trunk/Source/WebCore/WebCore.exp.in (143135 => 143136)


--- trunk/Source/WebCore/WebCore.exp.in	2013-02-17 20:05:43 UTC (rev 143135)
+++ trunk/Source/WebCore/WebCore.exp.in	2013-02-17 20:57:42 UTC (rev 143136)
@@ -1534,6 +1534,9 @@
 __ZTVN7WebCore16IconDatabaseBaseE
 __ZTVN7WebCore17FrameLoaderClientE
 __ZTVN7WebCore25HistoryPropertyListWriterE
+#if ENABLE(SPEECH_SYNTHESIS)
+__ZTVN7WebCore25PlatformSpeechSynthesizerE
+#endif
 __ZTVN7WebCore28InspectorFrontendClientLocal8SettingsE
 __ZN7WebCore16CSSParserContextC1EPNS_8DocumentERKNS_4KURLERKN3WTF6StringE
 __ZN7WebCore18StyleSheetContents11parseStringERKN3WTF6StringE
@@ -1689,6 +1692,9 @@
 __ZN7WebCore13toDeviceSpaceERKNS_9FloatRectEP8NSWindow
 __ZN7WebCore15GraphicsContextC1EP9CGContext
 __ZN7WebCore15GraphicsContext15drawNativeImageEP7CGImageRKNS_9FloatSizeENS_10ColorSpaceERKNS_9FloatRectES9_NS_17CompositeOperatorENS_9BlendModeENS_16ImageOrientationE
+#if ENABLE(SPEECH_SYNTHESIS)
+__ZN7WebCore15SpeechSynthesis22setPlatformSynthesizerEN3WTF10PassOwnPtrINS_25PlatformSpeechSynthesizerEEE
+#endif
 __ZN7WebCore16FontPlatformDataC1EP6NSFontfbbbNS_15FontOrientationENS_16FontWidthVariantE
 __ZN7WebCore16FontPlatformDataC2EP6NSFontfbbbNS_15FontOrientationENS_16FontWidthVariantE
 __ZN7WebCore16colorFromNSColorEP7NSColor
@@ -1708,6 +1714,10 @@
 __ZN7WebCore24contextMenuItemTagItalicEv
 __ZN7WebCore24contextMenuItemTagStylesEv
 __ZN7WebCore24keyIdentifierForKeyEventEP7NSEvent
+#if ENABLE(SPEECH_SYNTHESIS)
+__ZN7WebCore24DOMWindowSpeechSynthesis15speechSynthesisEPNS_9DOMWindowE
+__ZN7WebCore25PlatformSpeechSynthesizerC2EPNS_31PlatformSpeechSynthesizerClientE
+#endif
 __ZN7WebCore25PluginMainThreadScheduler12scheduleCallEP4_NPPPFvPvES3_
 __ZN7WebCore25PluginMainThreadScheduler14registerPluginEP4_NPP
 __ZN7WebCore25PluginMainThreadScheduler16unregisterPluginEP4_NPP
@@ -1726,6 +1736,9 @@
 __ZN7WebCore28contextMenuItemTagShowColorsEv
 __ZN7WebCore28contextMenuItemTagSmartLinksEv
 __ZN7WebCore28contextMenuItemTagSpeechMenuEv
+#if ENABLE(SPEECH_SYNTHESIS)
+__ZN7WebCore28PlatformSpeechSynthesisVoice6createERKN3WTF6StringES4_S4_bb
+#endif
 __ZN7WebCore29applicationIsMicrosoftOutlookEv
 __ZN7WebCore29contextMenuItemTagLeftToRightEv
 __ZN7WebCore29contextMenuItemTagRightToLeftEv

Modified: trunk/Source/WebCore/WebCore.gypi (143135 => 143136)


--- trunk/Source/WebCore/WebCore.gypi	2013-02-17 20:05:43 UTC (rev 143135)
+++ trunk/Source/WebCore/WebCore.gypi	2013-02-17 20:57:42 UTC (rev 143136)
@@ -4421,6 +4421,8 @@
             'platform/mock/DeviceMotionClientMock.cpp',
             'platform/mock/DeviceOrientationClientMock.cpp',
             'platform/mock/GeolocationClientMock.cpp',
+            'platform/mock/PlatformSpeechSynthesizerMock.cpp',
+            'platform/mock/PlatformSpeechSynthesizerMock.h',
             'platform/mock/ScrollbarThemeMock.cpp',
             'platform/mock/ScrollbarThemeMock.h',
             'platform/network/AuthenticationChallengeBase.cpp',
@@ -5149,6 +5151,8 @@
         'webcore_test_support_files': [
             'inspector/InspectorFrontendClientLocal.cpp',
             'inspector/InspectorFrontendClientLocal.h',
+            'platform/mock/PlatformSpeechSynthesizerMock.cpp',
+            'platform/mock/PlatformSpeechSynthesizerMock.h',
             'testing/v8/WebCoreTestSupport.cpp',
             'testing/v8/WebCoreTestSupport.h',
             'testing/js/WebCoreTestSupport.cpp',

Modified: trunk/Source/WebCore/WebCore.vcproj/WebCoreTestSupport.vcproj (143135 => 143136)


--- trunk/Source/WebCore/WebCore.vcproj/WebCoreTestSupport.vcproj	2013-02-17 20:05:43 UTC (rev 143135)
+++ trunk/Source/WebCore/WebCore.vcproj/WebCoreTestSupport.vcproj	2013-02-17 20:57:42 UTC (rev 143136)
@@ -757,6 +757,82 @@
 			</File>
 		</Filter>
 		<Filter
+			Name="platform"
+			>
+			<Filter
+				Name="mock"
+				>
+				<File
+					RelativePath="..\platform\mock\PlatformSpeechSynthesizerMock.cpp"
+					>
+					<FileConfiguration
+						Name="Debug|Win32"
+						>
+						<Tool
+							Name="VCCLCompilerTool"
+							UsePrecompiledHeader="0"
+							DisableSpecificWarnings="4065;4273;4565;4701;4702"
+							ForcedIncludeFiles="$(NOINHERIT)"
+						/>
+					</FileConfiguration>
+					<FileConfiguration
+						Name="Release|Win32"
+						>
+						<Tool
+							Name="VCCLCompilerTool"
+							UsePrecompiledHeader="0"
+							DisableSpecificWarnings="4065;4273;4565;4701;4702"
+							ForcedIncludeFiles="$(NOINHERIT)"
+						/>
+					</FileConfiguration>
+					<FileConfiguration
+						Name="Debug_Cairo_CFLite|Win32"
+						>
+						<Tool
+							Name="VCCLCompilerTool"
+							UsePrecompiledHeader="0"
+							DisableSpecificWarnings="4065;4273;4565;4701;4702"
+							ForcedIncludeFiles="$(NOINHERIT)"
+						/>
+					</FileConfiguration>
+					<FileConfiguration
+						Name="Release_Cairo_CFLite|Win32"
+						>
+						<Tool
+							Name="VCCLCompilerTool"
+							UsePrecompiledHeader="0"
+							DisableSpecificWarnings="4065;4273;4565;4701;4702"
+							ForcedIncludeFiles="$(NOINHERIT)"
+						/>
+					</FileConfiguration>
+					<FileConfiguration
+						Name="Debug_All|Win32"
+						>
+						<Tool
+							Name="VCCLCompilerTool"
+							UsePrecompiledHeader="0"
+							DisableSpecificWarnings="4065;4273;4565;4701;4702"
+							ForcedIncludeFiles="$(NOINHERIT)"
+						/>
+					</FileConfiguration>
+					<FileConfiguration
+						Name="Production|Win32"
+						>
+						<Tool
+							Name="VCCLCompilerTool"
+							UsePrecompiledHeader="0"
+							DisableSpecificWarnings="4065;4273;4565;4701;4702"
+							ForcedIncludeFiles="$(NOINHERIT)"
+						/>
+					</FileConfiguration>
+				</File>
+				<File
+					RelativePath="..\platform\mock\PlatformSpeechSynthesizerMock.h"
+					>
+				</File>
+			</Filter>
+		</Filter>
+		<Filter
 			Name="testing"
 			>
 			<File

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (143135 => 143136)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2013-02-17 20:05:43 UTC (rev 143135)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2013-02-17 20:57:42 UTC (rev 143136)
@@ -4670,6 +4670,9 @@
 		AA478A8016CD70C3007D1BB4 /* WebAccessibilityObjectWrapperMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = AA478A7E16CD70C3007D1BB4 /* WebAccessibilityObjectWrapperMac.mm */; };
 		AA4C3A760B2B1679002334A2 /* StyleElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AA4C3A740B2B1679002334A2 /* StyleElement.cpp */; };
 		AA4C3A770B2B1679002334A2 /* StyleElement.h in Headers */ = {isa = PBXBuildFile; fileRef = AA4C3A750B2B1679002334A2 /* StyleElement.h */; };
+		AA5F3B8D16CC33D100455EB0 /* PlatformSpeechSynthesizerMock.h in Headers */ = {isa = PBXBuildFile; fileRef = AAE27B7516CBFC0D00623043 /* PlatformSpeechSynthesizerMock.h */; };
+		AA5F3B8F16CC4B3900455EB0 /* PlatformSpeechSynthesizerMock.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AAE27B7416CBFC0D00623043 /* PlatformSpeechSynthesizerMock.cpp */; };
+		AA5F3B9116CC5BEB00455EB0 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AA5F3B9016CC5BEB00455EB0 /* CoreFoundation.framework */; };
 		AA73183E159255B900A93E6E /* InjectedScriptCanvasModule.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AA73183C159255B900A93E6E /* InjectedScriptCanvasModule.cpp */; };
 		AA73183F159255B900A93E6E /* InjectedScriptCanvasModule.h in Headers */ = {isa = PBXBuildFile; fileRef = AA73183D159255B900A93E6E /* InjectedScriptCanvasModule.h */; };
 		AA7FEEA416A4E6F3004C0C33 /* JSSpeechSynthesis.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AA7FEE9C16A4E6F3004C0C33 /* JSSpeechSynthesis.cpp */; };
@@ -12068,6 +12071,7 @@
 		AA478A7E16CD70C3007D1BB4 /* WebAccessibilityObjectWrapperMac.mm */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; fileEncoding = 4; path = WebAccessibilityObjectWrapperMac.mm; sourceTree = "<group>"; };
 		AA4C3A740B2B1679002334A2 /* StyleElement.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = StyleElement.cpp; sourceTree = "<group>"; };
 		AA4C3A750B2B1679002334A2 /* StyleElement.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = StyleElement.h; sourceTree = "<group>"; };
+		AA5F3B9016CC5BEB00455EB0 /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = ../../../../../System/Library/Frameworks/CoreFoundation.framework; sourceTree = "<group>"; };
 		AA73183C159255B900A93E6E /* InjectedScriptCanvasModule.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InjectedScriptCanvasModule.cpp; sourceTree = "<group>"; };
 		AA73183D159255B900A93E6E /* InjectedScriptCanvasModule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InjectedScriptCanvasModule.h; sourceTree = "<group>"; };
 		AA7FEE9C16A4E6F3004C0C33 /* JSSpeechSynthesis.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSSpeechSynthesis.cpp; sourceTree = "<group>"; };
@@ -12088,6 +12092,8 @@
 		AAD766E8157E502F00E85423 /* InspectorCanvasAgent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InspectorCanvasAgent.cpp; sourceTree = "<group>"; };
 		AAD766E9157E502F00E85423 /* InspectorCanvasAgent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorCanvasAgent.h; sourceTree = "<group>"; };
 		AAD766EA157E502F00E85423 /* InspectorCanvasInstrumentation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorCanvasInstrumentation.h; sourceTree = "<group>"; };
+		AAE27B7416CBFC0D00623043 /* PlatformSpeechSynthesizerMock.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PlatformSpeechSynthesizerMock.cpp; path = mock/PlatformSpeechSynthesizerMock.cpp; sourceTree = "<group>"; };
+		AAE27B7516CBFC0D00623043 /* PlatformSpeechSynthesizerMock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PlatformSpeechSynthesizerMock.h; path = mock/PlatformSpeechSynthesizerMock.h; sourceTree = "<group>"; };
 		AAF5B7B11524B4BD0004CB49 /* WebSocketFrame.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WebSocketFrame.cpp; path = Modules/websockets/WebSocketFrame.cpp; sourceTree = "<group>"; };
 		AB23A32509BBA7D00067CC53 /* BeforeTextInsertedEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = BeforeTextInsertedEvent.cpp; sourceTree = "<group>"; };
 		AB23A32609BBA7D00067CC53 /* BeforeTextInsertedEvent.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = BeforeTextInsertedEvent.h; sourceTree = "<group>"; };
@@ -14570,6 +14576,7 @@
 			isa = PBXFrameworksBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				AA5F3B9116CC5BEB00455EB0 /* CoreFoundation.framework in Frameworks */,
 				41230913138C42FF00BCCFCA /* _javascript_Core.framework in Frameworks */,
 				4123081B138C429700BCCFCA /* WebCore.framework in Frameworks */,
 			);
@@ -14718,6 +14725,7 @@
 		0867D69AFE84028FC02AAC07 /* Frameworks */ = {
 			isa = PBXGroup;
 			children = (
+				AA5F3B9016CC5BEB00455EB0 /* CoreFoundation.framework */,
 				FD2DBF0E12B048A300ED98C6 /* Accelerate.framework */,
 				F5C2869302846DCD018635CA /* ApplicationServices.framework */,
 				FD2DBF0F12B048A300ED98C6 /* AudioToolbox.framework */,
@@ -16011,6 +16019,8 @@
 			children = (
 				59309A1011F4AE5800250603 /* DeviceOrientationClientMock.cpp */,
 				59309A1211F4AE6A00250603 /* DeviceOrientationClientMock.h */,
+				AAE27B7416CBFC0D00623043 /* PlatformSpeechSynthesizerMock.cpp */,
+				AAE27B7516CBFC0D00623043 /* PlatformSpeechSynthesizerMock.h */,
 				0FE71403142170B800DB33BA /* ScrollbarThemeMock.cpp */,
 				0FE71404142170B800DB33BA /* ScrollbarThemeMock.h */,
 			);
@@ -23142,6 +23152,7 @@
 				417DA6DA13734E6E007C57FB /* Internals.h in Headers */,
 				A7BF7EE014C9175A0014489D /* InternalSettings.h in Headers */,
 				53E29E5F167A8A1900586D3D /* InternalSettingsGenerated.h in Headers */,
+				AA5F3B8D16CC33D100455EB0 /* PlatformSpeechSynthesizerMock.h in Headers */,
 				417DA71E13735DFA007C57FB /* JSInternals.h in Headers */,
 				A740B5A514C935AB00A77FA4 /* JSInternalSettings.h in Headers */,
 				53ED3FDF167A88E7006762E6 /* JSInternalSettingsGenerated.h in Headers */,
@@ -26891,6 +26902,7 @@
 				A740B59714C935AF00A77FA4 /* JSMallocStatistics.cpp in Sources */,
 				EBF5121C1696496C0056BD25 /* JSTypeConversions.cpp in Sources */,
 				CDC26B40160A8CC60026757B /* MockCDM.cpp in Sources */,
+				AA5F3B8F16CC4B3900455EB0 /* PlatformSpeechSynthesizerMock.cpp in Sources */,
 				41815C1E138319830057AAA4 /* WebCoreTestSupport.cpp in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;

Modified: trunk/Source/WebCore/platform/PlatformSpeechSynthesizer.cpp (143135 => 143136)


--- trunk/Source/WebCore/platform/PlatformSpeechSynthesizer.cpp	2013-02-17 20:05:43 UTC (rev 143135)
+++ trunk/Source/WebCore/platform/PlatformSpeechSynthesizer.cpp	2013-02-17 20:57:42 UTC (rev 143136)
@@ -30,6 +30,11 @@
 
 namespace WebCore {
     
+PassOwnPtr<PlatformSpeechSynthesizer> PlatformSpeechSynthesizer::create(PlatformSpeechSynthesizerClient* client)
+{
+    return adoptPtr(new PlatformSpeechSynthesizer(client));
+}
+
 PlatformSpeechSynthesizer::PlatformSpeechSynthesizer(PlatformSpeechSynthesizerClient* client)
     : m_speechSynthesizerClient(client)
 {

Modified: trunk/Source/WebCore/platform/PlatformSpeechSynthesizer.h (143135 => 143136)


--- trunk/Source/WebCore/platform/PlatformSpeechSynthesizer.h	2013-02-17 20:05:43 UTC (rev 143135)
+++ trunk/Source/WebCore/platform/PlatformSpeechSynthesizer.h	2013-02-17 20:57:42 UTC (rev 143136)
@@ -29,6 +29,7 @@
 #if ENABLE(SPEECH_SYNTHESIS)
 
 #include "PlatformSpeechSynthesisVoice.h"
+#include <wtf/PassOwnPtr.h>
 #include <wtf/Vector.h>
 
 #if PLATFORM(MAC)
@@ -53,19 +54,23 @@
     
 class PlatformSpeechSynthesizer {
 public:
-    explicit PlatformSpeechSynthesizer(PlatformSpeechSynthesizerClient*);
+    static PassOwnPtr<PlatformSpeechSynthesizer> create(PlatformSpeechSynthesizerClient*);
+
+    virtual ~PlatformSpeechSynthesizer() { }
     
     const Vector<RefPtr<PlatformSpeechSynthesisVoice> >& voiceList() const { return m_voiceList; }
-    void speak(const PlatformSpeechSynthesisUtterance&);
+    virtual void speak(const PlatformSpeechSynthesisUtterance&);
     
     PlatformSpeechSynthesizerClient* client() const { return m_speechSynthesizerClient; }
     
+protected:
+    explicit PlatformSpeechSynthesizer(PlatformSpeechSynthesizerClient*);
+    Vector<RefPtr<PlatformSpeechSynthesisVoice> > m_voiceList;
+    
 private:
     PlatformSpeechSynthesizerClient* m_speechSynthesizerClient;
-    Vector<RefPtr<PlatformSpeechSynthesisVoice> > m_voiceList;
+    virtual void initializeVoiceList();
     
-    void initializeVoiceList();
-    
 #if PLATFORM(MAC)
     RetainPtr<WebSpeechSynthesisWrapper> m_platformSpeechWrapper;
 #endif

Added: trunk/Source/WebCore/platform/mock/PlatformSpeechSynthesizerMock.cpp (0 => 143136)


--- trunk/Source/WebCore/platform/mock/PlatformSpeechSynthesizerMock.cpp	                        (rev 0)
+++ trunk/Source/WebCore/platform/mock/PlatformSpeechSynthesizerMock.cpp	2013-02-17 20:57:42 UTC (rev 143136)
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2013 Apple Computer, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "PlatformSpeechSynthesizerMock.h"
+
+#if ENABLE(SPEECH_SYNTHESIS)
+
+namespace WebCore {
+
+PassOwnPtr<PlatformSpeechSynthesizerMock> PlatformSpeechSynthesizerMock::create(PlatformSpeechSynthesizerClient* client)
+{
+    return adoptPtr(new PlatformSpeechSynthesizerMock(client));
+}
+    
+PlatformSpeechSynthesizerMock::PlatformSpeechSynthesizerMock(PlatformSpeechSynthesizerClient* client)
+    : PlatformSpeechSynthesizer(client)
+    , m_speakingFinishedTimer(this, &PlatformSpeechSynthesizerMock::speakingFinished)
+    , m_utterance(0)
+{
+}
+    
+PlatformSpeechSynthesizerMock::~PlatformSpeechSynthesizerMock()
+{
+    m_speakingFinishedTimer.stop();
+}
+
+void PlatformSpeechSynthesizerMock::speakingFinished(Timer<PlatformSpeechSynthesizerMock>*)
+{
+    client()->didFinishSpeaking(m_utterance);
+    m_utterance = 0;
+}
+    
+void PlatformSpeechSynthesizerMock::initializeVoiceList()
+{
+    m_voiceList.clear();
+    m_voiceList.append(PlatformSpeechSynthesisVoice::create(String("mock.voice.bruce"), String("bruce"), String("en-US"), true, true));
+    m_voiceList.append(PlatformSpeechSynthesisVoice::create(String("mock.voice.clark"), String("clark"), String("en-US"), true, false));
+    m_voiceList.append(PlatformSpeechSynthesisVoice::create(String("mock.voice.logan"), String("logan"), String("fr-CA"), true, true));
+}
+
+void PlatformSpeechSynthesizerMock::speak(const PlatformSpeechSynthesisUtterance& utterance)
+{
+    m_utterance = &utterance;
+    client()->didStartSpeaking(m_utterance);
+    m_speakingFinishedTimer.startOneShot(0);
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(SPEECH_SYNTHESIS)

Added: trunk/Source/WebCore/platform/mock/PlatformSpeechSynthesizerMock.h (0 => 143136)


--- trunk/Source/WebCore/platform/mock/PlatformSpeechSynthesizerMock.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/mock/PlatformSpeechSynthesizerMock.h	2013-02-17 20:57:42 UTC (rev 143136)
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2013 Apple Computer, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef PlatformSpeechSynthesizerMock_h
+#define PlatformSpeechSynthesizerMock_h
+
+#if ENABLE(SPEECH_SYNTHESIS)
+
+#include "PlatformSpeechSynthesizer.h"
+#include "Timer.h"
+#include <wtf/PassOwnPtr.h>
+
+namespace WebCore {
+    
+class PlatformSpeechSynthesizerMock : public PlatformSpeechSynthesizer {
+public:
+    static PassOwnPtr<PlatformSpeechSynthesizerMock> create(PlatformSpeechSynthesizerClient*);
+    
+    virtual ~PlatformSpeechSynthesizerMock();
+    virtual void speak(const PlatformSpeechSynthesisUtterance&);
+    
+private:
+    explicit PlatformSpeechSynthesizerMock(PlatformSpeechSynthesizerClient*);
+    virtual void initializeVoiceList();
+    void speakingFinished(Timer<PlatformSpeechSynthesizerMock>*);
+    
+    Timer<PlatformSpeechSynthesizerMock> m_speakingFinishedTimer;
+    const PlatformSpeechSynthesisUtterance* m_utterance;
+};
+    
+} // namespace WebCore
+
+#endif // ENABLE(SPEECH_SYNTHESIS)
+
+#endif // PlatformSpeechSynthesizer_h

Modified: trunk/Source/WebCore/testing/Internals.cpp (143135 => 143136)


--- trunk/Source/WebCore/testing/Internals.cpp	2013-02-17 20:05:43 UTC (rev 143135)
+++ trunk/Source/WebCore/testing/Internals.cpp	2013-02-17 20:57:42 UTC (rev 143136)
@@ -137,6 +137,12 @@
 #include "PageGroup.h"
 #endif
 
+#if ENABLE(SPEECH_SYNTHESIS)
+#include "DOMWindowSpeechSynthesis.h"
+#include "PlatformSpeechSynthesizerMock.h"
+#include "SpeechSynthesis.h"
+#endif
+
 namespace WebCore {
 
 #if ENABLE(PAGE_POPUP)
@@ -827,6 +833,20 @@
         ec = INVALID_ACCESS_ERR;
 }
 
+#if ENABLE(SPEECH_SYNTHESIS)
+void Internals::enableMockSpeechSynthesizer()
+{
+    Document* document = contextDocument();
+    if (!document || !document->domWindow())
+        return;
+    SpeechSynthesis* synthesis = DOMWindowSpeechSynthesis::speechSynthesis(document->domWindow());
+    if (!synthesis)
+        return;
+    
+    synthesis->setPlatformSynthesizer(PlatformSpeechSynthesizerMock::create(synthesis));
+}
+#endif
+    
 void Internals::setEnableMockPagePopup(bool enabled, ExceptionCode& ec)
 {
 #if ENABLE(PAGE_POPUP)

Modified: trunk/Source/WebCore/testing/Internals.h (143135 => 143136)


--- trunk/Source/WebCore/testing/Internals.h	2013-02-17 20:05:43 UTC (rev 143135)
+++ trunk/Source/WebCore/testing/Internals.h	2013-02-17 20:57:42 UTC (rev 143136)
@@ -285,6 +285,10 @@
     void initializeMockCDM();
 #endif
 
+#if ENABLE(SPEECH_SYNTHESIS)
+    void enableMockSpeechSynthesizer();
+#endif
+                    
 private:
     explicit Internals(Document*);
     Document* contextDocument() const;

Modified: trunk/Source/WebCore/testing/Internals.idl (143135 => 143136)


--- trunk/Source/WebCore/testing/Internals.idl	2013-02-17 20:05:43 UTC (rev 143135)
+++ trunk/Source/WebCore/testing/Internals.idl	2013-02-17 20:57:42 UTC (rev 143136)
@@ -251,4 +251,6 @@
     void setUsesOverlayScrollbars(in boolean enabled);
 
     [Conditional=ENCRYPTED_MEDIA_V2] void initializeMockCDM();
+    
+    [Conditional=SPEECH_SYNTHESIS] void enableMockSpeechSynthesizer();
 };
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to