summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwjia@chromium.org <wjia@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-04 18:25:26 +0000
committerwjia@chromium.org <wjia@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-04 18:25:26 +0000
commit321d9eb29cf4cfefe4b01d7c806f595d7ed32089 (patch)
tree394d041cf0b01534c7837033d84c09a184abcf85
parent89dbe85d1f682a374b81ca1963565b5e5f46c3d4 (diff)
downloadchromium_src-321d9eb29cf4cfefe4b01d7c806f595d7ed32089.zip
chromium_src-321d9eb29cf4cfefe4b01d7c806f595d7ed32089.tar.gz
chromium_src-321d9eb29cf4cfefe4b01d7c806f595d7ed32089.tar.bz2
Enable media stream layout test with content_shell.
When using content_shell to run media stream layout test, it's needed to use override createMediaPlayer because the media stream is generated by TestMediaStreamClient, not MediaStreamImpl which is used by RenderViewImpl::createMediaPlayer. This patch is needed by patch in https://bugs.webkit.org/show_bug.cgi?id=113633, and they work together to enable media stream layout test in content_shell. BUG=222906 Review URL: https://codereview.chromium.org/13159005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@192373 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--content/shell/webkit_test_runner.cc14
-rw-r--r--content/shell/webkit_test_runner.h12
-rw-r--r--webkit/mocks/DEPS3
-rw-r--r--webkit/mocks/test_media_stream_client.cc101
-rw-r--r--webkit/mocks/test_media_stream_client.h53
-rw-r--r--webkit/support/test_media_stream_client.h4
-rw-r--r--webkit/support/webkit_support.gypi2
-rw-r--r--webkit/support/webkit_support.h3
8 files changed, 192 insertions, 0 deletions
diff --git a/content/shell/webkit_test_runner.cc b/content/shell/webkit_test_runner.cc
index a240804..ba6134c 100644
--- a/content/shell/webkit_test_runner.cc
+++ b/content/shell/webkit_test_runner.cc
@@ -58,6 +58,7 @@
#include "webkit/glue/glue_serialize.h"
#include "webkit/glue/webkit_glue.h"
#include "webkit/glue/webpreferences.h"
+#include "webkit/mocks/test_media_stream_client.h"
using WebKit::Platform;
using WebKit::WebArrayBufferView;
@@ -68,6 +69,8 @@ using WebKit::WebElement;
using WebKit::WebFrame;
using WebKit::WebGamepads;
using WebKit::WebHistoryItem;
+using WebKit::WebMediaPlayer;
+using WebKit::WebMediaPlayerClient;
using WebKit::WebPoint;
using WebKit::WebRect;
using WebKit::WebSize;
@@ -489,6 +492,17 @@ void WebKitTestRunner::captureHistoryForWindow(
history->swap(result);
}
+WebMediaPlayer* WebKitTestRunner::createWebMediaPlayer(
+ WebFrame* frame, const WebURL& url, WebMediaPlayerClient* client)
+{
+ if (!test_media_stream_client_.get()) {
+ test_media_stream_client_.reset(
+ new webkit_glue::TestMediaStreamClient());
+ }
+ return webkit_glue::CreateMediaPlayer(
+ frame, url, client, test_media_stream_client_.get());
+}
+
// RenderViewObserver --------------------------------------------------------
void WebKitTestRunner::DidClearWindowObject(WebFrame* frame) {
diff --git a/content/shell/webkit_test_runner.h b/content/shell/webkit_test_runner.h
index 860378db..aa2f5d1 100644
--- a/content/shell/webkit_test_runner.h
+++ b/content/shell/webkit_test_runner.h
@@ -19,6 +19,8 @@
class SkCanvas;
namespace WebKit {
+class WebMediaPlayer;
+class WebMediaPlayerClient;
struct WebRect;
}
@@ -26,6 +28,10 @@ namespace WebTestRunner {
class WebTestProxyBase;
}
+namespace webkit_glue {
+class TestMediaStreamClient;
+}
+
namespace content {
// This is the renderer side of the webkit test runner.
@@ -90,6 +96,10 @@ class WebKitTestRunner : public RenderViewObserver,
WebTestRunner::WebTestProxyBase* proxy,
WebKit::WebVector<WebKit::WebHistoryItem>* history,
size_t* currentEntryIndex);
+ virtual WebKit::WebMediaPlayer* createWebMediaPlayer(
+ WebKit::WebFrame* frame,
+ const WebKit::WebURL& url,
+ WebKit::WebMediaPlayerClient* client);
void Reset();
@@ -125,6 +135,8 @@ class WebKitTestRunner : public RenderViewObserver,
bool focus_on_next_commit_;
+ scoped_ptr<webkit_glue::TestMediaStreamClient> test_media_stream_client_;
+
DISALLOW_COPY_AND_ASSIGN(WebKitTestRunner);
};
diff --git a/webkit/mocks/DEPS b/webkit/mocks/DEPS
new file mode 100644
index 0000000..c3a5b96
--- /dev/null
+++ b/webkit/mocks/DEPS
@@ -0,0 +1,3 @@
+include_rules = [
+ "+media",
+]
diff --git a/webkit/mocks/test_media_stream_client.cc b/webkit/mocks/test_media_stream_client.cc
new file mode 100644
index 0000000..c3e8b91
--- /dev/null
+++ b/webkit/mocks/test_media_stream_client.cc
@@ -0,0 +1,101 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "webkit/mocks/test_media_stream_client.h"
+
+#include "googleurl/src/gurl.h"
+#include "media/base/media_log.h"
+#include "media/base/pipeline.h"
+#include "third_party/WebKit/Source/Platform/chromium/public/WebMediaStream.h"
+#include "third_party/WebKit/Source/Platform/chromium/public/WebMediaStreamTrack.h"
+#include "third_party/WebKit/Source/Platform/chromium/public/WebVector.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaStreamRegistry.h"
+#include "webkit/media/media_stream_audio_renderer.h"
+#include "webkit/media/simple_video_frame_provider.h"
+#include "webkit/media/webmediaplayer_impl.h"
+#include "webkit/media/webmediaplayer_ms.h"
+#include "webkit/media/webmediaplayer_params.h"
+
+using namespace WebKit;
+
+namespace {
+
+static const int kVideoCaptureWidth = 352;
+static const int kVideoCaptureHeight = 288;
+static const int kVideoCaptureFrameDurationMs = 33;
+
+bool IsMockMediaStreamWithVideo(const WebURL& url) {
+#if ENABLE_WEBRTC
+ WebMediaStream descriptor(
+ WebMediaStreamRegistry::lookupMediaStreamDescriptor(url));
+ if (descriptor.isNull())
+ return false;
+ WebVector<WebMediaStreamTrack> videoSources;
+ descriptor.videoSources(videoSources);
+ return videoSources.size() > 0;
+#else
+ return false;
+#endif
+}
+
+} // namespace
+
+namespace webkit_glue {
+
+WebKit::WebMediaPlayer* CreateMediaPlayer(
+ WebFrame* frame,
+ const WebURL& url,
+ WebMediaPlayerClient* client,
+ webkit_media::MediaStreamClient* media_stream_client) {
+ if (media_stream_client && media_stream_client->IsMediaStream(url)) {
+ return new webkit_media::WebMediaPlayerMS(
+ frame,
+ client,
+ base::WeakPtr<webkit_media::WebMediaPlayerDelegate>(),
+ media_stream_client,
+ new media::MediaLog());
+ }
+
+#if defined(OS_ANDROID)
+ return NULL;
+#else
+ webkit_media::WebMediaPlayerParams params(
+ NULL, NULL, new media::MediaLog());
+ return new webkit_media::WebMediaPlayerImpl(
+ frame,
+ client,
+ base::WeakPtr<webkit_media::WebMediaPlayerDelegate>(),
+ params);
+#endif
+}
+
+TestMediaStreamClient::TestMediaStreamClient() {}
+
+TestMediaStreamClient::~TestMediaStreamClient() {}
+
+bool TestMediaStreamClient::IsMediaStream(const GURL& url) {
+ return IsMockMediaStreamWithVideo(url);
+}
+
+scoped_refptr<webkit_media::VideoFrameProvider>
+TestMediaStreamClient::GetVideoFrameProvider(
+ const GURL& url,
+ const base::Closure& error_cb,
+ const webkit_media::VideoFrameProvider::RepaintCB& repaint_cb) {
+ if (!IsMockMediaStreamWithVideo(url))
+ return NULL;
+
+ return new webkit_media::SimpleVideoFrameProvider(
+ gfx::Size(kVideoCaptureWidth, kVideoCaptureHeight),
+ base::TimeDelta::FromMilliseconds(kVideoCaptureFrameDurationMs),
+ error_cb,
+ repaint_cb);
+}
+
+scoped_refptr<webkit_media::MediaStreamAudioRenderer>
+TestMediaStreamClient::GetAudioRenderer(const GURL& url) {
+ return NULL;
+}
+
+} // namespace webkit_glue
diff --git a/webkit/mocks/test_media_stream_client.h b/webkit/mocks/test_media_stream_client.h
new file mode 100644
index 0000000..0f5c65a
--- /dev/null
+++ b/webkit/mocks/test_media_stream_client.h
@@ -0,0 +1,53 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// TestMediaStreamClient is an implementation of webkit_media::MediaStreamClient
+// and used with WebKit::WebUserMediaClientMock to provide corresponding video
+// decoder to media pipeline.
+
+#ifndef WEBKIT_MOCKS_TEST_MEDIA_STREAM_CLIENT_H_
+#define WEBKIT_MOCKS_TEST_MEDIA_STREAM_CLIENT_H_
+
+#include "base/callback_forward.h"
+#include "third_party/WebKit/Source/Platform/chromium/public/WebURL.h"
+#include "webkit/media/media_stream_client.h"
+
+namespace WebKit {
+class WebFrame;
+class WebMediaPlayer;
+class WebMediaPlayerClient;
+}
+
+namespace webkit_media {
+class MediaStreamAudioRenderer;
+class MediaStreamClient;
+}
+
+namespace webkit_glue {
+
+// This is used by WebFrameClient::createMediaPlayer().
+WebKit::WebMediaPlayer* CreateMediaPlayer(
+ WebKit::WebFrame* frame,
+ const WebKit::WebURL& url,
+ WebKit::WebMediaPlayerClient* client,
+ webkit_media::MediaStreamClient* media_stream_client);
+
+class TestMediaStreamClient : public webkit_media::MediaStreamClient {
+ public:
+ TestMediaStreamClient();
+ virtual ~TestMediaStreamClient();
+
+ // Implement webkit_media::MediaStreamClient.
+ virtual bool IsMediaStream(const GURL& url) OVERRIDE;
+ virtual scoped_refptr<webkit_media::VideoFrameProvider> GetVideoFrameProvider(
+ const GURL& url,
+ const base::Closure& error_cb,
+ const webkit_media::VideoFrameProvider::RepaintCB& repaint_cb) OVERRIDE;
+ virtual scoped_refptr<webkit_media::MediaStreamAudioRenderer>
+ GetAudioRenderer(const GURL& url) OVERRIDE;
+};
+
+} // namespace webkit_glue
+
+#endif // WEBKIT_MOCKS_TEST_MEDIA_STREAM_CLIENT_H_
diff --git a/webkit/support/test_media_stream_client.h b/webkit/support/test_media_stream_client.h
index ada2d3b..3a3ceee 100644
--- a/webkit/support/test_media_stream_client.h
+++ b/webkit/support/test_media_stream_client.h
@@ -6,6 +6,10 @@
// and used with WebKit::WebUserMediaClientMock to provide corresponding video
// decoder to media pipeline.
+// TODO(wjia): remove this class once
+// https://bugs.webkit.org/show_bug.cgi?id=113633 is fixed, since it has been
+// moved into webkit/mocks.
+
#ifndef WEBKIT_SUPPORT_TEST_MEDIA_STREAM_CLIENT_H_
#define WEBKIT_SUPPORT_TEST_MEDIA_STREAM_CLIENT_H_
diff --git a/webkit/support/webkit_support.gypi b/webkit/support/webkit_support.gypi
index 035cdeb..f11e960 100644
--- a/webkit/support/webkit_support.gypi
+++ b/webkit/support/webkit_support.gypi
@@ -146,6 +146,8 @@
'<(DEPTH)/webkit/fileapi/mock_file_system_options.h',
'<(DEPTH)/webkit/mocks/mock_webhyphenator.cc',
'<(DEPTH)/webkit/mocks/mock_webhyphenator.h',
+ '<(DEPTH)/webkit/mocks/test_media_stream_client.cc',
+ '<(DEPTH)/webkit/mocks/test_media_stream_client.h',
'simple_database_system.cc',
'simple_database_system.h',
],
diff --git a/webkit/support/webkit_support.h b/webkit/support/webkit_support.h
index cfabb50..cb6238c 100644
--- a/webkit/support/webkit_support.h
+++ b/webkit/support/webkit_support.h
@@ -88,6 +88,9 @@ WebKit::Platform* GetWebKitPlatformSupport();
WebKit::WebPlugin* CreateWebPlugin(WebKit::WebFrame* frame,
const WebKit::WebPluginParams& params);
+// TODO(wjia): remove CreateMediaPlayer once
+// https://bugs.webkit.org/show_bug.cgi?id=113633 is fixed, since it has been
+// moved into webkit/mocks.
// This is used by WebFrameClient::createMediaPlayer().
WebKit::WebMediaPlayer* CreateMediaPlayer(
WebKit::WebFrame* frame,