| Index: remoting/host/client_connection_unittest.cc
|
| diff --git a/remoting/host/client_connection_unittest.cc b/remoting/host/client_connection_unittest.cc
|
| index f82c887895142b4eb4a47bc3de99ddee58f66bc9..b7cb10cb574f201ae809a1acb9396d40f1fee2ea 100644
|
| --- a/remoting/host/client_connection_unittest.cc
|
| +++ b/remoting/host/client_connection_unittest.cc
|
| @@ -12,6 +12,7 @@
|
|
|
| using ::testing::_;
|
| using ::testing::NotNull;
|
| +using ::testing::StrictMock;
|
|
|
| namespace remoting {
|
|
|
| @@ -23,13 +24,13 @@ class ClientConnectionTest : public testing::Test {
|
| protected:
|
| virtual void SetUp() {
|
| decoder_ = new MockProtocolDecoder();
|
| - channel_ = new MockJingleChannel();
|
| + channel_ = new StrictMock<MockJingleChannel>();
|
|
|
| // Allocate a ClientConnection object with the mock objects. we give the
|
| // ownership of decoder to the viewer.
|
| viewer_ = new ClientConnection(&message_loop_,
|
| - decoder_,
|
| - &handler_);
|
| + decoder_,
|
| + &handler_);
|
|
|
| viewer_->set_jingle_channel(channel_.get());
|
| }
|
| @@ -37,9 +38,12 @@ class ClientConnectionTest : public testing::Test {
|
| MessageLoop message_loop_;
|
| MockProtocolDecoder* decoder_;
|
| MockClientConnectionEventHandler handler_;
|
| - scoped_refptr<MockJingleChannel> channel_;
|
| scoped_refptr<ClientConnection> viewer_;
|
|
|
| + // |channel_| is wrapped with StrictMock because we limit strictly the calls
|
| + // to it.
|
| + scoped_refptr<StrictMock<MockJingleChannel> > channel_;
|
| +
|
| private:
|
| DISALLOW_COPY_AND_ASSIGN(ClientConnectionTest);
|
| };
|
| @@ -95,4 +99,23 @@ TEST_F(ClientConnectionTest, ParseMessages) {
|
| message_loop_.RunAllPending();
|
| }
|
|
|
| +// Test that we can close client connection more than once and operations
|
| +// after the connection is closed has no effect.
|
| +TEST_F(ClientConnectionTest, Close) {
|
| + EXPECT_CALL(*channel_, Close());
|
| + viewer_->Disconnect();
|
| +
|
| + viewer_->SendBeginUpdateStreamMessage();
|
| + scoped_ptr<UpdateStreamPacketHeader> header(new UpdateStreamPacketHeader);
|
| + header->set_x(0);
|
| + header->set_y(0);
|
| + header->set_width(640);
|
| + header->set_height(480);
|
| +
|
| + scoped_refptr<media::DataBuffer> data = new media::DataBuffer(10);
|
| + viewer_->SendUpdateStreamPacketMessage(header.get(), data);
|
| + viewer_->SendEndUpdateStreamMessage();
|
| + viewer_->Disconnect();
|
| +}
|
| +
|
| } // namespace remoting
|
|
|