Title: [116315] trunk
Revision
116315
Author
[email protected]
Date
2012-05-07 10:21:55 -0700 (Mon, 07 May 2012)

Log Message

[chromium] MediaStream API: Enhance WebUserMediaClientMock and add a test for it
https://bugs.webkit.org/show_bug.cgi?id=85618

Reviewed by Adam Barth.

Adding the capability to control which MediaStreamTracks actually get created,
and adding a test that exercises the JS api using that capability.

Tools:

* DumpRenderTree/chromium/WebUserMediaClientMock.cpp:
(WebKit::WebUserMediaClientMock::requestUserMedia):
* DumpRenderTree/chromium/WebUserMediaClientMock.h:
* DumpRenderTree/chromium/WebViewHost.cpp:
(WebViewHost::testMediaStreamClient):
* DumpRenderTree/chromium/WebViewHost.h:
(WebViewHost):

LayoutTests:

* fast/mediastream/getusermedia-expected.txt: Added.
* fast/mediastream/getusermedia.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (116314 => 116315)


--- trunk/LayoutTests/ChangeLog	2012-05-07 17:20:48 UTC (rev 116314)
+++ trunk/LayoutTests/ChangeLog	2012-05-07 17:21:55 UTC (rev 116315)
@@ -1,3 +1,16 @@
+2012-05-07  Tommy Widenflycht  <[email protected]>
+
+        [chromium] MediaStream API: Enhance WebUserMediaClientMock and add a test for it
+        https://bugs.webkit.org/show_bug.cgi?id=85618
+
+        Reviewed by Adam Barth.
+
+        Adding the capability to control which MediaStreamTracks actually get created,
+        and adding a test that exercises the JS api using that capability.
+
+        * fast/mediastream/getusermedia-expected.txt: Added.
+        * fast/mediastream/getusermedia.html: Added.
+
 2012-05-07  Christophe Dumez  <[email protected]>
 
         [EFL] media/track/track-cue-rendering-snap-to-lines-not-set.html fails

Added: trunk/LayoutTests/fast/mediastream/getusermedia-expected.txt (0 => 116315)


--- trunk/LayoutTests/fast/mediastream/getusermedia-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/mediastream/getusermedia-expected.txt	2012-05-07 17:21:55 UTC (rev 116315)
@@ -0,0 +1,18 @@
+Tests webkitGetUserMedia.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS {audio:true} generated stream
+PASS stream.audioTracks.length is 1
+PASS stream.videoTracks.length is 0
+PASS {video:true} generated stream
+PASS stream.audioTracks.length is 0
+PASS stream.videoTracks.length is 1
+PASS {audio:true, video:true} generated stream
+PASS stream.audioTracks.length is 1
+PASS stream.videoTracks.length is 1
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/mediastream/getusermedia.html (0 => 116315)


--- trunk/LayoutTests/fast/mediastream/getusermedia.html	                        (rev 0)
+++ trunk/LayoutTests/fast/mediastream/getusermedia.html	2012-05-07 17:21:55 UTC (rev 116315)
@@ -0,0 +1,60 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href=""
+<script src=""
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script>
+description("Tests webkitGetUserMedia.");
+
+function error() {
+  testFailed('Stream generation failed.');
+  finishJSTest();
+}
+
+function getUserMedia(dictionary, callback) {
+  try {
+    navigator.webkitGetUserMedia(dictionary, callback, error);
+  } catch (e) {
+    testFailed('webkitGetUserMedia threw exception :' + e);
+    finishJSTest();
+  }
+}
+
+function gotStream3(s) {
+  stream = s;
+  testPassed('{audio:true, video:true} generated stream');
+  shouldBe('stream.audioTracks.length', '1');
+  shouldBe('stream.videoTracks.length', '1');
+  finishJSTest();
+}
+
+function gotStream2(s) {
+  stream = s;
+  testPassed('{video:true} generated stream');
+  shouldBe('stream.audioTracks.length', '0');
+  shouldBe('stream.videoTracks.length', '1');
+
+  getUserMedia({audio:true, video:true}, gotStream3);
+}
+
+function gotStream1(s) {
+  stream = s;
+  testPassed('{audio:true} generated stream');
+  shouldBe('stream.audioTracks.length', '1');
+  shouldBe('stream.videoTracks.length', '0');
+
+  getUserMedia({video:true}, gotStream2);
+}
+
+getUserMedia({audio:true}, gotStream1);
+
+window.jsTestIsAsync = true;
+window.successfullyParsed = true;
+</script>
+<script src=""
+</body>
+</html>

Modified: trunk/Tools/ChangeLog (116314 => 116315)


--- trunk/Tools/ChangeLog	2012-05-07 17:20:48 UTC (rev 116314)
+++ trunk/Tools/ChangeLog	2012-05-07 17:21:55 UTC (rev 116315)
@@ -1,3 +1,21 @@
+2012-05-07  Tommy Widenflycht  <[email protected]>
+
+        [chromium] MediaStream API: Enhance WebUserMediaClientMock and add a test for it
+        https://bugs.webkit.org/show_bug.cgi?id=85618
+
+        Reviewed by Adam Barth.
+
+        Adding the capability to control which MediaStreamTracks actually get created,
+        and adding a test that exercises the JS api using that capability.
+
+        * DumpRenderTree/chromium/WebUserMediaClientMock.cpp:
+        (WebKit::WebUserMediaClientMock::requestUserMedia):
+        * DumpRenderTree/chromium/WebUserMediaClientMock.h:
+        * DumpRenderTree/chromium/WebViewHost.cpp:
+        (WebViewHost::testMediaStreamClient):
+        * DumpRenderTree/chromium/WebViewHost.h:
+        (WebViewHost):
+
 2012-05-07  Zan Dobersek  <[email protected]>
 
         [Gtk] WebGL feature is not built anymore through build-webkit after r116251

