Unreviewed, rolling out r106219.
authorhans@chromium.org <hans@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 30 Jan 2012 10:10:33 +0000 (10:10 +0000)
committerhans@chromium.org <hans@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 30 Jan 2012 10:10:33 +0000 (10:10 +0000)
http://trac.webkit.org/changeset/106219
https://bugs.webkit.org/show_bug.cgi?id=77083

This broke Chromium's test_shell.

Source/WebCore:

* GNUmakefile.list.am:
* Target.pri:
* WebCore.gypi:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.xcodeproj/project.pbxproj:
* platform/mock/SpeechInputClientMock.cpp: Added.
(WebCore):
(WebCore::SpeechInputClientMock::SpeechInputClientMock):
(WebCore::SpeechInputClientMock::setListener):
(WebCore::SpeechInputClientMock::startRecognition):
(WebCore::SpeechInputClientMock::stopRecording):
(WebCore::SpeechInputClientMock::cancelRecognition):
(WebCore::SpeechInputClientMock::addRecognitionResult):
(WebCore::SpeechInputClientMock::clearResults):
(WebCore::SpeechInputClientMock::timerFired):
* platform/mock/SpeechInputClientMock.h: Added.
(WebCore):
(SpeechInputClientMock):

Source/WebKit/chromium:

* WebKit.gyp:
* public/WebSpeechInputControllerMock.h: Added.
(WebKit):
(WebSpeechInputControllerMock):
(WebKit::WebSpeechInputControllerMock::~WebSpeechInputControllerMock):
* public/WebSpeechInputResult.h:
(WebSpeechInputResult):
* src/WebSpeechInputControllerMockImpl.cpp: Added.
(WebKit):
(WebKit::WebSpeechInputControllerMock::create):
(WebKit::WebSpeechInputControllerMockImpl::WebSpeechInputControllerMockImpl):
(WebKit::WebSpeechInputControllerMockImpl::~WebSpeechInputControllerMockImpl):
(WebKit::WebSpeechInputControllerMockImpl::addMockRecognitionResult):
(WebKit::WebSpeechInputControllerMockImpl::clearResults):
(WebKit::WebSpeechInputControllerMockImpl::didCompleteRecording):
(WebKit::WebSpeechInputControllerMockImpl::didCompleteRecognition):
(WebKit::WebSpeechInputControllerMockImpl::setRecognitionResult):
(WebKit::WebSpeechInputControllerMockImpl::startRecognition):
(WebKit::WebSpeechInputControllerMockImpl::cancelRecognition):
(WebKit::WebSpeechInputControllerMockImpl::stopRecording):
* src/WebSpeechInputControllerMockImpl.h: Added.
(WebCore):
(WebKit):
(WebSpeechInputControllerMockImpl):
* src/WebSpeechInputResult.cpp:

Tools:

* DumpRenderTree/DumpRenderTree.gypi:
* DumpRenderTree/chromium/LayoutTestController.cpp:
(LayoutTestController::addMockSpeechInputResult):
* DumpRenderTree/chromium/LayoutTestController.h:
(WebKit):
(LayoutTestController):
():
* DumpRenderTree/chromium/MockWebSpeechInputController.cpp: Removed.
* DumpRenderTree/chromium/MockWebSpeechInputController.h: Removed.
* DumpRenderTree/chromium/TestShell.cpp:
* DumpRenderTree/chromium/WebViewHost.cpp:
(WebViewHost::speechInputController):
* DumpRenderTree/chromium/WebViewHost.h:
(WebKit):
(WebViewHost::speechInputControllerMock):
(WebViewHost):
():

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@106223 268f45cc-cd09-0410-ab3c-d52691b4dbfc

24 files changed:
Source/WebCore/ChangeLog
Source/WebCore/GNUmakefile.list.am
Source/WebCore/Target.pri
Source/WebCore/WebCore.gypi
Source/WebCore/WebCore.vcproj/WebCore.vcproj
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/platform/mock/SpeechInputClientMock.cpp [new file with mode: 0644]
Source/WebCore/platform/mock/SpeechInputClientMock.h [new file with mode: 0644]
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/WebKit.gyp
Source/WebKit/chromium/public/WebSpeechInputControllerMock.h [new file with mode: 0644]
Source/WebKit/chromium/public/WebSpeechInputResult.h
Source/WebKit/chromium/src/WebSpeechInputControllerMockImpl.cpp [new file with mode: 0644]
Source/WebKit/chromium/src/WebSpeechInputControllerMockImpl.h [new file with mode: 0644]
Source/WebKit/chromium/src/WebSpeechInputResult.cpp
Tools/ChangeLog
Tools/DumpRenderTree/DumpRenderTree.gypi
Tools/DumpRenderTree/chromium/LayoutTestController.cpp
Tools/DumpRenderTree/chromium/LayoutTestController.h
Tools/DumpRenderTree/chromium/MockWebSpeechInputController.cpp [deleted file]
Tools/DumpRenderTree/chromium/MockWebSpeechInputController.h [deleted file]
Tools/DumpRenderTree/chromium/TestShell.cpp
Tools/DumpRenderTree/chromium/WebViewHost.cpp
Tools/DumpRenderTree/chromium/WebViewHost.h

