2011-06-13 Chris Rogers <crogers@google.com>
authorcrogers@google.com <crogers@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 13 Jun 2011 22:50:53 +0000 (22:50 +0000)
committercrogers@google.com <crogers@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 13 Jun 2011 22:50:53 +0000 (22:50 +0000)
        Reviewed by Dirk Pranke.

        Add Web Audio support to chromium DRT
        https://bugs.webkit.org/show_bug.cgi?id=62306

        * DumpRenderTree/chromium/LayoutTestController.cpp:
        (LayoutTestController::LayoutTestController):
        (LayoutTestController::reset):
        (LayoutTestController::setEncodedAudioData):
        * DumpRenderTree/chromium/LayoutTestController.h:
        (LayoutTestController::encodedAudioData):
        (LayoutTestController::shouldDumpAsAudio):
        (LayoutTestController::setShouldDumpAsAudio):
        * DumpRenderTree/chromium/TestEventPrinter.cpp:
        (DRTPrinter::handleAudioHeader):
        (TestShellPrinter::handleAudioHeader):
        * DumpRenderTree/chromium/TestEventPrinter.h:
        * DumpRenderTree/chromium/TestShell.cpp:
        (TestShell::TestShell):
        (TestShell::dump):

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

Tools/ChangeLog
Tools/DumpRenderTree/chromium/LayoutTestController.cpp
Tools/DumpRenderTree/chromium/LayoutTestController.h
Tools/DumpRenderTree/chromium/TestEventPrinter.cpp
Tools/DumpRenderTree/chromium/TestEventPrinter.h
Tools/DumpRenderTree/chromium/TestShell.cpp

index 60ee5ff..e9afea5 100644 (file)
@@ -1,3 +1,26 @@
+2011-06-13  Chris Rogers  <crogers@google.com>
+
+        Reviewed by Dirk Pranke.
+
+        Add Web Audio support to chromium DRT
+        https://bugs.webkit.org/show_bug.cgi?id=62306
+
+        * DumpRenderTree/chromium/LayoutTestController.cpp:
+        (LayoutTestController::LayoutTestController):
+        (LayoutTestController::reset):
+        (LayoutTestController::setEncodedAudioData):
+        * DumpRenderTree/chromium/LayoutTestController.h:
+        (LayoutTestController::encodedAudioData):
+        (LayoutTestController::shouldDumpAsAudio):
+        (LayoutTestController::setShouldDumpAsAudio):
+        * DumpRenderTree/chromium/TestEventPrinter.cpp:
+        (DRTPrinter::handleAudioHeader):
+        (TestShellPrinter::handleAudioHeader):
+        * DumpRenderTree/chromium/TestEventPrinter.h:
+        * DumpRenderTree/chromium/TestShell.cpp:
+        (TestShell::TestShell):
+        (TestShell::dump):
+
 2011-06-13  Jaehun Lim  <ljaehun.lim@samsung.com>
 
         Reviewed by Eric Seidel.
index d58d704..bd221b9 100644 (file)
@@ -156,6 +156,7 @@ LayoutTestController::LayoutTestController(TestShell* shell)
     bindMethod("setDeferMainResourceDataLoad", &LayoutTestController::setDeferMainResourceDataLoad);
     bindMethod("setDomainRelaxationForbiddenForURLScheme", &LayoutTestController::setDomainRelaxationForbiddenForURLScheme);
     bindMethod("setEditingBehavior", &LayoutTestController::setEditingBehavior);
+    bindMethod("setEncodedAudioData", &LayoutTestController::setEncodedAudioData);
     bindMethod("setGeolocationPermission", &LayoutTestController::setGeolocationPermission);
     bindMethod("setIconDatabaseEnabled", &LayoutTestController::setIconDatabaseEnabled);
     bindMethod("setJavaScriptCanAccessClipboard", &LayoutTestController::setJavaScriptCanAccessClipboard);
@@ -573,6 +574,7 @@ void LayoutTestController::reset()
         m_shell->webView()->removeAllUserContent();
     }
     m_dumpAsText = false;
+    m_dumpAsAudio = false;
     m_dumpEditingCallbacks = false;
     m_dumpFrameLoadCallbacks = false;
     m_dumpUserGestureInFrameLoadCallbacks = false;
@@ -1922,3 +1924,13 @@ void LayoutTestController::setTextDirection(const CppArgumentList& arguments, Cp
 
     m_shell->webView()->setTextDirection(direction);
 }
+
+void LayoutTestController::setEncodedAudioData(const CppArgumentList& arguments, CppVariant* result)
+{
+    result->setNull();
+    if (arguments.size() < 1 || !arguments[0].isString())
+        return;
+
+    m_encodedAudioData = arguments[0].toString();
+    setShouldDumpAsAudio(true);
+}
index 72f6051..135b026 100644 (file)
@@ -249,6 +249,10 @@ public:
     void setDeferMainResourceDataLoad(const CppArgumentList&, CppVariant*);
     void setEditingBehavior(const CppArgumentList&, CppVariant*);
 
