summaryrefslogtreecommitdiff
path: root/Tools/DumpRenderTree/chromium
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@nokia.com>2012-02-03 09:55:33 +0100
committerSimon Hausmann <simon.hausmann@nokia.com>2012-02-03 09:55:33 +0100
commitcd44dc59cdfc39534aef4d417e9f3c412e3be139 (patch)
tree8d89889ba95ed6ec9322e733846cc9cce9d7dff1 /Tools/DumpRenderTree/chromium
parentd11f84f5b5cdc0d92a08af01b13472fdd5f9acb9 (diff)
downloadqtwebkit-cd44dc59cdfc39534aef4d417e9f3c412e3be139.tar.gz
Imported WebKit commit fce473cb4d55aa9fe9d0b0322a2fffecb731b961 (http://svn.webkit.org/repository/webkit/trunk@106560)
Diffstat (limited to 'Tools/DumpRenderTree/chromium')
-rw-r--r--Tools/DumpRenderTree/chromium/AccessibilityUIElement.cpp45
-rw-r--r--Tools/DumpRenderTree/chromium/AccessibilityUIElement.h3
-rw-r--r--Tools/DumpRenderTree/chromium/LayoutTestController.cpp49
-rw-r--r--Tools/DumpRenderTree/chromium/LayoutTestController.h15
-rw-r--r--Tools/DumpRenderTree/chromium/LayoutTestHelper.mm64
-rw-r--r--Tools/DumpRenderTree/chromium/MockWebSpeechInputController.cpp198
-rw-r--r--Tools/DumpRenderTree/chromium/MockWebSpeechInputController.h93
-rw-r--r--Tools/DumpRenderTree/chromium/TestShell.cpp2
-rw-r--r--Tools/DumpRenderTree/chromium/TestWebPlugin.cpp14
-rw-r--r--Tools/DumpRenderTree/chromium/TestWebPlugin.h4
-rw-r--r--Tools/DumpRenderTree/chromium/TestWebWorker.h93
-rw-r--r--Tools/DumpRenderTree/chromium/WebUserMediaClientMock.cpp83
-rw-r--r--Tools/DumpRenderTree/chromium/WebUserMediaClientMock.h60
-rw-r--r--Tools/DumpRenderTree/chromium/WebViewHost.cpp118
-rw-r--r--Tools/DumpRenderTree/chromium/WebViewHost.h50
15 files changed, 735 insertions, 156 deletions
diff --git a/Tools/DumpRenderTree/chromium/AccessibilityUIElement.cpp b/Tools/DumpRenderTree/chromium/AccessibilityUIElement.cpp
index 3ca1ee72a..583806585 100644
--- a/Tools/DumpRenderTree/chromium/AccessibilityUIElement.cpp
+++ b/Tools/DumpRenderTree/chromium/AccessibilityUIElement.cpp
@@ -33,6 +33,7 @@
#include "WebAccessibilityObject.h"
#include "platform/WebCString.h"
+#include "platform/WebPoint.h"
#include "platform/WebRect.h"
#include "platform/WebString.h"
#include <wtf/Assertions.h>
@@ -355,6 +356,9 @@ AccessibilityUIElement::AccessibilityUIElement(const WebAccessibilityObject& obj
bindMethod("addNotificationListener", &AccessibilityUIElement::addNotificationListenerCallback);
bindMethod("removeNotificationListener", &AccessibilityUIElement::removeNotificationListenerCallback);
bindMethod("takeFocus", &AccessibilityUIElement::takeFocusCallback);
+ bindMethod("scrollToMakeVisible", &AccessibilityUIElement::scrollToMakeVisibleCallback);
+ bindMethod("scrollToMakeVisibleWithSubFocus", &AccessibilityUIElement::scrollToMakeVisibleWithSubFocusCallback);
+ bindMethod("scrollToGlobalPoint", &AccessibilityUIElement::scrollToGlobalPointCallback);
bindFallbackMethod(&AccessibilityUIElement::fallbackCallback);
}
@@ -763,6 +767,47 @@ void AccessibilityUIElement::takeFocusCallback(const CppArgumentList&, CppVarian
result->setNull();
}
+void AccessibilityUIElement::scrollToMakeVisibleCallback(const CppArgumentList&, CppVariant* result)
+{
+ accessibilityObject().scrollToMakeVisible();
+ result->setNull();
+}
+
+void AccessibilityUIElement::scrollToMakeVisibleWithSubFocusCallback(const CppArgumentList& arguments, CppVariant* result)
+{
+ result->setNull();
+
+ if (arguments.size() != 4
+ || !arguments[0].isNumber()
+ || !arguments[1].isNumber()
+ || !arguments[2].isNumber()
+ || !arguments[3].isNumber())
+ return;
+
+ int x = arguments[0].toInt32();
+ int y = arguments[1].toInt32();
+ int width = arguments[2].toInt32();
+ int height = arguments[3].toInt32();
+ accessibilityObject().scrollToMakeVisibleWithSubFocus(WebRect(x, y, width, height));
+ result->setNull();
+}
+
+void AccessibilityUIElement::scrollToGlobalPointCallback(const CppArgumentList& arguments, CppVariant* result)
+{
+ result->setNull();
+
+ if (arguments.size() != 2
+ || !arguments[0].isNumber()
+ || !arguments[1].isNumber())
+ return;
+
+ int x = arguments[0].toInt32();
+ int y = arguments[1].toInt32();
+
+ accessibilityObject().scrollToGlobalPoint(WebPoint(x, y));
+ result->setNull();
+}
+
void AccessibilityUIElement::fallbackCallback(const CppArgumentList &, CppVariant* result)
{
// FIXME: Implement this.
diff --git a/Tools/DumpRenderTree/chromium/AccessibilityUIElement.h b/Tools/DumpRenderTree/chromium/AccessibilityUIElement.h
index b5fce86f0..8ae6d412f 100644
--- a/Tools/DumpRenderTree/chromium/AccessibilityUIElement.h
+++ b/Tools/DumpRenderTree/chromium/AccessibilityUIElement.h
@@ -126,6 +126,9 @@ private:
void addNotificationListenerCallback(const CppArgumentList&, CppVariant*);
void removeNotificationListenerCallback(const CppArgumentList&, CppVariant*);
void takeFocusCallback(const CppArgumentList&, CppVariant*);
+ void scrollToMakeVisibleCallback(const CppArgumentList&, CppVariant*);
+ void scrollToMakeVisibleWithSubFocusCallback(const CppArgumentList&, CppVariant*);
+ void scrollToGlobalPointCallback(const CppArgumentList&, CppVariant*);
void fallbackCallback(const CppArgumentList&, CppVariant*);
diff --git a/Tools/DumpRenderTree/chromium/LayoutTestController.cpp b/Tools/DumpRenderTree/chromium/LayoutTestController.cpp
index f68e0d872..b0347c853 100644
--- a/Tools/DumpRenderTree/chromium/LayoutTestController.cpp
+++ b/Tools/DumpRenderTree/chromium/LayoutTestController.cpp
@@ -33,9 +33,11 @@
#include "LayoutTestController.h"
#include "DRTDevToolsAgent.h"
+#include "MockWebSpeechInputController.h"
#include "TestShell.h"
#include "WebAnimationController.h"
#include "WebBindings.h"
+#include "WebWorkerInfo.h"
#include "WebConsoleMessage.h"
#include "platform/WebData.h"
#include "WebDeviceOrientation.h"
@@ -54,7 +56,6 @@
#include "WebSecurityPolicy.h"
#include "WebSettings.h"
#include "platform/WebSize.h"
-#include "WebSpeechInputControllerMock.h"
#include "platform/WebURL.h"
#include "WebView.h"
#include "WebViewHost.h"
@@ -90,12 +91,16 @@ LayoutTestController::LayoutTestController(TestShell* shell)
// by CppBoundClass, the parent to LayoutTestController).
bindMethod("addFileToPasteboardOnDrag", &LayoutTestController::addFileToPasteboardOnDrag);
bindMethod("addMockSpeechInputResult", &LayoutTestController::addMockSpeechInputResult);
+ bindMethod("setMockSpeechInputDumpRect", &LayoutTestController::setMockSpeechInputDumpRect);
bindMethod("addOriginAccessWhitelistEntry", &LayoutTestController::addOriginAccessWhitelistEntry);
bindMethod("addUserScript", &LayoutTestController::addUserScript);
bindMethod("addUserStyleSheet", &LayoutTestController::addUserStyleSheet);
bindMethod("clearAllDatabases", &LayoutTestController::clearAllDatabases);
bindMethod("closeWebInspector", &LayoutTestController::closeWebInspector);
bindMethod("counterValueForElementById", &LayoutTestController::counterValueForElementById);
+#if ENABLE(POINTER_LOCK)
+ bindMethod("didLosePointerLock", &LayoutTestController::didLosePointerLock);
+#endif
bindMethod("disableImageLoading", &LayoutTestController::disableImageLoading);
bindMethod("display", &LayoutTestController::display);
bindMethod("displayInvalidatedRegion", &LayoutTestController::displayInvalidatedRegion);
@@ -181,6 +186,10 @@ LayoutTestController::LayoutTestController(TestShell* shell)
bindMethod("setMockGeolocationPosition", &LayoutTestController::setMockGeolocationPosition);
bindMethod("setPageVisibility", &LayoutTestController::setPageVisibility);
bindMethod("setPluginsEnabled", &LayoutTestController::setPluginsEnabled);
+#if ENABLE(POINTER_LOCK)
+ bindMethod("setPointerLockWillFailAsynchronously", &LayoutTestController::setPointerLockWillFailAsynchronously);
+ bindMethod("setPointerLockWillFailSynchronously", &LayoutTestController::setPointerLockWillFailSynchronously);
+#endif
bindMethod("setPopupBlockingEnabled", &LayoutTestController::setPopupBlockingEnabled);
bindMethod("setPOSIXLocale", &LayoutTestController::setPOSIXLocale);
bindMethod("setPrinting", &LayoutTestController::setPrinting);
@@ -252,6 +261,7 @@ LayoutTestController::LayoutTestController(TestShell* shell)
bindProperty("titleTextDirection", &m_titleTextDirection);
bindProperty("platformName", &m_platformName);
bindProperty("interceptPostMessage", &m_interceptPostMessage);
+ bindProperty("workerThreadCount", &LayoutTestController::workerThreadCount);
}
LayoutTestController::~LayoutTestController()
@@ -1925,10 +1935,20 @@ void LayoutTestController::addMockSpeechInputResult(const CppArgumentList& argum
if (arguments.size() < 3 || !arguments[0].isString() || !arguments[1].isNumber() || !arguments[2].isString())
return;
- if (WebSpeechInputControllerMock* controller = m_shell->webViewHost()->speechInputControllerMock())
+ if (MockWebSpeechInputController* controller = m_shell->webViewHost()->speechInputControllerMock())
controller->addMockRecognitionResult(cppVariantToWebString(arguments[0]), arguments[1].toDouble(), cppVariantToWebString(arguments[2]));
}
+void LayoutTestController::setMockSpeechInputDumpRect(const CppArgumentList& arguments, CppVariant* result)
+{
+ result->setNull();
+ if (arguments.size() < 1 || !arguments[0].isBool())
+ return;
+
+ if (MockWebSpeechInputController* controller = m_shell->webViewHost()->speechInputControllerMock())
+ controller->setDumpRect(arguments[0].value.boolValue);
+}
+
void LayoutTestController::startSpeechInput(const CppArgumentList& arguments, CppVariant* result)
{
result->setNull();
@@ -2107,6 +2127,11 @@ void LayoutTestController::setFixedLayoutSize(const CppArgumentList& arguments,
m_shell->webView()->setFixedLayoutSize(WebSize(width, height));
}
+void LayoutTestController::workerThreadCount(CppVariant* result)
+{
+ result->set(static_cast<int>(WebWorkerInfo::dedicatedWorkerCount()));
+}
+
void LayoutTestController::setPluginsEnabled(const CppArgumentList& arguments, CppVariant* result)
{
if (arguments.size() > 0 && arguments[0].isBool()) {
@@ -2171,3 +2196,23 @@ void LayoutTestController::setAudioData(const CppArgumentList& arguments, CppVar
setShouldDumpAsAudio(true);
}
+
+#if ENABLE(POINTER_LOCK)
+void LayoutTestController::didLosePointerLock(const CppArgumentList&, CppVariant* result)
+{
+ m_shell->webViewHost()->didLosePointerLock();
+ result->setNull();
+}
+
+void LayoutTestController::setPointerLockWillFailAsynchronously(const CppArgumentList&, CppVariant* result)
+{
+ m_shell->webViewHost()->setPointerLockWillFailAsynchronously();
+ result->setNull();
+}
+
+void LayoutTestController::setPointerLockWillFailSynchronously(const CppArgumentList&, CppVariant* result)
+{
+ m_shell->webViewHost()->setPointerLockWillFailSynchronously();
+ result->setNull();
+}
+#endif
diff --git a/Tools/DumpRenderTree/chromium/LayoutTestController.h b/Tools/DumpRenderTree/chromium/LayoutTestController.h
index 603b3b92e..a686e8605 100644
--- a/Tools/DumpRenderTree/chromium/LayoutTestController.h
+++ b/Tools/DumpRenderTree/chromium/LayoutTestController.h
@@ -52,9 +52,6 @@
namespace WebKit {
class WebGeolocationClientMock;
-class WebSpeechInputController;
-class WebSpeechInputControllerMock;
-class WebSpeechInputListener;
}
namespace webkit_support {
@@ -380,6 +377,7 @@ public:
// Speech input related functions.
void addMockSpeechInputResult(const CppArgumentList&, CppVariant*);
+ void setMockSpeechInputDumpRect(const CppArgumentList&, CppVariant*);
void startSpeechInput(const CppArgumentList&, CppVariant*);
void layerTreeAsText(const CppArgumentList& args, CppVariant* result);
@@ -430,11 +428,18 @@ public:
void enableFixedLayoutMode(const CppArgumentList&, CppVariant*);
void setFixedLayoutSize(const CppArgumentList&, CppVariant*);
+#if ENABLE(POINTER_LOCK)
+ void didLosePointerLock(const CppArgumentList&, CppVariant*);
+ void setPointerLockWillFailSynchronously(const CppArgumentList&, CppVariant*);
+ void setPointerLockWillFailAsynchronously(const CppArgumentList&, CppVariant*);
+#endif
+
+ void workerThreadCount(CppVariant*);
+
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; }
@@ -691,8 +696,6 @@ 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/LayoutTestHelper.mm b/Tools/DumpRenderTree/chromium/LayoutTestHelper.mm
index e34cf5fca..978f74c06 100644
--- a/Tools/DumpRenderTree/chromium/LayoutTestHelper.mm
+++ b/Tools/DumpRenderTree/chromium/LayoutTestHelper.mm
@@ -38,49 +38,56 @@
// test script, so it can do the job for multiple DumpRenderTree while they are
// running layout tests.
-static CMProfileRef userColorProfile = 0;
+namespace {
-static void saveCurrentColorProfile()
-{
- CGDirectDisplayID displayID = CGMainDisplayID();
- CMProfileRef previousProfile;
- CMError error = CMGetProfileByAVID((UInt32)displayID, &previousProfile);
- if (error) {
- NSLog(@"failed to get the current color profile, pixmaps won't match. "
- @"Error: %d", (int)error);
- } else {
- userColorProfile = previousProfile;
- }
-}
+const char colorProfilePath[] = "/System/Library/ColorSync/Profiles/Generic RGB Profile.icc";
+
+CMProfileLocation initialColorProfileLocation; // The locType field is initialized to 0 which is the same as cmNoProfileBase.
+
+} // namespace
static void installLayoutTestColorProfile()
{
// To make sure we get consistent colors (not dependent on the Main display),
// we force the generic rgb color profile. This cases a change the user can
// see.
+ const CMDeviceScope scope = { kCFPreferencesCurrentUser, kCFPreferencesCurrentHost };
- CGDirectDisplayID displayID = CGMainDisplayID();
- NSColorSpace* genericSpace = [NSColorSpace genericRGBColorSpace];
- CMProfileRef genericProfile = (CMProfileRef)[genericSpace colorSyncProfile];
- CMError error = CMSetProfileByAVID((UInt32)displayID, genericProfile);
+ CMProfileRef profile = 0;
+ int error = CMGetProfileByAVID((CMDisplayIDType)kCGDirectMainDisplay, &profile);
+ if (!error) {
+ UInt32 size = sizeof(initialColorProfileLocation);
+ error = NCMGetProfileLocation(profile, &initialColorProfileLocation, &size);
+ CMCloseProfile(profile);
+ }
if (error) {
- NSLog(@"failed install the generic color profile, pixmaps won't match. "
- @"Error: %d", (int)error);
+ NSLog(@"failed to get the current color profile, pixmaps won't match. Error: %d", (int)error);
+ initialColorProfileLocation.locType = cmNoProfileBase;
+ return;
+ }
+
+ CMProfileLocation location;
+ location.locType = cmPathBasedProfile;
+ strncpy(location.u.pathLoc.path, colorProfilePath, sizeof(location.u.pathLoc.path));
+ error = CMSetDeviceProfile(cmDisplayDeviceClass, (CMDeviceID)kCGDirectMainDisplay, &scope, cmDefaultProfileID, &location);
+ if (error) {
+ NSLog(@"failed install the generic color profile, pixmaps won't match. Error: %d", (int)error);
+ initialColorProfileLocation.locType = cmNoProfileBase;
}
}
static void restoreUserColorProfile(void)
{
- if (!userColorProfile)
- return;
- CGDirectDisplayID displayID = CGMainDisplayID();
- CMError error = CMSetProfileByAVID((UInt32)displayID, userColorProfile);
- CMCloseProfile(userColorProfile);
- if (error) {
- NSLog(@"Failed to restore color profile, use System Preferences -> "
- @"Displays -> Color to reset. Error: %d", (int)error);
+ // This is used as a signal handler, and thus the calls into ColorSync are unsafe.
+ // But we might as well try to restore the user's color profile, we're going down anyway...
+ if (initialColorProfileLocation.locType != cmNoProfileBase) {
+ const CMDeviceScope scope = { kCFPreferencesCurrentUser, kCFPreferencesCurrentHost };
+ int error = CMSetDeviceProfile(cmDisplayDeviceClass, (CMDeviceID)kCGDirectMainDisplay, &scope, cmDefaultProfileID, &initialColorProfileLocation);
+ if (error) {
+ NSLog(@"Failed to restore color profile, use System Preferences -> Displays -> Color to reset. Error: %d", (int)error);
+ }
+ initialColorProfileLocation.locType = cmNoProfileBase;
}
- userColorProfile = 0;
}
static void simpleSignalHandler(int sig)
@@ -100,7 +107,6 @@ int main(int argc, char* argv[])
signal(SIGTERM, simpleSignalHandler);
// Save off the current profile, and then install the layout test profile.
- saveCurrentColorProfile();
installLayoutTestColorProfile();
// Let the script know we're ready
diff --git a/Tools/DumpRenderTree/chromium/MockWebSpeechInputController.cpp b/Tools/DumpRenderTree/chromium/MockWebSpeechInputController.cpp
new file mode 100644
index 000000000..0bea45b35
--- /dev/null
+++ b/Tools/DumpRenderTree/chromium/MockWebSpeechInputController.cpp
@@ -0,0 +1,198 @@
+/*
+ * 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 "platform/WebVector.h"
+#include <wtf/text/CString.h>
+#include <wtf/text/StringBuilder.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.assign(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::setDumpRect(bool dumpRect)
+{
+ m_dumpRect = dumpRect;
+}
+
+void MockWebSpeechInputController::clearResults()
+{
+ m_resultsForEmptyLanguage.clear();
+ m_recognitionResults.clear();
+ m_dumpRect = false;
+}
+
+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_requestRect = elementRect;
+ 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)
+ , m_dumpRect(false)
+{
+}
+
+static WebSpeechInputResultArray makeRectResult(const WebRect& rect)
+{
+ StringBuilder sb;
+ sb.append(String::number(rect.x));
+ sb.append(",");
+ sb.append(String::number(rect.y));
+ sb.append(",");
+ sb.append(String::number(rect.width));
+ sb.append(",");
+ sb.append(String::number(rect.height));
+
+ WebSpeechInputResult res;
+ res.set(WebString(sb.characters(), sb.length()), 1.0);
+
+ WebSpeechInputResultArray results;
+ results.assign(&res, 1);
+ return results;
+}
+
+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;
+
+ if (m_dumpRect) {
+ m_listener->setRecognitionResult(requestId, makeRectResult(m_requestRect));
+ } else if (m_language.isEmpty()) {
+ // Empty language case must be handled separately to avoid problems with HashMap and empty keys.
+ 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.assign(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
new file mode 100644
index 000000000..8d7519603
--- /dev/null
+++ b/Tools/DumpRenderTree/chromium/MockWebSpeechInputController.h
@@ -0,0 +1,93 @@
+/*
+ * 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 "platform/WebRect.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 {
+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 setDumpRect(bool);
+ 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;
+ WebKit::WebRect m_requestRect;
+ String m_language;
+
+ HashMap<String, Vector<WebKit::WebSpeechInputResult> > m_recognitionResults;
+ Vector<WebKit::WebSpeechInputResult> m_resultsForEmptyLanguage;
+ bool m_dumpRect;
+};
+
+#endif // ENABLE(INPUT_SPEECH)
+
+#endif // MockWebSpeechInputController_h
diff --git a/Tools/DumpRenderTree/chromium/TestShell.cpp b/Tools/DumpRenderTree/chromium/TestShell.cpp
index 15a93890f..501e78b7a 100644
--- a/Tools/DumpRenderTree/chromium/TestShell.cpp
+++ b/Tools/DumpRenderTree/chromium/TestShell.cpp
@@ -52,7 +52,6 @@
#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"
@@ -127,6 +126,7 @@ TestShell::TestShell(bool testShellMode)
WebRuntimeFeatures::enableWebAudio(true);
WebRuntimeFeatures::enableVideoTrack(true);
WebRuntimeFeatures::enableGamepad(true);
+ WebRuntimeFeatures::enableShadowDOM(true);
m_webPermissions = adoptPtr(new WebPermissions(this));
m_accessibilityController = adoptPtr(new AccessibilityController(this));
diff --git a/Tools/DumpRenderTree/chromium/TestWebPlugin.cpp b/Tools/DumpRenderTree/chromium/TestWebPlugin.cpp
index ac2336664..da12fa706 100644
--- a/Tools/DumpRenderTree/chromium/TestWebPlugin.cpp
+++ b/Tools/DumpRenderTree/chromium/TestWebPlugin.cpp
@@ -32,6 +32,7 @@
#include "platform/WebKitPlatformSupport.h"
#include "WebPluginContainer.h"
#include "WebPluginParams.h"
+#include "WebViewClient.h"
#include <wtf/Assertions.h>
#include <wtf/text/CString.h>
@@ -61,9 +62,11 @@ static void premultiplyAlpha(const unsigned colorIn[3], float alpha, float color
colorOut[3] = alpha;
}
-TestWebPlugin::TestWebPlugin(WebKit::WebFrame* frame,
+TestWebPlugin::TestWebPlugin(WebKit::WebViewClient* webViewClient,
+ WebKit::WebFrame* frame,
const WebKit::WebPluginParams& params)
- : m_frame(frame)
+ : m_webViewClient(webViewClient)
+ , m_frame(frame)
, m_container(0)
, m_context(0)
{
@@ -101,12 +104,9 @@ const WebString& TestWebPlugin::mimeType()
bool TestWebPlugin::initialize(WebPluginContainer* container)
{
- m_context = webKitPlatformSupport()->createGraphicsContext3D();
- if (!m_context)
- return false;
-
WebGraphicsContext3D::Attributes attrs;
- if (!m_context->initialize(attrs, m_frame->view(), false))
+ m_context = m_webViewClient->createGraphicsContext3D(attrs, false);
+ if (!m_context)
return false;
if (!m_context->makeContextCurrent())
diff --git a/Tools/DumpRenderTree/chromium/TestWebPlugin.h b/Tools/DumpRenderTree/chromium/TestWebPlugin.h
index cef472884..926b3e833 100644
--- a/Tools/DumpRenderTree/chromium/TestWebPlugin.h
+++ b/Tools/DumpRenderTree/chromium/TestWebPlugin.h
@@ -31,6 +31,7 @@
namespace WebKit {
class WebGraphicsContext3D;
+class WebViewClient;
}
// A fake implemention of WebKit::WebPlugin for testing purposes.
@@ -44,7 +45,7 @@ class WebGraphicsContext3D;
// opacity: [0.0 - 1.0]. Default is 1.0.
class TestWebPlugin : public WebKit::WebPlugin {
public:
- TestWebPlugin(WebKit::WebFrame*, const WebKit::WebPluginParams&);
+ TestWebPlugin(WebKit::WebViewClient*, WebKit::WebFrame*, const WebKit::WebPluginParams&);
virtual ~TestWebPlugin();
static const WebKit::WebString& mimeType();
@@ -115,6 +116,7 @@ private:
unsigned loadProgram(const WTF::CString& vertexSource,
const WTF::CString& fragmentSource);
+ WebKit::WebViewClient* m_webViewClient;
WebKit::WebFrame* m_frame;
WebKit::WebPluginContainer* m_container;
diff --git a/Tools/DumpRenderTree/chromium/TestWebWorker.h b/Tools/DumpRenderTree/chromium/TestWebWorker.h
deleted file mode 100644
index ad82a87e9..000000000
--- a/Tools/DumpRenderTree/chromium/TestWebWorker.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * 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 TestWebWorker_h
-#define TestWebWorker_h
-
-#include "WebMessagePortChannel.h"
-#include "WebSharedWorkerClient.h"
-#include "WebWorker.h"
-#include <wtf/RefCounted.h>
-
-namespace WebKit {
-class WebNotificationPresenter;
-class WebString;
-class WebURL;
-}
-
-class TestWebWorker : public WebKit::WebWorker,
- public WebKit::WebSharedWorkerClient,
- public WTF::RefCounted<TestWebWorker> {
-public:
- TestWebWorker()
- {
- // This class expects refcounting semantics like those found in
- // Chromium's base::RefCounted, so it's OK to call ref() directly.
- relaxAdoptionRequirement();
- ref();
- // The initial counter value should be 2. One for a worker object,
- // another for a worker context object. We need to call ref() just once
- // because the default counter value of RefCounted is 1.
- }
-
- // WebWorker methods:
- virtual void startWorkerContext(const WebKit::WebURL&, const WebKit::WebString&, const WebKit::WebString&) { }
- virtual void terminateWorkerContext() { }
- virtual void postMessageToWorkerContext(const WebKit::WebString&, const WebKit::WebMessagePortChannelArray&) { }
- virtual void workerObjectDestroyed()
- {
- // Releases the reference held for worker object.
- deref();
- }
- virtual void clientDestroyed() { }
-
- // WebWorkerClient methods:
- virtual void postMessageToWorkerObject(const WebKit::WebString&, const WebKit::WebMessagePortChannelArray&) { }
- virtual void postExceptionToWorkerObject(const WebKit::WebString&, int, const WebKit::WebString&) { }
- virtual void postConsoleMessageToWorkerObject(int, int, int, int, const WebKit::WebString&, int, const WebKit::WebString&) { }
- virtual void confirmMessageFromWorkerObject(bool) { }
- virtual void reportPendingActivity(bool) { }
- virtual void workerContextClosed() { }
- virtual void workerContextDestroyed()
- {
- // Releases the reference held for worker context object.
- deref();
- }
- virtual WebKit::WebWorker* createWorker(WebKit::WebSharedWorkerClient*) { return 0; }
- virtual WebKit::WebNotificationPresenter* notificationPresenter() { return 0; }
- virtual WebKit::WebApplicationCacheHost* createApplicationCacheHost(WebKit::WebApplicationCacheHostClient*) { return 0; }
- virtual bool allowDatabase(WebKit::WebFrame*, const WebKit::WebString&, const WebKit::WebString&, unsigned long) { return true; }
-
-private:
- ~TestWebWorker() { }
- friend class WTF::RefCounted<TestWebWorker>;
-};
-
-#endif // TestWebWorker_h
diff --git a/Tools/DumpRenderTree/chromium/WebUserMediaClientMock.cpp b/Tools/DumpRenderTree/chromium/WebUserMediaClientMock.cpp
new file mode 100644
index 000000000..0f442a676
--- /dev/null
+++ b/Tools/DumpRenderTree/chromium/WebUserMediaClientMock.cpp
@@ -0,0 +1,83 @@
+/*
+ * 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:
+ *
+ * * 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 "WebUserMediaClientMock.h"
+
+#include "WebMediaStreamRegistry.h"
+#include "WebUserMediaRequest.h"
+#include "platform/WebMediaStreamDescriptor.h"
+#include "platform/WebMediaStreamSource.h"
+#include "platform/WebVector.h"
+#include <wtf/Assertions.h>
+
+namespace WebKit {
+
+PassOwnPtr<WebUserMediaClientMock> WebUserMediaClientMock::create()
+{
+ return adoptPtr(new WebUserMediaClientMock());
+}
+
+bool WebUserMediaClientMock::IsMockStream(const WebURL& url)
+{
+ WebMediaStreamDescriptor descriptor(WebMediaStreamRegistry::lookupMediaStreamDescriptor(url));
+ if (descriptor.isNull())
+ return false;
+
+ WebVector<WebMediaStreamSource> sourceVector;
+ descriptor.sources(sourceVector);
+ WebString trackId;
+ for (size_t i = 0; i < sourceVector.size(); ++i) {
+ if (sourceVector[i].type() == WebMediaStreamSource::TypeVideo) {
+ trackId = sourceVector[i].id();
+ break;
+ }
+ }
+ return trackId.equals("mediastreamtest");
+}
+
+void WebUserMediaClientMock::requestUserMedia(const WebUserMediaRequest& streamRequest, const WebVector<WebMediaStreamSource>& streamSourceVector)
+{
+ ASSERT(!streamRequest.isNull());
+
+ WebUserMediaRequest request = streamRequest;
+ const size_t size = 1;
+ WebVector<WebMediaStreamSource> sourceVector(size);
+ WebString trackId("mediastreamtest");
+ WebString trackName("VideoCapture");
+ sourceVector[0].initialize(trackId, WebMediaStreamSource::TypeVideo, trackName);
+ request.requestSucceeded(sourceVector);
+}
+
+void WebUserMediaClientMock::cancelUserMediaRequest(const WebUserMediaRequest&)
+{
+}
+
+} // namespace WebKit
diff --git a/Tools/DumpRenderTree/chromium/WebUserMediaClientMock.h b/Tools/DumpRenderTree/chromium/WebUserMediaClientMock.h
new file mode 100644
index 000000000..4d91839c6
--- /dev/null
+++ b/Tools/DumpRenderTree/chromium/WebUserMediaClientMock.h
@@ -0,0 +1,60 @@
+/*
+ * 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:
+ *
+ * * 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 WebUserMediaClientMock_h
+#define WebUserMediaClientMock_h
+
+#include "WebUserMediaClient.h"
+#include "platform/WebCommon.h"
+#include "platform/WebString.h"
+#include "platform/WebURL.h"
+#include "webkit/support/test_media_stream_client.h"
+#include <wtf/PassOwnPtr.h>
+
+namespace WebKit {
+
+class WebUserMediaClientMock : public WebUserMediaClient,
+ public webkit_support::MediaStreamUtil {
+public:
+ static PassOwnPtr<WebUserMediaClientMock> create();
+ ~WebUserMediaClientMock() { }
+
+ bool IsMockStream(const WebURL&);
+
+ virtual void requestUserMedia(const WebUserMediaRequest&, const WebVector<WebMediaStreamSource>&);
+ virtual void cancelUserMediaRequest(const WebUserMediaRequest&);
+
+private:
+ WebUserMediaClientMock() { }
+};
+
+} // namespace WebKit
+
+#endif // WebUserMediaClientMock_h
diff --git a/Tools/DumpRenderTree/chromium/WebViewHost.cpp b/Tools/DumpRenderTree/chromium/WebViewHost.cpp
index 5d378ba5b..32b20dbf0 100644
--- a/Tools/DumpRenderTree/chromium/WebViewHost.cpp
+++ b/Tools/DumpRenderTree/chromium/WebViewHost.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010, 2011 Google Inc. All rights reserved.
+ * Copyright (C) 2010, 2011, 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
@@ -32,10 +32,10 @@
#include "WebViewHost.h"
#include "LayoutTestController.h"
+#include "MockWebSpeechInputController.h"
#include "TestNavigationController.h"
#include "TestShell.h"
#include "TestWebPlugin.h"
-#include "TestWebWorker.h"
#include "platform/WebCString.h"
#include "WebConsoleMessage.h"
#include "WebContextMenuData.h"
@@ -56,16 +56,17 @@
#include "platform/WebRect.h"
#include "WebScreenInfo.h"
#include "platform/WebSize.h"
-#include "WebSpeechInputControllerMock.h"
#include "WebStorageNamespace.h"
#include "WebTextCheckingCompletion.h"
#include "WebTextCheckingResult.h"
+#include "WebUserMediaClientMock.h"
#include "platform/WebThread.h"
#include "platform/WebURLRequest.h"
#include "platform/WebURLResponse.h"
#include "WebView.h"
#include "WebWindowFeatures.h"
#include "skia/ext/platform_canvas.h"
+#include "webkit/support/test_media_stream_client.h"
#include "webkit/support/webkit_support.h"
#include <wtf/Assertions.h>
@@ -271,6 +272,13 @@ WebStorageNamespace* WebViewHost::createSessionStorageNamespace(unsigned quota)
return WebKit::WebStorageNamespace::createSessionStorageNamespace(quota);
}
+WebKit::WebGraphicsContext3D* WebViewHost::createGraphicsContext3D(const WebKit::WebGraphicsContext3D::Attributes& attributes, bool direct)
+{
+ if (!webView())
+ return 0;
+ return webkit_support::CreateGraphicsContext3D(attributes, webView(), direct);
+}
+
void WebViewHost::didAddMessageToConsole(const WebConsoleMessage& message, const WebString& sourceName, unsigned sourceLine)
{
// This matches win DumpRenderTree's UIDelegate.cpp.
@@ -285,7 +293,10 @@ void WebViewHost::didAddMessageToConsole(const WebConsoleMessage& message, const
+ urlSuitableForTestResult(newMessage.substr(fileProtocol));
}
}
- printf("CONSOLE MESSAGE: line %d: %s\n", sourceLine, newMessage.data());
+ printf("CONSOLE MESSAGE: ");
+ if (sourceLine)
+ printf("line %d: ", sourceLine);
+ printf("%s\n", newMessage.data());
}
void WebViewHost::didStartLoading()
@@ -674,7 +685,7 @@ WebKit::WebGeolocationClientMock* WebViewHost::geolocationClientMock()
WebSpeechInputController* WebViewHost::speechInputController(WebKit::WebSpeechInputListener* listener)
{
if (!m_speechInputControllerMock)
- m_speechInputControllerMock = adoptPtr(WebSpeechInputControllerMock::create(listener));
+ m_speechInputControllerMock = MockWebSpeechInputController::create(listener);
return m_speechInputControllerMock.get();
}
@@ -695,6 +706,18 @@ WebDeviceOrientationClient* WebViewHost::deviceOrientationClient()
return deviceOrientationClientMock();
}
+WebUserMediaClient* WebViewHost::userMediaClient()
+{
+ return userMediaClientMock();
+}
+
+WebUserMediaClientMock* WebViewHost::userMediaClientMock()
+{
+ if (!m_userMediaClientMock.get())
+ m_userMediaClientMock = WebUserMediaClientMock::create();
+ return m_userMediaClientMock.get();
+}
+
// WebWidgetClient -----------------------------------------------------------
void WebViewHost::didInvalidateRect(const WebRect& rect)
@@ -755,6 +778,57 @@ WebScreenInfo WebViewHost::screenInfo()
return info;
}
+#if ENABLE(POINTER_LOCK)
+bool WebViewHost::requestPointerLock()
+{
+ switch (m_pointerLockPlannedResult) {
+ case PointerLockWillSucceed:
+ postDelayedTask(new HostMethodTask(this, &WebViewHost::didAcquirePointerLock), 0);
+ return true;
+ case PointerLockWillFailAsync:
+ ASSERT(!m_pointerLocked);
+ postDelayedTask(new HostMethodTask(this, &WebViewHost::didNotAcquirePointerLock), 0);
+ return true;
+ case PointerLockWillFailSync:
+ ASSERT(!m_pointerLocked);
+ return false;
+ default:
+ ASSERT_NOT_REACHED();
+ return false;
+ }
+}
+
+void WebViewHost::requestPointerUnlock()
+{
+ postDelayedTask(new HostMethodTask(this, &WebViewHost::didLosePointerLock), 0);
+}
+
+bool WebViewHost::isPointerLocked()
+{
+ return m_pointerLocked;
+}
+
+void WebViewHost::didAcquirePointerLock()
+{
+ m_pointerLocked = true;
+ webWidget()->didAcquirePointerLock();
+}
+
+void WebViewHost::didNotAcquirePointerLock()
+{
+ ASSERT(!m_pointerLocked);
+ m_pointerLocked = false;
+ webWidget()->didNotAcquirePointerLock();
+}
+
+void WebViewHost::didLosePointerLock()
+{
+ ASSERT(m_pointerLocked);
+ m_pointerLocked = false;
+ webWidget()->didLosePointerLock();
+}
+#endif
+
void WebViewHost::show(WebNavigationPolicy)
{
m_hasWindow = true;
@@ -839,19 +913,14 @@ void WebViewHost::exitFullScreen()
WebPlugin* WebViewHost::createPlugin(WebFrame* frame, const WebPluginParams& params)
{
if (params.mimeType == TestWebPlugin::mimeType())
- return new TestWebPlugin(frame, params);
+ return new TestWebPlugin(this, frame, params);
return webkit_support::CreateWebPlugin(frame, params);
}
-WebWorker* WebViewHost::createWorker(WebFrame*, WebSharedWorkerClient*)
-{
- return new TestWebWorker();
-}
-
WebMediaPlayer* WebViewHost::createMediaPlayer(WebFrame* frame, WebMediaPlayerClient* client)
{
- return webkit_support::CreateMediaPlayer(frame, client);
+ return webkit_support::CreateMediaPlayer(frame, client, testMediaStreamClient());
}
WebApplicationCacheHost* WebViewHost::createApplicationCacheHost(WebFrame* frame, WebApplicationCacheHostClient* client)
@@ -1291,6 +1360,10 @@ void WebViewHost::reset()
m_requestReturnNull = false;
m_isPainting = false;
m_canvas.clear();
+#if ENABLE(POINTER_LOCK)
+ m_pointerLocked = false;
+ m_pointerLockPlannedResult = PointerLockWillSucceed;
+#endif
m_navigationController = adoptPtr(new TestNavigationController(this));
@@ -1560,6 +1633,18 @@ void WebViewHost::exitFullScreenNow()
webView()->didExitFullScreen();
}
+webkit_support::MediaStreamUtil* WebViewHost::mediaStreamUtil()
+{
+ return userMediaClientMock();
+}
+
+webkit_support::TestMediaStreamClient* WebViewHost::testMediaStreamClient()
+{
+ if (!m_testMediaStreamClient.get())
+ m_testMediaStreamClient = adoptPtr(new webkit_support::TestMediaStreamClient(mediaStreamUtil()));
+ return m_testMediaStreamClient.get();
+}
+
// Painting functions ---------------------------------------------------------
void WebViewHost::updatePaintRect(const WebRect& rect)
@@ -1692,3 +1777,12 @@ void WebViewHost::displayRepaintMask()
{
canvas()->drawARGB(167, 0, 0, 0);
}
+
+// Simulate a print by going into print mode and then exit straight away.
+void WebViewHost::printPage(WebKit::WebFrame* frame)
+{
+ WebSize pageSizeInPixels = webWidget()->size();
+
+ frame->printBegin(pageSizeInPixels);
+ frame->printEnd();
+}
diff --git a/Tools/DumpRenderTree/chromium/WebViewHost.h b/Tools/DumpRenderTree/chromium/WebViewHost.h
index 8323fd8c9..6f759728f 100644
--- a/Tools/DumpRenderTree/chromium/WebViewHost.h
+++ b/Tools/DumpRenderTree/chromium/WebViewHost.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010 Google Inc. All rights reserved.
+ * 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
@@ -45,6 +45,7 @@
#include <wtf/text/WTFString.h>
class LayoutTestController;
+class MockWebSpeechInputController;
class SkCanvas;
class TestShell;
@@ -57,14 +58,19 @@ class WebGeolocationClientMock;
class WebGeolocationServiceMock;
class WebSharedWorkerClient;
class WebSpeechInputController;
-class WebSpeechInputControllerMock;
class WebSpeechInputListener;
class WebURL;
+class WebUserMediaClientMock;
struct WebRect;
struct WebURLError;
struct WebWindowFeatures;
}
+namespace webkit_support {
+class MediaStreamUtil;
+class TestMediaStreamClient;
+}
+
class WebViewHost : public WebKit::WebSpellCheckClient, public WebKit::WebViewClient, public WebKit::WebFrameClient, public NavigationHost {
public:
WebViewHost(TestShell*);
@@ -102,7 +108,13 @@ class WebViewHost : public WebKit::WebSpellCheckClient, public WebKit::WebViewCl
WebKit::WebContextMenuData* lastContextMenuData() const;
void clearContextMenuData();
- WebKit::WebSpeechInputControllerMock* speechInputControllerMock() { return m_speechInputControllerMock.get(); }
+ MockWebSpeechInputController* speechInputControllerMock() { return m_speechInputControllerMock.get(); }
+
+#if ENABLE(POINTER_LOCK)
+ void didLosePointerLock();
+ void setPointerLockWillFailAsynchronously() { m_pointerLockPlannedResult = PointerLockWillFailAsync; }
+ void setPointerLockWillFailSynchronously() { m_pointerLockPlannedResult = PointerLockWillFailSync; }
+#endif
// NavigationHost
virtual bool navigate(const TestNavigationEntry&, bool reload);
@@ -117,6 +129,7 @@ class WebViewHost : public WebKit::WebSpellCheckClient, public WebKit::WebViewCl
virtual WebKit::WebWidget* createPopupMenu(WebKit::WebPopupType);
virtual WebKit::WebWidget* createPopupMenu(const WebKit::WebPopupMenuInfo&);
virtual WebKit::WebStorageNamespace* createSessionStorageNamespace(unsigned quota);
+ virtual WebKit::WebGraphicsContext3D* createGraphicsContext3D(const WebKit::WebGraphicsContext3D::Attributes&, bool direct);
virtual void didAddMessageToConsole(const WebKit::WebConsoleMessage&, const WebKit::WebString& sourceName, unsigned sourceLine);
virtual void didStartLoading();
virtual void didStopLoading();
@@ -150,6 +163,8 @@ class WebViewHost : public WebKit::WebSpellCheckClient, public WebKit::WebViewCl
virtual WebKit::WebGeolocationClient* geolocationClient();
virtual WebKit::WebSpeechInputController* speechInputController(WebKit::WebSpeechInputListener*);
virtual WebKit::WebDeviceOrientationClient* deviceOrientationClient();
+ virtual WebKit::WebUserMediaClient* userMediaClient();
+ virtual void printPage(WebKit::WebFrame*);
// WebKit::WebWidgetClient
virtual void didInvalidateRect(const WebKit::WebRect&);
@@ -172,10 +187,14 @@ class WebViewHost : public WebKit::WebSpellCheckClient, public WebKit::WebViewCl
virtual WebKit::WebRect rootWindowRect();
virtual WebKit::WebRect windowResizerRect();
virtual WebKit::WebScreenInfo screenInfo();
+#if ENABLE(POINTER_LOCK)
+ virtual bool requestPointerLock();
+ virtual void requestPointerUnlock();
+ virtual bool isPointerLocked();
+#endif
// WebKit::WebFrameClient
virtual WebKit::WebPlugin* createPlugin(WebKit::WebFrame*, const WebKit::WebPluginParams&);
- virtual WebKit::WebWorker* createWorker(WebKit::WebFrame*, WebKit::WebSharedWorkerClient*);
virtual WebKit::WebMediaPlayer* createMediaPlayer(WebKit::WebFrame*, WebKit::WebMediaPlayerClient*);
virtual WebKit::WebApplicationCacheHost* createApplicationCacheHost(WebKit::WebFrame*, WebKit::WebApplicationCacheHostClient*);
virtual void loadURLExternally(WebKit::WebFrame*, const WebKit::WebURLRequest&, WebKit::WebNavigationPolicy);
@@ -281,6 +300,15 @@ private:
void resetScrollRect();
void discardBackingStore();
+#if ENABLE(POINTER_LOCK)
+ void didAcquirePointerLock();
+ void didNotAcquirePointerLock();
+#endif
+
+ WebKit::WebUserMediaClientMock* userMediaClientMock();
+ webkit_support::MediaStreamUtil* mediaStreamUtil();
+ webkit_support::TestMediaStreamClient* testMediaStreamClient();
+
// Causes navigation actions just printout the intended navigation instead
// of taking you to the page. This is used for cases like mailto, where you
// don't actually want to open the mail program.
@@ -355,7 +383,10 @@ private:
OwnPtr<WebKit::WebGeolocationClientMock> m_geolocationClientMock;
OwnPtr<WebKit::WebDeviceOrientationClientMock> m_deviceOrientationClientMock;
- OwnPtr<WebKit::WebSpeechInputControllerMock> m_speechInputControllerMock;
+ OwnPtr<MockWebSpeechInputController> m_speechInputControllerMock;
+
+ OwnPtr<WebKit::WebUserMediaClientMock> m_userMediaClientMock;
+ OwnPtr<webkit_support::TestMediaStreamClient> m_testMediaStreamClient;
OwnPtr<TestNavigationController> m_navigationController;
@@ -364,6 +395,15 @@ private:
TaskList m_taskList;
Vector<WebKit::WebWidget*> m_popupmenus;
+
+#if ENABLE(POINTER_LOCK)
+ bool m_pointerLocked;
+ enum {
+ PointerLockWillSucceed,
+ PointerLockWillFailAsync,
+ PointerLockWillFailSync
+ } m_pointerLockPlannedResult;
+#endif
};
#endif // WebViewHost_h