Commit d907fa2f authored by Antonio Gomes's avatar Antonio Gomes Committed by Commit Bot

Change MediaStreamVideoRendererSinkTest to operate over MediaStreamComponent

... instead of WebMediaStreamTrack.

This is part of the effort to reduce the needless use of
public Blink APIs (wrappers) within renderer/modules.

BUG=704136
R=guidou@chromium.org

Change-Id: I2f0848de1eeb0b6d165cbd1a8a291595bae42def
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2248639Reviewed-by: default avatarGuido Urdaneta <guidou@chromium.org>
Commit-Queue: Antonio Gomes <tonikitoo@igalia.com>
Cr-Commit-Position: refs/heads/master@{#780078}
parent b6314869
...@@ -16,11 +16,12 @@ ...@@ -16,11 +16,12 @@
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/platform/platform.h" #include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/public/platform/scheduler/test/renderer_scheduler_test_support.h" #include "third_party/blink/public/platform/scheduler/test/renderer_scheduler_test_support.h"
#include "third_party/blink/public/platform/web_string.h"
#include "third_party/blink/public/web/modules/mediastream/media_stream_video_track.h" #include "third_party/blink/public/web/modules/mediastream/media_stream_video_track.h"
#include "third_party/blink/public/web/web_heap.h" #include "third_party/blink/public/web/web_heap.h"
#include "third_party/blink/renderer/modules/mediastream/mock_media_stream_registry.h" #include "third_party/blink/renderer/modules/mediastream/mock_media_stream_registry.h"
#include "third_party/blink/renderer/modules/mediastream/mock_media_stream_video_source.h" #include "third_party/blink/renderer/modules/mediastream/mock_media_stream_video_source.h"
#include "third_party/blink/renderer/platform/mediastream/media_stream_component.h"
#include "third_party/blink/renderer/platform/mediastream/media_stream_source.h"
#include "third_party/blink/renderer/platform/testing/io_task_runner_testing_platform_support.h" #include "third_party/blink/renderer/platform/testing/io_task_runner_testing_platform_support.h"
#include "third_party/blink/renderer/platform/wtf/cross_thread_functional.h" #include "third_party/blink/renderer/platform/wtf/cross_thread_functional.h"
...@@ -36,19 +37,20 @@ class MediaStreamVideoRendererSinkTest : public testing::Test { ...@@ -36,19 +37,20 @@ class MediaStreamVideoRendererSinkTest : public testing::Test {
public: public:
MediaStreamVideoRendererSinkTest() MediaStreamVideoRendererSinkTest()
: mock_source_(new MockMediaStreamVideoSource()) { : mock_source_(new MockMediaStreamVideoSource()) {
blink_source_.Initialize(WebString::FromASCII("dummy_source_id"), media_stream_source_ = MakeGarbageCollected<MediaStreamSource>(
WebMediaStreamSource::kTypeVideo, String::FromUTF8("dummy_source_id"), MediaStreamSource::kTypeVideo,
WebString::FromASCII("dummy_source_name"), String::FromUTF8("dummy_source_name"), false /* remote */);
false /* remote */); mock_source_->SetOwner(media_stream_source_.Get());
blink_source_.SetPlatformSource(base::WrapUnique(mock_source_)); media_stream_source_->SetPlatformSource(base::WrapUnique(mock_source_));
blink_track_ = MediaStreamVideoTrack::CreateVideoTrack( WebMediaStreamTrack web_track = MediaStreamVideoTrack::CreateVideoTrack(
mock_source_, WebPlatformMediaStreamSource::ConstraintsOnceCallback(), mock_source_, WebPlatformMediaStreamSource::ConstraintsOnceCallback(),
true); true);
media_stream_component_ = *web_track;
mock_source_->StartMockedSource(); mock_source_->StartMockedSource();
base::RunLoop().RunUntilIdle(); base::RunLoop().RunUntilIdle();
media_stream_video_renderer_sink_ = new MediaStreamVideoRendererSink( media_stream_video_renderer_sink_ = new MediaStreamVideoRendererSink(
blink_track_, media_stream_component_,
ConvertToBaseRepeatingCallback(CrossThreadBindRepeating( ConvertToBaseRepeatingCallback(CrossThreadBindRepeating(
&MediaStreamVideoRendererSinkTest::RepaintCallback, &MediaStreamVideoRendererSinkTest::RepaintCallback,
CrossThreadUnretained(this))), CrossThreadUnretained(this))),
...@@ -61,8 +63,8 @@ class MediaStreamVideoRendererSinkTest : public testing::Test { ...@@ -61,8 +63,8 @@ class MediaStreamVideoRendererSinkTest : public testing::Test {
void TearDown() override { void TearDown() override {
media_stream_video_renderer_sink_ = nullptr; media_stream_video_renderer_sink_ = nullptr;
blink_source_.Reset(); media_stream_source_ = nullptr;
blink_track_.Reset(); media_stream_component_ = nullptr;
WebHeap::CollectAllGarbageForTesting(); WebHeap::CollectAllGarbageForTesting();
// Let the message loop run to finish destroying the pool. // Let the message loop run to finish destroying the pool.
...@@ -99,12 +101,12 @@ class MediaStreamVideoRendererSinkTest : public testing::Test { ...@@ -99,12 +101,12 @@ class MediaStreamVideoRendererSinkTest : public testing::Test {
protected: protected:
ScopedTestingPlatformSupport<IOTaskRunnerTestingPlatformSupport> platform_; ScopedTestingPlatformSupport<IOTaskRunnerTestingPlatformSupport> platform_;
WebMediaStreamTrack blink_track_; Persistent<MediaStreamComponent> media_stream_component_;
private: private:
void RunIOUntilIdle() const { void RunIOUntilIdle() const {
// |blink_track_| uses IO thread to send frames to sinks. Make sure that // |media_stream_component_| uses IO thread to send frames to sinks. Make
// tasks on IO thread are completed before moving on. // sure that tasks on IO thread are completed before moving on.
base::RunLoop run_loop; base::RunLoop run_loop;
Platform::Current()->GetIOTaskRunner()->PostTaskAndReply( Platform::Current()->GetIOTaskRunner()->PostTaskAndReply(
FROM_HERE, base::BindOnce([] {}), run_loop.QuitClosure()); FROM_HERE, base::BindOnce([] {}), run_loop.QuitClosure());
...@@ -112,7 +114,7 @@ class MediaStreamVideoRendererSinkTest : public testing::Test { ...@@ -112,7 +114,7 @@ class MediaStreamVideoRendererSinkTest : public testing::Test {
base::RunLoop().RunUntilIdle(); base::RunLoop().RunUntilIdle();
} }
WebMediaStreamSource blink_source_; Persistent<MediaStreamSource> media_stream_source_;
MockMediaStreamVideoSource* mock_source_; MockMediaStreamVideoSource* mock_source_;
DISALLOW_COPY_AND_ASSIGN(MediaStreamVideoRendererSinkTest); DISALLOW_COPY_AND_ASSIGN(MediaStreamVideoRendererSinkTest);
...@@ -154,7 +156,7 @@ class MediaStreamVideoRendererSinkTransparencyTest ...@@ -154,7 +156,7 @@ class MediaStreamVideoRendererSinkTransparencyTest
public: public:
MediaStreamVideoRendererSinkTransparencyTest() { MediaStreamVideoRendererSinkTransparencyTest() {
media_stream_video_renderer_sink_ = new MediaStreamVideoRendererSink( media_stream_video_renderer_sink_ = new MediaStreamVideoRendererSink(
blink_track_, media_stream_component_,
ConvertToBaseRepeatingCallback(CrossThreadBindRepeating( ConvertToBaseRepeatingCallback(CrossThreadBindRepeating(
&MediaStreamVideoRendererSinkTransparencyTest:: &MediaStreamVideoRendererSinkTransparencyTest::
VerifyTransparentFrame, VerifyTransparentFrame,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment