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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: content/renderer/media/webrtc_uma_histograms_unittest.cc
diff --git a/content/renderer/media/webrtc_uma_histograms_unittest.cc b/content/renderer/media/webrtc_uma_histograms_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..7d3a9199fcb2fac9b5156aefe1b284e069ef508c
--- /dev/null
+++ b/content/renderer/media/webrtc_uma_histograms_unittest.cc
@@ -0,0 +1,66 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/renderer/media/webrtc_uma_histograms.h"
+
+#include "testing/gmock/include/gmock/gmock.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+using ::testing::_;
+
+namespace content {
+
+class MockPerSessionWebRTCAPIMetrics : public PerSessionWebRTCAPIMetrics {
+ public:
+ MockPerSessionWebRTCAPIMetrics() {}
+
+ using PerSessionWebRTCAPIMetrics::LogUsageOnlyOnce;
+
+ MOCK_METHOD1(LogUsage, void(JavaScriptAPIName));
+};
+
+TEST(PerSessionWebRTCAPIMetrics, NoCallOngoingGetUserMedia) {
+ MockPerSessionWebRTCAPIMetrics metrics;
+ EXPECT_CALL(metrics, LogUsage(_)).Times(1);
+ metrics.LogUsageOnlyOnce(WEBKIT_GET_USER_MEDIA);
+}
+
+TEST(PerSessionWebRTCAPIMetrics, CallOngoingGetUserMedia) {
+ MockPerSessionWebRTCAPIMetrics metrics;
+ metrics.IncrementStreamCounter();
+ EXPECT_CALL(metrics, LogUsage(WEBKIT_GET_USER_MEDIA)).Times(1);
+ metrics.LogUsageOnlyOnce(WEBKIT_GET_USER_MEDIA);
+}
+
+TEST(PerSessionWebRTCAPIMetrics, NoCallOngoingRTCPeerConnection) {
+ MockPerSessionWebRTCAPIMetrics metrics;
+ EXPECT_CALL(metrics, LogUsage(WEBKIT_RTC_PEER_CONNECTION));
+ metrics.LogUsageOnlyOnce(WEBKIT_RTC_PEER_CONNECTION);
+}
+
+TEST(PerSessionWebRTCAPIMetrics, NoCallOngoingMultiplePC) {
+ MockPerSessionWebRTCAPIMetrics metrics;
+ EXPECT_CALL(metrics, LogUsage(WEBKIT_RTC_PEER_CONNECTION)).Times(1);
+ metrics.LogUsageOnlyOnce(WEBKIT_RTC_PEER_CONNECTION);
+ metrics.LogUsageOnlyOnce(WEBKIT_RTC_PEER_CONNECTION);
+ metrics.LogUsageOnlyOnce(WEBKIT_RTC_PEER_CONNECTION);
+}
+
+TEST(PerSessionWebRTCAPIMetrics, BeforeAfterCallMultiplePC) {
+ MockPerSessionWebRTCAPIMetrics metrics;
+ EXPECT_CALL(metrics, LogUsage(WEBKIT_RTC_PEER_CONNECTION)).Times(1);
+ metrics.LogUsageOnlyOnce(WEBKIT_RTC_PEER_CONNECTION);
+ metrics.LogUsageOnlyOnce(WEBKIT_RTC_PEER_CONNECTION);
+ metrics.IncrementStreamCounter();
+ metrics.IncrementStreamCounter();
+ metrics.LogUsageOnlyOnce(WEBKIT_RTC_PEER_CONNECTION);
+ metrics.DecrementStreamCounter();
+ metrics.LogUsageOnlyOnce(WEBKIT_RTC_PEER_CONNECTION);
+ metrics.DecrementStreamCounter();
+ EXPECT_CALL(metrics, LogUsage(WEBKIT_RTC_PEER_CONNECTION)).Times(1);
+ metrics.LogUsageOnlyOnce(WEBKIT_RTC_PEER_CONNECTION);
+ metrics.LogUsageOnlyOnce(WEBKIT_RTC_PEER_CONNECTION);
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698