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

Side by Side Diff: webrtc/modules/remote_bitrate_estimator/test/bwe_unittest.cc

Issue 1202253003: More Simulation Framework features (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Comments addressed [4] Created 5 years, 5 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
(Empty)
1 /*
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #include "webrtc/modules/remote_bitrate_estimator/test/bwe.h"
12
13 #include <vector>
14
15 #include "testing/gtest/include/gtest/gtest.h"
16
17 namespace webrtc {
18 namespace testing {
19 namespace bwe {
20
21 const int kSetCapacity = 10000;
22
23 class LinkedSetTest : public ::testing::Test {
24 public:
25 LinkedSetTest() : linked_set_(kSetCapacity) {}
26 ~LinkedSetTest() {}
27
28 protected:
29 LinkedSet linked_set_;
30 };
31
32 TEST_F(LinkedSetTest, EmptySet) {
33 EXPECT_EQ(linked_set_.OldestSeqNumber(), 0);
34 EXPECT_EQ(linked_set_.NewestSeqNumber(), 0);
35 }
36
37 TEST_F(LinkedSetTest, SinglePacket) {
38 const uint16_t kSeqNumber = 1; // Arbitrary.
39 // Other parameters don't matter here.
40 linked_set_.Insert(kSeqNumber, 0, 0, 0);
41 EXPECT_EQ(linked_set_.OldestSeqNumber(), kSeqNumber);
42 EXPECT_EQ(linked_set_.NewestSeqNumber(), kSeqNumber);
43 }
44
45 TEST_F(LinkedSetTest, MultiplePackets) {
46 const uint16_t kNumberPackets = 100;
47
48 std::vector<uint16_t> sequence_numbers;
49 for (size_t i = 0; i < kNumberPackets; ++i) {
50 sequence_numbers.push_back(static_cast<uint16_t>(i + 1));
51 }
52 random_shuffle(sequence_numbers.begin(), sequence_numbers.end());
53
54 for (size_t i = 0; i < kNumberPackets; ++i) {
55 // Other parameters don't matter here.
56 linked_set_.Insert(static_cast<uint16_t>(i), 0, 0, 0);
57 }
58
59 // Packets arriving out of order should not affect the following values:
60 EXPECT_EQ(linked_set_.OldestSeqNumber(), 0);
61 EXPECT_EQ(linked_set_.NewestSeqNumber(), kNumberPackets - 1);
62 }
63
64 TEST_F(LinkedSetTest, Overflow) {
65 const int kFirstSeqNumber = -100;
66 const int kLastSeqNumber = 100;
67
68 for (int i = kFirstSeqNumber; i <= kLastSeqNumber; ++i) {
69 // Other parameters don't matter here.
70 linked_set_.Insert(static_cast<uint16_t>(i), 0, 0, 0);
71 }
72
73 // Packets arriving out of order should not affect the following values:
74 EXPECT_EQ(linked_set_.OldestSeqNumber(),
75 static_cast<uint16_t>(kFirstSeqNumber));
76 EXPECT_EQ(linked_set_.NewestSeqNumber(),
77 static_cast<uint16_t>(kLastSeqNumber));
78 }
79
80 } // namespace bwe
81 } // namespace testing
82 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698