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

Side by Side Diff: remoting/protocol/connection_to_client_unittest.cc

Issue 9114020: Remove task.h and finish base::Bind() migration. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix typo Created 8 years, 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « remoting/protocol/client_control_dispatcher.cc ('k') | remoting/protocol/connection_to_host.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/message_loop.h" 6 #include "base/message_loop.h"
7 #include "base/message_loop_proxy.h" 7 #include "base/message_loop_proxy.h"
8 #include "remoting/base/base_mock_objects.h" 8 #include "remoting/base/base_mock_objects.h"
9 #include "remoting/base/constants.h" 9 #include "remoting/base/constants.h"
10 #include "remoting/protocol/fake_session.h" 10 #include "remoting/protocol/fake_session.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 protocol::FakeSession* session_; 57 protocol::FakeSession* session_;
58 58
59 private: 59 private:
60 DISALLOW_COPY_AND_ASSIGN(ConnectionToClientTest); 60 DISALLOW_COPY_AND_ASSIGN(ConnectionToClientTest);
61 }; 61 };
62 62
63 TEST_F(ConnectionToClientTest, SendUpdateStream) { 63 TEST_F(ConnectionToClientTest, SendUpdateStream) {
64 // Then send the actual data. 64 // Then send the actual data.
65 VideoPacket* packet = new VideoPacket(); 65 VideoPacket* packet = new VideoPacket();
66 viewer_->video_stub()->ProcessVideoPacket( 66 viewer_->video_stub()->ProcessVideoPacket(
67 packet, base::Bind(&DeletePointer<VideoPacket>, packet)); 67 packet, base::Bind(&base::DeletePointer<VideoPacket>, packet));
68 68
69 message_loop_.RunAllPending(); 69 message_loop_.RunAllPending();
70 70
71 // Verify that something has been written. 71 // Verify that something has been written.
72 // TODO(sergeyu): Verify that the correct data has been written. 72 // TODO(sergeyu): Verify that the correct data has been written.
73 ASSERT_TRUE(session_->GetStreamChannel(kVideoChannelName)); 73 ASSERT_TRUE(session_->GetStreamChannel(kVideoChannelName));
74 EXPECT_GT(session_->GetStreamChannel(kVideoChannelName)-> 74 EXPECT_GT(session_->GetStreamChannel(kVideoChannelName)->
75 written_data().size(), 0u); 75 written_data().size(), 0u);
76 76
77 // And then close the connection to ConnectionToClient. 77 // And then close the connection to ConnectionToClient.
78 viewer_->Disconnect(); 78 viewer_->Disconnect();
79 79
80 message_loop_.RunAllPending(); 80 message_loop_.RunAllPending();
81 } 81 }
82 82
83 TEST_F(ConnectionToClientTest, NoWriteAfterDisconnect) { 83 TEST_F(ConnectionToClientTest, NoWriteAfterDisconnect) {
84 // Then send the actual data. 84 // Then send the actual data.
85 VideoPacket* packet = new VideoPacket(); 85 VideoPacket* packet = new VideoPacket();
86 viewer_->video_stub()->ProcessVideoPacket( 86 viewer_->video_stub()->ProcessVideoPacket(
87 packet, base::Bind(&DeletePointer<VideoPacket>, packet)); 87 packet, base::Bind(&base::DeletePointer<VideoPacket>, packet));
88 88
89 // And then close the connection to ConnectionToClient. 89 // And then close the connection to ConnectionToClient.
90 viewer_->Disconnect(); 90 viewer_->Disconnect();
91 91
92 // The test will crash if data writer tries to write data to the 92 // The test will crash if data writer tries to write data to the
93 // channel socket. 93 // channel socket.
94 // TODO(sergeyu): Use MockSession to verify that no data is written? 94 // TODO(sergeyu): Use MockSession to verify that no data is written?
95 message_loop_.RunAllPending(); 95 message_loop_.RunAllPending();
96 } 96 }
97 97
98 TEST_F(ConnectionToClientTest, StateChange) { 98 TEST_F(ConnectionToClientTest, StateChange) {
99 EXPECT_CALL(handler_, OnConnectionClosed(viewer_.get())); 99 EXPECT_CALL(handler_, OnConnectionClosed(viewer_.get()));
100 session_->state_change_callback().Run(protocol::Session::CLOSED); 100 session_->state_change_callback().Run(protocol::Session::CLOSED);
101 message_loop_.RunAllPending(); 101 message_loop_.RunAllPending();
102 102
103 EXPECT_CALL(handler_, OnConnectionFailed( 103 EXPECT_CALL(handler_, OnConnectionFailed(
104 viewer_.get(), Session::SESSION_REJECTED)); 104 viewer_.get(), Session::SESSION_REJECTED));
105 session_->set_error(Session::SESSION_REJECTED); 105 session_->set_error(Session::SESSION_REJECTED);
106 session_->state_change_callback().Run(protocol::Session::FAILED); 106 session_->state_change_callback().Run(protocol::Session::FAILED);
107 message_loop_.RunAllPending(); 107 message_loop_.RunAllPending();
108 } 108 }
109 109
110 } // namespace protocol 110 } // namespace protocol
111 } // namespace remoting 111 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/protocol/client_control_dispatcher.cc ('k') | remoting/protocol/connection_to_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698