diff options
author | jochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-24 08:20:20 +0000 |
---|---|---|
committer | jochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-24 08:20:20 +0000 |
commit | 75eda33a79ab30dc52c975dd3f4950585f5c3012 (patch) | |
tree | 29379da8e936648d6f9fd8236b596f152878f2ac /base/metrics/histogram_unittest.cc | |
parent | 214ba2d9264bea909215b4ce1a793d9df683b6aa (diff) | |
download | chromium_src-75eda33a79ab30dc52c975dd3f4950585f5c3012.zip chromium_src-75eda33a79ab30dc52c975dd3f4950585f5c3012.tar.gz chromium_src-75eda33a79ab30dc52c975dd3f4950585f5c3012.tar.bz2 |
Revert 148055 - Move CachedRanges out and add support for checksum.
This breaks the NaCL compiler, as the addition the base.gypi results in a too long command line. For the sake of getting the tree green, I'm reverting this, although the NaCL compiler is really to blame
Review URL: https://chromiumcodereview.appspot.com/10796047
TBR=kaiwang@chromium.org
Review URL: https://chromiumcodereview.appspot.com/10807083
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@148060 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/metrics/histogram_unittest.cc')
-rw-r--r-- | base/metrics/histogram_unittest.cc | 34 |
1 files changed, 15 insertions, 19 deletions
diff --git a/base/metrics/histogram_unittest.cc b/base/metrics/histogram_unittest.cc index be9a412..6b50ca5 100644 --- a/base/metrics/histogram_unittest.cc +++ b/base/metrics/histogram_unittest.cc @@ -9,7 +9,6 @@ #include "base/logging.h" #include "base/memory/scoped_ptr.h" -#include "base/metrics/bucket_ranges.h" #include "base/metrics/histogram.h" #include "base/metrics/statistics_recorder.h" #include "base/time.h" @@ -383,29 +382,26 @@ TEST(HistogramTest, CorruptBucketBounds) { EXPECT_EQ(Histogram::NO_INCONSISTENCIES, 0); EXPECT_EQ(0, histogram->FindCorruption(snapshot)); // No default corruption. - BucketRanges* bucket_ranges = histogram->bucket_ranges(); - HistogramBase::Sample tmp = bucket_ranges->range(1); - bucket_ranges->set_range(1, bucket_ranges->range(2)); - bucket_ranges->set_range(2, tmp); + CachedRanges* cached_ranges = histogram->cached_ranges(); + std::swap(cached_ranges->ranges_[1], cached_ranges->ranges_[2]); EXPECT_EQ(Histogram::BUCKET_ORDER_ERROR | Histogram::RANGE_CHECKSUM_ERROR, histogram->FindCorruption(snapshot)); - bucket_ranges->set_range(2, bucket_ranges->range(1)); - bucket_ranges->set_range(1, tmp); + std::swap(cached_ranges->ranges_[1], cached_ranges->ranges_[2]); EXPECT_EQ(0, histogram->FindCorruption(snapshot)); - bucket_ranges->set_range(3, bucket_ranges->range(3) + 1); + ++cached_ranges->ranges_[3]; EXPECT_EQ(Histogram::RANGE_CHECKSUM_ERROR, histogram->FindCorruption(snapshot)); // Show that two simple changes don't offset each other - bucket_ranges->set_range(4, bucket_ranges->range(4) - 1); + --cached_ranges->ranges_[4]; EXPECT_EQ(Histogram::RANGE_CHECKSUM_ERROR, histogram->FindCorruption(snapshot)); // Repair histogram so that destructor won't DCHECK(). - bucket_ranges->set_range(3, bucket_ranges->range(3) - 1); - bucket_ranges->set_range(4, bucket_ranges->range(4) + 1); + --cached_ranges->ranges_[3]; + ++cached_ranges->ranges_[4]; } // Table was generated similarly to sample code for CRC-32 given on: @@ -424,9 +420,9 @@ TEST(HistogramTest, Crc32TableTest) { } } -// RangeTest, CustomRangeTest and CorruptBucketBounds test BucketRanges class. -// The following tests sharing of BucketRanges object. -TEST(HistogramTest, BucketRangesTest) { +// RangeTest, CustomRangeTest and CorruptBucketBounds test CachedRanges class. +// The following tests sharing of CachedRanges object. +TEST(HistogramTest, CachedRangesTest) { StatisticsRecorder recorder; StatisticsRecorder::Histograms histograms; @@ -442,11 +438,11 @@ TEST(HistogramTest, BucketRangesTest) { Histogram* histogram3(Histogram::FactoryGet( "Histogram3", 1, 64, 16, Histogram::kNoFlags)); - BucketRanges* bucket_ranges1 = histogram1->bucket_ranges(); - BucketRanges* bucket_ranges2 = histogram2->bucket_ranges(); - BucketRanges* bucket_ranges3 = histogram3->bucket_ranges(); - EXPECT_TRUE(bucket_ranges1->Equals(bucket_ranges2)); - EXPECT_FALSE(bucket_ranges1->Equals(bucket_ranges3)); + CachedRanges* cached_ranges1 = histogram1->cached_ranges(); + CachedRanges* cached_ranges2 = histogram2->cached_ranges(); + CachedRanges* cached_ranges3 = histogram3->cached_ranges(); + EXPECT_TRUE(cached_ranges1->Equals(cached_ranges2)); + EXPECT_FALSE(cached_ranges1->Equals(cached_ranges3)); } } // namespace base |