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

Side by Side Diff: media/cast/rtcp/receiver_rtcp_event_subscriber_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
« no previous file with comments | « media/cast/rtcp/receiver_rtcp_event_subscriber.cc ('k') | media/cast/rtcp/rtcp.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/memory/ref_counted.h" 5 #include "base/memory/ref_counted.h"
6 #include "base/memory/scoped_ptr.h" 6 #include "base/memory/scoped_ptr.h"
7 #include "base/test/simple_test_tick_clock.h" 7 #include "base/test/simple_test_tick_clock.h"
8 #include "base/time/tick_clock.h" 8 #include "base/time/tick_clock.h"
9 #include "media/cast/cast_environment.h" 9 #include "media/cast/cast_environment.h"
10 #include "media/cast/logging/logging_defines.h" 10 #include "media/cast/logging/logging_defines.h"
(...skipping 24 matching lines...) Expand all
35 35
36 virtual ~ReceiverRtcpEventSubscriberTest() {} 36 virtual ~ReceiverRtcpEventSubscriberTest() {}
37 37
38 virtual void TearDown() OVERRIDE { 38 virtual void TearDown() OVERRIDE {
39 if (event_subscriber_) { 39 if (event_subscriber_) {
40 cast_environment_->Logging()->RemoveRawEventSubscriber( 40 cast_environment_->Logging()->RemoveRawEventSubscriber(
41 event_subscriber_.get()); 41 event_subscriber_.get());
42 } 42 }
43 } 43 }
44 44
45 void Init(ReceiverRtcpEventSubscriber::Type type) { 45 void Init(EventMediaType type) {
46 event_subscriber_.reset( 46 event_subscriber_.reset(
47 new ReceiverRtcpEventSubscriber(kMaxEventEntries, type)); 47 new ReceiverRtcpEventSubscriber(kMaxEventEntries, type));
48 cast_environment_->Logging()->AddRawEventSubscriber( 48 cast_environment_->Logging()->AddRawEventSubscriber(
49 event_subscriber_.get()); 49 event_subscriber_.get());
50 } 50 }
51 51
52 void InsertEvents() { 52 void InsertEvents() {
53 // Video events 53 // Video events
54 cast_environment_->Logging()->InsertFrameEventWithDelay( 54 cast_environment_->Logging()->InsertFrameEventWithDelay(
55 testing_clock_->NowTicks(), kVideoRenderDelay, /*rtp_timestamp*/ 100u, 55 testing_clock_->NowTicks(), FRAME_PLAYOUT, VIDEO_EVENT,
56 /*frame_id*/ 2u, base::TimeDelta::FromMilliseconds(kDelayMs)); 56 /*rtp_timestamp*/ 100u, /*frame_id*/ 2u,
57 base::TimeDelta::FromMilliseconds(kDelayMs));
57 cast_environment_->Logging()->InsertFrameEvent( 58 cast_environment_->Logging()->InsertFrameEvent(
58 testing_clock_->NowTicks(), kVideoFrameDecoded, /*rtp_timestamp*/ 200u, 59 testing_clock_->NowTicks(), FRAME_DECODED, VIDEO_EVENT,
59 /*frame_id*/ 1u); 60 /*rtp_timestamp*/ 200u, /*frame_id*/ 1u);
60 cast_environment_->Logging()->InsertPacketEvent( 61 cast_environment_->Logging()->InsertPacketEvent(
61 testing_clock_->NowTicks(), kVideoPacketReceived, 62 testing_clock_->NowTicks(), PACKET_RECEIVED, VIDEO_EVENT,
62 /*rtp_timestamp */ 200u, /*frame_id*/ 2u, /*packet_id*/ 1u, 63 /*rtp_timestamp */ 200u, /*frame_id*/ 2u, /*packet_id*/ 1u,
63 /*max_packet_id*/ 10u, /*size*/ 1024u); 64 /*max_packet_id*/ 10u, /*size*/ 1024u);
64 65
65 // Audio events 66 // Audio events
66 cast_environment_->Logging()->InsertFrameEventWithDelay( 67 cast_environment_->Logging()->InsertFrameEventWithDelay(
67 testing_clock_->NowTicks(), kAudioPlayoutDelay, /*rtp_timestamp*/ 300u, 68 testing_clock_->NowTicks(), FRAME_PLAYOUT, AUDIO_EVENT,
68 /*frame_id*/ 4u, base::TimeDelta::FromMilliseconds(kDelayMs)); 69 /*rtp_timestamp*/ 300u, /*frame_id*/ 4u,
70 base::TimeDelta::FromMilliseconds(kDelayMs));
69 cast_environment_->Logging()->InsertFrameEvent( 71 cast_environment_->Logging()->InsertFrameEvent(
70 testing_clock_->NowTicks(), kAudioFrameDecoded, /*rtp_timestamp*/ 400u, 72 testing_clock_->NowTicks(), FRAME_DECODED, AUDIO_EVENT,
71 /*frame_id*/ 3u); 73 /*rtp_timestamp*/ 400u, /*frame_id*/ 3u);
72 cast_environment_->Logging()->InsertPacketEvent( 74 cast_environment_->Logging()->InsertPacketEvent(
73 testing_clock_->NowTicks(), kAudioPacketReceived, 75 testing_clock_->NowTicks(), PACKET_RECEIVED, AUDIO_EVENT,
74 /*rtp_timestamp */ 400u, /*frame_id*/ 5u, /*packet_id*/ 1u, 76 /*rtp_timestamp */ 400u, /*frame_id*/ 5u, /*packet_id*/ 1u,
75 /*max_packet_id*/ 10u, /*size*/ 128u); 77 /*max_packet_id*/ 10u, /*size*/ 128u);
76 78
77 // Unrelated events 79 // Unrelated events
78 cast_environment_->Logging()->InsertFrameEvent(testing_clock_->NowTicks(), 80 cast_environment_->Logging()->InsertFrameEvent(testing_clock_->NowTicks(),
79 kVideoFrameCaptureEnd, 81 FRAME_CAPTURE_END,
82 VIDEO_EVENT,
80 /*rtp_timestamp*/ 100u, 83 /*rtp_timestamp*/ 100u,
81 /*frame_id*/ 1u); 84 /*frame_id*/ 1u);
82 cast_environment_->Logging()->InsertFrameEvent(testing_clock_->NowTicks(), 85 cast_environment_->Logging()->InsertFrameEvent(testing_clock_->NowTicks(),
83 kAudioFrameCaptureEnd, 86 FRAME_CAPTURE_END,
87 AUDIO_EVENT,
84 /*rtp_timestamp*/ 100u, 88 /*rtp_timestamp*/ 100u,
85 /*frame_id*/ 1u); 89 /*frame_id*/ 1u);
86 } 90 }
87 91
88 base::SimpleTestTickClock* testing_clock_; // Owned by CastEnvironment. 92 base::SimpleTestTickClock* testing_clock_; // Owned by CastEnvironment.
89 scoped_refptr<test::FakeSingleThreadTaskRunner> task_runner_; 93 scoped_refptr<test::FakeSingleThreadTaskRunner> task_runner_;
90 scoped_refptr<CastEnvironment> cast_environment_; 94 scoped_refptr<CastEnvironment> cast_environment_;
91 scoped_ptr<ReceiverRtcpEventSubscriber> event_subscriber_; 95 scoped_ptr<ReceiverRtcpEventSubscriber> event_subscriber_;
92 }; 96 };
93 97
94 TEST_F(ReceiverRtcpEventSubscriberTest, LogVideoEvents) { 98 TEST_F(ReceiverRtcpEventSubscriberTest, LogVideoEvents) {
95 Init(ReceiverRtcpEventSubscriber::kVideoEventSubscriber); 99 Init(VIDEO_EVENT);
96 100
97 InsertEvents(); 101 InsertEvents();
98 ReceiverRtcpEventSubscriber::RtcpEventMultiMap rtcp_events; 102 ReceiverRtcpEventSubscriber::RtcpEventMultiMap rtcp_events;
99 event_subscriber_->GetRtcpEventsAndReset(&rtcp_events); 103 event_subscriber_->GetRtcpEventsAndReset(&rtcp_events);
100 EXPECT_EQ(3u, rtcp_events.size()); 104 EXPECT_EQ(3u, rtcp_events.size());
101 } 105 }
102 106
103 TEST_F(ReceiverRtcpEventSubscriberTest, LogAudioEvents) { 107 TEST_F(ReceiverRtcpEventSubscriberTest, LogAudioEvents) {
104 Init(ReceiverRtcpEventSubscriber::kAudioEventSubscriber); 108 Init(AUDIO_EVENT);
105 109
106 InsertEvents(); 110 InsertEvents();
107 ReceiverRtcpEventSubscriber::RtcpEventMultiMap rtcp_events; 111 ReceiverRtcpEventSubscriber::RtcpEventMultiMap rtcp_events;
108 event_subscriber_->GetRtcpEventsAndReset(&rtcp_events); 112 event_subscriber_->GetRtcpEventsAndReset(&rtcp_events);
109 EXPECT_EQ(3u, rtcp_events.size()); 113 EXPECT_EQ(3u, rtcp_events.size());
110 } 114 }
111 115
112 TEST_F(ReceiverRtcpEventSubscriberTest, DropEventsWhenSizeExceeded) { 116 TEST_F(ReceiverRtcpEventSubscriberTest, DropEventsWhenSizeExceeded) {
113 Init(ReceiverRtcpEventSubscriber::kVideoEventSubscriber); 117 Init(VIDEO_EVENT);
114 118
115 for (uint32 i = 1u; i <= 10u; ++i) { 119 for (uint32 i = 1u; i <= 10u; ++i) {
116 cast_environment_->Logging()->InsertFrameEvent( 120 cast_environment_->Logging()->InsertFrameEvent(
117 testing_clock_->NowTicks(), kVideoFrameDecoded, 121 testing_clock_->NowTicks(), FRAME_DECODED, VIDEO_EVENT,
118 /*rtp_timestamp*/ i * 10, /*frame_id*/ i); 122 /*rtp_timestamp*/ i * 10, /*frame_id*/ i);
119 } 123 }
120 124
121 ReceiverRtcpEventSubscriber::RtcpEventMultiMap rtcp_events; 125 ReceiverRtcpEventSubscriber::RtcpEventMultiMap rtcp_events;
122 event_subscriber_->GetRtcpEventsAndReset(&rtcp_events); 126 event_subscriber_->GetRtcpEventsAndReset(&rtcp_events);
123 EXPECT_EQ(10u, rtcp_events.size()); 127 EXPECT_EQ(10u, rtcp_events.size());
124 } 128 }
125 129
126 } // namespace cast 130 } // namespace cast
127 } // namespace media 131 } // namespace media
OLDNEW
« no previous file with comments | « media/cast/rtcp/receiver_rtcp_event_subscriber.cc ('k') | media/cast/rtcp/rtcp.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698