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

Unified Diff: remoting/protocol/connection_unittest.cc

Issue 2200273003: Enable video stats reporting when using WebRTC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address feedback Created 4 years, 4 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
Index: remoting/protocol/connection_unittest.cc
diff --git a/remoting/protocol/connection_unittest.cc b/remoting/protocol/connection_unittest.cc
index 4f7b3627e5f660c6abc1385ea6559569cd3931ba..380bba3adc1630b841627737566fa7ed00235c3c 100644
--- a/remoting/protocol/connection_unittest.cc
+++ b/remoting/protocol/connection_unittest.cc
@@ -223,15 +223,38 @@ class ConnectionTest : public testing::Test,
1U);
EXPECT_EQ(
client_video_renderer_.GetVideoStub()->received_packets().size(), 0U);
+ client_video_renderer_.GetFrameConsumer()->set_on_frame_callback(
+ base::Closure());
} else {
EXPECT_EQ(
client_video_renderer_.GetFrameConsumer()->received_frames().size(),
0U);
EXPECT_EQ(
client_video_renderer_.GetVideoStub()->received_packets().size(), 1U);
+ client_video_renderer_.GetVideoStub()->set_on_frame_callback(
+ base::Closure());
}
}
+ void WaitFirstFrameStats() {
+ if (!client_video_renderer_.GetFrameStatsConsumer()
+ ->received_stats()
+ .empty()) {
+ return;
+ }
+
+ base::RunLoop run_loop;
+ client_video_renderer_.GetFrameStatsConsumer()->set_on_stats_callback(
+ base::Bind(&base::RunLoop::Quit, base::Unretained(&run_loop)));
+ run_loop.Run();
+ client_video_renderer_.GetFrameStatsConsumer()->set_on_stats_callback(
+ base::Closure());
+
+ EXPECT_FALSE(client_video_renderer_.GetFrameStatsConsumer()
+ ->received_stats()
+ .empty());
+ }
+
base::MessageLoopForIO message_loop_;
std::unique_ptr<base::RunLoop> run_loop_;
@@ -369,5 +392,58 @@ TEST_P(ConnectionTest, DestroyOnIncomingMessage) {
run_loop.Run();
}
+TEST_P(ConnectionTest, VideoStats) {
+ // Currently this test only works for WebRTC because for ICE connections stats
+ // are reported by SoftwareVideoRenderer which is not used in this test.
+ // TODO(sergeyu): Fix this.
+ if (!is_using_webrtc())
+ return;
+
+ Connect();
+
+ base::TimeTicks start_time = base::TimeTicks::Now();
+
+ std::unique_ptr<VideoStream> video_stream =
+ host_connection_->StartVideoStream(
+ base::WrapUnique(new TestScreenCapturer()));
+
+ // Simulate an input invent injected at the start.
+ video_stream->OnInputEventReceived(start_time.ToInternalValue());
+
+ WaitFirstVideoFrame();
+
+ base::TimeTicks finish_time = base::TimeTicks::Now();
+
+ WaitFirstFrameStats();
+
+ const FrameStats& stats =
+ client_video_renderer_.GetFrameStatsConsumer()->received_stats().front();
+
+ EXPECT_TRUE(stats.host_stats.frame_size > 0);
+
+ EXPECT_TRUE(stats.host_stats.latest_event_timestamp == start_time);
+ EXPECT_TRUE(stats.host_stats.capture_delay != base::TimeDelta::Max());
+ EXPECT_TRUE(stats.host_stats.capture_overhead_delay !=
+ base::TimeDelta::Max());
+ EXPECT_TRUE(stats.host_stats.encode_delay != base::TimeDelta::Max());
+ EXPECT_TRUE(stats.host_stats.send_pending_delay != base::TimeDelta::Max());
+
+ EXPECT_FALSE(stats.client_stats.time_received.is_null());
+ EXPECT_FALSE(stats.client_stats.time_decoded.is_null());
+ EXPECT_FALSE(stats.client_stats.time_rendered.is_null());
+
+ EXPECT_TRUE(start_time + stats.host_stats.capture_pending_delay +
+ stats.host_stats.capture_delay +
+ stats.host_stats.capture_overhead_delay +
+ stats.host_stats.encode_delay +
+ stats.host_stats.send_pending_delay <=
+ stats.client_stats.time_received);
+ EXPECT_TRUE(stats.client_stats.time_received <=
+ stats.client_stats.time_decoded);
+ EXPECT_TRUE(stats.client_stats.time_decoded <=
+ stats.client_stats.time_rendered);
+ EXPECT_TRUE(stats.client_stats.time_rendered <= finish_time);
+}
+
} // namespace protocol
} // namespace remoting
« no previous file with comments | « no previous file | remoting/protocol/webrtc_connection_to_host.h » ('j') | remoting/protocol/webrtc_video_renderer_adapter.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698