forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed wrap-around in MapTo32bitsFrameId and added unit tests.
BUG=326625 Review URL: https://codereview.chromium.org/106183005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@239316 0039d316-1c4b-4281-b951-d872f2087c98
- Loading branch information
hguihot@google.com
committed
Dec 7, 2013
1 parent
94cf31c
commit 372145b
Showing
3 changed files
with
92 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Copyright 2013 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include <gtest/gtest.h> | ||
#include <media/cast/cast_defines.h> | ||
|
||
namespace media { | ||
namespace cast { | ||
|
||
class FrameIdWrapHelperTest : public ::testing::Test { | ||
protected: | ||
FrameIdWrapHelperTest() {} | ||
virtual ~FrameIdWrapHelperTest() {} | ||
|
||
FrameIdWrapHelper frame_id_wrap_helper_; | ||
}; | ||
|
||
TEST_F(FrameIdWrapHelperTest, FirstFrame) { | ||
EXPECT_EQ(kStartFrameId, frame_id_wrap_helper_.MapTo32bitsFrameId(255u)); | ||
} | ||
|
||
TEST_F(FrameIdWrapHelperTest, Rollover) { | ||
uint32 new_frame_id = 0u; | ||
for (int i = 0; i <= 256; ++i) { | ||
new_frame_id = frame_id_wrap_helper_.MapTo32bitsFrameId( | ||
static_cast<uint8>(i)); | ||
} | ||
EXPECT_EQ(256u, new_frame_id); | ||
} | ||
|
||
TEST_F(FrameIdWrapHelperTest, OutOfOrder) { | ||
uint32 new_frame_id = 0u; | ||
for (int i = 0; i < 255; ++i) { | ||
new_frame_id = frame_id_wrap_helper_.MapTo32bitsFrameId( | ||
static_cast<uint8>(i)); | ||
} | ||
EXPECT_EQ(254u, new_frame_id); | ||
new_frame_id = frame_id_wrap_helper_.MapTo32bitsFrameId(0u); | ||
EXPECT_EQ(256u, new_frame_id); | ||
new_frame_id = frame_id_wrap_helper_.MapTo32bitsFrameId(255u); | ||
EXPECT_EQ(255u, new_frame_id); | ||
new_frame_id = frame_id_wrap_helper_.MapTo32bitsFrameId(1u); | ||
EXPECT_EQ(257u, new_frame_id); | ||
} | ||
|
||
} // namespace cast | ||
} // namespace media |