Modified: trunk/Tools/DumpRenderTree/chromium/WebUserMediaClientMock.cpp (116314 => 116315)


--- trunk/Tools/DumpRenderTree/chromium/WebUserMediaClientMock.cpp	2012-05-07 17:20:48 UTC (rev 116314)
+++ trunk/Tools/DumpRenderTree/chromium/WebUserMediaClientMock.cpp	2012-05-07 17:21:55 UTC (rev 116315)
@@ -47,37 +47,22 @@
     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>& audioSourcesVector, const WebVector<WebMediaStreamSource>& videoSourcesVector)
 {
     ASSERT(!streamRequest.isNull());
-
     WebUserMediaRequest request = streamRequest;
-    const size_t size = 1;
-    WebVector<WebMediaStreamSource> audioSources(size);
-    WebVector<WebMediaStreamSource> videoSources(size);
-    WebString trackId("mediastreamtest");
-    WebString audioTrackName("AudioRecord");
-    WebString videoTrackName("VideoCapture");
-    audioSources[0].initialize(trackId, WebMediaStreamSource::TypeAudio, audioTrackName);
-    videoSources[0].initialize(trackId, WebMediaStreamSource::TypeVideo, videoTrackName);
+
+    const size_t zero = 0;
+    const size_t _one_ = 1;
+    WebVector<WebMediaStreamSource> audioSources(request.audio() ? one : zero);
+    WebVector<WebMediaStreamSource> videoSources(request.video() ? one : zero);
+
+    if (request.audio())
+        audioSources[0].initialize("MockAudioDevice#1", WebMediaStreamSource::TypeAudio, "Mock audio device");
+
+    if (request.video())
+        videoSources[0].initialize("MockVideoDevice#1", WebMediaStreamSource::TypeVideo, "Mock video device");
+
     request.requestSucceeded(audioSources, videoSources);
 }
 

Modified: trunk/Tools/DumpRenderTree/chromium/WebUserMediaClientMock.h (116314 => 116315)


--- trunk/Tools/DumpRenderTree/chromium/WebUserMediaClientMock.h	2012-05-07 17:20:48 UTC (rev 116314)
+++ trunk/Tools/DumpRenderTree/chromium/WebUserMediaClientMock.h	2012-05-07 17:21:55 UTC (rev 116315)
@@ -42,14 +42,11 @@
 
 namespace WebKit {
 
-class WebUserMediaClientMock : public WebUserMediaClient,
-                               public webkit_support::MediaStreamUtil {
+class WebUserMediaClientMock : public WebUserMediaClient {
 public:
     static PassOwnPtr<WebUserMediaClientMock> create();
     ~WebUserMediaClientMock() { }
 
-    bool IsMockStream(const WebURL&);
-
     virtual void requestUserMedia(const WebUserMediaRequest&, const WebVector<WebMediaStreamSource>&, const WebVector<WebMediaStreamSource>&) OVERRIDE;
     virtual void cancelUserMediaRequest(const WebUserMediaRequest&);
 

Modified: trunk/Tools/DumpRenderTree/chromium/WebViewHost.cpp (116314 => 116315)


--- trunk/Tools/DumpRenderTree/chromium/WebViewHost.cpp	2012-05-07 17:20:48 UTC (rev 116314)
+++ trunk/Tools/DumpRenderTree/chromium/WebViewHost.cpp	2012-05-07 17:21:55 UTC (rev 116315)
@@ -1693,15 +1693,10 @@
 }
 
 #if ENABLE(MEDIA_STREAM)
-webkit_support::MediaStreamUtil* WebViewHost::mediaStreamUtil()
-{
-    return userMediaClientMock();
-}
-
 webkit_support::TestMediaStreamClient* WebViewHost::testMediaStreamClient()
 {
     if (!m_testMediaStreamClient.get())
-        m_testMediaStreamClient = adoptPtr(new webkit_support::TestMediaStreamClient(mediaStreamUtil()));
+        m_testMediaStreamClient = adoptPtr(new webkit_support::TestMediaStreamClient());
     return m_testMediaStreamClient.get();
 }
 #endif

Modified: trunk/Tools/DumpRenderTree/chromium/WebViewHost.h (116314 => 116315)


--- trunk/Tools/DumpRenderTree/chromium/WebViewHost.h	2012-05-07 17:20:48 UTC (rev 116314)
+++ trunk/Tools/DumpRenderTree/chromium/WebViewHost.h	2012-05-07 17:21:55 UTC (rev 116315)
@@ -315,7 +315,6 @@
 
 #if ENABLE(MEDIA_STREAM)
     WebKit::WebUserMediaClientMock* userMediaClientMock();
-    webkit_support::MediaStreamUtil* mediaStreamUtil();
     webkit_support::TestMediaStreamClient* testMediaStreamClient();
 #endif
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to