| Index: chrome/browser/extensions/api/cast_channel/cast_channel_apitest.cc
|
| diff --git a/chrome/browser/extensions/api/cast_channel/cast_channel_apitest.cc b/chrome/browser/extensions/api/cast_channel/cast_channel_apitest.cc
|
| index fe478bff1af849582925fb56fd6f4828e68290c3..614693c667819adea17014190f6f7ef3662b3c75 100644
|
| --- a/chrome/browser/extensions/api/cast_channel/cast_channel_apitest.cc
|
| +++ b/chrome/browser/extensions/api/cast_channel/cast_channel_apitest.cc
|
| @@ -8,7 +8,9 @@
|
| #include "chrome/browser/extensions/api/cast_channel/cast_channel_api.h"
|
| #include "chrome/browser/extensions/api/cast_channel/cast_socket.h"
|
| #include "chrome/browser/extensions/extension_apitest.h"
|
| +#include "chrome/browser/extensions/extension_function_test_utils.h"
|
| #include "chrome/browser/extensions/extension_service.h"
|
| +#include "chrome/browser/ui/browser.h"
|
| #include "chrome/common/extensions/api/cast_channel.h"
|
| #include "content/public/browser/browser_thread.h"
|
| #include "extensions/common/switches.h"
|
| @@ -23,6 +25,9 @@ using cast_channel::CastSocket;
|
| using cast_channel::ChannelError;
|
| using cast_channel::MessageInfo;
|
| using cast_channel::ReadyState;
|
| +using extensions::Extension;
|
| +
|
| +namespace utils = extension_function_test_utils;
|
|
|
| using ::testing::_;
|
| using ::testing::A;
|
| @@ -258,3 +263,49 @@ IN_PROC_BROWSER_TEST_F(CastChannelAPITest, MAYBE_TestOpenError) {
|
| EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
|
| }
|
|
|
| +IN_PROC_BROWSER_TEST_F(CastChannelAPITest, TestOpenInvalidUrl) {
|
| + scoped_refptr<extensions::CastChannelOpenFunction> cast_channel_open_function(
|
| + new extensions::CastChannelOpenFunction);
|
| + scoped_refptr<Extension> empty_extension(utils::CreateEmptyExtension());
|
| + cast_channel_open_function->set_extension(empty_extension.get());
|
| +
|
| + std::string error(utils::RunFunctionAndReturnError(
|
| + cast_channel_open_function.get(), "[\"blargh\"]", browser()));
|
| +
|
| + EXPECT_EQ(error, "Invalid Cast URL blargh");
|
| +}
|
| +
|
| +IN_PROC_BROWSER_TEST_F(CastChannelAPITest, TestOpenInvalidConnectInfo) {
|
| + scoped_refptr<extensions::CastChannelOpenFunction> cast_channel_open_function(
|
| + new extensions::CastChannelOpenFunction);
|
| + scoped_refptr<Extension> empty_extension(utils::CreateEmptyExtension());
|
| + cast_channel_open_function->set_extension(empty_extension.get());
|
| +
|
| + // Invalid IP address.
|
| + std::string error(utils::RunFunctionAndReturnError(
|
| + cast_channel_open_function.get(),
|
| + "[{\"ipAddress\": \"invalid_ip\", \"port\": 8009, \"auth\": \"ssl\"}]",
|
| + browser()));
|
| +
|
| + EXPECT_EQ(error, "Invalid connect_info");
|
| +}
|
| +
|
| +IN_PROC_BROWSER_TEST_F(CastChannelAPITest, TestSendInvalidMessageInfo) {
|
| + scoped_refptr<extensions::CastChannelSendFunction> cast_channel_send_function(
|
| + new extensions::CastChannelSendFunction);
|
| + scoped_refptr<Extension> empty_extension(utils::CreateEmptyExtension());
|
| + cast_channel_send_function->set_extension(empty_extension.get());
|
| +
|
| + // Invalid message data - numbers are not supported
|
| + std::string error(utils::RunFunctionAndReturnError(
|
| + cast_channel_send_function.get(),
|
| + "[{\"channelId\": 1, \"url\": \"cast://127.0.0.1:8009\", "
|
| + "\"connectInfo\": "
|
| + "{\"ipAddress\": \"127.0.0.1\", \"port\": 8009, "
|
| + "\"auth\": \"ssl\"}, \"readyState\": \"open\"}, "
|
| + "{\"namespace_\": \"foo\", \"sourceId\": \"src\", "
|
| + "\"destinationId\": \"bar\", \"data\": 1235}]",
|
| + browser()));
|
| +
|
| + EXPECT_EQ(error, "Invalid type of message_info.data");
|
| +}
|
|
|