summaryrefslogtreecommitdiff
path: root/chromium/media/remoting/metrics_unittest.cc
blob: 728e8548d4af333888cba6f108152e706d0b6db9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// Copyright 2016 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "media/remoting/metrics.h"

#include <string>

#include "base/test/metrics/histogram_tester.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"

using base::Bucket;
using testing::ElementsAre;

namespace media {
namespace remoting {

namespace {

class MediaRemotingMetricsTest : public testing::Test {
 protected:
  media::remoting::SessionMetricsRecorder recorder_;
};

}  // namespace

TEST_F(MediaRemotingMetricsTest, RecordVideoPixelRateSupport) {
  constexpr char kPixelRateSupportHistogramName[] =
      "Media.Remoting.VideoPixelRateSupport";
  base::HistogramTester tester;
  tester.ExpectTotalCount(kPixelRateSupportHistogramName, 0);

  recorder_.RecordVideoPixelRateSupport(PixelRateSupport::k4kNotSupported);
  recorder_.RecordVideoPixelRateSupport(PixelRateSupport::k2kSupported);
  recorder_.RecordVideoPixelRateSupport(PixelRateSupport::k4kNotSupported);

  // We record only for the first RecordVideoPixelRateSupport() call for the
  // given SessionMetricsRecorder instance.
  EXPECT_THAT(tester.GetAllSamples(kPixelRateSupportHistogramName),
              ElementsAre(Bucket(
                  static_cast<int>(PixelRateSupport::k4kNotSupported), 1)));
}

TEST_F(MediaRemotingMetricsTest, RecordCompatibility) {
  constexpr char kCompatibilityHistogramName[] = "Media.Remoting.Compatibility";
  base::HistogramTester tester;
  tester.ExpectTotalCount(kCompatibilityHistogramName, 0);

  recorder_.RecordCompatibility(RemotingCompatibility::kIncompatibleVideoCodec);
  recorder_.RecordCompatibility(RemotingCompatibility::kCompatible);
  recorder_.RecordCompatibility(RemotingCompatibility::kIncompatibleVideoCodec);

  // We record only for the first RecordCompatibility() call for the
  // given SessionMetricsRecorder instance.
  EXPECT_THAT(
      tester.GetAllSamples(kCompatibilityHistogramName),
      ElementsAre(Bucket(
          static_cast<int>(RemotingCompatibility::kIncompatibleVideoCodec),
          1)));
}

}  // namespace remoting
}  // namespace media