1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chromecast/base/metrics/cast_metrics_test_helper.h"
7 #include "base/logging.h"
8 #include "base/macros.h"
9 #include "chromecast/base/metrics/cast_metrics_helper.h"
11 namespace chromecast
{
16 class CastMetricsHelperStub
: public CastMetricsHelper
{
18 CastMetricsHelperStub();
19 ~CastMetricsHelperStub() override
;
21 void UpdateCurrentAppInfo(const std::string
& app_id
,
22 const std::string
& session_id
) override
;
23 void UpdateSDKInfo(const std::string
& sdk_version
) override
;
24 void LogMediaPlay() override
;
25 void LogMediaPause() override
;
26 void LogTimeToBufferAv(BufferingType buffering_type
,
27 base::TimeDelta time
) override
;
28 std::string
GetMetricsNameWithAppName(
29 const std::string
& prefix
, const std::string
& suffix
) const override
;
30 void SetMetricsSink(MetricsSink
* delegate
) override
;
33 DISALLOW_COPY_AND_ASSIGN(CastMetricsHelperStub
);
36 bool stub_instance_exists
= false;
38 CastMetricsHelperStub::CastMetricsHelperStub()
39 : CastMetricsHelper() {
40 DCHECK(!stub_instance_exists
);
41 stub_instance_exists
= true;
44 CastMetricsHelperStub::~CastMetricsHelperStub() {
45 DCHECK(stub_instance_exists
);
46 stub_instance_exists
= false;
49 void CastMetricsHelperStub::UpdateCurrentAppInfo(
50 const std::string
& app_id
,
51 const std::string
& session_id
) {
54 void CastMetricsHelperStub::UpdateSDKInfo(const std::string
& sdk_version
) {
57 void CastMetricsHelperStub::LogMediaPlay() {
60 void CastMetricsHelperStub::LogMediaPause() {
63 void CastMetricsHelperStub::LogTimeToBufferAv(BufferingType buffering_type
,
64 base::TimeDelta time
) {
67 std::string
CastMetricsHelperStub::GetMetricsNameWithAppName(
68 const std::string
& prefix
,
69 const std::string
& suffix
) const {
73 void CastMetricsHelperStub::SetMetricsSink(MetricsSink
* delegate
) {
78 void InitializeMetricsHelperForTesting() {
79 if (!stub_instance_exists
) {
80 new CastMetricsHelperStub();
84 } // namespace metrics
85 } // namespace chromecast