Changeset 83138 in webkit


Ignore:
Timestamp:
Apr 6, 2011 8:55:19 PM (13 years ago)
Author:
crogers@google.com
Message:

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):
Location:
trunk/Tools
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r83137 r83138  
     12011-04-06  Chris Rogers  <crogers@google.com>
     2
     3        Reviewed by Tony Chang.
     4
     5        Add web audio support to DumpRenderTree (mac port)
     6        https://bugs.webkit.org/show_bug.cgi?id=57969
     7
     8        * DumpRenderTree/LayoutTestController.cpp:
     9        (LayoutTestController::LayoutTestController):
     10        (setEncodedAudioDataCallback):
     11        (LayoutTestController::staticFunctions):
     12        * DumpRenderTree/LayoutTestController.h:
     13        (LayoutTestController::dumpAsAudio):
     14        (LayoutTestController::setDumpAsAudio):
     15        (LayoutTestController::encodedAudioData):
     16        (LayoutTestController::setEncodedAudioData):
     17        * DumpRenderTree/mac/DumpRenderTree.mm:
     18        (dumpAudio):
     19        (dump):
     20
    1212011-04-06  Benjamin Poulain  <benjamin.poulain@nokia.com>
    222
  • trunk/Tools/DumpRenderTree/LayoutTestController.cpp

    r82536 r83138  
    4545LayoutTestController::LayoutTestController(const std::string& testPathOrURL, const std::string& expectedPixelHash)
    4646    : m_dumpApplicationCacheDelegateCallbacks(false)
     47    , m_dumpAsAudio(false)
    4748    , m_dumpAsPDF(false)
    4849    , m_dumpAsText(false)
     
    313314    LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
    314315    controller->setCloseRemainingWindowsWhenComplete(JSValueToBoolean(context, arguments[0]));
     316    return JSValueMakeUndefined(context);
     317}
     318
     319static JSValueRef setEncodedAudioDataCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
     320{
     321    if (argumentCount < 1)
     322        return JSValueMakeUndefined(context);
     323
     324    JSRetainPtr<JSStringRef> encodedAudioData(Adopt, JSValueToStringCopy(context, arguments[0], exception));
     325    ASSERT(!*exception);
     326   
     327    size_t maxLength = JSStringGetMaximumUTF8CStringSize(encodedAudioData.get());
     328    OwnArrayPtr<char> encodedAudioDataBuffer = adoptArrayPtr(new char[maxLength + 1]);
     329    JSStringGetUTF8CString(encodedAudioData.get(), encodedAudioDataBuffer.get(), maxLength + 1);
     330
     331    LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
     332    controller->setEncodedAudioData(encodedAudioDataBuffer.get());
     333    controller->setDumpAsAudio(true);
     334   
    315335    return JSValueMakeUndefined(context);
    316336}
     
    22222242        { "setAppCacheMaximumSize", setAppCacheMaximumSizeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
    22232243        { "setApplicationCacheOriginQuota", setApplicationCacheOriginQuotaCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
     2244        { "setEncodedAudioData", setEncodedAudioDataCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
    22242245        { "setAuthenticationPassword", setAuthenticationPasswordCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
    22252246        { "setAuthenticationUsername", setAuthenticationUsernameCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
  • trunk/Tools/DumpRenderTree/LayoutTestController.h

    r82536 r83138  
    135135    bool elementDoesAutoCompleteForElementWithId(JSStringRef id);
    136136
     137    bool dumpAsAudio() const { return m_dumpAsAudio; }
     138    void setDumpAsAudio(bool dumpAsAudio) { m_dumpAsAudio = dumpAsAudio; }
     139   
    137140    bool dumpAsPDF() const { return m_dumpAsPDF; }
    138141    void setDumpAsPDF(bool dumpAsPDF) { m_dumpAsPDF = dumpAsPDF; }
     
    264267    const std::string& testPathOrURL() const { return m_testPathOrURL; }
    265268    const std::string& expectedPixelHash() const { return m_expectedPixelHash; }
     269
     270    const std::string& encodedAudioData() const { return m_encodedAudioData; }
     271    void setEncodedAudioData(const std::string& encodedAudioData) { m_encodedAudioData = encodedAudioData; }
    266272   
    267273    bool pauseAnimationAtTimeOnElementWithId(JSStringRef animationName, double time, JSStringRef elementId);
     
    335341
    336342    bool m_dumpApplicationCacheDelegateCallbacks;
     343    bool m_dumpAsAudio;
    337344    bool m_dumpAsPDF;
    338345    bool m_dumpAsText;
     
    384391    std::set<std::string> m_willSendRequestClearHeaders;
    385392   
     393    // base64 encoded WAV audio data is stored here.
     394    std::string m_encodedAudioData;
     395   
    386396    // origins which have been granted desktop notification access
    387397    std::vector<JSStringRef> m_desktopNotificationAllowedOrigins;
  • trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm

    r82784 r83138  
    735735}
    736736
     737static NSData *dumpAudio()
     738{
     739    const char *encodedAudioData = gLayoutTestController->encodedAudioData().c_str();
     740   
     741    NSData *data = [NSData dataWithBytes:encodedAudioData length:gLayoutTestController->encodedAudioData().length()];
     742    return data;
     743}
     744
    737745static void dumpHistoryItem(WebHistoryItem *item, int indent, BOOL current)
    738746{
     
    938946            gLayoutTestController->setGeneratePixelResults(false);
    939947        }
    940         if (gLayoutTestController->dumpAsText()) {
     948        if (gLayoutTestController->dumpAsAudio()) {
     949            resultData = dumpAudio();
     950            resultMimeType = @"audio/wav";
     951        } else if (gLayoutTestController->dumpAsText()) {
    941952            resultString = dumpFramesAsText(mainFrame);
    942953        } else if (gLayoutTestController->dumpAsPDF()) {
     
    961972        printf("Content-Type: %s\n", [resultMimeType UTF8String]);
    962973
     974        if (gLayoutTestController->dumpAsAudio())
     975            printf("Content-Transfer-Encoding: base64\n");           
     976       
    963977        if (resultData) {
    964978            fwrite([resultData bytes], 1, [resultData length], stdout);
Note: See TracChangeset for help on using the changeset viewer.