index 73fc871..c02af10 100644 (file)
@@ -1,3 +1,30 @@
+2012-01-30  Hans Wennborg  <hans@chromium.org>
+
+        Unreviewed, rolling out r106219.
+        http://trac.webkit.org/changeset/106219
+        https://bugs.webkit.org/show_bug.cgi?id=77083
+
+        This broke Chromium's test_shell.
+
+        * GNUmakefile.list.am:
+        * Target.pri:
+        * WebCore.gypi:
+        * WebCore.vcproj/WebCore.vcproj:
+        * WebCore.xcodeproj/project.pbxproj:
+        * platform/mock/SpeechInputClientMock.cpp: Added.
+        (WebCore):
+        (WebCore::SpeechInputClientMock::SpeechInputClientMock):
+        (WebCore::SpeechInputClientMock::setListener):
+        (WebCore::SpeechInputClientMock::startRecognition):
+        (WebCore::SpeechInputClientMock::stopRecording):
+        (WebCore::SpeechInputClientMock::cancelRecognition):
+        (WebCore::SpeechInputClientMock::addRecognitionResult):
+        (WebCore::SpeechInputClientMock::clearResults):
+        (WebCore::SpeechInputClientMock::timerFired):
+        * platform/mock/SpeechInputClientMock.h: Added.
+        (WebCore):
+        (SpeechInputClientMock):
+
 2012-01-30  Yury Semikhatsky  <yurys@chromium.org>
 
         Unreviewed. Clang build fix after r106218
index 2cc3816..d485ee5 100644 (file)
@@ -3141,6 +3141,8 @@ webcore_sources += \
        Source/WebCore/platform/mock/GeolocationServiceMock.h \
        Source/WebCore/platform/mock/ScrollbarThemeMock.cpp \
        Source/WebCore/platform/mock/ScrollbarThemeMock.h \
+       Source/WebCore/platform/mock/SpeechInputClientMock.cpp \
+       Source/WebCore/platform/mock/SpeechInputClientMock.h \
        Source/WebCore/platform/network/AuthenticationChallengeBase.cpp \
        Source/WebCore/platform/network/AuthenticationChallengeBase.h \
        Source/WebCore/platform/network/AuthenticationClient.h \
index 626bb8a..b34c542 100644 (file)
@@ -1106,6 +1106,7 @@ SOURCES += \
     platform/mock/DeviceOrientationClientMock.cpp \
     platform/mock/GeolocationClientMock.cpp \
     platform/mock/GeolocationServiceMock.cpp \
+    platform/mock/SpeechInputClientMock.cpp \
     platform/mock/ScrollbarThemeMock.cpp \
     platform/network/AuthenticationChallengeBase.cpp \
     platform/network/BlobData.cpp \
@@ -2099,6 +2100,7 @@ HEADERS += \
     platform/mock/DeviceOrientationClientMock.h \
     platform/mock/GeolocationClientMock.cpp \
     platform/mock/GeolocationServiceMock.h \
+    platform/mock/SpeechInputClientMock.h \
     platform/mock/ScrollbarThemeMock.h \
     platform/graphics/BitmapImage.h \
     platform/graphics/Color.h \
index 50ade73..0330f10 100644 (file)
             'platform/mock/GeolocationServiceMock.h',
             'platform/mock/ScrollbarThemeMock.cpp',
             'platform/mock/ScrollbarThemeMock.h',
+            'platform/mock/SpeechInputClientMock.cpp',
+            'platform/mock/SpeechInputClientMock.h',
             'platform/network/AuthenticationChallengeBase.cpp',
             'platform/network/BlobData.cpp',
             'platform/network/BlobData.h',
index 4d6027b..f18f470 100755 (executable)
                                        RelativePath="..\platform\mock\ScrollbarThemeMock.h"
                                        >
                                </File>
+                               <File
+                                       RelativePath="..\platform\mock\SpeechInputClientMock.cpp"
+                                       >
+                               </File>
+                               <File
+                                       RelativePath="..\platform\mock\SpeechInputClientMock.h"
+                                       >
+                               </File>
                        </Filter>
                </Filter>
                <Filter
index d042613..63d868a 100644 (file)
                72626E020EF022FE00A07E20 /* FontFastPath.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 72626E010EF022FE00A07E20 /* FontFastPath.cpp */; };
                750D029311D0E7F300BD1B27 /* RenderInputSpeech.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 750D029111D0E7F300BD1B27 /* RenderInputSpeech.cpp */; };
                750D029411D0E7F300BD1B27 /* RenderInputSpeech.h in Headers */ = {isa = PBXBuildFile; fileRef = 750D029211D0E7F300BD1B27 /* RenderInputSpeech.h */; };
+               7535BC9412020CFF0037EC45 /* SpeechInputClientMock.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7535BC9212020CFF0037EC45 /* SpeechInputClientMock.cpp */; };
+               7535BC9512020CFF0037EC45 /* SpeechInputClientMock.h in Headers */ = {isa = PBXBuildFile; fileRef = 7535BC9312020CFF0037EC45 /* SpeechInputClientMock.h */; };
                754133A8102E00E800075D00 /* InspectorTimelineAgent.h in Headers */ = {isa = PBXBuildFile; fileRef = 754133A7102E00E800075D00 /* InspectorTimelineAgent.h */; };
                754133AA102E00F400075D00 /* InspectorTimelineAgent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 754133A9102E00F400075D00 /* InspectorTimelineAgent.cpp */; };
                75415AFD12958D5E003AD669 /* SpeechInputEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 75415AF812958D5E003AD669 /* SpeechInputEvent.h */; };
                72626E010EF022FE00A07E20 /* FontFastPath.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FontFastPath.cpp; sourceTree = "<group>"; };
                750D029111D0E7F300BD1B27 /* RenderInputSpeech.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderInputSpeech.cpp; sourceTree = "<group>"; };
                750D029211D0E7F300BD1B27 /* RenderInputSpeech.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderInputSpeech.h; sourceTree = "<group>"; };
+               7535BC9212020CFF0037EC45 /* SpeechInputClientMock.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SpeechInputClientMock.cpp; path = mock/SpeechInputClientMock.cpp; sourceTree = "<group>"; };
+               7535BC9312020CFF0037EC45 /* SpeechInputClientMock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SpeechInputClientMock.h; path = mock/SpeechInputClientMock.h; sourceTree = "<group>"; };
                754133A7102E00E800075D00 /* InspectorTimelineAgent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorTimelineAgent.h; sourceTree = "<group>"; };
                754133A9102E00F400075D00 /* InspectorTimelineAgent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InspectorTimelineAgent.cpp; sourceTree = "<group>"; };
                75415AF812958D5E003AD669 /* SpeechInputEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SpeechInputEvent.h; sourceTree = "<group>"; };
                                052BFCEA128ABF2100FD338D /* GeolocationClientMock.h */,
                                0FE71403142170B800DB33BA /* ScrollbarThemeMock.cpp */,
                                0FE71404142170B800DB33BA /* ScrollbarThemeMock.h */,
+                               7535BC9212020CFF0037EC45 /* SpeechInputClientMock.cpp */,
+                               7535BC9312020CFF0037EC45 /* SpeechInputClientMock.h */,
                        );
                        name = mock;
                        sourceTree = "<group>";
                                626CDE0F1140424C001E5A68 /* SpatialNavigation.h in Headers */,
                                7578F90C11DDF26900D933C5 /* SpeechInput.h in Headers */,
                                7578F90D11DDF26900D933C5 /* SpeechInputClient.h in Headers */,
+                               7535BC9512020CFF0037EC45 /* SpeechInputClientMock.h in Headers */,
                                75415AFD12958D5E003AD669 /* SpeechInputEvent.h in Headers */,
                                7578F92011E4E32800D933C5 /* SpeechInputListener.h in Headers */,
                                75415B0012958D5E003AD669 /* SpeechInputResultList.h in Headers */,
                                D01A27AD10C9BFD800026A42 /* SpaceSplitString.cpp in Sources */,
                                626CDE0E1140424C001E5A68 /* SpatialNavigation.cpp in Sources */,
                                7578F90B11DDF26900D933C5 /* SpeechInput.cpp in Sources */,
+                               7535BC9412020CFF0037EC45 /* SpeechInputClientMock.cpp in Sources */,
                                75415C28129A9920003AD669 /* SpeechInputEvent.cpp in Sources */,
                                758978EC127090D60076D5A9 /* SpeechInputResult.cpp in Sources */,
                                75415C29129A9920003AD669 /* SpeechInputResultList.cpp in Sources */,
