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

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

Issue 1472873005: Add VideoStream interface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@move_video_pump
Patch Set: Created 5 years 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "remoting/protocol/ice_connection_to_client.h" 5 #include "remoting/protocol/ice_connection_to_client.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "remoting/base/constants.h" 10 #include "remoting/base/constants.h"
(...skipping 11 matching lines...) Expand all
22 22
23 class IpcConnectionToClientTest : public testing::Test { 23 class IpcConnectionToClientTest : public testing::Test {
24 public: 24 public:
25 IpcConnectionToClientTest() {} 25 IpcConnectionToClientTest() {}
26 26
27 protected: 27 protected:
28 void SetUp() override { 28 void SetUp() override {
29 session_ = new FakeSession(); 29 session_ = new FakeSession();
30 30
31 // Allocate a ClientConnection object with the mock objects. 31 // Allocate a ClientConnection object with the mock objects.
32 viewer_.reset(new IceConnectionToClient(make_scoped_ptr(session_))); 32 viewer_.reset(new IceConnectionToClient(make_scoped_ptr(session_),
33 message_loop_.task_runner()));
33 viewer_->SetEventHandler(&handler_); 34 viewer_->SetEventHandler(&handler_);
34 EXPECT_CALL(handler_, OnConnectionAuthenticated(viewer_.get())) 35 EXPECT_CALL(handler_, OnConnectionAuthenticated(viewer_.get()))
35 .WillOnce( 36 .WillOnce(
36 InvokeWithoutArgs(this, &IpcConnectionToClientTest::ConnectStubs)); 37 InvokeWithoutArgs(this, &IpcConnectionToClientTest::ConnectStubs));
37 EXPECT_CALL(handler_, OnConnectionChannelsConnected(viewer_.get())); 38 EXPECT_CALL(handler_, OnConnectionChannelsConnected(viewer_.get()));
38 session_->event_handler()->OnSessionStateChange(Session::ACCEPTED); 39 session_->event_handler()->OnSessionStateChange(Session::ACCEPTED);
39 session_->event_handler()->OnSessionStateChange(Session::AUTHENTICATED); 40 session_->event_handler()->OnSessionStateChange(Session::AUTHENTICATED);
40 base::RunLoop().RunUntilIdle(); 41 base::RunLoop().RunUntilIdle();
41 } 42 }
42 43
(...skipping 15 matching lines...) Expand all
58 MockInputStub input_stub_; 59 MockInputStub input_stub_;
59 scoped_ptr<ConnectionToClient> viewer_; 60 scoped_ptr<ConnectionToClient> viewer_;
60 61
61 FakeSession* session_; 62 FakeSession* session_;
62 63
63 private: 64 private:
64 DISALLOW_COPY_AND_ASSIGN(IpcConnectionToClientTest); 65 DISALLOW_COPY_AND_ASSIGN(IpcConnectionToClientTest);
65 }; 66 };
66 67
67 TEST_F(IpcConnectionToClientTest, SendUpdateStream) { 68 TEST_F(IpcConnectionToClientTest, SendUpdateStream) {
68 scoped_ptr<VideoPacket> packet(new VideoPacket()); 69 Capabilities capabilities;
69 viewer_->video_stub()->ProcessVideoPacket(packet.Pass(), base::Closure()); 70 viewer_->client_stub()->SetCapabilities(capabilities);
70 71
71 base::RunLoop().RunUntilIdle(); 72 base::RunLoop().RunUntilIdle();
72 73
73 // Verify that something has been written. 74 // Verify that something has been written.
74 // TODO(sergeyu): Verify that the correct data has been written. 75 // TODO(sergeyu): Verify that the correct data has been written.
75 FakeStreamSocket* channel = 76 FakeStreamSocket* channel =
76 session_->GetTransport()->GetStreamChannelFactory()->GetFakeChannel( 77 session_->GetTransport()->GetStreamChannelFactory()->GetFakeChannel(
77 kVideoChannelName); 78 kControlChannelName);
78 ASSERT_TRUE(channel); 79 ASSERT_TRUE(channel);
79 EXPECT_FALSE(channel->written_data().empty()); 80 EXPECT_FALSE(channel->written_data().empty());
80 81
81 // And then close the connection to ConnectionToClient. 82 // And then close the connection to ConnectionToClient.
82 viewer_->Disconnect(protocol::OK); 83 viewer_->Disconnect(protocol::OK);
83 84
84 base::RunLoop().RunUntilIdle(); 85 base::RunLoop().RunUntilIdle();
85 } 86 }
86 87
87 TEST_F(IpcConnectionToClientTest, NoWriteAfterDisconnect) { 88 TEST_F(IpcConnectionToClientTest, NoWriteAfterDisconnect) {
88 scoped_ptr<VideoPacket> packet(new VideoPacket()); 89 Capabilities capabilities;
89 viewer_->video_stub()->ProcessVideoPacket(packet.Pass(), base::Closure()); 90 viewer_->client_stub()->SetCapabilities(capabilities);
90 91
91 // And then close the connection to ConnectionToClient. 92 // And then close the connection to ConnectionToClient.
92 viewer_->Disconnect(protocol::OK); 93 viewer_->Disconnect(protocol::OK);
93 94
94 // The test will crash if data writer tries to write data to the 95 // The test will crash if data writer tries to write data to the
95 // channel socket. 96 // channel socket.
96 // TODO(sergeyu): Use MockSession to verify that no data is written? 97 // TODO(sergeyu): Use MockSession to verify that no data is written?
97 base::RunLoop().RunUntilIdle(); 98 base::RunLoop().RunUntilIdle();
98 } 99 }
99 100
100 TEST_F(IpcConnectionToClientTest, StateChange) { 101 TEST_F(IpcConnectionToClientTest, StateChange) {
101 EXPECT_CALL(handler_, OnConnectionClosed(viewer_.get(), OK)); 102 EXPECT_CALL(handler_, OnConnectionClosed(viewer_.get(), OK));
102 session_->event_handler()->OnSessionStateChange(Session::CLOSED); 103 session_->event_handler()->OnSessionStateChange(Session::CLOSED);
103 base::RunLoop().RunUntilIdle(); 104 base::RunLoop().RunUntilIdle();
104 105
105 EXPECT_CALL(handler_, OnConnectionClosed(viewer_.get(), SESSION_REJECTED)); 106 EXPECT_CALL(handler_, OnConnectionClosed(viewer_.get(), SESSION_REJECTED));
106 session_->set_error(SESSION_REJECTED); 107 session_->set_error(SESSION_REJECTED);
107 session_->event_handler()->OnSessionStateChange(Session::FAILED); 108 session_->event_handler()->OnSessionStateChange(Session::FAILED);
108 base::RunLoop().RunUntilIdle(); 109 base::RunLoop().RunUntilIdle();
109 } 110 }
110 111
111 } // namespace protocol 112 } // namespace protocol
112 } // namespace remoting 113 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/protocol/ice_connection_to_client.cc ('k') | remoting/protocol/protocol_mock_objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698