Title: [104764] trunk
Revision
104764
Author
[email protected]
Date
2012-01-11 16:26:57 -0800 (Wed, 11 Jan 2012)

Log Message

implement layout tests for <video> with media stream
https://bugs.webkit.org/show_bug.cgi?id=74882

Patch by Wei Jia <[email protected]> on 2012-01-11
Reviewed by Kent Tamura.

Tools:

* DumpRenderTree/DumpRenderTree.gypi:
* DumpRenderTree/chromium/WebUserMediaClientMock.cpp: Added.
(WebKit::WebUserMediaClientMock::create):
(WebKit::WebUserMediaClientMock::IsMockStream):
(WebKit::WebUserMediaClientMock::requestUserMedia):
(WebKit::WebUserMediaClientMock::cancelUserMediaRequest):
* DumpRenderTree/chromium/WebUserMediaClientMock.h: Added.
(WebKit::WebUserMediaClientMock::~WebUserMediaClientMock):
(WebKit::WebUserMediaClientMock::WebUserMediaClientMock):
* DumpRenderTree/chromium/WebViewHost.cpp:
(WebViewHost::userMediaClient):
(WebViewHost::userMediaClientMock):
(WebViewHost::createMediaPlayer):
(WebViewHost::mediaStreamUtil):
(WebViewHost::testMediaStreamClient):
* DumpRenderTree/chromium/WebViewHost.h:

LayoutTests:

* platform/chromium/media/video-capture-preview-expected.txt: Added.
* platform/chromium/media/video-capture-preview.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (104763 => 104764)


--- trunk/LayoutTests/ChangeLog	2012-01-12 00:24:39 UTC (rev 104763)
+++ trunk/LayoutTests/ChangeLog	2012-01-12 00:26:57 UTC (rev 104764)
@@ -1,3 +1,13 @@
+2012-01-11  Wei Jia  <[email protected]>
+
+        implement layout tests for <video> with media stream
+        https://bugs.webkit.org/show_bug.cgi?id=74882
+
+        Reviewed by Kent Tamura.
+
+        * platform/chromium/media/video-capture-preview-expected.txt: Added.
+        * platform/chromium/media/video-capture-preview.html: Added.
+
 2012-01-09  Geoffrey Garen  <[email protected]>
 
         REGRESSION: d3 Bullet Charts demo doesn't work (call with argument assignment is broken)

Added: trunk/LayoutTests/platform/chromium/media/video-capture-preview-expected.txt (0 => 104764)


--- trunk/LayoutTests/platform/chromium/media/video-capture-preview-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/chromium/media/video-capture-preview-expected.txt	2012-01-12 00:26:57 UTC (rev 104764)
@@ -0,0 +1,16 @@
+request access to local media
+got a stream
+start preview
+EVENT(loadstart)
+EVENT(loadeddata)
+EVENT(canplay)
+EVENT(canplaythrough)
+EVENT(play)
+restart preview
+EVENT(loadstart)
+EVENT(loadeddata)
+EVENT(canplay)
+EVENT(canplaythrough)
+EVENT(play)
+END OF TEST
+

Added: trunk/LayoutTests/platform/chromium/media/video-capture-preview.html (0 => 104764)


--- trunk/LayoutTests/platform/chromium/media/video-capture-preview.html	                        (rev 0)
+++ trunk/LayoutTests/platform/chromium/media/video-capture-preview.html	2012-01-12 00:26:57 UTC (rev 104764)
@@ -0,0 +1,66 @@
+<!DOCTYPE HTML">
+<html>
+<head>
+<script src=""
+<script src=""
+<script src=""
+
+<script type="text/_javascript_">
+
+var previewURL = "";
+var localStream = null;
+
+function startPreview()
+{
+    video.src = ""
+}
+
+function gotStream(stream)
+{
+    consoleWrite("got a stream");
+    previewURL = webkitURL.createObjectURL(stream);
+    startPreview();
+    consoleWrite("start preview");
+    localStream = stream;
+    var playTimeInMillisecond = 2500;
+    var replayIfTimeIsReached = function ()
+    {
+        startPreview();
+        consoleWrite("restart preview");
+        setTimeout(endTest, playTimeInMillisecond);
+    }
+
+    setTimeout(replayIfTimeIsReached, playTimeInMillisecond);
+}
+
+function gotStreamFailed(error)
+{
+    consoleWrite("Failed to get access to local media. Error code was " + error.code);
+}
+
+function playPreview()
+{
+    findMediaElement();
+    try {
+        consoleWrite("request access to local media");
+        navigator.webkitGetUserMedia("video", gotStream, gotStreamFailed);
+    } catch (e) {
+        consoleWrite("getUserMedia error " + "(" + e.name + " / " + e.message + ")");
+    }
+
+    waitForEvent("error");
+    waitForEvent("loadstart");
+    waitForEvent("loadeddata");
+    waitForEvent("canplay");
+    waitForEvent("canplaythrough");
+    waitForEvent("play");
+}
+
+</script>
+</head>
+
+<body _onload_="playPreview()">
+<video width="320" height="240" autoplay="autoplay"></video>
+</body> 
+</html> 
+

Modified: trunk/Tools/ChangeLog (104763 => 104764)