diff --git a/Source/WebCore/platform/mock/SpeechInputClientMock.cpp b/Source/WebCore/platform/mock/SpeechInputClientMock.cpp
new file mode 100644 (file)
index 0000000..9aa3113
--- /dev/null
@@ -0,0 +1,146 @@
+/*
+ * Copyright (C) 2010 Google 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:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * 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.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "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 THE COPYRIGHT
+ * OWNER 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 "SpeechInputClientMock.h"
+
+#if ENABLE(INPUT_SPEECH)
+
+#include "SecurityOrigin.h"
+#include "SpeechInputListener.h"
+
+namespace WebCore {
+
+SpeechInputClientMock::SpeechInputClientMock()
+    : m_recording(false)
+    , m_timer(this, &SpeechInputClientMock::timerFired)
+    , m_listener(0)
+    , m_requestId(0)
+{
+}
+
+void SpeechInputClientMock::setListener(SpeechInputListener* listener)
+{
+    m_listener = listener;
+}
+
+bool SpeechInputClientMock::startRecognition(int requestId, const IntRect& elementRect, const AtomicString& language, const String& grammar, SecurityOrigin* origin)
+{
+    if (m_timer.isActive())
+        return false;
+    m_requestId = requestId;
+    m_recording = true;
+    m_language = language;
+    m_timer.startOneShot(0);
+    return true;
+}
+
+void SpeechInputClientMock::stopRecording(int requestId)
+{
+    ASSERT(requestId == m_requestId);
+    if (m_timer.isActive() && m_recording) {
+        m_timer.stop();
+        timerFired(&m_timer);
+    }
+}
+
+void SpeechInputClientMock::cancelRecognition(int requestId)
+{
+    if (m_timer.isActive()) {
+        ASSERT(requestId == m_requestId);
+        m_timer.stop();
+        m_recording = false;
+        m_listener->didCompleteRecognition(m_requestId);
+        m_requestId = 0;
+    }
+}
+
+void SpeechInputClientMock::addRecognitionResult(const String& result, double confidence, const AtomicString& language)
+{
+    if (language.isEmpty())
+        m_resultsForEmptyLanguage.append(SpeechInputResult::create(result, confidence));
+    else {
+        if (!m_recognitionResults.contains(language))
+            m_recognitionResults.set(language, SpeechInputResultArray());
+        m_recognitionResults.find(language)->second.append(SpeechInputResult::create(result, confidence));
+    }
+}
+
+void SpeechInputClientMock::clearResults()
+{
+    m_resultsForEmptyLanguage.clear();
+    m_recognitionResults.clear();
+}
+
+void SpeechInputClientMock::timerFired(WebCore::Timer<SpeechInputClientMock>*)
+{
+    if (m_recording) {
+        m_recording = false;
+        m_listener->didCompleteRecording(m_requestId);
+        m_timer.startOneShot(0);
+    } else {
+        bool noResultsFound = false;
+
+        // We take a copy of the requestId here so that if scripts destroyed the input element
+        // inside one of the callbacks below, we'll still know what this session's requestId was.
+        int requestId = m_requestId;
+        m_requestId = 0;
+
+        // Empty language case must be handled separately to avoid problems with HashMap and empty keys.
+        if (m_language.isEmpty()) {
+            if (!m_resultsForEmptyLanguage.isEmpty())
+                m_listener->setRecognitionResult(requestId, m_resultsForEmptyLanguage);
+            else
+                noResultsFound = true;
+        } else {
+            if (m_recognitionResults.contains(m_language))
+                m_listener->setRecognitionResult(requestId, m_recognitionResults.get(m_language));
+            else
+                noResultsFound = true;
+        }
+
+        if (noResultsFound) {
+            // Can't avoid setting a result even if no result was set for the given language.
+            // This would avoid generating the events used to check the results and the test would timeout.
+            String error("error: no result found for language '");
+            error.append(m_language);
+            error.append("'");
+            SpeechInputResultArray results;
+            results.append(SpeechInputResult::create(error, 1.0));
+            m_listener->setRecognitionResult(requestId, results);
+        }
+
+        m_listener->didCompleteRecognition(requestId);
+    }
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(INPUT_SPEECH)
diff --git a/Source/WebCore/platform/mock/SpeechInputClientMock.h b/Source/WebCore/platform/mock/SpeechInputClientMock.h
new file mode 100644 (file)
index 0000000..4e13242
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2010 Google 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:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * 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.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "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 THE COPYRIGHT
+ * OWNER 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 SpeechInputClientMock_h
+#define SpeechInputClientMock_h
+
+#include "PlatformString.h"
+#include "SpeechInputClient.h"
+#include "SpeechInputResult.h"
+#include "Timer.h"
+#include <wtf/HashMap.h>
+#include <wtf/text/StringHash.h>
+
+#if ENABLE(INPUT_SPEECH)
+
+namespace WebCore {
+
+class SpeechInputListener;
+
+// Provides a mock object for the speech input embedder API called by WebCore.
+class SpeechInputClientMock : public SpeechInputClient {
+public:
+    SpeechInputClientMock();
+
+    void addRecognitionResult(const String& result, double confidence, const AtomicString& language);
+    void clearResults();
+
+    // SpeechInputClient methods.
+    void setListener(SpeechInputListener*);
+    bool startRecognition(int requestId, const IntRect& elementRect, const AtomicString& language, const String& grammar, SecurityOrigin*);
+    void stopRecording(int);
+    void cancelRecognition(int);
+
+private:
+    void timerFired(Timer<SpeechInputClientMock>*);
+
+    bool m_recording;
+    Timer<SpeechInputClientMock> m_timer;
+    SpeechInputListener* m_listener;
+    int m_requestId;
+
+    HashMap<String, SpeechInputResultArray> m_recognitionResults;
+    AtomicString m_language;
+    SpeechInputResultArray m_resultsForEmptyLanguage;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(INPUT_SPEECH)
+
+#endif // SpeechInputClientMock_h
index 2b7a558..b829f67 100644 (file)
@@ -1,3 +1,37 @@
+2012-01-30  Hans Wennborg  <hans@chromium.org>
+
+        Unreviewed, rolling out r106219.
+        http://trac.webkit.org/changeset/106219
+        https://bugs.webkit.org/show_bug.cgi?id=77083
+
+        This broke Chromium's test_shell.
+
+        * WebKit.gyp:
+        * public/WebSpeechInputControllerMock.h: Added.
+        (WebKit):
+        (WebSpeechInputControllerMock):
+        (WebKit::WebSpeechInputControllerMock::~WebSpeechInputControllerMock):
+        * public/WebSpeechInputResult.h:
+        (WebSpeechInputResult):
+        * src/WebSpeechInputControllerMockImpl.cpp: Added.
+        (WebKit):
+        (WebKit::WebSpeechInputControllerMock::create):
+        (WebKit::WebSpeechInputControllerMockImpl::WebSpeechInputControllerMockImpl):
+        (WebKit::WebSpeechInputControllerMockImpl::~WebSpeechInputControllerMockImpl):
+        (WebKit::WebSpeechInputControllerMockImpl::addMockRecognitionResult):
+        (WebKit::WebSpeechInputControllerMockImpl::clearResults):
+        (WebKit::WebSpeechInputControllerMockImpl::didCompleteRecording):
+        (WebKit::WebSpeechInputControllerMockImpl::didCompleteRecognition):
+        (WebKit::WebSpeechInputControllerMockImpl::setRecognitionResult):
+        (WebKit::WebSpeechInputControllerMockImpl::startRecognition):
+        (WebKit::WebSpeechInputControllerMockImpl::cancelRecognition):
+        (WebKit::WebSpeechInputControllerMockImpl::stopRecording):
+        * src/WebSpeechInputControllerMockImpl.h: Added.
+        (WebCore):
+        (WebKit):
+        (WebSpeechInputControllerMockImpl):
+        * src/WebSpeechInputResult.cpp:
+
 2012-01-26  Hans Wennborg  <hans@chromium.org>
 
         Speech Input: move MockSpeechInputClient into Chromium DumpRenderTree implementation
index 71e57e3..2d92ba5 100644 (file)
                 'public/WebSocket.h',
                 'public/WebSocketClient.h',
                 'public/WebSpeechInputController.h',
+                'public/WebSpeechInputControllerMock.h',
                 'public/WebSpeechInputListener.h',
                 'public/WebSpeechInputResult.h',
                 'public/WebSpellCheckClient.h',
                 'src/WebSocketImpl.h',
                 'src/WebSolidColorLayer.cpp',
                 'src/WebSolidColorLayerImpl.cpp',
+                'src/WebSpeechInputControllerMockImpl.cpp',
+                'src/WebSpeechInputControllerMockImpl.h',
                 'src/WebSpeechInputResult.cpp',
                 'src/WebStorageAreaImpl.cpp',
                 'src/WebStorageAreaImpl.h',
diff --git a/Source/WebKit/chromium/public/WebSpeechInputControllerMock.h b/Source/WebKit/chromium/public/WebSpeechInputControllerMock.h
new file mode 100644 (file)
index 0000000..d4e543f
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2010 Google 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:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * 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.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "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 THE COPYRIGHT
+ * OWNER 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 WebSpeechInputControllerMock_h
+#define WebSpeechInputControllerMock_h
+
+#include "WebSpeechInputController.h"
+
+namespace WebKit {
+
+class WebString;
+class WebSpeechInputListener;
+
+class WebSpeechInputControllerMock : public WebSpeechInputController {
+public:
+    WEBKIT_EXPORT static WebSpeechInputControllerMock* create(
+        WebSpeechInputListener* listener);
+    virtual ~WebSpeechInputControllerMock() { }
+
+    virtual void addMockRecognitionResult(const WebString& result, double confidence, const WebString& language) = 0;
+
+    virtual void clearResults() = 0;
+};
+
+} // namespace WebKit
+
+#endif
index 8d02a49..a316fd2 100644 (file)
@@ -42,11 +42,9 @@ namespace WebKit {
 class WebSpeechInputResult {
 public:
     WebSpeechInputResult() { }
-    WebSpeechInputResult(const WebSpeechInputResult& other) { assign(other); }
     ~WebSpeechInputResult() { reset(); }
 
     WEBKIT_EXPORT void set(const WebString& utterance, double confidence);
-    WEBKIT_EXPORT void assign(const WebSpeechInputResult& other);
     WEBKIT_EXPORT void reset();
 
 #if WEBKIT_IMPLEMENTATION
diff --git a/Source/WebKit/chromium/src/WebSpeechInputControllerMockImpl.cpp b/Source/WebKit/chromium/src/WebSpeechInputControllerMockImpl.cpp
new file mode 100644 (file)
index 0000000..4f1f074
--- /dev/null
@@ -0,0 +1,117 @@
+/*
+ * Copyright (C) 2010 Google 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:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * 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.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "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 THE COPYRIGHT
+ * OWNER 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 "WebSpeechInputControllerMockImpl.h"
+
+#if ENABLE(INPUT_SPEECH)
+
+#include "PlatformString.h"
+#include "SecurityOrigin.h"
+#include "SpeechInputClientMock.h"
+#include "platform/WebRect.h"
+#include "WebSecurityOrigin.h"
+#include <wtf/PassOwnPtr.h>
+
+namespace WebKit {
+
+WebSpeechInputControllerMock* WebSpeechInputControllerMock::create(WebSpeechInputListener* listener)
+{
+    return new WebSpeechInputControllerMockImpl(listener);
+}
+
+WebSpeechInputControllerMockImpl::WebSpeechInputControllerMockImpl(
+    WebSpeechInputListener* listener)
+    : m_webcoreMock(adoptPtr(new WebCore::SpeechInputClientMock()))
+    , m_listener(listener)
+{
+    m_webcoreMock->setListener(this);
+}
+
+WebSpeechInputControllerMockImpl::~WebSpeechInputControllerMockImpl()
+{
+    m_webcoreMock->setListener(0);
+}
+
+void WebSpeechInputControllerMockImpl::addMockRecognitionResult(const WebString& result, double confidence, const WebString &language)
+{
+    m_webcoreMock->addRecognitionResult(result, confidence, language);
+}
+
+void WebSpeechInputControllerMockImpl::clearResults()
+{
+    m_webcoreMock->clearResults();
+}
+
+void WebSpeechInputControllerMockImpl::didCompleteRecording(int requestId)
+{
+    m_listener->didCompleteRecording(requestId);
+}
+
+void WebSpeechInputControllerMockImpl::didCompleteRecognition(int requestId)
+{
+    m_listener->didCompleteRecognition(requestId);
+}
+
+void WebSpeechInputControllerMockImpl::setRecognitionResult(int requestId, const WebCore::SpeechInputResultArray& result)
+{
+    m_listener->setRecognitionResult(requestId, result);
+}
+
+bool WebSpeechInputControllerMockImpl::startRecognition(int requestId, const WebRect& elementRect, const WebString& language, const WebString& grammar, const WebSecurityOrigin& origin)
+{
+    return m_webcoreMock->startRecognition(requestId, elementRect, language, grammar, origin.get());
+}
+
+void WebSpeechInputControllerMockImpl::cancelRecognition(int requestId)
+{
+    m_webcoreMock->cancelRecognition(requestId);
+}
+
+void WebSpeechInputControllerMockImpl::stopRecording(int requestId)
+{
+    m_webcoreMock->stopRecording(requestId);
+}
+
+} // namespace WebKit
+
+#else
+
+namespace WebKit {
+
+WebSpeechInputControllerMock* WebSpeechInputControllerMock::create(WebSpeechInputListener* listener)
+{
+    return 0;
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(INPUT_SPEECH)
+
diff --git a/Source/WebKit/chromium/src/WebSpeechInputControllerMockImpl.h b/Source/WebKit/chromium/src/WebSpeechInputControllerMockImpl.h
new file mode 100644 (file)
index 0000000..05bfd52
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2010 Google 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:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * 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.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "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 THE COPYRIGHT
+ * OWNER 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 WebSpeechInputControllerMockImpl_h
+#define WebSpeechInputControllerMockImpl_h
+
+#include "SpeechInputListener.h"
+#include "WebSpeechInputControllerMock.h"
+#include "WebSpeechInputListener.h"
+#include "platform/WebString.h"
+#include <wtf/OwnPtr.h>
+
+#if ENABLE(INPUT_SPEECH)
+
+namespace WebCore {
+class SpeechInputClientMock;
+}
+
+namespace WebKit {
+
+struct WebRect;
+
+class WebSpeechInputControllerMockImpl : public WebCore::SpeechInputListener
+                                       , public WebSpeechInputControllerMock {
+public:
+    WebSpeechInputControllerMockImpl(WebSpeechInputListener*);
+    virtual ~WebSpeechInputControllerMockImpl();
+
+    // WebCore::SpeechInputListener methods.
+    void didCompleteRecording(int requestId);
+    void didCompleteRecognition(int requestId);
+    void setRecognitionResult(int requestId, const WebCore::SpeechInputResultArray& result);
+
+    // WebSpeechInputController methods.
+    bool startRecognition(int requestId, const WebRect& elementRect, const WebString& language, const WebString& grammar, const WebSecurityOrigin&);
+    void cancelRecognition(int requestId);
+    void stopRecording(int requestId);
+
+    // WebSpeechInputControllerMock methods.
+    void addMockRecognitionResult(const WebString& result, double confidence, const WebString& language);
+    void clearResults();
+
+private:
+    OwnPtr<WebCore::SpeechInputClientMock> m_webcoreMock;
+    WebSpeechInputListener* m_listener;
+};
+
+} // namespace WebKit
+
+#endif // ENABLE(INPUT_SPEECH)
+
+#endif // WebSpeechInputControllerMockImpl_h
index 693538f..9b13144 100644 (file)
@@ -48,11 +48,6 @@ void WebSpeechInputResult::set(const WebString& utterance, double confidence)
     m_private = WebCore::SpeechInputResult::create(utterance, confidence);
 }
 
-void WebSpeechInputResult::assign(const WebSpeechInputResult& other)
-{
-    m_private = WebCore::SpeechInputResult::create(*other.m_private.get());
-}
-
 WebSpeechInputResult::operator PassRefPtr<WebCore::SpeechInputResult>() const
 {
     return m_private.get();
index 2f8415c..f3c9308 100644 (file)
@@ -1,3 +1,29 @@
+2012-01-30  Hans Wennborg  <hans@chromium.org>
+
+        Unreviewed, rolling out r106219.
+        http://trac.webkit.org/changeset/106219
+        https://bugs.webkit.org/show_bug.cgi?id=77083
+
+        This broke Chromium's test_shell.
+
+        * DumpRenderTree/DumpRenderTree.gypi:
+        * DumpRenderTree/chromium/LayoutTestController.cpp:
+        (LayoutTestController::addMockSpeechInputResult):
+        * DumpRenderTree/chromium/LayoutTestController.h:
+        (WebKit):
+        (LayoutTestController):
+        ():
+        * DumpRenderTree/chromium/MockWebSpeechInputController.cpp: Removed.
+        * DumpRenderTree/chromium/MockWebSpeechInputController.h: Removed.
+        * DumpRenderTree/chromium/TestShell.cpp:
+        * DumpRenderTree/chromium/WebViewHost.cpp:
+        (WebViewHost::speechInputController):
+        * DumpRenderTree/chromium/WebViewHost.h:
+        (WebKit):
+        (WebViewHost::speechInputControllerMock):
+        (WebViewHost):
+        ():
+
 2012-01-26  Hans Wennborg  <hans@chromium.org>
 
         Speech Input: move MockSpeechInputClient into Chromium DumpRenderTree implementation
index 0736c03..b707464 100644 (file)
@@ -22,8 +22,6 @@
             'chromium/LayoutTestController.h',
             'chromium/MockSpellCheck.cpp',
             'chromium/MockSpellCheck.h',
-            'chromium/MockWebSpeechInputController.cpp',
-            'chromium/MockWebSpeechInputController.h',
             'chromium/NotificationPresenter.h',
             'chromium/NotificationPresenter.cpp',
             'chromium/PlainTextController.cpp',
index 37480b0..de394a9 100644 (file)
@@ -33,7 +33,6 @@
 #include "LayoutTestController.h"
 
 #include "DRTDevToolsAgent.h"
-#include "MockWebSpeechInputController.h"
 #include "TestShell.h"
 #include "WebAnimationController.h"
 #include "WebBindings.h"
@@ -56,6 +55,7 @@
 #include "WebSecurityPolicy.h"
 #include "WebSettings.h"
 #include "platform/WebSize.h"
+#include "WebSpeechInputControllerMock.h"
 #include "platform/WebURL.h"
 #include "WebView.h"
 #include "WebViewHost.h"
@@ -1934,7 +1934,7 @@ void LayoutTestController::addMockSpeechInputResult(const CppArgumentList& argum
     if (arguments.size() < 3 || !arguments[0].isString() || !arguments[1].isNumber() || !arguments[2].isString())
         return;
 
-    if (MockWebSpeechInputController* controller = m_shell->webViewHost()->speechInputControllerMock())
+    if (WebSpeechInputControllerMock* controller = m_shell->webViewHost()->speechInputControllerMock())
         controller->addMockRecognitionResult(cppVariantToWebString(arguments[0]), arguments[1].toDouble(), cppVariantToWebString(arguments[2]));
 }
 
index e37ff7d..2c7df80 100644 (file)
@@ -52,6 +52,9 @@
 
 namespace WebKit {
 class WebGeolocationClientMock;
+class WebSpeechInputController;
+class WebSpeechInputControllerMock;
+class WebSpeechInputListener;
 }
 
 namespace webkit_support {
@@ -439,6 +442,7 @@ public:
     // The following methods are not exposed to JavaScript.
     void setWorkQueueFrozen(bool frozen) { m_workQueue.setFrozen(frozen); }
 
+    WebKit::WebSpeechInputController* speechInputController(WebKit::WebSpeechInputListener*);
     bool shouldDumpAsAudio() const { return m_dumpAsAudio; } 
     void setShouldDumpAsAudio(bool dumpAsAudio) { m_dumpAsAudio = dumpAsAudio; } 
     bool shouldDumpAsText() { return m_dumpAsText; }
@@ -695,6 +699,8 @@ private:
 
     WebKit::WebURL m_userStyleSheetLocation;
 
+    OwnPtr<WebKit::WebSpeechInputControllerMock> m_speechInputControllerMock;
+
     // WAV audio data is stored here.
     WebKit::WebArrayBufferView m_audioData;
 
diff --git a/Tools/DumpRenderTree/chromium/MockWebSpeechInputController.cpp b/Tools/DumpRenderTree/chromium/MockWebSpeechInputController.cpp
deleted file mode 100644 (file)
index cb0b066..0000000
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * Copyright (C) 2012 Google 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 AND ITS CONTRIBUTORS "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 OR ITS 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 "MockWebSpeechInputController.h"
-
-#include "WebSpeechInputListener.h"
-#include "platform/WebCString.h"
-#include <wtf/text/CString.h>
-
-using namespace WebKit;
-
-PassOwnPtr<MockWebSpeechInputController> MockWebSpeechInputController::create(WebSpeechInputListener* listener)
-{
-    return adoptPtr(new MockWebSpeechInputController(listener));
-}
-
-void MockWebSpeechInputController::addMockRecognitionResult(const WebString& result, double confidence, const WebString& language)
-{
-    WebSpeechInputResult res;
-    res.set(result, confidence);
-
-    if (language.isEmpty())
-        m_resultsForEmptyLanguage.append(res);
-    else {
-        String langString = String::fromUTF8(language.utf8().data());
-        if (!m_recognitionResults.contains(langString))
-            m_recognitionResults.set(langString, Vector<WebSpeechInputResult>());
-        m_recognitionResults.find(langString)->second.append(res);
-    }
-}
-
-void MockWebSpeechInputController::clearResults()
-{
-    m_resultsForEmptyLanguage.clear();
-    m_recognitionResults.clear();
-}
-
-bool MockWebSpeechInputController::startRecognition(int requestId, const WebRect& elementRect, const WebString& language, const WebString& grammar, const WebSecurityOrigin& origin)
-{
-    if (m_speechTask)
-        return false;
-
-    m_requestId = requestId;
-    m_recording = true;
-    m_language = String::fromUTF8(language.utf8().data());
-
-    m_speechTask = new SpeechTask(this);
-    postTask(m_speechTask);
-
-    return true;
-}
-
-void MockWebSpeechInputController::cancelRecognition(int requestId)
-{
-    if (m_speechTask) {
-        ASSERT(requestId == m_requestId);
-
-        m_speechTask->stop();
-        m_recording = false;
-        m_listener->didCompleteRecognition(m_requestId);
-        m_requestId = 0;
-    }
-}
-
-void MockWebSpeechInputController::stopRecording(int requestId)
-{
-    ASSERT(requestId == m_requestId);
-    if (m_speechTask && m_recording) {
-        m_speechTask->stop();
-        speechTaskFired();
-    }
-}
-
-MockWebSpeechInputController::MockWebSpeechInputController(WebSpeechInputListener* listener)
-    : m_listener(listener)
-    , m_speechTask(0)
-    , m_recording(false)
-    , m_requestId(-1)
-{
-}
-
-void MockWebSpeechInputController::speechTaskFired()
-{
-    if (m_recording) {
-        m_recording = false;
-        m_listener->didCompleteRecording(m_requestId);
-
-        m_speechTask = new SpeechTask(this);
-        postTask(m_speechTask);
-    } else {
-        bool noResultsFound = false;
-        // We take a copy of the requestId here so that if scripts destroyed the input element
-        // inside one of the callbacks below, we'll still know what this session's requestId was.
-        int requestId = m_requestId;
-        m_requestId = 0;
-
-        // Empty language case must be handled separately to avoid problems with HashMap and empty keys.
-        if (m_language.isEmpty()) {
-            if (!m_resultsForEmptyLanguage.isEmpty())
-                m_listener->setRecognitionResult(requestId, m_resultsForEmptyLanguage);
-            else
-                noResultsFound = true;
-        } else {
-            if (m_recognitionResults.contains(m_language))
-                m_listener->setRecognitionResult(requestId, m_recognitionResults.get(m_language));
-            else
-                noResultsFound = true;
-        }
-
-        if (noResultsFound) {
-            // Can't avoid setting a result even if no result was set for the given language.
-            // This would avoid generating the events used to check the results and the test would timeout.
-            String error("error: no result found for language '");
-            error.append(m_language);
-            error.append("'");
-
-            WebSpeechInputResult res;
-            res.set(WebString::fromUTF8(error.utf8().data()), 1.0);
-
-            Vector<WebSpeechInputResult> results;
-            results.append(res);
-
-            m_listener->setRecognitionResult(requestId, results);
-        }
-    }
-}
-
-MockWebSpeechInputController::SpeechTask::SpeechTask(MockWebSpeechInputController* mock)
-    : MethodTask<MockWebSpeechInputController>::MethodTask(mock)
-{
-}
-
-void MockWebSpeechInputController::SpeechTask::stop()
-{
-    m_object->m_speechTask = 0;
-    cancel();
-    delete(this);
-}
-
-void MockWebSpeechInputController::SpeechTask::runIfValid()
-{
-    m_object->m_speechTask = 0;
-    m_object->speechTaskFired();
-}
diff --git a/Tools/DumpRenderTree/chromium/MockWebSpeechInputController.h b/Tools/DumpRenderTree/chromium/MockWebSpeechInputController.h
deleted file mode 100644 (file)
index 96aadff..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright (C) 2012 Google 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 AND ITS CONTRIBUTORS "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 OR ITS 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 MockWebSpeechInputController_h
-#define MockWebSpeechInputController_h
-
-#if ENABLE(INPUT_SPEECH)
-
-#include "Task.h"
-#include "WebSpeechInputController.h"
-#include "WebSpeechInputResult.h"
-#include <wtf/Compiler.h>
-#include <wtf/HashMap.h>
-#include <wtf/PassOwnPtr.h>
-#include <wtf/Vector.h>
-#include <wtf/text/AtomicString.h>
-#include <wtf/text/StringHash.h>
-
-namespace WebKit {
-struct WebRect;
-class WebSecurityOrigin;
-class WebSpeechInputListener;
-class WebString;
-}
-
-class MockWebSpeechInputController : public WebKit::WebSpeechInputController {
-public:
-    static PassOwnPtr<MockWebSpeechInputController> create(WebKit::WebSpeechInputListener*);
-
-    void addMockRecognitionResult(const WebKit::WebString& result, double confidence, const WebKit::WebString& language);
-    void clearResults();
-
-    // WebSpeechInputController implementation:
-    virtual bool startRecognition(int requestId, const WebKit::WebRect& elementRect, const WebKit::WebString& language, const WebKit::WebString& grammar, const WebKit::WebSecurityOrigin&) OVERRIDE;
-    virtual void cancelRecognition(int requestId) OVERRIDE;
-    virtual void stopRecording(int requestId) OVERRIDE;
-
-    TaskList* taskList() { return &m_taskList; }
-
-private:
-    MockWebSpeechInputController(WebKit::WebSpeechInputListener*);
-    void speechTaskFired();
-
-    class SpeechTask : public MethodTask<MockWebSpeechInputController> {
-    public:
-        SpeechTask(MockWebSpeechInputController*);
-        void stop();
-
-    private:
-        virtual void runIfValid() OVERRIDE;
-    };
-
-    WebKit::WebSpeechInputListener* m_listener;
-
-    TaskList m_taskList;
-    SpeechTask* m_speechTask;
-
-    bool m_recording;
-    int m_requestId;
-    String m_language;
-
-    HashMap<String, Vector<WebKit::WebSpeechInputResult> > m_recognitionResults;
-    Vector<WebKit::WebSpeechInputResult> m_resultsForEmptyLanguage;
-};
-
-#endif // ENABLE(INPUT_SPEECH)
-
-#endif // MockWebSpeechInputController_h
index 501e78b..45cbc1e 100644 (file)
@@ -52,6 +52,7 @@
 #include "WebScriptController.h"
 #include "WebSettings.h"
 #include "platform/WebSize.h"
+#include "WebSpeechInputControllerMock.h"
 #include "platform/WebString.h"
 #include "platform/WebURLRequest.h"
 #include "platform/WebURLResponse.h"
index 2e68030..f8ee472 100644 (file)
@@ -32,7 +32,6 @@
 #include "WebViewHost.h"
 
 #include "LayoutTestController.h"
-#include "MockWebSpeechInputController.h"
 #include "TestNavigationController.h"
 #include "TestShell.h"
 #include "TestWebPlugin.h"
@@ -56,6 +55,7 @@
 #include "platform/WebRect.h"
 #include "WebScreenInfo.h"
 #include "platform/WebSize.h"
+#include "WebSpeechInputControllerMock.h"
 #include "WebStorageNamespace.h"
 #include "WebTextCheckingCompletion.h"
 #include "WebTextCheckingResult.h"
@@ -678,7 +678,7 @@ WebKit::WebGeolocationClientMock* WebViewHost::geolocationClientMock()
 WebSpeechInputController* WebViewHost::speechInputController(WebKit::WebSpeechInputListener* listener)
 {
     if (!m_speechInputControllerMock)
-        m_speechInputControllerMock = MockWebSpeechInputController::create(listener);
+        m_speechInputControllerMock = adoptPtr(WebSpeechInputControllerMock::create(listener));
     return m_speechInputControllerMock.get();
 }
 
index eb21369..1d0954a 100644 (file)
@@ -45,7 +45,6 @@
 #include <wtf/text/WTFString.h>
 
 class LayoutTestController;
-class MockWebSpeechInputController;
 class SkCanvas;
 class TestShell;
 
@@ -58,6 +57,7 @@ class WebGeolocationClientMock;
 class WebGeolocationServiceMock;
 class WebSharedWorkerClient;
 class WebSpeechInputController;
+class WebSpeechInputControllerMock;
 class WebSpeechInputListener;
 class WebURL;
 class WebUserMediaClientMock;
@@ -108,7 +108,7 @@ class WebViewHost : public WebKit::WebSpellCheckClient, public WebKit::WebViewCl
     WebKit::WebContextMenuData* lastContextMenuData() const;
     void clearContextMenuData();
 
-    MockWebSpeechInputController* speechInputControllerMock() { return m_speechInputControllerMock.get(); }
+    WebKit::WebSpeechInputControllerMock* speechInputControllerMock() { return m_speechInputControllerMock.get(); }
 
 #if ENABLE(POINTER_LOCK)
     void didLosePointerLock();
@@ -382,7 +382,7 @@ private:
     OwnPtr<WebKit::WebGeolocationClientMock> m_geolocationClientMock;
 
     OwnPtr<WebKit::WebDeviceOrientationClientMock> m_deviceOrientationClientMock;
-    OwnPtr<MockWebSpeechInputController> m_speechInputControllerMock;
+    OwnPtr<WebKit::WebSpeechInputControllerMock> m_speechInputControllerMock;
 
     OwnPtr<WebKit::WebUserMediaClientMock> m_userMediaClientMock;
     OwnPtr<webkit_support::TestMediaStreamClient> m_testMediaStreamClient;