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 */
10
11#include "webrtc/modules/video_coding/codecs/test/stats.h"
12
13#include "testing/gtest/include/gtest/gtest.h"
14#include "webrtc/typedefs.h"
15
16namespace webrtc {
17namespace test {
18
19class StatsTest: public testing::Test {
20 protected:
21  StatsTest() {
22  }
23
24  virtual ~StatsTest() {
25  }
26
27  void SetUp() {
28    stats_ = new Stats();
29  }
30
31  void TearDown() {
32    delete stats_;
33  }
34
35  Stats* stats_;
36};
37
38// Test empty object
39TEST_F(StatsTest, Uninitialized) {
40  EXPECT_EQ(0u, stats_->stats_.size());
41  stats_->PrintSummary();  // should not crash
42}
43
44// Add single frame stats and verify
45TEST_F(StatsTest, AddOne) {
46  stats_->NewFrame(0u);
47  FrameStatistic* frameStat = &stats_->stats_[0];
48  EXPECT_EQ(0, frameStat->frame_number);
49}
50
51// Add multiple frame stats and verify
52TEST_F(StatsTest, AddMany) {
53  int nbr_of_frames = 1000;
54  for (int i = 0; i < nbr_of_frames; ++i) {
55    FrameStatistic& frameStat = stats_->NewFrame(i);
56    EXPECT_EQ(i, frameStat.frame_number);
57  }
58  EXPECT_EQ(nbr_of_frames, static_cast<int>(stats_->stats_.size()));
59
60  stats_->PrintSummary();  // should not crash
61}
62
63}  // namespace test
64}  // namespace webrtc
65