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
3 // found in the LICENSE file.
5 #include "base/memory/ref_counted.h"
6 #include "base/memory/scoped_ptr.h"
7 #include "base/test/simple_test_tick_clock.h"
8 #include "base/time/tick_clock.h"
9 #include "media/cast/cast_environment.h"
10 #include "media/cast/logging/encoding_event_subscriber.h"
11 #include "media/cast/logging/logging_defines.h"
12 #include "media/cast/test/fake_single_thread_task_runner.h"
13 #include "testing/gtest/include/gtest/gtest.h"
15 using media::cast::proto::AggregatedFrameEvent
;
16 using media::cast::proto::AggregatedPacketEvent
;
17 using media::cast::proto::BasePacketEvent
;
18 using media::cast::proto::LogMetadata
;
22 int64
InMilliseconds(base::TimeTicks event_time
) {
23 return (event_time
- base::TimeTicks()).InMilliseconds();
31 class EncodingEventSubscriberTest
: public ::testing::Test
{
33 EncodingEventSubscriberTest()
34 : testing_clock_(new base::SimpleTestTickClock()),
35 task_runner_(new test::FakeSingleThreadTaskRunner(testing_clock_
)),
36 cast_environment_(new CastEnvironment(
37 scoped_ptr
<base::TickClock
>(testing_clock_
).Pass(),
41 first_rtp_timestamp_(0) {}
43 void Init(EventMediaType event_media_type
) {
44 DCHECK(!event_subscriber_
);
45 event_subscriber_
.reset(new EncodingEventSubscriber(event_media_type
, 10));
46 cast_environment_
->Logging()->AddRawEventSubscriber(
47 event_subscriber_
.get());
50 ~EncodingEventSubscriberTest() override
{
51 if (event_subscriber_
) {
52 cast_environment_
->Logging()->RemoveRawEventSubscriber(
53 event_subscriber_
.get());
57 void GetEventsAndReset() {
58 event_subscriber_
->GetEventsAndReset(
59 &metadata_
, &frame_events_
, &packet_events_
);
60 first_rtp_timestamp_
= metadata_
.first_rtp_timestamp();
63 base::SimpleTestTickClock
* testing_clock_
; // Owned by CastEnvironment.
64 scoped_refptr
<test::FakeSingleThreadTaskRunner
> task_runner_
;
65 scoped_refptr
<CastEnvironment
> cast_environment_
;
66 scoped_ptr
<EncodingEventSubscriber
> event_subscriber_
;
67 FrameEventList frame_events_
;
68 PacketEventList packet_events_
;
69 LogMetadata metadata_
;
70 RtpTimestamp first_rtp_timestamp_
;
73 TEST_F(EncodingEventSubscriberTest
, FrameEventTruncating
) {
76 base::TimeTicks
now(testing_clock_
->NowTicks());
78 // Entry with RTP timestamp 0 should get dropped.
81 for (int i
= 0; i
< 11; i
++) {
82 cast_environment_
->Logging()->InsertFrameEvent(now
,
87 cast_environment_
->Logging()->InsertCapturedVideoFrameEvent(now
,
91 cast_environment_
->Logging()->InsertFrameEvent(now
,
102 ASSERT_EQ(10u, frame_events_
.size());
103 EXPECT_EQ(100u, frame_events_
.front()->relative_rtp_timestamp());
104 EXPECT_EQ(1000u, frame_events_
.back()->relative_rtp_timestamp());
107 for (const auto& event
: frame_events_
) {
110 EXPECT_EQ(width
, event
->width());
111 EXPECT_EQ(height
, event
->height());
115 TEST_F(EncodingEventSubscriberTest
, PacketEventTruncating
) {
118 base::TimeTicks
now(testing_clock_
->NowTicks());
120 // Entry with RTP timestamp 0 should get dropped.
121 for (int i
= 0; i
< 11; i
++) {
122 cast_environment_
->Logging()->InsertPacketEvent(now
,
125 /*rtp_timestamp*/ i
* 100,
128 /*max_packet_id*/ 10,
134 ASSERT_EQ(10u, packet_events_
.size());
135 EXPECT_EQ(100u, packet_events_
.front()->relative_rtp_timestamp());
136 EXPECT_EQ(1000u, packet_events_
.back()->relative_rtp_timestamp());
139 TEST_F(EncodingEventSubscriberTest
, EventFiltering
) {
142 base::TimeTicks
now(testing_clock_
->NowTicks());
143 RtpTimestamp rtp_timestamp
= 100;
144 cast_environment_
->Logging()->InsertFrameEvent(now
,
150 // This is an AUDIO_EVENT and shouldn't be processed by the subscriber.
151 cast_environment_
->Logging()->InsertFrameEvent(now
,
159 ASSERT_EQ(1u, frame_events_
.size());
160 FrameEventList::iterator it
= frame_events_
.begin();
162 linked_ptr
<AggregatedFrameEvent
> frame_event
= *it
;
164 ASSERT_EQ(1, frame_event
->event_type_size());
165 EXPECT_EQ(media::cast::proto::FRAME_DECODED
,
166 frame_event
->event_type(0));
170 EXPECT_TRUE(packet_events_
.empty());
173 TEST_F(EncodingEventSubscriberTest
, FrameEvent
) {
175 base::TimeTicks
now(testing_clock_
->NowTicks());
176 RtpTimestamp rtp_timestamp
= 100;
177 cast_environment_
->Logging()->InsertFrameEvent(now
, FRAME_DECODED
,
184 ASSERT_EQ(1u, frame_events_
.size());
186 RtpTimestamp relative_rtp_timestamp
= rtp_timestamp
- first_rtp_timestamp_
;
187 FrameEventList::iterator it
= frame_events_
.begin();
189 linked_ptr
<AggregatedFrameEvent
> event
= *it
;
191 EXPECT_EQ(relative_rtp_timestamp
, event
->relative_rtp_timestamp());
193 ASSERT_EQ(1, event
->event_type_size());
194 EXPECT_EQ(media::cast::proto::FRAME_DECODED
, event
->event_type(0));
195 ASSERT_EQ(1, event
->event_timestamp_ms_size());
196 EXPECT_EQ(InMilliseconds(now
), event
->event_timestamp_ms(0));
198 EXPECT_EQ(0, event
->encoded_frame_size());
199 EXPECT_EQ(0, event
->delay_millis());
202 EXPECT_TRUE(frame_events_
.empty());
205 TEST_F(EncodingEventSubscriberTest
, FrameEventDelay
) {
207 base::TimeTicks
now(testing_clock_
->NowTicks());
208 RtpTimestamp rtp_timestamp
= 100;
210 cast_environment_
->Logging()->InsertFrameEventWithDelay(
211 now
, FRAME_PLAYOUT
, AUDIO_EVENT
, rtp_timestamp
,
212 /*frame_id*/ 0, base::TimeDelta::FromMilliseconds(delay_ms
));
216 ASSERT_EQ(1u, frame_events_
.size());
218 RtpTimestamp relative_rtp_timestamp
= rtp_timestamp
- first_rtp_timestamp_
;
219 FrameEventList::iterator it
= frame_events_
.begin();
221 linked_ptr
<AggregatedFrameEvent
> event
= *it
;
223 EXPECT_EQ(relative_rtp_timestamp
, event
->relative_rtp_timestamp());
225 ASSERT_EQ(1, event
->event_type_size());
226 EXPECT_EQ(media::cast::proto::FRAME_PLAYOUT
, event
->event_type(0));
227 ASSERT_EQ(1, event
->event_timestamp_ms_size());
228 EXPECT_EQ(InMilliseconds(now
), event
->event_timestamp_ms(0));
230 EXPECT_EQ(0, event
->encoded_frame_size());
231 EXPECT_EQ(100, event
->delay_millis());
232 EXPECT_FALSE(event
->has_key_frame());
235 TEST_F(EncodingEventSubscriberTest
, FrameEventSize
) {
237 base::TimeTicks
now(testing_clock_
->NowTicks());
238 RtpTimestamp rtp_timestamp
= 100;
240 bool key_frame
= true;
241 int target_bitrate
= 1024;
242 double encoder_cpu_utilization
= 0.90;
243 double idealized_bitrate_utilization
= 0.42;
244 cast_environment_
->Logging()->InsertEncodedFrameEvent(
245 now
, FRAME_ENCODED
, VIDEO_EVENT
, rtp_timestamp
,
246 /*frame_id*/ 0, size
, key_frame
, target_bitrate
,
247 encoder_cpu_utilization
, idealized_bitrate_utilization
);
251 ASSERT_EQ(1u, frame_events_
.size());
253 RtpTimestamp relative_rtp_timestamp
= rtp_timestamp
- first_rtp_timestamp_
;
254 FrameEventList::iterator it
= frame_events_
.begin();
256 linked_ptr
<AggregatedFrameEvent
> event
= *it
;
258 EXPECT_EQ(relative_rtp_timestamp
, event
->relative_rtp_timestamp());
260 ASSERT_EQ(1, event
->event_type_size());
261 EXPECT_EQ(media::cast::proto::FRAME_ENCODED
, event
->event_type(0));
262 ASSERT_EQ(1, event
->event_timestamp_ms_size());
263 EXPECT_EQ(InMilliseconds(now
), event
->event_timestamp_ms(0));
265 EXPECT_EQ(size
, event
->encoded_frame_size());
266 EXPECT_EQ(0, event
->delay_millis());
267 EXPECT_TRUE(event
->has_key_frame());
268 EXPECT_EQ(key_frame
, event
->key_frame());
269 EXPECT_EQ(target_bitrate
, event
->target_bitrate());
270 EXPECT_EQ(90, event
->encoder_cpu_percent_utilized());
271 EXPECT_EQ(42, event
->idealized_bitrate_percent_utilized());
274 TEST_F(EncodingEventSubscriberTest
, MultipleFrameEvents
) {
276 RtpTimestamp rtp_timestamp1
= 100;
277 RtpTimestamp rtp_timestamp2
= 200;
278 base::TimeTicks
now1(testing_clock_
->NowTicks());
279 cast_environment_
->Logging()->InsertFrameEventWithDelay(
280 now1
, FRAME_PLAYOUT
, AUDIO_EVENT
, rtp_timestamp1
,
281 /*frame_id*/ 0, /*delay*/ base::TimeDelta::FromMilliseconds(100));
283 testing_clock_
->Advance(base::TimeDelta::FromMilliseconds(20));
284 base::TimeTicks
now2(testing_clock_
->NowTicks());
285 cast_environment_
->Logging()->InsertEncodedFrameEvent(
286 now2
, FRAME_ENCODED
, AUDIO_EVENT
, rtp_timestamp2
,
287 /*frame_id*/ 0, /*size*/ 123, /* key_frame - unused */ false,
288 /*target_bitrate - unused*/ 0,
291 testing_clock_
->Advance(base::TimeDelta::FromMilliseconds(20));
292 base::TimeTicks
now3(testing_clock_
->NowTicks());
293 cast_environment_
->Logging()->InsertFrameEvent(
294 now3
, FRAME_DECODED
, AUDIO_EVENT
, rtp_timestamp1
, /*frame_id*/ 0);
298 ASSERT_EQ(2u, frame_events_
.size());
300 RtpTimestamp relative_rtp_timestamp
= rtp_timestamp1
- first_rtp_timestamp_
;
301 FrameEventList::iterator it
= frame_events_
.begin();
303 linked_ptr
<AggregatedFrameEvent
> event
= *it
;
305 EXPECT_EQ(relative_rtp_timestamp
, event
->relative_rtp_timestamp());
307 ASSERT_EQ(2, event
->event_type_size());
308 EXPECT_EQ(media::cast::proto::FRAME_PLAYOUT
, event
->event_type(0));
309 EXPECT_EQ(media::cast::proto::FRAME_DECODED
, event
->event_type(1));
311 ASSERT_EQ(2, event
->event_timestamp_ms_size());
312 EXPECT_EQ(InMilliseconds(now1
), event
->event_timestamp_ms(0));
313 EXPECT_EQ(InMilliseconds(now3
), event
->event_timestamp_ms(1));
315 EXPECT_FALSE(event
->has_key_frame());
317 relative_rtp_timestamp
= rtp_timestamp2
- first_rtp_timestamp_
;
322 EXPECT_EQ(relative_rtp_timestamp
, event
->relative_rtp_timestamp());
324 ASSERT_EQ(1, event
->event_type_size());
325 EXPECT_EQ(media::cast::proto::FRAME_ENCODED
, event
->event_type(0));
327 ASSERT_EQ(1, event
->event_timestamp_ms_size());
328 EXPECT_EQ(InMilliseconds(now2
), event
->event_timestamp_ms(0));
330 EXPECT_FALSE(event
->has_key_frame());
331 EXPECT_EQ(44, event
->encoder_cpu_percent_utilized());
332 EXPECT_EQ(55, event
->idealized_bitrate_percent_utilized());
335 TEST_F(EncodingEventSubscriberTest
, PacketEvent
) {
337 base::TimeTicks
now(testing_clock_
->NowTicks());
338 RtpTimestamp rtp_timestamp
= 100;
341 cast_environment_
->Logging()->InsertPacketEvent(
342 now
, PACKET_RECEIVED
, AUDIO_EVENT
,
343 rtp_timestamp
, /*frame_id*/ 0, packet_id
,
344 /*max_packet_id*/ 10, size
);
348 ASSERT_EQ(1u, packet_events_
.size());
350 RtpTimestamp relative_rtp_timestamp
= rtp_timestamp
- first_rtp_timestamp_
;
351 PacketEventList::iterator it
= packet_events_
.begin();
353 linked_ptr
<AggregatedPacketEvent
> event
= *it
;
355 EXPECT_EQ(relative_rtp_timestamp
, event
->relative_rtp_timestamp());
357 ASSERT_EQ(1, event
->base_packet_event_size());
358 const BasePacketEvent
& base_event
= event
->base_packet_event(0);
359 EXPECT_EQ(packet_id
, base_event
.packet_id());
360 ASSERT_EQ(1, base_event
.event_type_size());
361 EXPECT_EQ(media::cast::proto::PACKET_RECEIVED
,
362 base_event
.event_type(0));
363 ASSERT_EQ(1, base_event
.event_timestamp_ms_size());
364 EXPECT_EQ(InMilliseconds(now
), base_event
.event_timestamp_ms(0));
365 EXPECT_EQ(size
, base_event
.size());
368 EXPECT_TRUE(packet_events_
.empty());
371 TEST_F(EncodingEventSubscriberTest
, MultiplePacketEventsForPacket
) {
373 base::TimeTicks
now1(testing_clock_
->NowTicks());
374 RtpTimestamp rtp_timestamp
= 100;
377 cast_environment_
->Logging()->InsertPacketEvent(now1
,
378 PACKET_SENT_TO_NETWORK
,
383 /*max_packet_id*/ 10,
386 testing_clock_
->Advance(base::TimeDelta::FromMilliseconds(20));
387 base::TimeTicks
now2(testing_clock_
->NowTicks());
388 cast_environment_
->Logging()->InsertPacketEvent(now2
,
389 PACKET_RETRANSMITTED
,
394 /*max_packet_id*/ 10,
399 ASSERT_EQ(1u, packet_events_
.size());
401 RtpTimestamp relative_rtp_timestamp
= rtp_timestamp
- first_rtp_timestamp_
;
402 PacketEventList::iterator it
= packet_events_
.begin();
404 linked_ptr
<AggregatedPacketEvent
> event
= *it
;
406 EXPECT_EQ(relative_rtp_timestamp
, event
->relative_rtp_timestamp());
408 ASSERT_EQ(1, event
->base_packet_event_size());
409 const BasePacketEvent
& base_event
= event
->base_packet_event(0);
410 EXPECT_EQ(packet_id
, base_event
.packet_id());
411 ASSERT_EQ(2, base_event
.event_type_size());
412 EXPECT_EQ(media::cast::proto::PACKET_SENT_TO_NETWORK
,
413 base_event
.event_type(0));
414 EXPECT_EQ(media::cast::proto::PACKET_RETRANSMITTED
,
415 base_event
.event_type(1));
416 ASSERT_EQ(2, base_event
.event_timestamp_ms_size());
417 EXPECT_EQ(InMilliseconds(now1
), base_event
.event_timestamp_ms(0));
418 EXPECT_EQ(InMilliseconds(now2
), base_event
.event_timestamp_ms(1));
421 TEST_F(EncodingEventSubscriberTest
, MultiplePacketEventsForFrame
) {
423 base::TimeTicks
now1(testing_clock_
->NowTicks());
424 RtpTimestamp rtp_timestamp
= 100;
428 cast_environment_
->Logging()->InsertPacketEvent(now1
,
429 PACKET_SENT_TO_NETWORK
,
434 /*max_packet_id*/ 10,
437 testing_clock_
->Advance(base::TimeDelta::FromMilliseconds(20));
438 base::TimeTicks
now2(testing_clock_
->NowTicks());
439 cast_environment_
->Logging()->InsertPacketEvent(now2
,
440 PACKET_RETRANSMITTED
,
445 /*max_packet_id*/ 10,
450 ASSERT_EQ(1u, packet_events_
.size());
452 RtpTimestamp relative_rtp_timestamp
= rtp_timestamp
- first_rtp_timestamp_
;
453 PacketEventList::iterator it
= packet_events_
.begin();
455 linked_ptr
<AggregatedPacketEvent
> event
= *it
;
457 EXPECT_EQ(relative_rtp_timestamp
, event
->relative_rtp_timestamp());
459 ASSERT_EQ(2, event
->base_packet_event_size());
460 const BasePacketEvent
& base_event
= event
->base_packet_event(0);
461 EXPECT_EQ(packet_id_1
, base_event
.packet_id());
462 ASSERT_EQ(1, base_event
.event_type_size());
463 EXPECT_EQ(media::cast::proto::PACKET_SENT_TO_NETWORK
,
464 base_event
.event_type(0));
465 ASSERT_EQ(1, base_event
.event_timestamp_ms_size());
466 EXPECT_EQ(InMilliseconds(now1
), base_event
.event_timestamp_ms(0));
468 const BasePacketEvent
& base_event_2
= event
->base_packet_event(1);
469 EXPECT_EQ(packet_id_2
, base_event_2
.packet_id());
470 ASSERT_EQ(1, base_event_2
.event_type_size());
471 EXPECT_EQ(media::cast::proto::PACKET_RETRANSMITTED
,
472 base_event_2
.event_type(0));
473 ASSERT_EQ(1, base_event_2
.event_timestamp_ms_size());
474 EXPECT_EQ(InMilliseconds(now2
), base_event_2
.event_timestamp_ms(0));
477 TEST_F(EncodingEventSubscriberTest
, MultiplePacketEvents
) {
479 base::TimeTicks
now1(testing_clock_
->NowTicks());
480 RtpTimestamp rtp_timestamp_1
= 100;
481 RtpTimestamp rtp_timestamp_2
= 200;
485 cast_environment_
->Logging()->InsertPacketEvent(now1
,
486 PACKET_SENT_TO_NETWORK
,
491 /*max_packet_id*/ 10,
494 testing_clock_
->Advance(base::TimeDelta::FromMilliseconds(20));
495 base::TimeTicks
now2(testing_clock_
->NowTicks());
496 cast_environment_
->Logging()->InsertPacketEvent(now2
,
497 PACKET_RETRANSMITTED
,
502 /*max_packet_id*/ 10,
507 ASSERT_EQ(2u, packet_events_
.size());
509 RtpTimestamp relative_rtp_timestamp
= rtp_timestamp_1
- first_rtp_timestamp_
;
510 PacketEventList::iterator it
= packet_events_
.begin();
512 linked_ptr
<AggregatedPacketEvent
> event
= *it
;
514 EXPECT_EQ(relative_rtp_timestamp
, event
->relative_rtp_timestamp());
516 ASSERT_EQ(1, event
->base_packet_event_size());
517 const BasePacketEvent
& base_event
= event
->base_packet_event(0);
518 EXPECT_EQ(packet_id_1
, base_event
.packet_id());
519 ASSERT_EQ(1, base_event
.event_type_size());
520 EXPECT_EQ(media::cast::proto::PACKET_SENT_TO_NETWORK
,
521 base_event
.event_type(0));
522 ASSERT_EQ(1, base_event
.event_timestamp_ms_size());
523 EXPECT_EQ(InMilliseconds(now1
), base_event
.event_timestamp_ms(0));
525 relative_rtp_timestamp
= rtp_timestamp_2
- first_rtp_timestamp_
;
527 ASSERT_TRUE(it
!= packet_events_
.end());
530 EXPECT_EQ(relative_rtp_timestamp
, event
->relative_rtp_timestamp());
532 ASSERT_EQ(1, event
->base_packet_event_size());
533 const BasePacketEvent
& base_event_2
= event
->base_packet_event(0);
534 EXPECT_EQ(packet_id_2
, base_event_2
.packet_id());
535 ASSERT_EQ(1, base_event_2
.event_type_size());
536 EXPECT_EQ(media::cast::proto::PACKET_RETRANSMITTED
,
537 base_event_2
.event_type(0));
538 ASSERT_EQ(1, base_event_2
.event_timestamp_ms_size());
539 EXPECT_EQ(InMilliseconds(now2
), base_event_2
.event_timestamp_ms(0));
542 TEST_F(EncodingEventSubscriberTest
, FirstRtpTimestamp
) {
544 RtpTimestamp rtp_timestamp
= 12345;
545 base::TimeTicks
now(testing_clock_
->NowTicks());
547 cast_environment_
->Logging()->InsertFrameEvent(now
,
553 cast_environment_
->Logging()->InsertCapturedVideoFrameEvent(
560 EXPECT_EQ(rtp_timestamp
, first_rtp_timestamp_
);
561 FrameEventList::iterator it
= frame_events_
.begin();
562 ASSERT_NE(frame_events_
.end(), it
);
563 EXPECT_EQ(0u, (*it
)->relative_rtp_timestamp());
566 ASSERT_NE(frame_events_
.end(), it
);
567 EXPECT_EQ(30u, (*it
)->relative_rtp_timestamp());
568 EXPECT_EQ(1280, (*it
)->width());
569 EXPECT_EQ(720, (*it
)->height());
571 rtp_timestamp
= 67890;
573 cast_environment_
->Logging()->InsertFrameEvent(now
,
580 EXPECT_EQ(rtp_timestamp
, first_rtp_timestamp_
);
583 TEST_F(EncodingEventSubscriberTest
, RelativeRtpTimestampWrapAround
) {
585 RtpTimestamp rtp_timestamp
= 0xffffffff - 20;
586 base::TimeTicks
now(testing_clock_
->NowTicks());
588 cast_environment_
->Logging()->InsertFrameEvent(now
,
594 // RtpTimestamp has now wrapped around.
595 cast_environment_
->Logging()->InsertCapturedVideoFrameEvent(
602 FrameEventList::iterator it
= frame_events_
.begin();
603 ASSERT_NE(frame_events_
.end(), it
);
604 EXPECT_EQ(0u, (*it
)->relative_rtp_timestamp());
607 ASSERT_NE(frame_events_
.end(), it
);
608 EXPECT_EQ(30u, (*it
)->relative_rtp_timestamp());
609 EXPECT_EQ(1280, (*it
)->width());
610 EXPECT_EQ(720, (*it
)->height());
613 TEST_F(EncodingEventSubscriberTest
, MaxEventsPerProto
) {
615 RtpTimestamp rtp_timestamp
= 100;
616 for (int i
= 0; i
< kMaxEventsPerProto
+ 1; i
++) {
617 cast_environment_
->Logging()->InsertFrameEvent(testing_clock_
->NowTicks(),
622 testing_clock_
->Advance(base::TimeDelta::FromMilliseconds(30));
627 ASSERT_EQ(2u, frame_events_
.size());
628 FrameEventList::iterator frame_it
= frame_events_
.begin();
629 ASSERT_TRUE(frame_it
!= frame_events_
.end());
631 linked_ptr
<AggregatedFrameEvent
> frame_event
= *frame_it
;
633 EXPECT_EQ(kMaxEventsPerProto
, frame_event
->event_type_size());
635 for (int i
= 0; i
< kMaxPacketsPerFrame
+ 1; i
++) {
636 cast_environment_
->Logging()->InsertPacketEvent(
637 testing_clock_
->NowTicks(),
638 PACKET_SENT_TO_NETWORK
,
645 testing_clock_
->Advance(base::TimeDelta::FromMilliseconds(30));
650 EXPECT_EQ(2u, packet_events_
.size());
652 PacketEventList::iterator packet_it
= packet_events_
.begin();
653 ASSERT_TRUE(packet_it
!= packet_events_
.end());
655 linked_ptr
<AggregatedPacketEvent
> packet_event
= *packet_it
;
657 EXPECT_EQ(kMaxPacketsPerFrame
,
658 packet_event
->base_packet_event_size());
661 packet_event
= *packet_it
;
662 EXPECT_EQ(1, packet_event
->base_packet_event_size());
664 for (int j
= 0; j
< kMaxEventsPerProto
+ 1; j
++) {
665 cast_environment_
->Logging()->InsertPacketEvent(
666 testing_clock_
->NowTicks(),
667 PACKET_SENT_TO_NETWORK
,
674 testing_clock_
->Advance(base::TimeDelta::FromMilliseconds(30));
679 EXPECT_EQ(2u, packet_events_
.size());
680 packet_it
= packet_events_
.begin();
681 ASSERT_TRUE(packet_it
!= packet_events_
.end());
683 packet_event
= *packet_it
;
685 EXPECT_EQ(kMaxEventsPerProto
,
686 packet_event
->base_packet_event(0).event_type_size());
689 packet_event
= *packet_it
;
690 EXPECT_EQ(1, packet_event
->base_packet_event(0).event_type_size());