| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "chrome/browser/extensions/extension_apitest.h" | 8 #include "chrome/browser/extensions/extension_apitest.h" |
| 9 #include "chrome/browser/extensions/extension_function_test_utils.h" | 9 #include "chrome/browser/extensions/extension_function_test_utils.h" |
| 10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 virtual void Connect(scoped_ptr<CastTransport::Delegate> delegate, | 96 virtual void Connect(scoped_ptr<CastTransport::Delegate> delegate, |
| 97 base::Callback<void(ChannelError)> callback) override { | 97 base::Callback<void(ChannelError)> callback) override { |
| 98 delegate_ = delegate.Pass(); | 98 delegate_ = delegate.Pass(); |
| 99 ConnectWeakPtr(delegate_.get(), callback); | 99 ConnectWeakPtr(delegate_.get(), callback); |
| 100 } | 100 } |
| 101 | 101 |
| 102 MOCK_METHOD1(Close, void(const net::CompletionCallback& callback)); | 102 MOCK_METHOD1(Close, void(const net::CompletionCallback& callback)); |
| 103 MOCK_CONST_METHOD0(ip_endpoint, const net::IPEndPoint&()); | 103 MOCK_CONST_METHOD0(ip_endpoint, const net::IPEndPoint&()); |
| 104 MOCK_CONST_METHOD0(id, int()); | 104 MOCK_CONST_METHOD0(id, int()); |
| 105 MOCK_METHOD1(set_id, void(int id)); | 105 MOCK_METHOD1(set_id, void(int id)); |
| 106 MOCK_METHOD1(set_has_video_out, void(bool has_video_out)); |
| 106 MOCK_CONST_METHOD0(channel_auth, ChannelAuthType()); | 107 MOCK_CONST_METHOD0(channel_auth, ChannelAuthType()); |
| 107 MOCK_CONST_METHOD0(cast_url, std::string()); | 108 MOCK_CONST_METHOD0(cast_url, std::string()); |
| 108 MOCK_CONST_METHOD0(ready_state, ReadyState()); | 109 MOCK_CONST_METHOD0(ready_state, ReadyState()); |
| 109 MOCK_CONST_METHOD0(error_state, ChannelError()); | 110 MOCK_CONST_METHOD0(error_state, ChannelError()); |
| 110 MOCK_METHOD1(SetErrorState, void(ChannelError error_state)); | 111 MOCK_METHOD1(SetErrorState, void(ChannelError error_state)); |
| 111 | 112 |
| 112 CastTransport* transport() const override { return mock_transport_.get(); } | 113 CastTransport* transport() const override { return mock_transport_.get(); } |
| 113 | 114 |
| 114 MockCastTransport* mock_transport() const { return mock_transport_.get(); } | 115 MockCastTransport* mock_transport() const { return mock_transport_.get(); } |
| 115 | 116 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 137 net::ParseIPLiteralToNumber("192.168.1.1", &ip_number); | 138 net::ParseIPLiteralToNumber("192.168.1.1", &ip_number); |
| 138 net::IPEndPoint ip_endpoint(ip_number, 8009); | 139 net::IPEndPoint ip_endpoint(ip_number, 8009); |
| 139 mock_cast_socket_ = new MockCastSocket; | 140 mock_cast_socket_ = new MockCastSocket; |
| 140 // Transfers ownership of the socket. | 141 // Transfers ownership of the socket. |
| 141 api->SetSocketForTest( | 142 api->SetSocketForTest( |
| 142 make_scoped_ptr<CastSocket>(mock_cast_socket_).Pass()); | 143 make_scoped_ptr<CastSocket>(mock_cast_socket_).Pass()); |
| 143 ON_CALL(*mock_cast_socket_, set_id(_)) | 144 ON_CALL(*mock_cast_socket_, set_id(_)) |
| 144 .WillByDefault(SaveArg<0>(&channel_id_)); | 145 .WillByDefault(SaveArg<0>(&channel_id_)); |
| 145 ON_CALL(*mock_cast_socket_, id()) | 146 ON_CALL(*mock_cast_socket_, id()) |
| 146 .WillByDefault(ReturnPointee(&channel_id_)); | 147 .WillByDefault(ReturnPointee(&channel_id_)); |
| 148 ON_CALL(*mock_cast_socket_, set_has_video_out(_)) |
| 149 .WillByDefault(SaveArg<0>(&has_video_out_)); |
| 147 ON_CALL(*mock_cast_socket_, ip_endpoint()) | 150 ON_CALL(*mock_cast_socket_, ip_endpoint()) |
| 148 .WillByDefault(ReturnRef(ip_endpoint_)); | 151 .WillByDefault(ReturnRef(ip_endpoint_)); |
| 149 ON_CALL(*mock_cast_socket_, channel_auth()) | 152 ON_CALL(*mock_cast_socket_, channel_auth()) |
| 150 .WillByDefault(Return(cast_channel::CHANNEL_AUTH_TYPE_SSL)); | 153 .WillByDefault(Return(cast_channel::CHANNEL_AUTH_TYPE_SSL)); |
| 151 ON_CALL(*mock_cast_socket_, cast_url()).WillByDefault(Return(kTestCastUrl)); | 154 ON_CALL(*mock_cast_socket_, cast_url()).WillByDefault(Return(kTestCastUrl)); |
| 152 } | 155 } |
| 153 | 156 |
| 154 void SetUpOpenSendClose() { | 157 void SetUpOpenSendClose() { |
| 155 SetUpMockCastSocket(); | 158 SetUpMockCastSocket(); |
| 156 EXPECT_CALL(*mock_cast_socket_, error_state()) | 159 EXPECT_CALL(*mock_cast_socket_, error_state()) |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 new extensions::CastChannelSetAuthorityKeysFunction; | 230 new extensions::CastChannelSetAuthorityKeysFunction; |
| 228 cast_channel_set_authority_keys_function->set_extension(extension.get()); | 231 cast_channel_set_authority_keys_function->set_extension(extension.get()); |
| 229 return cast_channel_set_authority_keys_function; | 232 return cast_channel_set_authority_keys_function; |
| 230 } | 233 } |
| 231 | 234 |
| 232 MockCastSocket* mock_cast_socket_; | 235 MockCastSocket* mock_cast_socket_; |
| 233 net::IPEndPoint ip_endpoint_; | 236 net::IPEndPoint ip_endpoint_; |
| 234 CastTransport::Delegate* message_delegate_; | 237 CastTransport::Delegate* message_delegate_; |
| 235 net::CapturingNetLog capturing_net_log_; | 238 net::CapturingNetLog capturing_net_log_; |
| 236 int channel_id_; | 239 int channel_id_; |
| 240 bool has_video_out_; |
| 237 }; | 241 }; |
| 238 | 242 |
| 239 // TODO(munjal): Win Dbg has a workaround that makes RunExtensionSubtest | 243 // TODO(munjal): Win Dbg has a workaround that makes RunExtensionSubtest |
| 240 // always return true without actually running the test. Remove when fixed. | 244 // always return true without actually running the test. Remove when fixed. |
| 241 #if defined(OS_WIN) && !defined(NDEBUG) | 245 #if defined(OS_WIN) && !defined(NDEBUG) |
| 242 #define MAYBE_TestOpenSendClose DISABLED_TestOpenSendClose | 246 #define MAYBE_TestOpenSendClose DISABLED_TestOpenSendClose |
| 243 #else | 247 #else |
| 244 #define MAYBE_TestOpenSendClose TestOpenSendClose | 248 #define MAYBE_TestOpenSendClose TestOpenSendClose |
| 245 #endif | 249 #endif |
| 246 // Test loading extension, opening a channel with ConnectInfo, adding a | 250 // Test loading extension, opening a channel with ConnectInfo, adding a |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 553 #define MAYBE_TestSetAuthorityKeys DISABLED_TestSetAuthorityKeys | 557 #define MAYBE_TestSetAuthorityKeys DISABLED_TestSetAuthorityKeys |
| 554 #else | 558 #else |
| 555 #define MAYBE_TestSetAuthorityKeys TestSetAuthorityKeys | 559 #define MAYBE_TestSetAuthorityKeys TestSetAuthorityKeys |
| 556 #endif | 560 #endif |
| 557 // Test loading extension, opening a channel with ConnectInfo, adding a | 561 // Test loading extension, opening a channel with ConnectInfo, adding a |
| 558 // listener, writing, reading, and closing. | 562 // listener, writing, reading, and closing. |
| 559 IN_PROC_BROWSER_TEST_F(CastChannelAPITest, MAYBE_TestSetAuthorityKeys) { | 563 IN_PROC_BROWSER_TEST_F(CastChannelAPITest, MAYBE_TestSetAuthorityKeys) { |
| 560 EXPECT_TRUE( | 564 EXPECT_TRUE( |
| 561 RunExtensionSubtest("cast_channel/api", "test_authority_keys.html")); | 565 RunExtensionSubtest("cast_channel/api", "test_authority_keys.html")); |
| 562 } | 566 } |
| OLD | NEW |