blob: 87727e2889f759f07281195189300c4b0c6949b9 [file] [log] [blame]
kjellander@webrtc.org35a17562011-10-06 06:44:54 +00001/*
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.org5b97b122011-12-08 07:42:18 +000010
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020011#include "modules/video_coding/codecs/test/stats.h"
kjellander@webrtc.org5b97b122011-12-08 07:42:18 +000012
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020013#include "test/gtest.h"
kjellander@webrtc.org35a17562011-10-06 06:44:54 +000014
15namespace webrtc {
16namespace test {
17
asapersson68b91d72017-06-04 23:43:41 -070018TEST(StatsTest, TestEmptyObject) {
19 Stats stats;
brandtr8935d972017-09-06 01:53:22 -070020 stats.PrintSummary(); // Should not crash.
kjellander@webrtc.org35a17562011-10-06 06:44:54 +000021}
22
asapersson68b91d72017-06-04 23:43:41 -070023TEST(StatsTest, AddSingleFrame) {
asapersson68b91d72017-06-04 23:43:41 -070024 Stats stats;
brandtr8935d972017-09-06 01:53:22 -070025 FrameStatistic* frame_stat = stats.AddFrame();
26 EXPECT_EQ(0, frame_stat->frame_number);
27 EXPECT_EQ(1u, stats.size());
kjellander@webrtc.org35a17562011-10-06 06:44:54 +000028}
29
asapersson68b91d72017-06-04 23:43:41 -070030TEST(StatsTest, AddMultipleFrames) {
31 Stats stats;
32 const int kNumFrames = 1000;
33 for (int i = 0; i < kNumFrames; ++i) {
brandtr8935d972017-09-06 01:53:22 -070034 FrameStatistic* frame_stat = stats.AddFrame();
35 EXPECT_EQ(i, frame_stat->frame_number);
kjellander@webrtc.org35a17562011-10-06 06:44:54 +000036 }
brandtr8935d972017-09-06 01:53:22 -070037 EXPECT_EQ(kNumFrames, static_cast<int>(stats.size()));
kjellander@webrtc.org35a17562011-10-06 06:44:54 +000038
brandtr8935d972017-09-06 01:53:22 -070039 stats.PrintSummary(); // Should not crash.
kjellander@webrtc.org35a17562011-10-06 06:44:54 +000040}
41
42} // namespace test
43} // namespace webrtc