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

Side by Side Diff: media/cast/test/end2end_unittest.cc

Issue 270493003: Cast: Deduplicate event types in cast library. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 // This test generate synthetic data. For audio it's a sinusoid waveform with 5 // This test generate synthetic data. For audio it's a sinusoid waveform with
6 // frequency kSoundFrequency and different amplitudes. For video it's a pattern 6 // frequency kSoundFrequency and different amplitudes. For video it's a pattern
7 // that is shifting by one pixel per frame, each pixels neighbors right and down 7 // that is shifting by one pixel per frame, each pixels neighbors right and down
8 // is this pixels value +1, since the pixel value is 8 bit it will wrap 8 // is this pixels value +1, since the pixel value is 8 bit it will wrap
9 // frequently within the image. Visually this will create diagonally color bands 9 // frequently within the image. Visually this will create diagonally color bands
10 // that moves across the screen 10 // that moves across the screen
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 void AudioInitializationStatus(CastInitializationStatus status) { 102 void AudioInitializationStatus(CastInitializationStatus status) {
103 EXPECT_EQ(STATUS_AUDIO_INITIALIZED, status); 103 EXPECT_EQ(STATUS_AUDIO_INITIALIZED, status);
104 } 104 }
105 105
106 void VideoInitializationStatus(CastInitializationStatus status) { 106 void VideoInitializationStatus(CastInitializationStatus status) {
107 EXPECT_EQ(STATUS_VIDEO_INITIALIZED, status); 107 EXPECT_EQ(STATUS_VIDEO_INITIALIZED, status);
108 } 108 }
109 109
110 // This is wrapped in a struct because it needs to be put into a std::map. 110 // This is wrapped in a struct because it needs to be put into a std::map.
111 typedef struct { 111 typedef struct {
112 int counter[kNumOfLoggingEvents]; 112 int counter[kNumOfLoggingEvents+1];
113 } LoggingEventCounts; 113 } LoggingEventCounts;
114 114
115 // Constructs a map from each frame (RTP timestamp) to counts of each event 115 // Constructs a map from each frame (RTP timestamp) to counts of each event
116 // type logged for that frame. 116 // type logged for that frame.
117 std::map<RtpTimestamp, LoggingEventCounts> GetEventCountForFrameEvents( 117 std::map<RtpTimestamp, LoggingEventCounts> GetEventCountForFrameEvents(
118 const std::vector<FrameEvent>& frame_events) { 118 const std::vector<FrameEvent>& frame_events) {
119 std::map<RtpTimestamp, LoggingEventCounts> event_counter_for_frame; 119 std::map<RtpTimestamp, LoggingEventCounts> event_counter_for_frame;
120 for (std::vector<FrameEvent>::const_iterator it = frame_events.begin(); 120 for (std::vector<FrameEvent>::const_iterator it = frame_events.begin();
121 it != frame_events.end(); 121 it != frame_events.end();
122 ++it) { 122 ++it) {
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
631 } 631 }
632 632
633 void LogRawEvents(const std::vector<PacketEvent>& packet_events) { 633 void LogRawEvents(const std::vector<PacketEvent>& packet_events) {
634 EXPECT_FALSE(packet_events.empty()); 634 EXPECT_FALSE(packet_events.empty());
635 for (std::vector<media::cast::PacketEvent>::const_iterator it = 635 for (std::vector<media::cast::PacketEvent>::const_iterator it =
636 packet_events.begin(); 636 packet_events.begin();
637 it != packet_events.end(); 637 it != packet_events.end();
638 ++it) { 638 ++it) {
639 cast_environment_sender_->Logging()->InsertPacketEvent(it->timestamp, 639 cast_environment_sender_->Logging()->InsertPacketEvent(it->timestamp,
640 it->type, 640 it->type,
641 it->media_type,
641 it->rtp_timestamp, 642 it->rtp_timestamp,
642 it->frame_id, 643 it->frame_id,
643 it->packet_id, 644 it->packet_id,
644 it->max_packet_id, 645 it->max_packet_id,
645 it->size); 646 it->size);
646 } 647 }
647 } 648 }
648 649
649 AudioReceiverConfig audio_receiver_config_; 650 AudioReceiverConfig audio_receiver_config_;
650 VideoReceiverConfig video_receiver_config_; 651 VideoReceiverConfig video_receiver_config_;
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
1078 1079
1079 // Verify that there are logs for expected number of frames. 1080 // Verify that there are logs for expected number of frames.
1080 EXPECT_EQ(num_frames, static_cast<int>(event_counter_for_frame.size())); 1081 EXPECT_EQ(num_frames, static_cast<int>(event_counter_for_frame.size()));
1081 1082
1082 // Verify that each frame have the expected types of events logged. 1083 // Verify that each frame have the expected types of events logged.
1083 for (std::map<RtpTimestamp, LoggingEventCounts>::iterator map_it = 1084 for (std::map<RtpTimestamp, LoggingEventCounts>::iterator map_it =
1084 event_counter_for_frame.begin(); 1085 event_counter_for_frame.begin();
1085 map_it != event_counter_for_frame.end(); 1086 map_it != event_counter_for_frame.end();
1086 ++map_it) { 1087 ++map_it) {
1087 int total_event_count_for_frame = 0; 1088 int total_event_count_for_frame = 0;
1088 for (int i = 0; i < kNumOfLoggingEvents; ++i) { 1089 for (int i = 0; i <= kNumOfLoggingEvents; ++i) {
1089 total_event_count_for_frame += map_it->second.counter[i]; 1090 total_event_count_for_frame += map_it->second.counter[i];
1090 } 1091 }
1091 1092
1092 int expected_event_count_for_frame = 0; 1093 int expected_event_count_for_frame = 0;
1093 1094
1094 EXPECT_EQ(1, map_it->second.counter[kVideoFrameCaptureBegin]); 1095 EXPECT_EQ(1, map_it->second.counter[FRAME_CAPTURE_BEGIN]);
1095 expected_event_count_for_frame += 1096 expected_event_count_for_frame +=
1096 map_it->second.counter[kVideoFrameCaptureBegin]; 1097 map_it->second.counter[FRAME_CAPTURE_BEGIN];
1097 1098
1098 EXPECT_EQ(1, map_it->second.counter[kVideoFrameEncoded]); 1099 EXPECT_EQ(1, map_it->second.counter[FRAME_CAPTURE_END]);
1099 expected_event_count_for_frame += 1100 expected_event_count_for_frame +=
1100 map_it->second.counter[kVideoFrameEncoded]; 1101 map_it->second.counter[FRAME_CAPTURE_END];
1101 1102
1102 EXPECT_EQ(1, map_it->second.counter[kVideoFrameCaptureEnd]); 1103 EXPECT_EQ(1, map_it->second.counter[FRAME_ENCODED]);
1103 expected_event_count_for_frame += 1104 expected_event_count_for_frame +=
1104 map_it->second.counter[kVideoFrameCaptureEnd]; 1105 map_it->second.counter[FRAME_ENCODED];
1105 1106
1106 EXPECT_EQ(1, map_it->second.counter[kVideoRenderDelay]); 1107 EXPECT_EQ(1, map_it->second.counter[FRAME_DECODED]);
1107 expected_event_count_for_frame += map_it->second.counter[kVideoRenderDelay]; 1108 expected_event_count_for_frame +=
1109 map_it->second.counter[FRAME_DECODED];
1108 1110
1109 EXPECT_EQ(1, map_it->second.counter[kVideoFrameDecoded]); 1111 EXPECT_EQ(1, map_it->second.counter[FRAME_PLAYOUT]);
1112 expected_event_count_for_frame += map_it->second.counter[FRAME_PLAYOUT];
1113
1114
1115 // There is no guarantee that FRAME_ACK_SENT is loggeed exactly once per
1116 // frame.
1117 EXPECT_GT(map_it->second.counter[FRAME_ACK_SENT], 0);
1118 expected_event_count_for_frame += map_it->second.counter[FRAME_ACK_SENT];
1119
1120 // There is no guarantee that FRAME_ACK_RECEIVED is loggeed exactly once per
1121 // frame.
1122 EXPECT_GT(map_it->second.counter[FRAME_ACK_RECEIVED], 0);
1110 expected_event_count_for_frame += 1123 expected_event_count_for_frame +=
1111 map_it->second.counter[kVideoFrameDecoded]; 1124 map_it->second.counter[FRAME_ACK_RECEIVED];
1112
1113 // There is no guarantee that kVideoAckSent is loggeed exactly once per
1114 // frame.
1115 EXPECT_GT(map_it->second.counter[kVideoAckSent], 0);
1116 expected_event_count_for_frame += map_it->second.counter[kVideoAckSent];
1117
1118 // There is no guarantee that kVideoAckReceived is loggeed exactly once per
1119 // frame.
1120 EXPECT_GT(map_it->second.counter[kVideoAckReceived], 0);
1121 expected_event_count_for_frame += map_it->second.counter[kVideoAckReceived];
1122 1125
1123 // Verify that there were no other events logged with respect to this 1126 // Verify that there were no other events logged with respect to this
1124 // frame. 1127 // frame.
1125 // (i.e. Total event count = expected event count) 1128 // (i.e. Total event count = expected event count)
1126 EXPECT_EQ(total_event_count_for_frame, expected_event_count_for_frame); 1129 EXPECT_EQ(total_event_count_for_frame, expected_event_count_for_frame);
1127 } 1130 }
1128 1131
1129 // Packet logging. 1132 // Packet logging.
1130 // Verify that all packet related events were logged. 1133 // Verify that all packet related events were logged.
1131 event_subscriber_sender_.GetPacketEventsAndReset(&packet_events_); 1134 event_subscriber_sender_.GetPacketEventsAndReset(&packet_events_);
1132 std::map<uint16, LoggingEventCounts> event_count_for_packet = 1135 std::map<uint16, LoggingEventCounts> event_count_for_packet =
1133 GetEventCountForPacketEvents(packet_events_); 1136 GetEventCountForPacketEvents(packet_events_);
1134 1137
1135 // Verify that each packet have the expected types of events logged. 1138 // Verify that each packet have the expected types of events logged.
1136 for (std::map<uint16, LoggingEventCounts>::iterator map_it = 1139 for (std::map<uint16, LoggingEventCounts>::iterator map_it =
1137 event_count_for_packet.begin(); 1140 event_count_for_packet.begin();
1138 map_it != event_count_for_packet.end(); 1141 map_it != event_count_for_packet.end();
1139 ++map_it) { 1142 ++map_it) {
1140 int total_event_count_for_packet = 0; 1143 int total_event_count_for_packet = 0;
1141 for (int i = 0; i < kNumOfLoggingEvents; ++i) { 1144 for (int i = 0; i <= kNumOfLoggingEvents; ++i) {
1142 total_event_count_for_packet += map_it->second.counter[i]; 1145 total_event_count_for_packet += map_it->second.counter[i];
1143 } 1146 }
1144 1147
1145 int expected_event_count_for_packet = 0; 1148 int expected_event_count_for_packet = 0;
1146 EXPECT_GT(map_it->second.counter[kVideoPacketReceived], 0); 1149 EXPECT_GT(map_it->second.counter[PACKET_RECEIVED], 0);
1147 expected_event_count_for_packet += 1150 expected_event_count_for_packet +=
1148 map_it->second.counter[kVideoPacketReceived]; 1151 map_it->second.counter[PACKET_RECEIVED];
1149 1152
1150 // Verify that there were no other events logged with respect to this 1153 // Verify that there were no other events logged with respect to this
1151 // packet. (i.e. Total event count = expected event count) 1154 // packet. (i.e. Total event count = expected event count)
1152 EXPECT_EQ(total_event_count_for_packet, expected_event_count_for_packet); 1155 EXPECT_EQ(total_event_count_for_packet, expected_event_count_for_packet);
1153 } 1156 }
1154 } 1157 }
1155 1158
1156 // Audio test without packet loss - tests the logging aspects of the end2end, 1159 // Audio test without packet loss - tests the logging aspects of the end2end,
1157 // but is basically equivalent to LoopNoLossPcm16. 1160 // but is basically equivalent to LoopNoLossPcm16.
1158 TEST_F(End2EndTest, AudioLogging) { 1161 TEST_F(End2EndTest, AudioLogging) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1190 std::map<RtpTimestamp, LoggingEventCounts> event_counter_for_frame = 1193 std::map<RtpTimestamp, LoggingEventCounts> event_counter_for_frame =
1191 GetEventCountForFrameEvents(frame_events_); 1194 GetEventCountForFrameEvents(frame_events_);
1192 1195
1193 int encoded_count = 0; 1196 int encoded_count = 0;
1194 1197
1195 // Verify the right number of events were logged for each event type. 1198 // Verify the right number of events were logged for each event type.
1196 for (std::map<RtpTimestamp, LoggingEventCounts>::iterator it = 1199 for (std::map<RtpTimestamp, LoggingEventCounts>::iterator it =
1197 event_counter_for_frame.begin(); 1200 event_counter_for_frame.begin();
1198 it != event_counter_for_frame.end(); 1201 it != event_counter_for_frame.end();
1199 ++it) { 1202 ++it) {
1200 encoded_count += it->second.counter[kAudioFrameEncoded]; 1203 encoded_count += it->second.counter[FRAME_ENCODED];
1201 } 1204 }
1202 1205
1203 EXPECT_EQ(num_audio_frames_requested, encoded_count); 1206 EXPECT_EQ(num_audio_frames_requested, encoded_count);
1204 1207
1205 // Verify that each frame have the expected types of events logged. 1208 // Verify that each frame have the expected types of events logged.
1206 for (std::map<RtpTimestamp, LoggingEventCounts>::const_iterator map_it = 1209 for (std::map<RtpTimestamp, LoggingEventCounts>::const_iterator map_it =
1207 event_counter_for_frame.begin(); 1210 event_counter_for_frame.begin();
1208 map_it != event_counter_for_frame.end(); ++map_it) { 1211 map_it != event_counter_for_frame.end(); ++map_it) {
1209 int total_event_count_for_frame = 0; 1212 int total_event_count_for_frame = 0;
1210 for (int j = 0; j < kNumOfLoggingEvents; ++j) 1213 for (int j = 0; j <= kNumOfLoggingEvents; ++j)
1211 total_event_count_for_frame += map_it->second.counter[j]; 1214 total_event_count_for_frame += map_it->second.counter[j];
1212 1215
1213 int expected_event_count_for_frame = 0; 1216 int expected_event_count_for_frame = 0;
1214 1217
1215 EXPECT_EQ(1, map_it->second.counter[kAudioFrameEncoded]); 1218 EXPECT_EQ(1, map_it->second.counter[FRAME_ENCODED]);
1216 expected_event_count_for_frame += 1219 expected_event_count_for_frame +=
1217 map_it->second.counter[kAudioFrameEncoded]; 1220 map_it->second.counter[FRAME_ENCODED];
1218 1221
1219 EXPECT_EQ(1, map_it->second.counter[kAudioPlayoutDelay]); 1222 EXPECT_EQ(1, map_it->second.counter[FRAME_PLAYOUT]);
1220 expected_event_count_for_frame += 1223 expected_event_count_for_frame +=
1221 map_it->second.counter[kAudioPlayoutDelay]; 1224 map_it->second.counter[FRAME_PLAYOUT];
1222 1225
1223 EXPECT_EQ(1, map_it->second.counter[kAudioFrameDecoded]); 1226 EXPECT_EQ(1, map_it->second.counter[FRAME_DECODED]);
1224 expected_event_count_for_frame += 1227 expected_event_count_for_frame +=
1225 map_it->second.counter[kAudioFrameDecoded]; 1228 map_it->second.counter[FRAME_DECODED];
1226 1229
1227 EXPECT_GT(map_it->second.counter[kAudioAckSent], 0); 1230 EXPECT_GT(map_it->second.counter[FRAME_ACK_SENT], 0);
1228 expected_event_count_for_frame += map_it->second.counter[kAudioAckSent]; 1231 expected_event_count_for_frame += map_it->second.counter[FRAME_ACK_SENT];
1229 1232
1230 // Verify that there were no other events logged with respect to this frame. 1233 // Verify that there were no other events logged with respect to this frame.
1231 // (i.e. Total event count = expected event count) 1234 // (i.e. Total event count = expected event count)
1232 EXPECT_EQ(total_event_count_for_frame, expected_event_count_for_frame); 1235 EXPECT_EQ(total_event_count_for_frame, expected_event_count_for_frame);
1233 } 1236 }
1234 } 1237 }
1235 1238
1236 TEST_F(End2EndTest, BasicFakeSoftwareVideo) { 1239 TEST_F(End2EndTest, BasicFakeSoftwareVideo) {
1237 Configure(transport::kFakeSoftwareVideo, transport::kPcm16, 32000, false, 1); 1240 Configure(transport::kFakeSoftwareVideo, transport::kPcm16, 32000, false, 1);
1238 Create(); 1241 Create();
(...skipping 10 matching lines...) Expand all
1249 EXPECT_EQ(1000, received_counter); 1252 EXPECT_EQ(1000, received_counter);
1250 } 1253 }
1251 1254
1252 // TODO(pwestin): Add repeatable packet loss test. 1255 // TODO(pwestin): Add repeatable packet loss test.
1253 // TODO(pwestin): Add test for misaligned send get calls. 1256 // TODO(pwestin): Add test for misaligned send get calls.
1254 // TODO(pwestin): Add more tests that does not resample. 1257 // TODO(pwestin): Add more tests that does not resample.
1255 // TODO(pwestin): Add test when we have starvation for our RunTask. 1258 // TODO(pwestin): Add test when we have starvation for our RunTask.
1256 1259
1257 } // namespace cast 1260 } // namespace cast
1258 } // namespace media 1261 } // namespace media
OLDNEW
« no previous file with comments | « media/cast/rtcp/sender_rtcp_event_subscriber_unittest.cc ('k') | media/cast/transport/pacing/paced_sender.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698