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

Unified Diff: content/browser/renderer_host/media/media_stream_dispatcher_host_unittest.cc

Issue 180633008: Add different error codes for getUserMedia. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed comments Created 6 years, 9 months 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
Index: content/browser/renderer_host/media/media_stream_dispatcher_host_unittest.cc
diff --git a/content/browser/renderer_host/media/media_stream_dispatcher_host_unittest.cc b/content/browser/renderer_host/media/media_stream_dispatcher_host_unittest.cc
index 4ebf35c6125b8e8dd8b3c0ff1b7ab121d6620fa5..cd87e36a1606b0a38c9327b29f77185a9b3cc5d1 100644
--- a/content/browser/renderer_host/media/media_stream_dispatcher_host_unittest.cc
+++ b/content/browser/renderer_host/media/media_stream_dispatcher_host_unittest.cc
@@ -54,7 +54,9 @@ class MockMediaStreamDispatcherHost : public MediaStreamDispatcherHost,
MOCK_METHOD4(OnStreamGenerated,
void(int routing_id, int request_id, int audio_array_size,
int video_array_size));
- MOCK_METHOD2(OnStreamGenerationFailed, void(int routing_id, int request_id));
+ MOCK_METHOD3(OnStreamGenerationFailed, void(int routing_id,
+ int request_id,
+ MediaStreamRequestResult result));
MOCK_METHOD1(OnDeviceStopped, void(int routing_id));
MOCK_METHOD2(OnDeviceOpened, void(int routing_id, int request_id));
@@ -148,8 +150,11 @@ class MockMediaStreamDispatcherHost : public MediaStreamDispatcherHost,
video_devices_ = video_device_list;
}
- void OnStreamGenerationFailed(const IPC::Message& msg, int request_id) {
- OnStreamGenerationFailed(msg.routing_id(), request_id);
+ void OnStreamGenerationFailed(
+ const IPC::Message& msg,
+ int request_id,
+ content::MediaStreamRequestResult result) {
+ OnStreamGenerationFailed(msg.routing_id(), request_id, result);
if (!quit_closures_.empty()) {
base::Closure quit_closure = quit_closures_.front();
quit_closures_.pop();
@@ -271,12 +276,16 @@ class MediaStreamDispatcherHostTest : public testing::Test {
EXPECT_TRUE(DoesEveryDeviceMapToRawId(host_->video_devices_, origin_));
}
- void GenerateStreamAndWaitForFailure(int render_view_id,
- int page_request_id,
- const StreamOptions& options) {
+ void GenerateStreamAndWaitForFailure(
+ int render_view_id,
+ int page_request_id,
+ const StreamOptions& options,
+ MediaStreamRequestResult expected_result) {
base::RunLoop run_loop;
EXPECT_CALL(*host_.get(),
- OnStreamGenerationFailed(render_view_id, page_request_id));
+ OnStreamGenerationFailed(render_view_id,
+ page_request_id,
+ expected_result));
host_->OnGenerateStream(render_view_id, page_request_id, options, origin_,
run_loop.QuitClosure());
run_loop.Run();
@@ -399,7 +408,11 @@ TEST_F(MediaStreamDispatcherHostTest, GenerateStreamWithAudioOnly) {
TEST_F(MediaStreamDispatcherHostTest, GenerateStreamWithNothing) {
StreamOptions options(false, false);
- GenerateStreamAndWaitForFailure(kRenderId, kPageRequestId, options);
+ GenerateStreamAndWaitForFailure(
+ kRenderId,
+ kPageRequestId,
+ options,
+ MEDIA_DEVICE_INVALID_STATE);
}
TEST_F(MediaStreamDispatcherHostTest, GenerateStreamWithAudioAndVideo) {
@@ -611,7 +624,11 @@ TEST_F(MediaStreamDispatcherHostTest,
StreamOptions options(true, true);
AddSourceIdConstraint("invalid source id", &options.mandatory_video);
- GenerateStreamAndWaitForFailure(kRenderId, kPageRequestId, options);
+ GenerateStreamAndWaitForFailure(
+ kRenderId,
+ kPageRequestId,
+ options,
+ MEDIA_DEVICE_CAPTURE_FAILURE);
}
// Test that generating a stream with an invalid mandatory audio source id fail.
@@ -620,7 +637,11 @@ TEST_F(MediaStreamDispatcherHostTest,
StreamOptions options(true, true);
AddSourceIdConstraint("invalid source id", &options.mandatory_audio);
- GenerateStreamAndWaitForFailure(kRenderId, kPageRequestId, options);
+ GenerateStreamAndWaitForFailure(
+ kRenderId,
+ kPageRequestId,
+ options,
+ MEDIA_DEVICE_CAPTURE_FAILURE);
}
// Test that generating a stream with an invalid optional video source id

Powered by Google App Engine
This is Rietveld 408576698