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

Side by Side Diff: media/cast/logging/logging_impl_unittest.cc

Issue 178073004: Cast: IPC from browser to renderer to send packet events from transport to cast library. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 9 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/logging/logging_impl.cc ('k') | media/cast/logging/proto/proto_utils.cc » ('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 <vector> 5 #include <vector>
6 6
7 #include "base/rand_util.h" 7 #include "base/rand_util.h"
8 #include "base/test/simple_test_tick_clock.h" 8 #include "base/test/simple_test_tick_clock.h"
9 #include "base/time/tick_clock.h" 9 #include "base/time/tick_clock.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 const int kNumPacketsPerFrame = 10; 207 const int kNumPacketsPerFrame = 10;
208 const int kBaseSize = 2500; 208 const int kBaseSize = 2500;
209 const int kSizeInterval = 100; 209 const int kSizeInterval = 100;
210 base::TimeTicks start_time = testing_clock_.NowTicks(); 210 base::TimeTicks start_time = testing_clock_.NowTicks();
211 base::TimeDelta time_interval = testing_clock_.NowTicks() - start_time; 211 base::TimeDelta time_interval = testing_clock_.NowTicks() - start_time;
212 uint32 rtp_timestamp = 0; 212 uint32 rtp_timestamp = 0;
213 uint32 frame_id = 0; 213 uint32 frame_id = 0;
214 do { 214 do {
215 for (int i = 0; i < kNumPacketsPerFrame; ++i) { 215 for (int i = 0; i < kNumPacketsPerFrame; ++i) {
216 int size = kBaseSize + base::RandInt(-kSizeInterval, kSizeInterval); 216 int size = kBaseSize + base::RandInt(-kSizeInterval, kSizeInterval);
217 logging_->InsertPacketEvent(testing_clock_.NowTicks(), kPacketSentToPacer, 217 logging_->InsertPacketEvent(testing_clock_.NowTicks(),
218 rtp_timestamp, frame_id, i, 218 kVideoPacketSentToPacer,
219 kNumPacketsPerFrame, size); 219 rtp_timestamp,
220 frame_id,
221 i,
222 kNumPacketsPerFrame,
223 size);
220 } 224 }
221 testing_clock_.Advance(base::TimeDelta::FromMilliseconds(kFrameIntervalMs)); 225 testing_clock_.Advance(base::TimeDelta::FromMilliseconds(kFrameIntervalMs));
222 rtp_timestamp += kFrameIntervalMs * 90; 226 rtp_timestamp += kFrameIntervalMs * 90;
223 ++frame_id; 227 ++frame_id;
224 time_interval = testing_clock_.NowTicks() - start_time; 228 time_interval = testing_clock_.NowTicks() - start_time;
225 } while (time_interval.InSeconds() < kIntervalTime1S); 229 } while (time_interval.InSeconds() < kIntervalTime1S);
226 // Get logging data. 230 // Get logging data.
227 std::vector<PacketEvent> packet_events; 231 std::vector<PacketEvent> packet_events;
228 event_subscriber_.GetPacketEventsAndReset(&packet_events); 232 event_subscriber_.GetPacketEventsAndReset(&packet_events);
229 // Size of vector should be equal to the number of packets logged. 233 // Size of vector should be equal to the number of packets logged.
230 EXPECT_EQ(frame_id * kNumPacketsPerFrame, packet_events.size()); 234 EXPECT_EQ(frame_id * kNumPacketsPerFrame, packet_events.size());
231 // Verify stats. 235 // Verify stats.
232 PacketStatsMap stats_map = logging_->GetPacketStatsData(); 236 PacketStatsMap stats_map = logging_->GetPacketStatsData();
233 // Size of stats equals the number of events. 237 // Size of stats equals the number of events.
234 EXPECT_EQ(1u, stats_map.size()); 238 EXPECT_EQ(1u, stats_map.size());
235 PacketStatsMap::const_iterator it = stats_map.find(kPacketSentToPacer); 239 PacketStatsMap::const_iterator it = stats_map.find(kVideoPacketSentToPacer);
236 EXPECT_TRUE(it != stats_map.end()); 240 EXPECT_TRUE(it != stats_map.end());
237 } 241 }
238 242
239 TEST_F(LoggingImplTest, GenericLogging) { 243 TEST_F(LoggingImplTest, GenericLogging) {
240 // Insert multiple generic types. 244 // Insert multiple generic types.
241 const size_t kNumRuns = 20;//1000; 245 const size_t kNumRuns = 20;//1000;
242 const int kBaseValue = 20; 246 const int kBaseValue = 20;
243 int sum_value_rtt = 0; 247 int sum_value_rtt = 0;
244 int sum_value_pl = 0; 248 int sum_value_pl = 0;
245 int sum_value_jitter = 0; 249 int sum_value_jitter = 0;
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 EXPECT_EQ(1u, frame_events.size()); 343 EXPECT_EQ(1u, frame_events.size());
340 frame_events.clear(); 344 frame_events.clear();
341 event_subscriber_2.GetFrameEventsAndReset(&frame_events); 345 event_subscriber_2.GetFrameEventsAndReset(&frame_events);
342 EXPECT_EQ(1u, frame_events.size()); 346 EXPECT_EQ(1u, frame_events.size());
343 347
344 logging_->RemoveRawEventSubscriber(&event_subscriber_2); 348 logging_->RemoveRawEventSubscriber(&event_subscriber_2);
345 } 349 }
346 350
347 } // namespace cast 351 } // namespace cast
348 } // namespace media 352 } // namespace media
OLDNEW
« no previous file with comments | « media/cast/logging/logging_impl.cc ('k') | media/cast/logging/proto/proto_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698