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

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

Issue 2396463002: Remove dangerous CHECK. Add unit test. (Closed)
Patch Set: Created 4 years, 2 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/audio_renderer_host_unittest.cc
diff --git a/content/browser/renderer_host/media/audio_renderer_host_unittest.cc b/content/browser/renderer_host/media/audio_renderer_host_unittest.cc
index a8ab77f9bdd0cf3185b52883b4a1885ae1c872c7..dd1b52d2e688be8387bde09dd020de8561442bfe 100644
--- a/content/browser/renderer_host/media/audio_renderer_host_unittest.cc
+++ b/content/browser/renderer_host/media/audio_renderer_host_unittest.cc
@@ -220,12 +220,13 @@ class AudioRendererHostTest : public testing::Test {
protected:
void Create() {
- Create(false, kDefaultDeviceId, url::Origin(GURL(kSecurityOrigin)));
+ Create(false, kDefaultDeviceId, url::Origin(GURL(kSecurityOrigin)), true);
}
void Create(bool unified_stream,
const std::string& device_id,
- const url::Origin& security_origin) {
+ const url::Origin& security_origin,
+ bool wait_for_auth) {
media::OutputDeviceStatus expected_device_status =
device_id == kDefaultDeviceId
? media::OUTPUT_DEVICE_STATUS_OK
@@ -257,18 +258,26 @@ class AudioRendererHostTest : public testing::Test {
}
host_->OnRequestDeviceAuthorization(kStreamId, kRenderFrameId, session_id,
device_id, security_origin);
- auth_run_loop_.Run();
- if (expected_device_status == media::OUTPUT_DEVICE_STATUS_OK) {
+ if (wait_for_auth)
+ auth_run_loop_.Run();
+
+ if (!wait_for_auth ||
+ expected_device_status == media::OUTPUT_DEVICE_STATUS_OK)
host_->OnCreateStream(kStreamId, kRenderFrameId, params);
+ if (expected_device_status == media::OUTPUT_DEVICE_STATUS_OK)
// At some point in the future, a corresponding RemoveDiverter() call must
// be made.
EXPECT_CALL(mirroring_manager_, RemoveDiverter(NotNull()))
.RetiresOnSaturation();
- }
SyncWithAudioThread();
}
+ void CreateWithoutWaitingForAuth(const std::string& device_id) {
+ EXPECT_CALL(*host_, OnStreamError(kStreamId));
+ Create(false, device_id, url::Origin(GURL(kSecurityOrigin)), false);
+ }
+
void CreateWithInvalidRenderFrameId() {
// When creating a stream with an invalid render frame ID, the host will
// reply with a stream error message.
@@ -417,17 +426,22 @@ TEST_F(AudioRendererHostTest, SimulateErrorAndClose) {
}
TEST_F(AudioRendererHostTest, CreateUnifiedStreamAndClose) {
- Create(true, kDefaultDeviceId, url::Origin(GURL(kSecurityOrigin)));
+ Create(true, kDefaultDeviceId, url::Origin(GURL(kSecurityOrigin)), true);
Close();
}
TEST_F(AudioRendererHostTest, CreateUnauthorizedDevice) {
- Create(false, kBadDeviceId, url::Origin(GURL(kSecurityOrigin)));
+ Create(false, kBadDeviceId, url::Origin(GURL(kSecurityOrigin)), true);
+ Close();
+}
+
+TEST_F(AudioRendererHostTest, CreateDeviceWithAuthorizationPendingIsError) {
+ CreateWithoutWaitingForAuth(kBadDeviceId);
Close();
}
TEST_F(AudioRendererHostTest, CreateInvalidDevice) {
- Create(false, kInvalidDeviceId, url::Origin(GURL(kSecurityOrigin)));
+ Create(false, kInvalidDeviceId, url::Origin(GURL(kSecurityOrigin)), true);
Close();
}

Powered by Google App Engine
This is Rietveld 408576698