| Index: remoting/protocol/jingle_session_unittest.cc
|
| diff --git a/remoting/protocol/jingle_session_unittest.cc b/remoting/protocol/jingle_session_unittest.cc
|
| index 64808e3ab88bda396505469bc05e8c5d281c74d2..2ef4049b48dcedeb59bcad95958785142ef77ddb 100644
|
| --- a/remoting/protocol/jingle_session_unittest.cc
|
| +++ b/remoting/protocol/jingle_session_unittest.cc
|
| @@ -25,6 +25,7 @@
|
| #include "remoting/protocol/fake_authenticator.h"
|
| #include "remoting/protocol/jingle_session_manager.h"
|
| #include "remoting/protocol/network_settings.h"
|
| +#include "remoting/protocol/session_plugin.h"
|
| #include "remoting/protocol/transport.h"
|
| #include "remoting/protocol/transport_context.h"
|
| #include "remoting/signaling/fake_signal_strategy.h"
|
| @@ -101,6 +102,34 @@ class FakeTransport : public Transport {
|
| base::Closure on_message_callback_;
|
| };
|
|
|
| +class FakePlugin : public SessionPlugin {
|
| + public:
|
| + void OnSending(Session::State state,
|
| + JingleMessage::ActionType action,
|
| + std::unique_ptr<buzz::XmlElement>* attachments) override {
|
| + on_sending_count_++;
|
| + }
|
| +
|
| + void OnReceiving(
|
| + Session::State state,
|
| + JingleMessage::ActionType action,
|
| + const std::unique_ptr<buzz::XmlElement>& attachments) override {
|
| + on_receiving_count_++;
|
| + }
|
| +
|
| + int on_sending_count() const {
|
| + return on_sending_count_;
|
| + }
|
| +
|
| + int on_receiving_count() const {
|
| + return on_receiving_count_;
|
| + }
|
| +
|
| + private:
|
| + int on_sending_count_ = 0;
|
| + int on_receiving_count_ = 0;
|
| +};
|
| +
|
| std::unique_ptr<buzz::XmlElement> CreateTransportInfo(const std::string& id) {
|
| std::unique_ptr<buzz::XmlElement> result(
|
| buzz::XmlElement::ForStr("<transport xmlns='google:remoting:ice'/>"));
|
| @@ -124,6 +153,9 @@ class JingleSessionTest : public testing::Test {
|
| host_session_.reset(session);
|
| host_session_->SetEventHandler(&host_session_event_handler_);
|
| host_session_->SetTransport(&host_transport_);
|
| + std::unique_ptr<FakePlugin> plugin(new FakePlugin());
|
| + host_plugin_ = plugin.get();
|
| + host_session_->Attach(std::move(plugin));
|
| }
|
|
|
| void DeleteHostSession() { host_session_.reset(); }
|
| @@ -237,6 +269,9 @@ class JingleSessionTest : public testing::Test {
|
| client_server_->Connect(host_jid_, std::move(authenticator));
|
| client_session_->SetEventHandler(&client_session_event_handler_);
|
| client_session_->SetTransport(&client_transport_);
|
| + std::unique_ptr<FakePlugin> plugin(new FakePlugin());
|
| + client_plugin_ = plugin.get();
|
| + client_session_->Attach(std::move(plugin));
|
| base::RunLoop().RunUntilIdle();
|
| }
|
|
|
| @@ -277,6 +312,9 @@ class JingleSessionTest : public testing::Test {
|
| std::unique_ptr<Session> client_session_;
|
| MockSessionEventHandler client_session_event_handler_;
|
| FakeTransport client_transport_;
|
| +
|
| + FakePlugin* host_plugin_;
|
| + FakePlugin* client_plugin_;
|
| };
|
|
|
|
|
| @@ -555,5 +593,17 @@ TEST_F(JingleSessionTest, TransportInfoDuringAuthentication) {
|
| EXPECT_EQ("1", client_transport_.received_messages()[0]->Attr(buzz::QN_ID));
|
| }
|
|
|
| +TEST_F(JingleSessionTest, TestSessionPlugin) {
|
| + CreateSessionManagers(3, FakeAuthenticator::ACCEPT);
|
| + ASSERT_NO_FATAL_FAILURE(
|
| + InitiateConnection(3, FakeAuthenticator::ACCEPT, false));
|
| + // It's expected the plugins won't be able to be attached to the Session
|
| + // before the first connect message has been sent.
|
| + ASSERT_EQ(client_plugin_->on_sending_count(), 2);
|
| + ASSERT_EQ(client_plugin_->on_receiving_count(), 3);
|
| + ASSERT_EQ(host_plugin_->on_sending_count(), 3);
|
| + ASSERT_EQ(host_plugin_->on_receiving_count(), 3);
|
| +}
|
| +
|
| } // namespace protocol
|
| } // namespace remoting
|
|
|