Commit 15c9564c authored by crogers@google.com's avatar crogers@google.com

2011-04-06 Chris Rogers <crogers@google.com>

        Reviewed by Tony Chang.

        Add web audio support to DumpRenderTree (mac port)
        https://bugs.webkit.org/show_bug.cgi?id=57969

        * DumpRenderTree/LayoutTestController.cpp:
        (LayoutTestController::LayoutTestController):
        (setEncodedAudioDataCallback):
        (LayoutTestController::staticFunctions):
        * DumpRenderTree/LayoutTestController.h:
        (LayoutTestController::dumpAsAudio):
        (LayoutTestController::setDumpAsAudio):
        (LayoutTestController::encodedAudioData):
        (LayoutTestController::setEncodedAudioData):
        * DumpRenderTree/mac/DumpRenderTree.mm:
        (dumpAudio):
        (dump):

git-svn-id: svn://svn.chromium.org/blink/trunk@83138 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 0965409e
2011-04-06 Chris Rogers <crogers@google.com>
Reviewed by Tony Chang.
Add web audio support to DumpRenderTree (mac port)
https://bugs.webkit.org/show_bug.cgi?id=57969
* DumpRenderTree/LayoutTestController.cpp:
(LayoutTestController::LayoutTestController):
(setEncodedAudioDataCallback):
(LayoutTestController::staticFunctions):
* DumpRenderTree/LayoutTestController.h:
(LayoutTestController::dumpAsAudio):
(LayoutTestController::setDumpAsAudio):
(LayoutTestController::encodedAudioData):
(LayoutTestController::setEncodedAudioData):
* DumpRenderTree/mac/DumpRenderTree.mm:
(dumpAudio):
(dump):
2011-04-06 Benjamin Poulain <benjamin.poulain@nokia.com> 2011-04-06 Benjamin Poulain <benjamin.poulain@nokia.com>
Reviewed by Kenneth Rohde Christiansen. Reviewed by Kenneth Rohde Christiansen.
......
...@@ -44,6 +44,7 @@ ...@@ -44,6 +44,7 @@
LayoutTestController::LayoutTestController(const std::string& testPathOrURL, const std::string& expectedPixelHash) LayoutTestController::LayoutTestController(const std::string& testPathOrURL, const std::string& expectedPixelHash)
: m_dumpApplicationCacheDelegateCallbacks(false) : m_dumpApplicationCacheDelegateCallbacks(false)
, m_dumpAsAudio(false)
, m_dumpAsPDF(false) , m_dumpAsPDF(false)
, m_dumpAsText(false) , m_dumpAsText(false)
, m_dumpBackForwardList(false) , m_dumpBackForwardList(false)
...@@ -315,6 +316,25 @@ static JSValueRef setCloseRemainingWindowsWhenCompleteCallback(JSContextRef cont ...@@ -315,6 +316,25 @@ static JSValueRef setCloseRemainingWindowsWhenCompleteCallback(JSContextRef cont
return JSValueMakeUndefined(context); return JSValueMakeUndefined(context);
} }
static JSValueRef setEncodedAudioDataCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
{
if (argumentCount < 1)
return JSValueMakeUndefined(context);
JSRetainPtr<JSStringRef> encodedAudioData(Adopt, JSValueToStringCopy(context, arguments[0], exception));
ASSERT(!*exception);
size_t maxLength = JSStringGetMaximumUTF8CStringSize(encodedAudioData.get());
OwnArrayPtr<char> encodedAudioDataBuffer = adoptArrayPtr(new char[maxLength + 1]);
JSStringGetUTF8CString(encodedAudioData.get(), encodedAudioDataBuffer.get(), maxLength + 1);
LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
controller->setEncodedAudioData(encodedAudioDataBuffer.get());
controller->setDumpAsAudio(true);
return JSValueMakeUndefined(context);
}
static JSValueRef testOnscreenCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) static JSValueRef testOnscreenCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
{ {
LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
...@@ -2221,6 +2241,7 @@ JSStaticFunction* LayoutTestController::staticFunctions() ...@@ -2221,6 +2241,7 @@ JSStaticFunction* LayoutTestController::staticFunctions()
{ "setAlwaysAcceptCookies", setAlwaysAcceptCookiesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "setAlwaysAcceptCookies", setAlwaysAcceptCookiesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
{ "setAppCacheMaximumSize", setAppCacheMaximumSizeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "setAppCacheMaximumSize", setAppCacheMaximumSizeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
{ "setApplicationCacheOriginQuota", setApplicationCacheOriginQuotaCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "setApplicationCacheOriginQuota", setApplicationCacheOriginQuotaCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
{ "setEncodedAudioData", setEncodedAudioDataCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
{ "setAuthenticationPassword", setAuthenticationPasswordCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "setAuthenticationPassword", setAuthenticationPasswordCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
{ "setAuthenticationUsername", setAuthenticationUsernameCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "setAuthenticationUsername", setAuthenticationUsernameCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
{ "setAuthorAndUserStylesEnabled", setAuthorAndUserStylesEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, { "setAuthorAndUserStylesEnabled", setAuthorAndUserStylesEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
......
...@@ -134,6 +134,9 @@ public: ...@@ -134,6 +134,9 @@ public:
bool elementDoesAutoCompleteForElementWithId(JSStringRef id); bool elementDoesAutoCompleteForElementWithId(JSStringRef id);
bool dumpAsAudio() const { return m_dumpAsAudio; }
void setDumpAsAudio(bool dumpAsAudio) { m_dumpAsAudio = dumpAsAudio; }
bool dumpAsPDF() const { return m_dumpAsPDF; } bool dumpAsPDF() const { return m_dumpAsPDF; }
void setDumpAsPDF(bool dumpAsPDF) { m_dumpAsPDF = dumpAsPDF; } void setDumpAsPDF(bool dumpAsPDF) { m_dumpAsPDF = dumpAsPDF; }
...@@ -263,6 +266,9 @@ public: ...@@ -263,6 +266,9 @@ public:
const std::string& testPathOrURL() const { return m_testPathOrURL; } const std::string& testPathOrURL() const { return m_testPathOrURL; }
const std::string& expectedPixelHash() const { return m_expectedPixelHash; } const std::string& expectedPixelHash() const { return m_expectedPixelHash; }
const std::string& encodedAudioData() const { return m_encodedAudioData; }
void setEncodedAudioData(const std::string& encodedAudioData) { m_encodedAudioData = encodedAudioData; }
bool pauseAnimationAtTimeOnElementWithId(JSStringRef animationName, double time, JSStringRef elementId); bool pauseAnimationAtTimeOnElementWithId(JSStringRef animationName, double time, JSStringRef elementId);
bool pauseTransitionAtTimeOnElementWithId(JSStringRef propertyName, double time, JSStringRef elementId); bool pauseTransitionAtTimeOnElementWithId(JSStringRef propertyName, double time, JSStringRef elementId);
...@@ -334,6 +340,7 @@ private: ...@@ -334,6 +340,7 @@ private:
void setGeolocationPermissionCommon(bool allow); void setGeolocationPermissionCommon(bool allow);
bool m_dumpApplicationCacheDelegateCallbacks; bool m_dumpApplicationCacheDelegateCallbacks;
bool m_dumpAsAudio;
bool m_dumpAsPDF; bool m_dumpAsPDF;
bool m_dumpAsText; bool m_dumpAsText;
bool m_dumpBackForwardList; bool m_dumpBackForwardList;
...@@ -383,6 +390,9 @@ private: ...@@ -383,6 +390,9 @@ private:
std::set<std::string> m_willSendRequestClearHeaders; std::set<std::string> m_willSendRequestClearHeaders;
// base64 encoded WAV audio data is stored here.
std::string m_encodedAudioData;
// origins which have been granted desktop notification access // origins which have been granted desktop notification access
std::vector<JSStringRef> m_desktopNotificationAllowedOrigins; std::vector<JSStringRef> m_desktopNotificationAllowedOrigins;
......
...@@ -734,6 +734,14 @@ static NSInteger compareHistoryItems(id item1, id item2, void *context) ...@@ -734,6 +734,14 @@ static NSInteger compareHistoryItems(id item1, id item2, void *context)
return [[item1 target] caseInsensitiveCompare:[item2 target]]; return [[item1 target] caseInsensitiveCompare:[item2 target]];
} }
static NSData *dumpAudio()
{
const char *encodedAudioData = gLayoutTestController->encodedAudioData().c_str();
NSData *data = [NSData dataWithBytes:encodedAudioData length:gLayoutTestController->encodedAudioData().length()];
return data;
}
static void dumpHistoryItem(WebHistoryItem *item, int indent, BOOL current) static void dumpHistoryItem(WebHistoryItem *item, int indent, BOOL current)
{ {
int start = 0; int start = 0;
...@@ -937,7 +945,10 @@ void dump() ...@@ -937,7 +945,10 @@ void dump()
gLayoutTestController->setDumpAsText(true); gLayoutTestController->setDumpAsText(true);
gLayoutTestController->setGeneratePixelResults(false); gLayoutTestController->setGeneratePixelResults(false);
} }
if (gLayoutTestController->dumpAsText()) { if (gLayoutTestController->dumpAsAudio()) {
resultData = dumpAudio();
resultMimeType = @"audio/wav";
} else if (gLayoutTestController->dumpAsText()) {
resultString = dumpFramesAsText(mainFrame); resultString = dumpFramesAsText(mainFrame);
} else if (gLayoutTestController->dumpAsPDF()) { } else if (gLayoutTestController->dumpAsPDF()) {
resultData = dumpFrameAsPDF(mainFrame); resultData = dumpFrameAsPDF(mainFrame);
...@@ -960,6 +971,9 @@ void dump() ...@@ -960,6 +971,9 @@ void dump()
printf("Content-Type: %s\n", [resultMimeType UTF8String]); printf("Content-Type: %s\n", [resultMimeType UTF8String]);
if (gLayoutTestController->dumpAsAudio())
printf("Content-Transfer-Encoding: base64\n");
if (resultData) { if (resultData) {
fwrite([resultData bytes], 1, [resultData length], stdout); fwrite([resultData bytes], 1, [resultData length], stdout);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment