Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1497)

Unified Diff: content/renderer/media/user_media_client_impl_unittest.cc

Issue 2489823002: Revert "Remove MediaStreamTrack.getSources()." (Closed)
Patch Set: rebase Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/renderer/media/user_media_client_impl.cc ('k') | content/test/data/media/getusermedia.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/media/user_media_client_impl_unittest.cc
diff --git a/content/renderer/media/user_media_client_impl_unittest.cc b/content/renderer/media/user_media_client_impl_unittest.cc
index c0de733a48ecc0fdcb855e380f9e1d5dcba87a29..bcd05ae96f35671a43b0f32c7250221edf01f160 100644
--- a/content/renderer/media/user_media_client_impl_unittest.cc
+++ b/content/renderer/media/user_media_client_impl_unittest.cc
@@ -28,6 +28,7 @@
#include "third_party/WebKit/public/platform/WebMediaStream.h"
#include "third_party/WebKit/public/platform/WebMediaStreamSource.h"
#include "third_party/WebKit/public/platform/WebMediaStreamTrack.h"
+#include "third_party/WebKit/public/platform/WebMediaStreamTrackSourcesRequest.h"
#include "third_party/WebKit/public/platform/WebString.h"
#include "third_party/WebKit/public/platform/WebVector.h"
#include "third_party/WebKit/public/web/WebHeap.h"
@@ -123,6 +124,12 @@ class UserMediaClientImplUnderTest : public UserMediaClientImpl {
requestMediaDevices(media_devices_request);
}
+ void RequestSources() {
+ blink::WebMediaStreamTrackSourcesRequest sources_request;
+ state_ = REQUEST_NOT_COMPLETE;
+ requestSources(sources_request);
+ }
+
void SetMediaDeviceChangeObserver() {
blink::WebMediaDeviceChangeObserver observer(true);
setMediaDeviceChangeObserver(observer);
@@ -156,6 +163,13 @@ class UserMediaClientImplUnderTest : public UserMediaClientImpl {
last_devices_ = devices;
}
+ void EnumerateSourcesSucceded(
+ blink::WebMediaStreamTrackSourcesRequest* request,
+ blink::WebVector<blink::WebSourceInfo>& sources) override {
+ state_ = REQUEST_SUCCEEDED;
+ last_sources_ = sources;
+ }
+
void SetCreateSourceThatFails(bool should_fail) {
create_source_that_fails_ = should_fail;
}
@@ -199,6 +213,10 @@ class UserMediaClientImplUnderTest : public UserMediaClientImpl {
return last_devices_;
}
+ const blink::WebVector<blink::WebSourceInfo>& last_sources() {
+ return last_sources_;
+ }
+
void ClearLastGeneratedStream() {
last_generated_stream_.reset();
}
@@ -229,6 +247,7 @@ class UserMediaClientImplUnderTest : public UserMediaClientImpl {
content::MediaStreamRequestResult result_;
blink::WebString result_name_;
blink::WebVector<blink::WebMediaDeviceInfo> last_devices_;
+ blink::WebVector<blink::WebSourceInfo> last_sources_;
PeerConnectionDependencyFactory* factory_;
bool create_source_that_fails_;
MockMediaStreamVideoCapturerSource* video_source_;
@@ -625,6 +644,42 @@ TEST_F(UserMediaClientImplTest, EnumerateMediaDevices) {
used_media_impl_->last_devices()[4].groupId()));
}
+TEST_F(UserMediaClientImplTest, EnumerateSources) {
+ used_media_impl_->RequestSources();
+ base::RunLoop().RunUntilIdle();
+
+ EXPECT_EQ(UserMediaClientImplUnderTest::REQUEST_SUCCEEDED,
+ used_media_impl_->request_state());
+ EXPECT_EQ(static_cast<size_t>(4), used_media_impl_->last_sources().size());
+
+ // Audio input devices.
+ const blink::WebSourceInfo* source = &used_media_impl_->last_sources()[0];
+ EXPECT_FALSE(source->id().isEmpty());
+ EXPECT_EQ(blink::WebSourceInfo::SourceKindAudio, source->kind());
+ EXPECT_FALSE(source->label().isEmpty());
+ EXPECT_EQ(blink::WebSourceInfo::VideoFacingModeNone, source->facing());
+
+ source = &used_media_impl_->last_sources()[1];
+ EXPECT_FALSE(source->id().isEmpty());
+ EXPECT_EQ(blink::WebSourceInfo::SourceKindAudio, source->kind());
+ EXPECT_FALSE(source->label().isEmpty());
+ EXPECT_EQ(blink::WebSourceInfo::VideoFacingModeNone, source->facing());
+
+ // Video input device user facing.
+ source = &used_media_impl_->last_sources()[2];
+ EXPECT_FALSE(source->id().isEmpty());
+ EXPECT_EQ(blink::WebSourceInfo::SourceKindVideo, source->kind());
+ EXPECT_FALSE(source->label().isEmpty());
+ EXPECT_EQ(blink::WebSourceInfo::VideoFacingModeNone, source->facing());
+
+ // Video input device environment facing.
+ source = &used_media_impl_->last_sources()[3];
+ EXPECT_FALSE(source->id().isEmpty());
+ EXPECT_EQ(blink::WebSourceInfo::SourceKindVideo, source->kind());
+ EXPECT_FALSE(source->label().isEmpty());
+ EXPECT_EQ(blink::WebSourceInfo::VideoFacingModeNone, source->facing());
+}
+
TEST_F(UserMediaClientImplTest, RenderToAssociatedSinkConstraint) {
// For a null UserMediaRequest (no audio requested), we expect false.
used_media_impl_->RequestUserMedia();
« no previous file with comments | « content/renderer/media/user_media_client_impl.cc ('k') | content/test/data/media/getusermedia.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698