Index: chrome/renderer/net/net_error_helper_core_unittest.cc |
diff --git a/chrome/renderer/net/net_error_helper_core_unittest.cc b/chrome/renderer/net/net_error_helper_core_unittest.cc |
index eee80f712388fc78e363f183f4399512b0480de5..c6a0bcb6f73a899deab020a54f573a6c6e7dde06 100644 |
--- a/chrome/renderer/net/net_error_helper_core_unittest.cc |
+++ b/chrome/renderer/net/net_error_helper_core_unittest.cc |
@@ -17,7 +17,7 @@ |
#include "base/timer/timer.h" |
#include "base/values.h" |
#include "chrome/common/net/net_error_info.h" |
-#include "chrome/test/base/uma_histogram_helper.h" |
+#include "chrome/test/base/chrome_histogram_tester.h" |
#include "content/public/common/url_constants.h" |
#include "net/base/net_errors.h" |
#include "testing/gtest/include/gtest/gtest.h" |
@@ -2230,37 +2230,15 @@ TEST_F(NetErrorHelperCoreAutoReloadTest, ShownWhileNotReloading) { |
EXPECT_TRUE(timer()->IsRunning()); |
} |
-// Return the count for the named histogram, or 0 if there is no histogram by |
-// that name. This function is error-tolerant because histograms that have no |
-// data points may not be registered, and the unit tests below still need to be |
-// able to check that they haven't changed. |
-int GetHistogramCount(const char *name) { |
- base::HistogramBase* histogram = |
- base::StatisticsRecorder::FindHistogram(name); |
- if (!histogram) |
- return 0; |
- scoped_ptr<base::HistogramSamples> samples = histogram->SnapshotSamples(); |
- if (!samples) |
- return 0; |
- return samples->TotalCount(); |
-} |
- |
-void ExpectHistogramDelta(const char *name, int old_count, int delta) { |
- int new_count = GetHistogramCount(name); |
- EXPECT_EQ(old_count + delta, new_count) << "For histogram " << name; |
-} |
- |
class NetErrorHelperCoreHistogramTest |
: public NetErrorHelperCoreAutoReloadTest { |
public: |
virtual void SetUp() OVERRIDE { |
NetErrorHelperCoreAutoReloadTest::SetUp(); |
- StoreOldCounts(); |
} |
void ExpectDelta(const char *name, int delta) { |
- DCHECK(old_counts_.count(name) == 1); |
- ExpectHistogramDelta(name, old_counts_[name], delta); |
+ histogram_tester_.ExpectTotalCount(name, delta); |
} |
Ilya Sherman
2014/07/15 03:56:35
nit: Please inline the calls to histogram_tester_.
Mike Lerman
2014/07/16 17:29:04
Done.
|
static const char kCountAtStop[]; |
@@ -2270,14 +2248,7 @@ class NetErrorHelperCoreHistogramTest |
static const char kErrorAtFirstSuccess[]; |
private: |
Ilya Sherman
2014/07/15 03:56:35
Note: There's no need to make the HistogramTester
Mike Lerman
2014/07/16 17:29:04
It can stay private.
|
- void StoreOldCounts() { |
- for (size_t i = 0; kHistogramNames[i]; i++) |
- old_counts_[kHistogramNames[i]] = GetHistogramCount(kHistogramNames[i]); |
- } |
- |
- static const char *kHistogramNames[]; |
- |
- std::map<std::string, int> old_counts_; |
+ base::HistogramTester histogram_tester_; |
}; |
const char NetErrorHelperCoreHistogramTest::kCountAtStop[] = |
@@ -2290,14 +2261,6 @@ const char NetErrorHelperCoreHistogramTest::kErrorAtSuccess[] = |
"Net.AutoReload.ErrorAtSuccess"; |
const char NetErrorHelperCoreHistogramTest::kErrorAtFirstSuccess[] = |
"Net.AutoReload.ErrorAtFirstSuccess"; |
-const char *NetErrorHelperCoreHistogramTest::kHistogramNames[] = { |
- kCountAtStop, |
- kErrorAtStop, |
- kCountAtSuccess, |
- kErrorAtSuccess, |
- kErrorAtFirstSuccess, |
- NULL |
-}; |
// Test that the success histograms are updated when auto-reload succeeds at the |
// first attempt, and that the failure histograms are not updated. |