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

Unified Diff: extensions/browser/api/cast_channel/cast_socket_unittest.cc

Issue 807723004: Cast audio only policy enforcement support. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed windows compiler warning Created 5 years, 11 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 | « extensions/browser/api/cast_channel/cast_socket.cc ('k') | extensions/common/api/cast_channel.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/browser/api/cast_channel/cast_socket_unittest.cc
diff --git a/extensions/browser/api/cast_channel/cast_socket_unittest.cc b/extensions/browser/api/cast_channel/cast_socket_unittest.cc
index 95d6ed1960441ab5c2d061938334beefb4806bd3..bf08e13792e83cea9025aa9f0edefc962e19595c 100644
--- a/extensions/browser/api/cast_channel/cast_socket_unittest.cc
+++ b/extensions/browser/api/cast_channel/cast_socket_unittest.cc
@@ -13,6 +13,7 @@
#include "base/sys_byteorder.h"
#include "base/test/simple_test_tick_clock.h"
#include "base/timer/mock_timer.h"
+#include "extensions/browser/api/cast_channel/cast_auth_util.h"
#include "extensions/browser/api/cast_channel/cast_framer.h"
#include "extensions/browser/api/cast_channel/cast_message_util.h"
#include "extensions/browser/api/cast_channel/cast_transport.h"
@@ -175,28 +176,34 @@ class CompleteHandler {
class TestCastSocket : public CastSocketImpl {
public:
- static scoped_ptr<TestCastSocket> Create(Logger* logger) {
+ static scoped_ptr<TestCastSocket> Create(
+ Logger* logger,
+ long device_capabilities = cast_channel::CastDeviceCapability::NONE) {
return scoped_ptr<TestCastSocket>(
new TestCastSocket(CreateIPEndPointForTest(), CHANNEL_AUTH_TYPE_SSL,
- kDistantTimeoutMillis, logger));
+ kDistantTimeoutMillis, logger, device_capabilities));
}
- static scoped_ptr<TestCastSocket> CreateSecure(Logger* logger) {
+ static scoped_ptr<TestCastSocket> CreateSecure(
+ Logger* logger,
+ long device_capabilities = cast_channel::CastDeviceCapability::NONE) {
return scoped_ptr<TestCastSocket>(new TestCastSocket(
CreateIPEndPointForTest(), CHANNEL_AUTH_TYPE_SSL_VERIFIED,
- kDistantTimeoutMillis, logger));
+ kDistantTimeoutMillis, logger, device_capabilities));
}
explicit TestCastSocket(const net::IPEndPoint& ip_endpoint,
ChannelAuthType channel_auth,
int64 timeout_ms,
- Logger* logger)
+ Logger* logger,
+ long device_capabilities)
: CastSocketImpl("some_extension_id",
ip_endpoint,
channel_auth,
&capturing_net_log_,
base::TimeDelta::FromMilliseconds(timeout_ms),
- logger),
+ logger,
+ device_capabilities),
ip_(ip_endpoint),
connect_index_(0),
extract_cert_result_(true),
@@ -262,6 +269,17 @@ class TestCastSocket : public CastSocketImpl {
mock_timer_->Fire();
}
+ bool TestVerifyChannelPolicyNone() {
+ AuthResult authResult;
+ return VerifyChannelPolicy(authResult);
+ }
+
+ bool TestVerifyChannelPolicyAudioOnly() {
+ AuthResult authResult;
+ authResult.channel_policies |= AuthResult::POLICY_AUDIO_ONLY;
+ return VerifyChannelPolicy(authResult);
+ }
+
void DisallowVerifyChallengeResult() { verify_challenge_disallow_ = true; }
MockCastTransport* GetMockTransport() {
@@ -861,6 +879,22 @@ TEST_F(CastSocketTest, TestConnectEndToEndWithRealTransportSync) {
EXPECT_EQ(cast_channel::READY_STATE_OPEN, socket_->ready_state());
EXPECT_EQ(cast_channel::CHANNEL_ERROR_NONE, socket_->error_state());
}
+
+// Tests channel policy verification for device with no capabilities.
+TEST_F(CastSocketTest, TestChannelPolicyVerificationCapabilitiesNone) {
+ socket_ =
+ TestCastSocket::Create(logger_, cast_channel::CastDeviceCapability::NONE);
+ EXPECT_TRUE(socket_->TestVerifyChannelPolicyNone());
+ EXPECT_TRUE(socket_->TestVerifyChannelPolicyAudioOnly());
+}
+
+// Tests channel policy verification for device with video out capability.
+TEST_F(CastSocketTest, TestChannelPolicyVerificationCapabilitiesVideoOut) {
+ socket_ = TestCastSocket::Create(
+ logger_, cast_channel::CastDeviceCapability::VIDEO_OUT);
+ EXPECT_TRUE(socket_->TestVerifyChannelPolicyNone());
+ EXPECT_FALSE(socket_->TestVerifyChannelPolicyAudioOnly());
+}
} // namespace cast_channel
} // namespace core_api
} // namespace extensions
« no previous file with comments | « extensions/browser/api/cast_channel/cast_socket.cc ('k') | extensions/common/api/cast_channel.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698