--- trunk/Tools/ChangeLog	2012-01-12 00:24:39 UTC (rev 104763)
+++ trunk/Tools/ChangeLog	2012-01-12 00:26:57 UTC (rev 104764)
@@ -1,3 +1,27 @@
+2012-01-11  Wei Jia  <[email protected]>
+
+        implement layout tests for <video> with media stream
+        https://bugs.webkit.org/show_bug.cgi?id=74882
+
+        Reviewed by Kent Tamura.
+
+        * DumpRenderTree/DumpRenderTree.gypi:
+        * DumpRenderTree/chromium/WebUserMediaClientMock.cpp: Added.
+        (WebKit::WebUserMediaClientMock::create):
+        (WebKit::WebUserMediaClientMock::IsMockStream):
+        (WebKit::WebUserMediaClientMock::requestUserMedia):
+        (WebKit::WebUserMediaClientMock::cancelUserMediaRequest):
+        * DumpRenderTree/chromium/WebUserMediaClientMock.h: Added.
+        (WebKit::WebUserMediaClientMock::~WebUserMediaClientMock):
+        (WebKit::WebUserMediaClientMock::WebUserMediaClientMock):
+        * DumpRenderTree/chromium/WebViewHost.cpp:
+        (WebViewHost::userMediaClient):
+        (WebViewHost::userMediaClientMock):
+        (WebViewHost::createMediaPlayer):
+        (WebViewHost::mediaStreamUtil):
+        (WebViewHost::testMediaStreamClient):
+        * DumpRenderTree/chromium/WebViewHost.h:
+
 2012-01-11  Dirk Pranke  <[email protected]>
 
         Unreviewed, build fix.

Modified: trunk/Tools/DumpRenderTree/DumpRenderTree.gypi (104763 => 104764)


--- trunk/Tools/DumpRenderTree/DumpRenderTree.gypi	2012-01-12 00:24:39 UTC (rev 104763)
+++ trunk/Tools/DumpRenderTree/DumpRenderTree.gypi	2012-01-12 00:26:57 UTC (rev 104764)
@@ -46,6 +46,8 @@
             'chromium/WebPermissions.h',
             'chromium/WebPreferences.cpp',
             'chromium/WebPreferences.h',
+            'chromium/WebUserMediaClientMock.cpp',
+            'chromium/WebUserMediaClientMock.h',
             'chromium/WebViewHost.cpp',
             'chromium/WebViewHost.h',
         ],

Added: trunk/Tools/DumpRenderTree/chromium/WebUserMediaClientMock.cpp (0 => 104764)


--- trunk/Tools/DumpRenderTree/chromium/WebUserMediaClientMock.cpp	                        (rev 0)
+++ trunk/Tools/DumpRenderTree/chromium/WebUserMediaClientMock.cpp	2012-01-12 00:26:57 UTC (rev 104764)
@@ -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

Added: trunk/Tools/DumpRenderTree/chromium/WebUserMediaClientMock.h (0 => 104764)


--- trunk/Tools/DumpRenderTree/chromium/WebUserMediaClientMock.h	                        (rev 0)
+++ trunk/Tools/DumpRenderTree/chromium/WebUserMediaClientMock.h	2012-01-12 00:26:57 UTC (rev 104764)
@@ -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

Modified: trunk/Tools/DumpRenderTree/chromium/WebViewHost.cpp (104763 => 104764)


--- trunk/Tools/DumpRenderTree/chromium/WebViewHost.cpp	2012-01-12 00:24:39 UTC (rev 104763)
+++ trunk/Tools/DumpRenderTree/chromium/WebViewHost.cpp	2012-01-12 00:26:57 UTC (rev 104764)
@@ -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
@@ -59,12 +59,14 @@
 #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>
@@ -694,6 +696,18 @@
     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)
@@ -845,7 +859,7 @@
 
 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)
@@ -1554,6 +1568,18 @@
     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)

Modified: trunk/Tools/DumpRenderTree/chromium/WebViewHost.h (104763 => 104764)


--- trunk/Tools/DumpRenderTree/chromium/WebViewHost.h	2012-01-12 00:24:39 UTC (rev 104763)
+++ trunk/Tools/DumpRenderTree/chromium/WebViewHost.h	2012-01-12 00:26:57 UTC (rev 104764)
@@ -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
@@ -60,11 +60,17 @@
 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*);
@@ -150,6 +156,7 @@
     virtual WebKit::WebGeolocationClient* geolocationClient();
     virtual WebKit::WebSpeechInputController* speechInputController(WebKit::WebSpeechInputListener*);
     virtual WebKit::WebDeviceOrientationClient* deviceOrientationClient();
+    virtual WebKit::WebUserMediaClient* userMediaClient();
 
     // WebKit::WebWidgetClient
     virtual void didInvalidateRect(const WebKit::WebRect&);
@@ -280,6 +287,10 @@
     void resetScrollRect();
     void discardBackingStore();
 
+    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.
@@ -356,6 +367,9 @@
     OwnPtr<WebKit::WebDeviceOrientationClientMock> m_deviceOrientationClientMock;
     OwnPtr<WebKit::WebSpeechInputControllerMock> m_speechInputControllerMock;
 
+    OwnPtr<WebKit::WebUserMediaClientMock> m_userMediaClientMock;
+    OwnPtr<webkit_support::TestMediaStreamClient> m_testMediaStreamClient;
+
     OwnPtr<TestNavigationController> m_navigationController;
 
     WebKit::WebString m_lastRequestedTextCheckString;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to