Ignore title parameter for navigator.registerProtocolHandler
[chromium-blink-merge.git] / media / cast / framer / frame_buffer_unittest.cc
blobc00aa2b77bb9b25f9c71fa67ba6f43a3a4d5ee91
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/framer/frame_buffer.h"
6 #include "testing/gtest/include/gtest/gtest.h"
8 namespace media {
9 namespace cast {
11 class FrameBufferTest : public ::testing::Test {
12 protected:
13 FrameBufferTest() {
14 payload_.assign(kMaxIpPacketSize, 0);
17 virtual ~FrameBufferTest() {}
19 FrameBuffer buffer_;
20 std::vector<uint8> payload_;
21 RtpCastHeader rtp_header_;
23 DISALLOW_COPY_AND_ASSIGN(FrameBufferTest);
26 TEST_F(FrameBufferTest, OnePacketInsertSanity) {
27 rtp_header_.rtp_timestamp = 3000;
28 rtp_header_.is_key_frame = true;
29 rtp_header_.frame_id = 5;
30 rtp_header_.reference_frame_id = 5;
31 buffer_.InsertPacket(payload_.data(), payload_.size(), rtp_header_);
32 transport::EncodedVideoFrame frame;
33 EXPECT_TRUE(buffer_.GetEncodedVideoFrame(&frame));
34 EXPECT_EQ(5u, frame.frame_id);
35 EXPECT_TRUE(frame.key_frame);
36 EXPECT_EQ(3000u, frame.rtp_timestamp);
39 TEST_F(FrameBufferTest, EmptyBuffer) {
40 EXPECT_FALSE(buffer_.Complete());
41 EXPECT_FALSE(buffer_.is_key_frame());
42 transport::EncodedVideoFrame frame;
43 EXPECT_FALSE(buffer_.GetEncodedVideoFrame(&frame));
46 TEST_F(FrameBufferTest, DefaultOnePacketFrame) {
47 buffer_.InsertPacket(payload_.data(), payload_.size(), rtp_header_);
48 EXPECT_TRUE(buffer_.Complete());
49 EXPECT_FALSE(buffer_.is_key_frame());
50 transport::EncodedVideoFrame frame;
51 EXPECT_TRUE(buffer_.GetEncodedVideoFrame(&frame));
52 EXPECT_EQ(payload_.size(), frame.data.size());
55 TEST_F(FrameBufferTest, MultiplePacketFrame) {
56 rtp_header_.is_key_frame = true;
57 rtp_header_.max_packet_id = 2;
58 buffer_.InsertPacket(payload_.data(), payload_.size(), rtp_header_);
59 ++rtp_header_.packet_id;
60 buffer_.InsertPacket(payload_.data(), payload_.size(), rtp_header_);
61 ++rtp_header_.packet_id;
62 buffer_.InsertPacket(payload_.data(), payload_.size(), rtp_header_);
63 ++rtp_header_.packet_id;
64 EXPECT_TRUE(buffer_.Complete());
65 EXPECT_TRUE(buffer_.is_key_frame());
66 transport::EncodedVideoFrame frame;
67 EXPECT_TRUE(buffer_.GetEncodedVideoFrame(&frame));
68 EXPECT_EQ(3 * payload_.size(), frame.data.size());
71 TEST_F(FrameBufferTest, IncompleteFrame) {
72 rtp_header_.max_packet_id = 4;
73 buffer_.InsertPacket(payload_.data(), payload_.size(), rtp_header_);
74 ++rtp_header_.packet_id;
75 buffer_.InsertPacket(payload_.data(), payload_.size(), rtp_header_);
76 ++rtp_header_.packet_id;
77 // Increment again - skip packet #2.
78 ++rtp_header_.packet_id;
79 buffer_.InsertPacket(payload_.data(), payload_.size(), rtp_header_);
80 ++rtp_header_.packet_id;
81 buffer_.InsertPacket(payload_.data(), payload_.size(), rtp_header_);
82 EXPECT_FALSE(buffer_.Complete());
83 // Insert missing packet.
84 rtp_header_.packet_id = 2;
85 buffer_.InsertPacket(payload_.data(), payload_.size(), rtp_header_);
86 EXPECT_TRUE(buffer_.Complete());
89 } // namespace media
90 } // namespace cast