Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 <gtest/gtest.h> | 5 #include <gtest/gtest.h> |
| 6 #include "media/cast/cast_defines.h" | |
| 6 #include "media/cast/net/cast_transport_defines.h" | 7 #include "media/cast/net/cast_transport_defines.h" |
| 7 | 8 |
| 8 namespace media { | 9 namespace media { |
| 9 namespace cast { | 10 namespace cast { |
| 10 | 11 |
| 11 class FrameIdWrapHelperTest : public ::testing::Test { | 12 class FrameIdWrapHelperTest : public ::testing::Test { |
| 12 protected: | 13 protected: |
| 13 FrameIdWrapHelperTest() {} | 14 FrameIdWrapHelperTest() {} |
| 14 virtual ~FrameIdWrapHelperTest() {} | 15 virtual ~FrameIdWrapHelperTest() {} |
| 15 | 16 |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 39 } | 40 } |
| 40 EXPECT_EQ(254u, new_frame_id); | 41 EXPECT_EQ(254u, new_frame_id); |
| 41 new_frame_id = frame_id_wrap_helper_.MapTo32bitsFrameId(0u); | 42 new_frame_id = frame_id_wrap_helper_.MapTo32bitsFrameId(0u); |
| 42 EXPECT_EQ(256u, new_frame_id); | 43 EXPECT_EQ(256u, new_frame_id); |
| 43 new_frame_id = frame_id_wrap_helper_.MapTo32bitsFrameId(255u); | 44 new_frame_id = frame_id_wrap_helper_.MapTo32bitsFrameId(255u); |
| 44 EXPECT_EQ(255u, new_frame_id); | 45 EXPECT_EQ(255u, new_frame_id); |
| 45 new_frame_id = frame_id_wrap_helper_.MapTo32bitsFrameId(1u); | 46 new_frame_id = frame_id_wrap_helper_.MapTo32bitsFrameId(1u); |
| 46 EXPECT_EQ(257u, new_frame_id); | 47 EXPECT_EQ(257u, new_frame_id); |
| 47 } | 48 } |
| 48 | 49 |
| 50 TEST_F(FrameIdWrapHelperTest, Windowed) { | |
| 51 srand(0); | |
|
miu
2014/08/13 18:38:57
For the normal, consecutive case, consider adding:
| |
| 52 const int window_size = 64; | |
| 53 uint32 window_base = 0; | |
| 54 for (int i = 0; i < 100000; i++) { | |
| 55 int offset = rand() % window_size; | |
| 56 uint32 frame_id = window_base + offset; | |
| 57 uint32 mapped_frame_id = | |
| 58 frame_id_wrap_helper_.MapTo32bitsFrameId(frame_id & 0xff); | |
| 59 EXPECT_EQ(frame_id, mapped_frame_id); | |
| 60 if (frame_id != mapped_frame_id) { | |
| 61 break; | |
| 62 } | |
| 63 window_base += rand() % window_size; | |
| 64 } | |
| 65 } | |
| 66 | |
| 49 } // namespace cast | 67 } // namespace cast |
| 50 } // namespace media | 68 } // namespace media |
| OLD | NEW |