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

Unified Diff: remoting/host/capture_scheduler_unittest.cc

Issue 850983002: Implement video frame acknowledgements in the chromoting protocol. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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/capture_scheduler.cc ('k') | remoting/host/client_session.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/host/capture_scheduler_unittest.cc
diff --git a/remoting/host/capture_scheduler_unittest.cc b/remoting/host/capture_scheduler_unittest.cc
index b07fc6daed5e48a7de6a2967aa472f9f380a0caa..95ddf6b27b7e995e8b8cf57d57494b0e6dceefdb 100644
--- a/remoting/host/capture_scheduler_unittest.cc
+++ b/remoting/host/capture_scheduler_unittest.cc
@@ -7,6 +7,7 @@
#include "base/message_loop/message_loop.h"
#include "base/test/simple_test_tick_clock.h"
#include "base/timer/mock_timer.h"
+#include "remoting/proto/video.pb.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace remoting {
@@ -47,9 +48,17 @@ class CaptureSchedulerTest : public testing::Test {
CheckCaptureCalled();
tick_clock_->Advance(capture_delay);
scheduler_->OnCaptureCompleted();
- scheduler_->OnFrameEncoded(encode_delay);
+
+ VideoPacket packet;
+ packet.set_encode_time_ms(encode_delay.InMilliseconds());
+ scheduler_->OnFrameEncoded(&packet);
+
scheduler_->OnFrameSent();
+ scoped_ptr<VideoAck> ack(new VideoAck());
+ ack->set_frame_id(packet.frame_id());
+ scheduler_->ProcessVideoAck(ack.Pass());
+
EXPECT_TRUE(capture_timer_->IsRunning());
EXPECT_EQ(std::max(base::TimeDelta(),
expected_delay_between_frames - capture_delay),
@@ -132,10 +141,16 @@ TEST_F(CaptureSchedulerTest, RollingAverageDifferentTimes) {
}
}
-// Verify that we never have more than 2 pending frames.
-TEST_F(CaptureSchedulerTest, MaximumPendingFrames) {
+// Verify that we never have more than 2 encoding frames.
+TEST_F(CaptureSchedulerTest, MaximumEncodingFrames) {
InitScheduler();
+ // Process the first frame to let the scheduler know that receiver supports
+ // ACKs.
+ SimulateSingleFrameCapture(
+ base::TimeDelta(), base::TimeDelta(),
+ base::TimeDelta::FromMilliseconds(kMinumumFrameIntervalMs));
+
capture_timer_->Fire();
CheckCaptureCalled();
scheduler_->OnCaptureCompleted();
@@ -145,11 +160,55 @@ TEST_F(CaptureSchedulerTest, MaximumPendingFrames) {
scheduler_->OnCaptureCompleted();
EXPECT_FALSE(capture_timer_->IsRunning());
+ VideoPacket packet;
+ scheduler_->OnFrameEncoded(&packet);
+ EXPECT_TRUE(capture_timer_->IsRunning());
+}
- scheduler_->OnFrameEncoded(base::TimeDelta());
- scheduler_->OnFrameSent();
+// Verify that the scheduler doesn't exceed maximum number of pending frames.
+TEST_F(CaptureSchedulerTest, MaximumPendingFrames) {
+ InitScheduler();
+ // Process the first frame to let the scheduler know that receiver supports
+ // ACKs.
+ SimulateSingleFrameCapture(
+ base::TimeDelta(), base::TimeDelta(),
+ base::TimeDelta::FromMilliseconds(kMinumumFrameIntervalMs));
+
+ // Queue some frames until the sender is blocked.
+ while (capture_timer_->IsRunning()) {
+ capture_timer_->Fire();
+ CheckCaptureCalled();
+ scheduler_->OnCaptureCompleted();
+ VideoPacket packet;
+ scheduler_->OnFrameEncoded(&packet);
+ scheduler_->OnFrameSent();
+ }
+
+ // Next frame should be scheduled, once one of the queued frames is
+ // acknowledged.
+ EXPECT_FALSE(capture_timer_->IsRunning());
+ scheduler_->ProcessVideoAck(make_scoped_ptr(new VideoAck()));
EXPECT_TRUE(capture_timer_->IsRunning());
}
+// Verify that the scheduler doesn't exceed maximum number of pending frames
+// when acks are not supported.
+TEST_F(CaptureSchedulerTest, MaximumPendingFramesNoAcks) {
+ InitScheduler();
+
+ // Queue some frames until the sender is blocked.
+ while (capture_timer_->IsRunning()) {
+ capture_timer_->Fire();
+ CheckCaptureCalled();
+ scheduler_->OnCaptureCompleted();
+ VideoPacket packet;
+ scheduler_->OnFrameEncoded(&packet);
+ }
+
+ // Next frame should be scheduled, once one of the queued frames is sent.
+ EXPECT_FALSE(capture_timer_->IsRunning());
+ scheduler_->OnFrameSent();
+ EXPECT_TRUE(capture_timer_->IsRunning());
+}
} // namespace remoting
« no previous file with comments | « remoting/host/capture_scheduler.cc ('k') | remoting/host/client_session.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698