+    // Deals with Web Audio base64 encoded WAVE file data.
+    void setEncodedAudioData(const CppArgumentList&, CppVariant*);
+    const std::string& encodedAudioData() const { return m_encodedAudioData; } 
+
     // The following are only stubs.
     // FIXME: Implement any of these that are needed to pass the layout tests.
     void dumpAsWebArchive(const CppArgumentList&, CppVariant*);
@@ -398,6 +402,8 @@ public:
     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; }
     void setShouldDumpAsText(bool value) { m_dumpAsText = value; }
     bool shouldDumpEditingCallbacks() { return m_dumpEditingCallbacks; }
@@ -518,6 +524,9 @@ private:
     // text representation of the renderer.
     bool m_dumpAsText;
 
+    // If true, the test_shell will output a base64 encoded WAVE file.
+    bool m_dumpAsAudio;
+
     // If true, the test_shell will write a descriptive line for each editing
     // command.
     bool m_dumpEditingCallbacks;
@@ -617,6 +626,9 @@ private:
     WebKit::WebURL m_userStyleSheetLocation;
 
     OwnPtr<WebKit::WebSpeechInputControllerMock> m_speechInputControllerMock;
+
+    // base64 encoded WAV audio data is stored here.
+    std::string m_encodedAudioData;
 };
 
 #endif // LayoutTestController_h
index ae0dc82..bb78259 100644 (file)
@@ -42,6 +42,7 @@ public:
     void handleTimedOut() const;
     void handleTextHeader() const;
     void handleTextFooter() const;
+    void handleAudioHeader() const;
     void handleImage(const char* actualHash, const char* expectedHash, const unsigned char* imageData, size_t imageSize, const char* fileName) const;
     void handleImageFooter() const;
     void handleTestFooter(bool dumpedAnything) const;
@@ -54,6 +55,7 @@ public:
     void handleTimedOut() const;
     void handleTextHeader() const;
     void handleTextFooter() const;
+    void handleAudioHeader() const;
     void handleImage(const char* actualHash, const char* expectedHash, const unsigned char* imageData, size_t imageSize, const char* fileName) const;
     void handleImageFooter() const;
     void handleTestFooter(bool dumpedAnything) const;
@@ -95,6 +97,12 @@ void DRTPrinter::handleTextFooter() const
     printf("#EOF\n");
 }
 
+void DRTPrinter::handleAudioHeader() const
+{
+    printf("Content-Type: audio/wav\n");
+    printf("Content-Transfer-Encoding: base64\n");            
+}
+
 void DRTPrinter::handleImage(const char* actualHash, const char* expectedHash, const unsigned char* imageData, size_t imageSize, const char*) const
 {
     ASSERT(actualHash);
@@ -141,6 +149,12 @@ void TestShellPrinter::handleTextFooter() const
 {
 }
 
+void TestShellPrinter::handleAudioHeader() const
+{
+    printf("Content-Type: audio/wav\n");
+    printf("Content-Transfer-Encoding: base64\n");
+}
+
 void TestShellPrinter::handleImage(const char* actualHash, const char*, const unsigned char* imageData, size_t imageSize, const char* fileName) const
 {
     ASSERT(actualHash);
index 9cd18a8..f69523c 100644 (file)
@@ -43,6 +43,7 @@ public:
     virtual void handleTimedOut() const = 0;
     virtual void handleTextHeader() const = 0;
     virtual void handleTextFooter() const = 0;
+    virtual void handleAudioHeader() const = 0;
     virtual void handleImage(const char* actualHash, const char* expectedHash, const unsigned char* imageData, size_t imageSize, const char* fileName) const = 0;
     virtual void handleImageFooter() const = 0;
     virtual void handleTestFooter(bool dumpedAnything) const = 0;
index dc64053..583540b 100644 (file)
@@ -115,6 +115,8 @@ TestShell::TestShell(bool testShellMode)
     WebRuntimeFeatures::enableIndexedDatabase(true);
     WebRuntimeFeatures::enableFileSystem(true);
     WebRuntimeFeatures::enableJavaScriptI18NAPI(true);
+    WebRuntimeFeatures::enableWebAudio(true);
+
     m_webPermissions = adoptPtr(new WebPermissions());
     m_accessibilityController = adoptPtr(new AccessibilityController(this));
     m_layoutTestController = adoptPtr(new LayoutTestController(this));
@@ -461,8 +463,24 @@ void TestShell::dump()
     if (!frame)
         return;
     bool shouldDumpAsText = m_layoutTestController->shouldDumpAsText();
+    bool shouldDumpAsAudio = m_layoutTestController->shouldDumpAsAudio();
     bool shouldGeneratePixelResults = m_layoutTestController->shouldGeneratePixelResults();
     bool dumpedAnything = false;
+
+    if (shouldDumpAsAudio) {
+        m_printer->handleAudioHeader();
+
+        const string& encodedAudioData = m_layoutTestController->encodedAudioData();
+        if (fwrite(encodedAudioData.c_str(), 1, encodedAudioData.size(), stdout) != encodedAudioData.size())
+            FATAL("Short write to stdout, disk full?\n");
+        printf("\n");
+
+        m_printer->handleTestFooter(true);
+        fflush(stdout);
+        fflush(stderr);
+        return;
+    }
+
     if (m_params.dumpTree) {
         dumpedAnything = true;
         m_printer->handleTextHeader();