/* * Copyright 2019 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree.
*/
// Fill all one byte IDs. for (int i = 1; i <= webrtc::RtpExtension::kOneByteHeaderExtensionMaxId;
++i) {
webrtc::RtpExtension id("", i);
used_ids.FindAndSetIdUsed(&id);
}
// Add new extensions with colliding IDs.
webrtc::RtpExtension id1_collision("", 1);
webrtc::RtpExtension id2_collision("", 2);
webrtc::RtpExtension id3_collision("", 3);
// Expect to reassign to two-byte header extension IDs.
used_ids.FindAndSetIdUsed(&id1_collision);
EXPECT_EQ(id1_collision.id, 16);
used_ids.FindAndSetIdUsed(&id2_collision);
EXPECT_EQ(id2_collision.id, 17);
used_ids.FindAndSetIdUsed(&id3_collision);
EXPECT_EQ(id3_collision.id, 18);
}
// Death tests. // Disabled on Android because death tests misbehave on Android, see // base/test/gtest_util.h. #if RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID)
TEST(UsedIdsDeathTest, DieWhenAllIdsAreOccupied) {
UsedIds<Foo> used_ids(1, 5); for (int i = 1; i <= 5; ++i) {
Foo id = {i};
used_ids.FindAndSetIdUsed(&id);
}
Foo id_collision = {3};
EXPECT_DEATH(used_ids.FindAndSetIdUsed(&id_collision), "");
}
using UsedRtpHeaderExtensionIdsDeathTest = UsedRtpHeaderExtensionIdsTest;
INSTANTIATE_TEST_SUITE_P(All,
UsedRtpHeaderExtensionIdsDeathTest,
::testing::Values(kOneByteTestParams,
kTwoByteTestParams));
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.