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

Unified 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: switch to unsigned arithmetics 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/cast/net/cast_transport_defines.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/cast/net/frame_id_wrap_helper_test.cc
diff --git a/media/cast/net/frame_id_wrap_helper_test.cc b/media/cast/net/frame_id_wrap_helper_test.cc
index 92a84435334913406ecc9baba45114e816779715..c40979d9283afe8df08015e5fba42d853f8bbfe2 100644
--- a/media/cast/net/frame_id_wrap_helper_test.cc
+++ b/media/cast/net/frame_id_wrap_helper_test.cc
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include <gtest/gtest.h>
+#include "media/cast/cast_defines.h"
#include "media/cast/net/cast_transport_defines.h"
namespace media {
@@ -13,6 +14,25 @@ class FrameIdWrapHelperTest : public ::testing::Test {
FrameIdWrapHelperTest() {}
virtual ~FrameIdWrapHelperTest() {}
+ void RunOneTest(uint32 starting_point, int iterations) {
+ const int window_size = 127;
+ uint32 window_base = starting_point;
+ frame_id_wrap_helper_.largest_frame_id_seen_ = starting_point;
+ for (int i = 0; i < iterations; i++) {
+ uint32 largest_frame_id_seen =
+ frame_id_wrap_helper_.largest_frame_id_seen_;
+ int offset = rand() % window_size;
+ uint32 frame_id = window_base + offset;
+ uint32 mapped_frame_id =
+ frame_id_wrap_helper_.MapTo32bitsFrameId(frame_id & 0xff);
+ EXPECT_EQ(frame_id, mapped_frame_id)
+ << " Largest ID seen: " << largest_frame_id_seen
+ << " Window base: " << window_base
+ << " Offset: " << offset;
+ window_base = frame_id;
+ }
+ }
+
FrameIdWrapHelper frame_id_wrap_helper_;
DISALLOW_COPY_AND_ASSIGN(FrameIdWrapHelperTest);
@@ -46,5 +66,15 @@ TEST_F(FrameIdWrapHelperTest, OutOfOrder) {
EXPECT_EQ(257u, new_frame_id);
}
+TEST_F(FrameIdWrapHelperTest, Windowed) {
+ srand(0);
+ for (int i = 0; i < 50000 && !HasFailure(); i++) {
+ RunOneTest(i * 4711, 20);
+ // Test wrap-around scenarios.
+ RunOneTest(0x7fffff00ul, 20);
+ RunOneTest(0xffffff00ul, 20);
+ }
+}
+
} // namespace cast
} // namespace media
« no previous file with comments | « 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