OLD | NEW |
| (Empty) |
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. | |
4 | |
5 #include <gtest/gtest.h> | |
6 #include <media/cast/cast_defines.h> | |
7 | |
8 namespace media { | |
9 namespace cast { | |
10 | |
11 class FrameIdWrapHelperTest : public ::testing::Test { | |
12 protected: | |
13 FrameIdWrapHelperTest() {} | |
14 virtual ~FrameIdWrapHelperTest() {} | |
15 | |
16 FrameIdWrapHelper frame_id_wrap_helper_; | |
17 }; | |
18 | |
19 TEST_F(FrameIdWrapHelperTest, FirstFrame) { | |
20 EXPECT_EQ(kStartFrameId, frame_id_wrap_helper_.MapTo32bitsFrameId(255u)); | |
21 } | |
22 | |
23 TEST_F(FrameIdWrapHelperTest, Rollover) { | |
24 uint32 new_frame_id = 0u; | |
25 for (int i = 0; i <= 256; ++i) { | |
26 new_frame_id = frame_id_wrap_helper_.MapTo32bitsFrameId( | |
27 static_cast<uint8>(i)); | |
28 } | |
29 EXPECT_EQ(256u, new_frame_id); | |
30 } | |
31 | |
32 TEST_F(FrameIdWrapHelperTest, OutOfOrder) { | |
33 uint32 new_frame_id = 0u; | |
34 for (int i = 0; i < 255; ++i) { | |
35 new_frame_id = frame_id_wrap_helper_.MapTo32bitsFrameId( | |
36 static_cast<uint8>(i)); | |
37 } | |
38 EXPECT_EQ(254u, new_frame_id); | |
39 new_frame_id = frame_id_wrap_helper_.MapTo32bitsFrameId(0u); | |
40 EXPECT_EQ(256u, new_frame_id); | |
41 new_frame_id = frame_id_wrap_helper_.MapTo32bitsFrameId(255u); | |
42 EXPECT_EQ(255u, new_frame_id); | |
43 new_frame_id = frame_id_wrap_helper_.MapTo32bitsFrameId(1u); | |
44 EXPECT_EQ(257u, new_frame_id); | |
45 } | |
46 | |
47 } // namespace cast | |
48 } // namespace media | |
OLD | NEW |