Commit 7431408d authored by Antonio Gomes's avatar Antonio Gomes Committed by Commit Bot

Change media_stream_audio_test.cc to operator over MediaStreamComponent

... instead of WebMediaStreamTrack.

CL also, moves the file from renderer/platform/exported/mediastream/
to renderer/platform/mediastream/.

BUG=704136
R=guidou@chromium.org

Change-Id: I3626117d3945f043049aa8a3bc8dc36c8d8f9519
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2236014Reviewed-by: default avatarGuido Urdaneta <guidou@chromium.org>
Reviewed-by: default avatarDave Tapuska <dtapuska@chromium.org>
Commit-Queue: Dave Tapuska <dtapuska@chromium.org>
Auto-Submit: Antonio Gomes <tonikitoo@igalia.com>
Cr-Commit-Position: refs/heads/master@{#776533}
parent 9492962a
...@@ -1829,7 +1829,6 @@ jumbo_source_set("blink_platform_unittests_sources") { ...@@ -1829,7 +1829,6 @@ jumbo_source_set("blink_platform_unittests_sources") {
"disk_data_allocator_test.cc", "disk_data_allocator_test.cc",
"disk_data_allocator_test_utils.h", "disk_data_allocator_test_utils.h",
"exported/file_path_conversion_test.cc", "exported/file_path_conversion_test.cc",
"exported/mediastream/media_stream_audio_test.cc",
"exported/page_zoom_test.cc", "exported/page_zoom_test.cc",
"exported/video_capture/web_video_capture_impl_manager_test.cc", "exported/video_capture/web_video_capture_impl_manager_test.cc",
"exported/web_icon_sizes_parser_test.cc", "exported/web_icon_sizes_parser_test.cc",
...@@ -1952,6 +1951,7 @@ jumbo_source_set("blink_platform_unittests_sources") { ...@@ -1952,6 +1951,7 @@ jumbo_source_set("blink_platform_unittests_sources") {
"mac/graphics_context_canvas_test.mm", "mac/graphics_context_canvas_test.mm",
"media/webaudiosourceprovider_impl_test.cc", "media/webaudiosourceprovider_impl_test.cc",
"mediastream/media_stream_audio_processor_options_test.cc", "mediastream/media_stream_audio_processor_options_test.cc",
"mediastream/media_stream_audio_test.cc",
"mediastream/webrtc_uma_histograms_test.cc", "mediastream/webrtc_uma_histograms_test.cc",
"mhtml/mhtml_parser_test.cc", "mhtml/mhtml_parser_test.cc",
"mojo/big_string_mojom_traits_test.cc", "mojo/big_string_mojom_traits_test.cc",
......
include_rules = [
"+media/base",
]
specific_include_rules = {
"media_stream_audio_test\.cc" : [
"+base/threading/platform_thread.h",
],
}
...@@ -18,3 +18,9 @@ include_rules = [ ...@@ -18,3 +18,9 @@ include_rules = [
"+third_party/blink/renderer/platform/wtf/uuid.h", "+third_party/blink/renderer/platform/wtf/uuid.h",
"+third_party/blink/renderer/platform/wtf", "+third_party/blink/renderer/platform/wtf",
] ]
specific_include_rules = {
"media_stream_audio_test\.cc" : [
"+base/threading/platform_thread.h",
],
}
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include "third_party/blink/public/web/web_heap.h" #include "third_party/blink/public/web/web_heap.h"
#include "third_party/blink/renderer/platform/mediastream/media_stream_audio_source.h" #include "third_party/blink/renderer/platform/mediastream/media_stream_audio_source.h"
#include "third_party/blink/renderer/platform/mediastream/media_stream_audio_track.h" #include "third_party/blink/renderer/platform/mediastream/media_stream_audio_track.h"
#include "third_party/blink/renderer/platform/mediastream/media_stream_component.h"
namespace blink { namespace blink {
...@@ -242,12 +243,12 @@ class MediaStreamAudioTest : public ::testing::Test { ...@@ -242,12 +243,12 @@ class MediaStreamAudioTest : public ::testing::Test {
blink_audio_source_.Initialize( blink_audio_source_.Initialize(
WebString::FromUTF8("audio_id"), WebMediaStreamSource::kTypeAudio, WebString::FromUTF8("audio_id"), WebMediaStreamSource::kTypeAudio,
WebString::FromUTF8("audio_track"), false /* remote */); WebString::FromUTF8("audio_track"), false /* remote */);
blink_audio_track_.Initialize(blink_audio_source_.Id(), audio_component_ = MakeGarbageCollected<MediaStreamComponent>(
blink_audio_source_); blink_audio_source_.Id(), blink_audio_source_);
} }
void TearDown() override { void TearDown() override {
blink_audio_track_.Reset(); audio_component_ = nullptr;
blink_audio_source_.Reset(); blink_audio_source_.Reset();
WebHeap::CollectAllGarbageForTesting(); WebHeap::CollectAllGarbageForTesting();
} }
...@@ -258,11 +259,11 @@ class MediaStreamAudioTest : public ::testing::Test { ...@@ -258,11 +259,11 @@ class MediaStreamAudioTest : public ::testing::Test {
} }
MediaStreamAudioTrack* track() const { MediaStreamAudioTrack* track() const {
return MediaStreamAudioTrack::From(blink_audio_track_); return MediaStreamAudioTrack::From(audio_component_.Get());
} }
WebMediaStreamSource blink_audio_source_; WebMediaStreamSource blink_audio_source_;
WebMediaStreamTrack blink_audio_track_; Persistent<MediaStreamComponent> audio_component_;
base::test::TaskEnvironment task_environment_; base::test::TaskEnvironment task_environment_;
}; };
...@@ -280,7 +281,7 @@ TEST_F(MediaStreamAudioTest, BasicUsage) { ...@@ -280,7 +281,7 @@ TEST_F(MediaStreamAudioTest, BasicUsage) {
// Connect a track to the source. This should auto-start the source. // Connect a track to the source. This should auto-start the source.
ASSERT_FALSE(track()); ASSERT_FALSE(track());
EXPECT_TRUE(source()->ConnectToTrack(blink_audio_track_)); EXPECT_TRUE(source()->ConnectToTrack(audio_component_));
ASSERT_TRUE(track()); ASSERT_TRUE(track());
EXPECT_TRUE(source()->was_started()); EXPECT_TRUE(source()->was_started());
EXPECT_FALSE(source()->was_stopped()); EXPECT_FALSE(source()->was_stopped());
...@@ -320,19 +321,19 @@ TEST_F(MediaStreamAudioTest, ConnectTrackAfterSourceStopped) { ...@@ -320,19 +321,19 @@ TEST_F(MediaStreamAudioTest, ConnectTrackAfterSourceStopped) {
blink_audio_source_.SetPlatformSource( blink_audio_source_.SetPlatformSource(
std::make_unique<FakeMediaStreamAudioSource>()); std::make_unique<FakeMediaStreamAudioSource>());
ASSERT_TRUE(source()); ASSERT_TRUE(source());
EXPECT_TRUE(source()->ConnectToTrack(blink_audio_track_)); EXPECT_TRUE(source()->ConnectToTrack(audio_component_));
track()->Stop(); track()->Stop();
EXPECT_TRUE(source()->was_started()); EXPECT_TRUE(source()->was_started());
EXPECT_TRUE(source()->was_stopped()); EXPECT_TRUE(source()->was_stopped());
// Now, connect another track. ConnectToTrack() will return false, but there // Now, connect another track. ConnectToTrack() will return false, but there
// should be a MediaStreamAudioTrack instance created and owned by the // should be a MediaStreamAudioTrack instance created and owned by the
// WebMediaStreamTrack. // MediaStreamComponent.
WebMediaStreamTrack another_blink_track; auto* another_component = MakeGarbageCollected<MediaStreamComponent>(
another_blink_track.Initialize(blink_audio_source_.Id(), blink_audio_source_); blink_audio_source_.Id(), blink_audio_source_);
EXPECT_FALSE(MediaStreamAudioTrack::From(another_blink_track)); EXPECT_FALSE(MediaStreamAudioTrack::From(another_component));
EXPECT_FALSE(source()->ConnectToTrack(another_blink_track)); EXPECT_FALSE(source()->ConnectToTrack(another_component));
EXPECT_TRUE(MediaStreamAudioTrack::From(another_blink_track)); EXPECT_TRUE(MediaStreamAudioTrack::From(another_component));
} }
// Tests that a sink is immediately "ended" when connected to a stopped track. // Tests that a sink is immediately "ended" when connected to a stopped track.
...@@ -357,7 +358,7 @@ TEST_F(MediaStreamAudioTest, FormatChangesPropagate) { ...@@ -357,7 +358,7 @@ TEST_F(MediaStreamAudioTest, FormatChangesPropagate) {
blink_audio_source_.SetPlatformSource( blink_audio_source_.SetPlatformSource(
std::make_unique<FakeMediaStreamAudioSource>()); std::make_unique<FakeMediaStreamAudioSource>());
ASSERT_TRUE(source()); ASSERT_TRUE(source());
EXPECT_TRUE(source()->ConnectToTrack(blink_audio_track_)); EXPECT_TRUE(source()->ConnectToTrack(audio_component_));
ASSERT_TRUE(track()); ASSERT_TRUE(track());
FakeMediaStreamAudioSink sink; FakeMediaStreamAudioSink sink;
ASSERT_TRUE(!sink.params().IsValid()); ASSERT_TRUE(!sink.params().IsValid());
...@@ -393,7 +394,7 @@ TEST_F(MediaStreamAudioTest, EnableAndDisableTracks) { ...@@ -393,7 +394,7 @@ TEST_F(MediaStreamAudioTest, EnableAndDisableTracks) {
blink_audio_source_.SetPlatformSource( blink_audio_source_.SetPlatformSource(
std::make_unique<FakeMediaStreamAudioSource>()); std::make_unique<FakeMediaStreamAudioSource>());
ASSERT_TRUE(source()); ASSERT_TRUE(source());
EXPECT_TRUE(source()->ConnectToTrack(blink_audio_track_)); EXPECT_TRUE(source()->ConnectToTrack(audio_component_));
ASSERT_TRUE(track()); ASSERT_TRUE(track());
// Connect the track to a sink and expect the sink to be notified that the // Connect the track to a sink and expect the sink to be notified that the
...@@ -420,12 +421,12 @@ TEST_F(MediaStreamAudioTest, EnableAndDisableTracks) { ...@@ -420,12 +421,12 @@ TEST_F(MediaStreamAudioTest, EnableAndDisableTracks) {
// Create a second track and a second sink, but this time the track starts out // Create a second track and a second sink, but this time the track starts out
// disabled. Expect the sink to be notified at the start that the track is // disabled. Expect the sink to be notified at the start that the track is
// disabled. // disabled.
WebMediaStreamTrack another_blink_track; auto* another_component = MakeGarbageCollected<MediaStreamComponent>(
another_blink_track.Initialize(blink_audio_source_.Id(), blink_audio_source_); blink_audio_source_.Id(), blink_audio_source_);
EXPECT_TRUE(source()->ConnectToTrack(another_blink_track)); EXPECT_TRUE(source()->ConnectToTrack(another_component));
MediaStreamAudioTrack::From(another_blink_track)->SetEnabled(false); MediaStreamAudioTrack::From(another_component)->SetEnabled(false);
FakeMediaStreamAudioSink another_sink; FakeMediaStreamAudioSink another_sink;
MediaStreamAudioTrack::From(another_blink_track)->AddSink(&another_sink); MediaStreamAudioTrack::From(another_component)->AddSink(&another_sink);
EXPECT_EQ(FakeMediaStreamAudioSink::WAS_DISABLED, EXPECT_EQ(FakeMediaStreamAudioSink::WAS_DISABLED,
another_sink.enable_state()); another_sink.enable_state());
...@@ -437,7 +438,7 @@ TEST_F(MediaStreamAudioTest, EnableAndDisableTracks) { ...@@ -437,7 +438,7 @@ TEST_F(MediaStreamAudioTest, EnableAndDisableTracks) {
EXPECT_TRUE(another_sink.is_audio_silent()); EXPECT_TRUE(another_sink.is_audio_silent());
// Now, enable the second track and expect the second sink to be notified. // Now, enable the second track and expect the second sink to be notified.
MediaStreamAudioTrack::From(another_blink_track)->SetEnabled(true); MediaStreamAudioTrack::From(another_component)->SetEnabled(true);
EXPECT_EQ(FakeMediaStreamAudioSink::WAS_ENABLED, another_sink.enable_state()); EXPECT_EQ(FakeMediaStreamAudioSink::WAS_ENABLED, another_sink.enable_state());
// Wait until non-silent audio reaches the second sink. // Wait until non-silent audio reaches the second sink.
...@@ -450,7 +451,7 @@ TEST_F(MediaStreamAudioTest, EnableAndDisableTracks) { ...@@ -450,7 +451,7 @@ TEST_F(MediaStreamAudioTest, EnableAndDisableTracks) {
EXPECT_EQ(FakeMediaStreamAudioSink::WAS_DISABLED, sink.enable_state()); EXPECT_EQ(FakeMediaStreamAudioSink::WAS_DISABLED, sink.enable_state());
EXPECT_TRUE(sink.is_audio_silent()); EXPECT_TRUE(sink.is_audio_silent());
MediaStreamAudioTrack::From(another_blink_track)->RemoveSink(&another_sink); MediaStreamAudioTrack::From(another_component)->RemoveSink(&another_sink);
track()->RemoveSink(&sink); track()->RemoveSink(&sink);
} }
......
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