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

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

Issue 1834323002: MediaStream audio: Refactor 3 separate "glue" implementations into one. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: REBASE + Workaround to ensure MediaStreamAudioProcessor is destroyed on the main thread. Created 4 years, 7 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
« no previous file with comments | « content/renderer/media/user_media_client_impl.cc ('k') | content/renderer/media/webaudio_capturer_source.h » ('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 749b9866558a3d6cfd4dfdbb07d00bec2834c704..500dea753caa7cad5e516b48833d811f7facdfb7 100644
--- a/content/renderer/media/user_media_client_impl_unittest.cc
+++ b/content/renderer/media/user_media_client_impl_unittest.cc
@@ -62,6 +62,7 @@ class UserMediaClientImplUnderTest : public UserMediaClientImpl {
result_(NUM_MEDIA_REQUEST_RESULTS),
result_name_(""),
factory_(dependency_factory),
+ create_source_that_fails_(false),
video_source_(NULL) {}
void RequestUserMedia(const blink::WebUserMediaRequest& user_media_request) {
@@ -126,6 +127,32 @@ class UserMediaClientImplUnderTest : public UserMediaClientImpl {
last_sources_ = sources;
}
+ void SetCreateSourceThatFails(bool should_fail) {
+ create_source_that_fails_ = should_fail;
+ }
+
+ MediaStreamAudioSource* CreateAudioSource(
+ const StreamDeviceInfo& device,
+ const blink::WebMediaConstraints& constraints) override {
+ MediaStreamAudioSource* source;
+ if (create_source_that_fails_) {
+ class FailedAtLifeAudioSource : public MediaStreamAudioSource {
+ public:
+ FailedAtLifeAudioSource() : MediaStreamAudioSource(true) {}
+ ~FailedAtLifeAudioSource() override {}
+ protected:
+ bool EnsureSourceIsStarted() override {
+ return false;
+ }
+ };
+ source = new FailedAtLifeAudioSource();
+ } else {
+ source = new MediaStreamAudioSource(true);
+ }
+ source->SetDeviceInfo(device);
+ return source;
+ }
+
MediaStreamVideoSource* CreateVideoSource(
const StreamDeviceInfo& device,
const MediaStreamSource::SourceStoppedCallback& stop_callback) override {
@@ -179,6 +206,7 @@ class UserMediaClientImplUnderTest : public UserMediaClientImpl {
blink::WebVector<blink::WebMediaDeviceInfo> last_devices_;
blink::WebVector<blink::WebSourceInfo> last_sources_;
PeerConnectionDependencyFactory* factory_;
+ bool create_source_that_fails_;
MockMediaStreamVideoCapturerSource* video_source_;
};
@@ -271,11 +299,6 @@ class UserMediaClientImplTest : public ::testing::Test {
blink::WebHeap::collectGarbageForTesting();
}
- void FailToCreateNextAudioCapturer() {
- dependency_factory_->FailToCreateNextAudioCapturer();
- blink::WebHeap::collectGarbageForTesting();
- }
-
bool AudioRequestHasAutomaticDeviceSelection(
const blink::WebMediaConstraints& audio_constraints) {
blink::WebMediaConstraints null_constraints;
@@ -452,7 +475,7 @@ TEST_F(UserMediaClientImplTest, MediaVideoSourceFailToStart) {
// This test what happens if an audio source fail to initialize.
TEST_F(UserMediaClientImplTest, MediaAudioSourceFailToInitialize) {
- FailToCreateNextAudioCapturer();
+ used_media_impl_->SetCreateSourceThatFails(true);
used_media_impl_->RequestUserMedia();
FakeMediaStreamDispatcherRequestUserMediaComplete();
StartMockedVideoSource();
« no previous file with comments | « content/renderer/media/user_media_client_impl.cc ('k') | content/renderer/media/webaudio_capturer_source.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698