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 <gtest/gtest.h>
6 #include "media/cast/transport/cast_transport_defines.h"
12 class FrameIdWrapHelperTest : public ::testing::Test {
14 FrameIdWrapHelperTest() {}
15 virtual ~FrameIdWrapHelperTest() {}
17 FrameIdWrapHelper frame_id_wrap_helper_;
19 DISALLOW_COPY_AND_ASSIGN(FrameIdWrapHelperTest);
22 TEST_F(FrameIdWrapHelperTest, FirstFrame) {
23 EXPECT_EQ(kStartFrameId, frame_id_wrap_helper_.MapTo32bitsFrameId(255u));
26 TEST_F(FrameIdWrapHelperTest, Rollover) {
27 uint32 new_frame_id = 0u;
28 for (int i = 0; i <= 256; ++i) {
30 frame_id_wrap_helper_.MapTo32bitsFrameId(static_cast<uint8>(i));
32 EXPECT_EQ(256u, new_frame_id);
35 TEST_F(FrameIdWrapHelperTest, OutOfOrder) {
36 uint32 new_frame_id = 0u;
37 for (int i = 0; i < 255; ++i) {
39 frame_id_wrap_helper_.MapTo32bitsFrameId(static_cast<uint8>(i));
41 EXPECT_EQ(254u, new_frame_id);
42 new_frame_id = frame_id_wrap_helper_.MapTo32bitsFrameId(0u);
43 EXPECT_EQ(256u, new_frame_id);
44 new_frame_id = frame_id_wrap_helper_.MapTo32bitsFrameId(255u);
45 EXPECT_EQ(255u, new_frame_id);
46 new_frame_id = frame_id_wrap_helper_.MapTo32bitsFrameId(1u);
47 EXPECT_EQ(257u, new_frame_id);
50 } // namespace transport