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

Side by Side Diff: content/renderer/media/webrtc_uma_histograms_unittest.cc

Issue 214983003: Add the WebRTC.webkitApiCountPerSession metric. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix per discussion. Created 6 years, 9 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 | Annotate | Revision Log
OLDNEW
(Empty)
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.
4
5 #include "content/renderer/media/webrtc_uma_histograms.h"
6
7 #include "testing/gmock/include/gmock/gmock.h"
8 #include "testing/gtest/include/gtest/gtest.h"
9
10 using ::testing::_;
11
12 namespace content {
13
14 class MockPerSessionWebRTCAPIMetrics : public PerSessionWebRTCAPIMetrics {
15 public:
16 MockPerSessionWebRTCAPIMetrics() {}
17
18 using PerSessionWebRTCAPIMetrics::LogUsageOnlyOnce;
19
20 MOCK_METHOD1(LogUsage, void(JavaScriptAPIName));
21 };
22
23 TEST(PerSessionWebRTCAPIMetrics, NoCallOngoingGetUserMedia) {
24 MockPerSessionWebRTCAPIMetrics metrics;
25 EXPECT_CALL(metrics, LogUsage(_)).Times(1);
26 metrics.LogUsageOnlyOnce(WEBKIT_GET_USER_MEDIA);
27 }
28
29 TEST(PerSessionWebRTCAPIMetrics, CallOngoingGetUserMedia) {
30 MockPerSessionWebRTCAPIMetrics metrics;
31 metrics.IncrementStreamCounter();
32 EXPECT_CALL(metrics, LogUsage(WEBKIT_GET_USER_MEDIA)).Times(1);
33 metrics.LogUsageOnlyOnce(WEBKIT_GET_USER_MEDIA);
34 }
35
36 TEST(PerSessionWebRTCAPIMetrics, NoCallOngoingRTCPeerConnection) {
37 MockPerSessionWebRTCAPIMetrics metrics;
38 EXPECT_CALL(metrics, LogUsage(WEBKIT_RTC_PEER_CONNECTION));
39 metrics.LogUsageOnlyOnce(WEBKIT_RTC_PEER_CONNECTION);
40 }
41
42 TEST(PerSessionWebRTCAPIMetrics, NoCallOngoingMultiplePC) {
43 MockPerSessionWebRTCAPIMetrics metrics;
44 EXPECT_CALL(metrics, LogUsage(WEBKIT_RTC_PEER_CONNECTION)).Times(1);
45 metrics.LogUsageOnlyOnce(WEBKIT_RTC_PEER_CONNECTION);
46 metrics.LogUsageOnlyOnce(WEBKIT_RTC_PEER_CONNECTION);
47 metrics.LogUsageOnlyOnce(WEBKIT_RTC_PEER_CONNECTION);
48 }
49
50 TEST(PerSessionWebRTCAPIMetrics, BeforeAfterCallMultiplePC) {
51 MockPerSessionWebRTCAPIMetrics metrics;
52 EXPECT_CALL(metrics, LogUsage(WEBKIT_RTC_PEER_CONNECTION)).Times(1);
53 metrics.LogUsageOnlyOnce(WEBKIT_RTC_PEER_CONNECTION);
54 metrics.LogUsageOnlyOnce(WEBKIT_RTC_PEER_CONNECTION);
55 metrics.IncrementStreamCounter();
56 metrics.IncrementStreamCounter();
57 metrics.LogUsageOnlyOnce(WEBKIT_RTC_PEER_CONNECTION);
58 metrics.DecrementStreamCounter();
59 metrics.LogUsageOnlyOnce(WEBKIT_RTC_PEER_CONNECTION);
60 metrics.DecrementStreamCounter();
61 EXPECT_CALL(metrics, LogUsage(WEBKIT_RTC_PEER_CONNECTION)).Times(1);
62 metrics.LogUsageOnlyOnce(WEBKIT_RTC_PEER_CONNECTION);
63 metrics.LogUsageOnlyOnce(WEBKIT_RTC_PEER_CONNECTION);
64 }
65
66 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698