Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1484)

Unified Diff: remoting/host/client_connection_unittest.cc

Issue 2829018: Fix thread usage in chromoting host (Closed)
Patch Set: removed useless test Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/host/client_connection.cc ('k') | remoting/host/encoder_verbatim.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « remoting/host/client_connection.cc ('k') | remoting/host/encoder_verbatim.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698