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