Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(312)

Side by Side Diff: chrome/browser/media/router/media_router_metrics_unittest.cc

Issue 2916163002: [MediaRouter] Record DIAL device counts in DialMediaSinkServiceImpl (Closed)
Patch Set: resolve code review comments from isherman Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/media/router/media_router_metrics.h"
5 #include "base/macros.h" 6 #include "base/macros.h"
7 #include "base/memory/ptr_util.h"
6 #include "base/metrics/histogram_macros.h" 8 #include "base/metrics/histogram_macros.h"
7 #include "base/test/histogram_tester.h" 9 #include "base/test/histogram_tester.h"
10 #include "base/test/simple_test_clock.h"
8 #include "base/time/time.h" 11 #include "base/time/time.h"
9 #include "chrome/browser/media/router/media_router_metrics.h"
10 #include "testing/gmock/include/gmock/gmock.h" 12 #include "testing/gmock/include/gmock/gmock.h"
11 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
12 14
13 using base::Bucket; 15 using base::Bucket;
14 using testing::ElementsAre; 16 using testing::ElementsAre;
15 17
16 namespace media_router { 18 namespace media_router {
17 19
18 TEST(MediaRouterMetricsTest, RecordMediaRouterDialogOrigin) { 20 TEST(MediaRouterMetricsTest, RecordMediaRouterDialogOrigin) {
19 base::HistogramTester tester; 21 base::HistogramTester tester;
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 MediaRouterMetrics::RecordRouteCreationOutcome(outcome1); 88 MediaRouterMetrics::RecordRouteCreationOutcome(outcome1);
87 MediaRouterMetrics::RecordRouteCreationOutcome(outcome2); 89 MediaRouterMetrics::RecordRouteCreationOutcome(outcome2);
88 tester.ExpectTotalCount(MediaRouterMetrics::kHistogramRouteCreationOutcome, 90 tester.ExpectTotalCount(MediaRouterMetrics::kHistogramRouteCreationOutcome,
89 3); 91 3);
90 EXPECT_THAT( 92 EXPECT_THAT(
91 tester.GetAllSamples(MediaRouterMetrics::kHistogramRouteCreationOutcome), 93 tester.GetAllSamples(MediaRouterMetrics::kHistogramRouteCreationOutcome),
92 ElementsAre(Bucket(static_cast<int>(outcome1), 1), 94 ElementsAre(Bucket(static_cast<int>(outcome1), 1),
93 Bucket(static_cast<int>(outcome2), 2))); 95 Bucket(static_cast<int>(outcome2), 2)));
94 } 96 }
95 97
98 TEST(MediaRouterMetricsTest, RecordDialDeviceCounts) {
99 MediaRouterMetrics metrics;
100 base::SimpleTestClock* clock = new base::SimpleTestClock();
101 metrics.SetClockForTest(base::WrapUnique(clock));
102 base::HistogramTester tester;
103 tester.ExpectTotalCount(
104 MediaRouterMetrics::kHistogramDialAvailableDeviceCount, 0);
105 tester.ExpectTotalCount(MediaRouterMetrics::kHistogramDialKnownDeviceCount,
106 0);
107
108 clock->SetNow(base::Time::Now());
109 metrics.RecordDialDeviceCounts(6, 10);
110 metrics.RecordDialDeviceCounts(7, 10);
111 tester.ExpectTotalCount(
112 MediaRouterMetrics::kHistogramDialAvailableDeviceCount, 1);
113 tester.ExpectTotalCount(MediaRouterMetrics::kHistogramDialKnownDeviceCount,
114 1);
115 tester.ExpectBucketCount(
116 MediaRouterMetrics::kHistogramDialAvailableDeviceCount, 6, 1);
117 tester.ExpectBucketCount(MediaRouterMetrics::kHistogramDialKnownDeviceCount,
118 10, 1);
119
120 clock->Advance(base::TimeDelta::FromHours(2));
121 metrics.RecordDialDeviceCounts(7, 10);
122
123 tester.ExpectTotalCount(
124 MediaRouterMetrics::kHistogramDialAvailableDeviceCount, 2);
125 tester.ExpectTotalCount(MediaRouterMetrics::kHistogramDialKnownDeviceCount,
126 2);
127 tester.ExpectBucketCount(
128 MediaRouterMetrics::kHistogramDialAvailableDeviceCount, 6, 1);
129 tester.ExpectBucketCount(
130 MediaRouterMetrics::kHistogramDialAvailableDeviceCount, 7, 1);
131 tester.ExpectBucketCount(MediaRouterMetrics::kHistogramDialKnownDeviceCount,
132 10, 2);
133 }
134
96 } // namespace media_router 135 } // namespace media_router
OLDNEW
« no previous file with comments | « chrome/browser/media/router/media_router_metrics.cc ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698