Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(99)

Side by Side Diff: media/cast/net/frame_id_wrap_helper_test.cc

Issue 458313003: Smarter algorithm for extending 8-bit frame IDs to 32-bit frame IDs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: s/0LL/0/g Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
OLDNEW
« media/cast/net/cast_transport_defines.h ('K') | « media/cast/net/cast_transport_defines.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698