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
3 // found in the LICENSE file.
5 #include "media/cast/transport/rtp_sender/packet_storage/packet_storage.h"
11 #include "base/test/simple_test_tick_clock.h"
12 #include "base/time/time.h"
13 #include "testing/gmock/include/gmock/gmock.h"
19 static int kStoredFrames = 10;
21 class PacketStorageTest : public ::testing::Test {
23 PacketStorageTest() : packet_storage_(kStoredFrames) {
26 PacketStorage packet_storage_;
28 DISALLOW_COPY_AND_ASSIGN(PacketStorageTest);
31 TEST_F(PacketStorageTest, PacketContent) {
32 base::TimeTicks frame_tick;
33 for (uint32 frame_id = 0; frame_id < 200; ++frame_id) {
34 for (uint16 packet_id = 0; packet_id < 5; ++packet_id) {
35 Packet test_packet(frame_id + 1, packet_id);
36 packet_storage_.StorePacket(
39 PacedPacketSender::MakePacketKey(frame_tick,
42 new base::RefCountedData<Packet>(test_packet));
45 for (uint32 f = 0; f <= frame_id; f++) {
46 for (uint16 packet_id = 0; packet_id < 5; ++packet_id) {
47 SendPacketVector packets;
48 if (packet_storage_.GetPacket32(f, packet_id, &packets)) {
49 EXPECT_GT(f + kStoredFrames, frame_id);
50 EXPECT_EQ(f + 1, packets.back().second->data.size());
51 EXPECT_EQ(packet_id, packets.back().second->data[0]);
52 EXPECT_TRUE(packet_storage_.GetPacket(f & 0xff, packet_id, &packets));
53 EXPECT_TRUE(packets.back().second->data ==
54 packets.front().second->data);
56 EXPECT_LE(f + kStoredFrames, frame_id);
63 } // namespace transport