| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/monitored_video_stub.h" | 5 #include "remoting/protocol/monitored_video_stub.h" |
| 6 | 6 |
| 7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "base/test/test_timeouts.h" | 9 #include "base/test/test_timeouts.h" |
| 10 #include "remoting/protocol/protocol_mock_objects.h" | 10 #include "remoting/protocol/protocol_mock_objects.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 scoped_ptr<VideoPacket> packet_; | 43 scoped_ptr<VideoPacket> packet_; |
| 44 base::OneShotTimer timer_end_test_; | 44 base::OneShotTimer timer_end_test_; |
| 45 }; | 45 }; |
| 46 | 46 |
| 47 TEST_F(MonitoredVideoStubTest, OnChannelConnected) { | 47 TEST_F(MonitoredVideoStubTest, OnChannelConnected) { |
| 48 EXPECT_CALL(*this, OnVideoChannelStatus(true)); | 48 EXPECT_CALL(*this, OnVideoChannelStatus(true)); |
| 49 // On slow machines, the connectivity check timer may fire before the test | 49 // On slow machines, the connectivity check timer may fire before the test |
| 50 // finishes, so we expect to see at most one transition to not ready. | 50 // finishes, so we expect to see at most one transition to not ready. |
| 51 EXPECT_CALL(*this, OnVideoChannelStatus(false)).Times(AtMost(1)); | 51 EXPECT_CALL(*this, OnVideoChannelStatus(false)).Times(AtMost(1)); |
| 52 | 52 |
| 53 monitor_->ProcessVideoPacket(packet_.Pass(), base::Closure()); | 53 monitor_->ProcessVideoPacket(std::move(packet_), base::Closure()); |
| 54 base::RunLoop().RunUntilIdle(); | 54 base::RunLoop().RunUntilIdle(); |
| 55 } | 55 } |
| 56 | 56 |
| 57 TEST_F(MonitoredVideoStubTest, OnChannelDisconnected) { | 57 TEST_F(MonitoredVideoStubTest, OnChannelDisconnected) { |
| 58 EXPECT_CALL(*this, OnVideoChannelStatus(true)); | 58 EXPECT_CALL(*this, OnVideoChannelStatus(true)); |
| 59 monitor_->ProcessVideoPacket(packet_.Pass(), base::Closure()); | 59 monitor_->ProcessVideoPacket(std::move(packet_), base::Closure()); |
| 60 | 60 |
| 61 EXPECT_CALL(*this, OnVideoChannelStatus(false)) | 61 EXPECT_CALL(*this, OnVideoChannelStatus(false)) |
| 62 .WillOnce( | 62 .WillOnce( |
| 63 InvokeWithoutArgs(&message_loop_, &base::MessageLoop::QuitWhenIdle)); | 63 InvokeWithoutArgs(&message_loop_, &base::MessageLoop::QuitWhenIdle)); |
| 64 message_loop_.Run(); | 64 message_loop_.Run(); |
| 65 } | 65 } |
| 66 | 66 |
| 67 TEST_F(MonitoredVideoStubTest, OnChannelStayConnected) { | 67 TEST_F(MonitoredVideoStubTest, OnChannelStayConnected) { |
| 68 // Verify no extra connected events are fired when packets are received | 68 // Verify no extra connected events are fired when packets are received |
| 69 // frequently | 69 // frequently |
| 70 EXPECT_CALL(*this, OnVideoChannelStatus(true)); | 70 EXPECT_CALL(*this, OnVideoChannelStatus(true)); |
| 71 // On slow machines, the connectivity check timer may fire before the test | 71 // On slow machines, the connectivity check timer may fire before the test |
| 72 // finishes, so we expect to see at most one transition to not ready. | 72 // finishes, so we expect to see at most one transition to not ready. |
| 73 EXPECT_CALL(*this, OnVideoChannelStatus(false)).Times(AtMost(1)); | 73 EXPECT_CALL(*this, OnVideoChannelStatus(false)).Times(AtMost(1)); |
| 74 | 74 |
| 75 monitor_->ProcessVideoPacket(packet_.Pass(), base::Closure()); | 75 monitor_->ProcessVideoPacket(std::move(packet_), base::Closure()); |
| 76 monitor_->ProcessVideoPacket(packet_.Pass(), base::Closure()); | 76 monitor_->ProcessVideoPacket(std::move(packet_), base::Closure()); |
| 77 base::RunLoop().RunUntilIdle(); | 77 base::RunLoop().RunUntilIdle(); |
| 78 } | 78 } |
| 79 | 79 |
| 80 TEST_F(MonitoredVideoStubTest, OnChannelStayDisconnected) { | 80 TEST_F(MonitoredVideoStubTest, OnChannelStayDisconnected) { |
| 81 // Verify no extra disconnected events are fired. | 81 // Verify no extra disconnected events are fired. |
| 82 EXPECT_CALL(*this, OnVideoChannelStatus(true)).Times(1); | 82 EXPECT_CALL(*this, OnVideoChannelStatus(true)).Times(1); |
| 83 EXPECT_CALL(*this, OnVideoChannelStatus(false)).Times(1); | 83 EXPECT_CALL(*this, OnVideoChannelStatus(false)).Times(1); |
| 84 | 84 |
| 85 monitor_->ProcessVideoPacket(packet_.Pass(), base::Closure()); | 85 monitor_->ProcessVideoPacket(std::move(packet_), base::Closure()); |
| 86 | 86 |
| 87 message_loop_.PostDelayedTask( | 87 message_loop_.PostDelayedTask( |
| 88 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), | 88 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), |
| 89 // The delay should be much greater than |kTestOverrideDelayMilliseconds|. | 89 // The delay should be much greater than |kTestOverrideDelayMilliseconds|. |
| 90 TestTimeouts::tiny_timeout()); | 90 TestTimeouts::tiny_timeout()); |
| 91 message_loop_.Run(); | 91 message_loop_.Run(); |
| 92 } | 92 } |
| 93 | 93 |
| 94 } // namespace protocol | 94 } // namespace protocol |
| 95 } // namespace remoting | 95 } // namespace remoting |
| OLD | NEW |