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

Side by Side Diff: webrtc/video/quality_threshold_unittest.cc

Issue 2474913002: Logging basic bad call detection (Closed)
Patch Set: Rename + Tests Created 4 years 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) 2016 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/video/quality_threshold.h"
12
13 #include "webrtc/test/gtest.h"
14
15 namespace webrtc {
16
17 TEST(QualityThresholdTest, BackAndForth) {
18 QualityThreshold thresh(0, 1, 0.75f, 10);
sprang_webrtc 2016/11/24 16:25:21 Define constants for high / low / capacity and use
19 for (int i = 0; i < 8; ++i) {
20 EXPECT_FALSE(thresh.IsHigh());
21 thresh.AddMeasurement(0);
22 }
23 ASSERT_TRUE(thresh.IsHigh());
24 for (int i = 0; i < 8; ++i) {
25 EXPECT_FALSE(*thresh.IsHigh());
26 thresh.AddMeasurement(1);
27 }
28 EXPECT_TRUE(*thresh.IsHigh());
29
30 for (int i = 0; i < 8; ++i) {
31 EXPECT_TRUE(*thresh.IsHigh());
32 thresh.AddMeasurement(0);
33 }
34 EXPECT_FALSE(*thresh.IsHigh());
35 }
36
37 TEST(QualityThresholdTest, Variance) {
38 const int max_measurements = 10;
sprang_webrtc 2016/11/24 16:25:21 kMaxMeasurements or MAX_MEASUREMENTS
39 const double max_error = 0.01;
40 int values[] = {51, 79, 80, 56, 19, 20, 48, 57, 48, 25, 2, 25, 38, 37, 25};
41 double variances[] = {476.9, 687.6, 552, 336.4, 278.767, 265.167};
sprang_webrtc 2016/11/24 16:25:21 please comment what these numbers are
42 QualityThreshold thresh(0, 1, 0.8f, max_measurements);
43
44 for (int i = 0; i < max_measurements; ++i) {
45 EXPECT_FALSE(thresh.CalculateVariance());
46 thresh.AddMeasurement(values[i]);
47 }
48
49 ASSERT_TRUE(thresh.CalculateVariance());
50 EXPECT_NEAR(variances[0], *thresh.CalculateVariance(), max_error);
51 for (unsigned int i = 1; i < sizeof(variances) / sizeof(double); ++i) {
52 thresh.AddMeasurement(values[i + max_measurements - 1]);
53 EXPECT_NEAR(variances[i], *thresh.CalculateVariance(), max_error);
54 }
55
56 for (int i = 0; i < max_measurements; ++i) {
57 thresh.AddMeasurement(42);
58 }
59 EXPECT_NEAR(0, *thresh.CalculateVariance(), max_error);
60 }
61
62 TEST(QualityThresholdTest, BetweenThresholds) {
63 const int max_measurements = 10;
64 QualityThreshold thresh(0, 2, 0.6f, max_measurements);
65 for (int i = 0; i < 2 * max_measurements; ++i) {
66 EXPECT_FALSE(thresh.IsHigh());
67 thresh.AddMeasurement(1);
68 }
69 EXPECT_FALSE(thresh.IsHigh());
70 }
71
72 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698