summaryrefslogtreecommitdiffstats
path: root/ceee/ie/common/metrics_util_unittest.cc
diff options
context:
space:
mode:
authorhansl@google.com <hansl@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-23 00:56:37 +0000
committerhansl@google.com <hansl@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-23 00:56:37 +0000
commit58014de258cdb66f3b3b733031f386c6124f8e16 (patch)
treedeba2032a4dd584ac51bb44f98a165307691dc2d /ceee/ie/common/metrics_util_unittest.cc
parentf0b6b4881e24a1e7cd9524c4e381382c14bde1f1 (diff)
downloadchromium_src-58014de258cdb66f3b3b733031f386c6124f8e16.zip
chromium_src-58014de258cdb66f3b3b733031f386c6124f8e16.tar.gz
chromium_src-58014de258cdb66f3b3b733031f386c6124f8e16.tar.bz2
Add UMA histograms services to CEEE. The histograms are aggregated in the broker, using RPC to send them, and then sent once every 15 minutes to the server.
Uses metrics_service.cc from chrome_frame. Adds dependency to RPC runtime for the BHO and to glue_renderer for linking. This depends on http://codereview.chromium.org/5247001 for uploading data. BUG=none TEST=none Review URL: http://codereview.chromium.org/5116008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@67035 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ceee/ie/common/metrics_util_unittest.cc')
-rw-r--r--ceee/ie/common/metrics_util_unittest.cc72
1 files changed, 72 insertions, 0 deletions
diff --git a/ceee/ie/common/metrics_util_unittest.cc b/ceee/ie/common/metrics_util_unittest.cc
new file mode 100644
index 0000000..2acc41c
--- /dev/null
+++ b/ceee/ie/common/metrics_util_unittest.cc
@@ -0,0 +1,72 @@
+// Copyright (c) 2010 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.
+//
+// Unit tests for the CEEE metrics utilities.
+
+#include <atlconv.h>
+
+#include "ceee/ie/common/metrics_util.h"
+
+#include <wtypes.h>
+#include <string>
+
+#include "base/file_path.h"
+#include "base/file_util.h"
+#include "base/logging.h"
+#include "base/path_service.h"
+#include "base/win/registry.h"
+#include "base/string_util.h"
+#include "ceee/common/process_utils_win.h"
+#include "ceee/ie/testing/mock_broker_and_friends.h"
+#include "ceee/testing/utils/mock_com.h"
+#include "ceee/testing/utils/mock_window_utils.h"
+#include "ceee/testing/utils/mock_win32.h"
+#include "ceee/testing/utils/test_utils.h"
+#include "base/time.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+namespace {
+
+using testing::_;
+using testing::DoAll;
+using testing::NotNull;
+using testing::SetArgumentPointee;
+using testing::StrictMock;
+using testing::Return;
+
+class BrokerRpcClientMock : public BrokerRpcClient {
+public:
+ MOCK_METHOD2(SendUmaHistogramTimes, bool(BSTR, int));
+ MOCK_METHOD5(SendUmaHistogramData, bool(BSTR, int, int, int, int));
+};
+
+class CeeeMetricsUtilTest : public testing::Test {
+ protected:
+ virtual void CreateAndDestroyTimer(BrokerRpcClient* rpc_client) {
+ metrics_util::ScopedTimer timer("NonEmptyName", rpc_client);
+ }
+};
+
+// Invalid broker or empty name initialization should CHECK(false).
+TEST_F(CeeeMetricsUtilTest, ScopedTimerError) {
+ testing::LogDisabler no_dcheck;
+ // Since we can't test yet for NOTREACHED() or CHECK(false), do nothing.
+ // TODO(hansl): when we can test for NOTREACHED, validate that passing invalid
+ // values to the ScopedTimer will indeed fail.
+}
+
+
+// Test for successful uses of the ScopedTimer.
+TEST_F(CeeeMetricsUtilTest, ScopedTimerSuccess) {
+ testing::LogDisabler no_dcheck;
+
+ // Test that timing is right. This should ultimately succeed.
+ // We expect less than a couple milliseconds on this call.
+ BrokerRpcClientMock broker_rpc;
+ EXPECT_CALL(broker_rpc, SendUmaHistogramTimes(_, testing::Lt(10)));
+ CreateAndDestroyTimer(&broker_rpc);
+}
+
+} // namespace