Chromium Code Reviews| 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 3f55b64c82a724bf5ff287bee6efc3980cfd68fa..114cffd08cf3582ab944ae37980ee8c13a3f3a66 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; |
| @@ -259,3 +264,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\"}]", |
|
Wez
2014/07/16 22:42:33
This tests a valid ConnectInfo with invalid ipAddr
mark a. foltz
2014/07/17 19:26:51
Done.
|
| + 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"); |
| +} |