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

Side by Side Diff: webrtc/modules/video_coding/utility/quality_scaler_unittest.cc

Issue 2652893015: Rename adaptation api methods, extended vie_encoder unit test. (Closed)
Patch Set: Created 3 years, 10 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
1 /* 1 /*
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 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 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 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include "webrtc/modules/video_coding/utility/quality_scaler.h" 11 #include "webrtc/modules/video_coding/utility/quality_scaler.h"
12 12
13 #include <memory> 13 #include <memory>
14 14
15 #include "webrtc/base/event.h" 15 #include "webrtc/base/event.h"
16 #include "webrtc/base/task_queue.h" 16 #include "webrtc/base/task_queue.h"
17 #include "webrtc/test/gmock.h" 17 #include "webrtc/test/gmock.h"
18 #include "webrtc/test/gtest.h" 18 #include "webrtc/test/gtest.h"
19 19
20 namespace webrtc { 20 namespace webrtc {
21 namespace { 21 namespace {
22 static const int kFramerate = 30; 22 static const int kFramerate = 30;
23 static const int kLowQp = 15; 23 static const int kLowQp = 15;
24 static const int kLowQpThreshold = 18; 24 static const int kLowQpThreshold = 18;
25 static const int kHighQp = 40; 25 static const int kHighQp = 40;
26 static const size_t kDefaultTimeoutMs = 150; 26 static const size_t kDefaultTimeoutMs = 150;
27 } // namespace 27 } // namespace
28 28
29 class MockScaleObserver : public ScalingObserverInterface { 29 class MockScaleObserver : public AdaptationObserverInterface {
nisse-webrtc 2017/01/30 09:16:45 Could rename scale --> adapt everywhere in this cl
sprang_webrtc 2017/01/30 09:55:05 As related to the interface I think it makes sense
30 public: 30 public:
31 MockScaleObserver() : event(false, false) {} 31 MockScaleObserver() : event(false, false) {}
32 virtual ~MockScaleObserver() {} 32 virtual ~MockScaleObserver() {}
33 33
34 void ScaleUp(ScaleReason r) override { 34 void AdaptUp(AdaptReason r) override {
35 scaled_up++; 35 scaled_up++;
36 event.Set(); 36 event.Set();
37 } 37 }
38 void ScaleDown(ScaleReason r) override { 38 void AdaptDown(AdaptReason r) override {
39 scaled_down++; 39 scaled_down++;
40 event.Set(); 40 event.Set();
41 } 41 }
42 42
43 rtc::Event event; 43 rtc::Event event;
44 int scaled_up = 0; 44 int scaled_up = 0;
45 int scaled_down = 0; 45 int scaled_down = 0;
46 }; 46 };
47 47
48 // Pass a lower sampling period to speed up the tests. 48 // Pass a lower sampling period to speed up the tests.
49 class QualityScalerUnderTest : public QualityScaler { 49 class QualityScalerUnderTest : public QualityScaler {
50 public: 50 public:
51 explicit QualityScalerUnderTest(ScalingObserverInterface* observer, 51 explicit QualityScalerUnderTest(AdaptationObserverInterface* observer,
52 VideoEncoder::QpThresholds thresholds) 52 VideoEncoder::QpThresholds thresholds)
53 : QualityScaler(observer, thresholds, 5) {} 53 : QualityScaler(observer, thresholds, 5) {}
54 }; 54 };
55 55
56 class QualityScalerTest : public ::testing::Test { 56 class QualityScalerTest : public ::testing::Test {
57 protected: 57 protected:
58 enum ScaleDirection { 58 enum ScaleDirection {
59 kKeepScaleAtHighQp, 59 kKeepScaleAtHighQp,
60 kScaleDown, 60 kScaleDown,
61 kScaleDownAboveHighQp, 61 kScaleDownAboveHighQp,
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 EXPECT_TRUE(observer_->event.Wait(kDefaultTimeoutMs)); 169 EXPECT_TRUE(observer_->event.Wait(kDefaultTimeoutMs));
170 EXPECT_EQ(1, observer_->scaled_down); 170 EXPECT_EQ(1, observer_->scaled_down);
171 EXPECT_EQ(0, observer_->scaled_up); 171 EXPECT_EQ(0, observer_->scaled_up);
172 q_->PostTask([this] { TriggerScale(kScaleUp); }); 172 q_->PostTask([this] { TriggerScale(kScaleUp); });
173 EXPECT_TRUE(observer_->event.Wait(kDefaultTimeoutMs)); 173 EXPECT_TRUE(observer_->event.Wait(kDefaultTimeoutMs));
174 EXPECT_EQ(1, observer_->scaled_down); 174 EXPECT_EQ(1, observer_->scaled_down);
175 EXPECT_EQ(1, observer_->scaled_up); 175 EXPECT_EQ(1, observer_->scaled_up);
176 } 176 }
177 #undef DISABLED_TEST 177 #undef DISABLED_TEST
178 } // namespace webrtc 178 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698