kjellander@webrtc.org | 35a1756 | 2011-10-06 06:44:54 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2011 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 | */ |
kjellander@webrtc.org | 5b97b12 | 2011-12-08 07:42:18 +0000 | [diff] [blame] | 10 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame^] | 11 | #include "modules/video_coding/codecs/test/stats.h" |
kjellander@webrtc.org | 5b97b12 | 2011-12-08 07:42:18 +0000 | [diff] [blame] | 12 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame^] | 13 | #include "test/gtest.h" |
kjellander@webrtc.org | 35a1756 | 2011-10-06 06:44:54 +0000 | [diff] [blame] | 14 | |
| 15 | namespace webrtc { |
| 16 | namespace test { |
| 17 | |
asapersson | 68b91d7 | 2017-06-04 23:43:41 -0700 | [diff] [blame] | 18 | TEST(StatsTest, TestEmptyObject) { |
| 19 | Stats stats; |
brandtr | 8935d97 | 2017-09-06 01:53:22 -0700 | [diff] [blame] | 20 | stats.PrintSummary(); // Should not crash. |
kjellander@webrtc.org | 35a1756 | 2011-10-06 06:44:54 +0000 | [diff] [blame] | 21 | } |
| 22 | |
asapersson | 68b91d7 | 2017-06-04 23:43:41 -0700 | [diff] [blame] | 23 | TEST(StatsTest, AddSingleFrame) { |
asapersson | 68b91d7 | 2017-06-04 23:43:41 -0700 | [diff] [blame] | 24 | Stats stats; |
brandtr | 8935d97 | 2017-09-06 01:53:22 -0700 | [diff] [blame] | 25 | FrameStatistic* frame_stat = stats.AddFrame(); |
| 26 | EXPECT_EQ(0, frame_stat->frame_number); |
| 27 | EXPECT_EQ(1u, stats.size()); |
kjellander@webrtc.org | 35a1756 | 2011-10-06 06:44:54 +0000 | [diff] [blame] | 28 | } |
| 29 | |
asapersson | 68b91d7 | 2017-06-04 23:43:41 -0700 | [diff] [blame] | 30 | TEST(StatsTest, AddMultipleFrames) { |
| 31 | Stats stats; |
| 32 | const int kNumFrames = 1000; |
| 33 | for (int i = 0; i < kNumFrames; ++i) { |
brandtr | 8935d97 | 2017-09-06 01:53:22 -0700 | [diff] [blame] | 34 | FrameStatistic* frame_stat = stats.AddFrame(); |
| 35 | EXPECT_EQ(i, frame_stat->frame_number); |
kjellander@webrtc.org | 35a1756 | 2011-10-06 06:44:54 +0000 | [diff] [blame] | 36 | } |
brandtr | 8935d97 | 2017-09-06 01:53:22 -0700 | [diff] [blame] | 37 | EXPECT_EQ(kNumFrames, static_cast<int>(stats.size())); |
kjellander@webrtc.org | 35a1756 | 2011-10-06 06:44:54 +0000 | [diff] [blame] | 38 | |
brandtr | 8935d97 | 2017-09-06 01:53:22 -0700 | [diff] [blame] | 39 | stats.PrintSummary(); // Should not crash. |
kjellander@webrtc.org | 35a1756 | 2011-10-06 06:44:54 +0000 | [diff] [blame] | 40 | } |
| 41 | |
| 42 | } // namespace test |
| 43 | } // namespace webrtc |