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

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: Removed std::next to advance iterator 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_.Max(), 0);
34 EXPECT_EQ(linked_set_.Min(), 0);
35 EXPECT_EQ(linked_set_.OldestSeqNumber(), 0);
36 EXPECT_EQ(linked_set_.NewestSeqNumber(), 0);
37 }
38
39 TEST_F(LinkedSetTest, SinglePacket) {
40 const uint16_t kSeqNumber = 1; // Arbitrary.
41 // Other parameters don't matter here.
42 linked_set_.Insert(kSeqNumber, 0, 0, 0);
43 EXPECT_EQ(linked_set_.Max(), kSeqNumber);
44 EXPECT_EQ(linked_set_.Min(), kSeqNumber);
45 EXPECT_EQ(linked_set_.OldestSeqNumber(), kSeqNumber);
46 EXPECT_EQ(linked_set_.NewestSeqNumber(), kSeqNumber);
47 }
48
49 TEST_F(LinkedSetTest, MultiplePackets) {
50 const uint16_t kNumberPackets = 100;
51
52 std::vector<uint16_t> sequence_numbers;
53 for (size_t i = 0; i < kNumberPackets; ++i) {
54 sequence_numbers.push_back(static_cast<uint16_t>(i + 1));
55 }
56 random_shuffle(sequence_numbers.begin(), sequence_numbers.end());
57
58 for (size_t i = 0; i < kNumberPackets; ++i) {
59 // Other parameters don't matter here.
60 linked_set_.Insert(static_cast<uint16_t>(i), 0, 0, 0);
61 }
62
63 // Packets arriving out of order should not affect the following values:
64 EXPECT_EQ(linked_set_.Max(), kNumberPackets - 1);
65 EXPECT_EQ(linked_set_.Min(), 0);
66 EXPECT_EQ(linked_set_.OldestSeqNumber(), 0);
67 EXPECT_EQ(linked_set_.NewestSeqNumber(), kNumberPackets - 1);
68 }
69
70 TEST_F(LinkedSetTest, Overflow) {
71 const int kFirstSeqNumber = -100;
72 const int kLastSeqNumber = 100;
73
74 for (int i = kFirstSeqNumber; i <= kLastSeqNumber; ++i) {
75 // Other parameters don't matter here.
76 linked_set_.Insert(static_cast<uint16_t>(i), 0, 0, 0);
77 }
78
79 // Packets arriving out of order should not affect the following values:
80 EXPECT_EQ(linked_set_.Max(), 0xFFFF);
81 EXPECT_EQ(linked_set_.Min(), 0);
82 EXPECT_EQ(linked_set_.OldestSeqNumber(),
83 static_cast<uint16_t>(kFirstSeqNumber));
84 EXPECT_EQ(linked_set_.NewestSeqNumber(),
85 static_cast<uint16_t>(kLastSeqNumber));
86 }
87
88 } // namespace bwe
89 } // namespace testing
90 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698