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

Side by Side Diff: base/metrics/persistent_sample_map_unittest.cc

Issue 2162053006: Move EXPECT_DCHECK_DEATH from base/task_scheduler and use it in relevant base/ tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge up to r408965 Created 4 years, 4 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
« no previous file with comments | « base/metrics/histogram_unittest.cc ('k') | base/metrics/sample_map_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/metrics/persistent_sample_map.h" 5 #include "base/metrics/persistent_sample_map.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/metrics/persistent_histogram_allocator.h" 10 #include "base/metrics/persistent_histogram_allocator.h"
11 #include "base/test/gtest_util.h"
11 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
12 13
13 namespace base { 14 namespace base {
14 namespace { 15 namespace {
15 16
16 std::unique_ptr<PersistentHistogramAllocator> CreateHistogramAllocator( 17 std::unique_ptr<PersistentHistogramAllocator> CreateHistogramAllocator(
17 size_t bytes) { 18 size_t bytes) {
18 return WrapUnique(new PersistentHistogramAllocator( 19 return WrapUnique(new PersistentHistogramAllocator(
19 WrapUnique(new LocalPersistentMemoryAllocator(bytes, 0, "")))); 20 WrapUnique(new LocalPersistentMemoryAllocator(bytes, 0, ""))));
20 } 21 }
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 227
227 it->Get(&min, &max, &count); 228 it->Get(&min, &max, &count);
228 EXPECT_EQ(15, min); 229 EXPECT_EQ(15, min);
229 EXPECT_EQ(16, max); 230 EXPECT_EQ(16, max);
230 EXPECT_EQ(3, count); 231 EXPECT_EQ(3, count);
231 232
232 it->Next(); 233 it->Next();
233 EXPECT_TRUE(it->Done()); 234 EXPECT_TRUE(it->Done());
234 } 235 }
235 236
236 // Only run this test on builds that support catching a DCHECK crash.
237 #if (!defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)) && GTEST_HAS_DEATH_TEST
238 TEST(PersistentSampleMapIteratorDeathTest, IterateDoneTest) { 237 TEST(PersistentSampleMapIteratorDeathTest, IterateDoneTest) {
239 std::unique_ptr<PersistentHistogramAllocator> allocator = 238 std::unique_ptr<PersistentHistogramAllocator> allocator =
240 CreateHistogramAllocator(64 << 10); // 64 KiB 239 CreateHistogramAllocator(64 << 10); // 64 KiB
241 HistogramSamples::Metadata meta; 240 HistogramSamples::Metadata meta;
242 PersistentSampleMap samples(1, allocator.get(), &meta); 241 PersistentSampleMap samples(1, allocator.get(), &meta);
243 242
244 std::unique_ptr<SampleCountIterator> it = samples.Iterator(); 243 std::unique_ptr<SampleCountIterator> it = samples.Iterator();
245 244
246 EXPECT_TRUE(it->Done()); 245 EXPECT_TRUE(it->Done());
247 246
248 HistogramBase::Sample min; 247 HistogramBase::Sample min;
249 HistogramBase::Sample max; 248 HistogramBase::Sample max;
250 HistogramBase::Count count; 249 HistogramBase::Count count;
251 EXPECT_DEATH(it->Get(&min, &max, &count), ""); 250 EXPECT_DCHECK_DEATH(it->Get(&min, &max, &count), "");
252 251
253 EXPECT_DEATH(it->Next(), ""); 252 EXPECT_DCHECK_DEATH(it->Next(), "");
254 253
255 samples.Accumulate(1, 100); 254 samples.Accumulate(1, 100);
256 it = samples.Iterator(); 255 it = samples.Iterator();
257 EXPECT_FALSE(it->Done()); 256 EXPECT_FALSE(it->Done());
258 } 257 }
259 #endif
260 // (!defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)) && GTEST_HAS_DEATH_TEST
261 258
262 } // namespace 259 } // namespace
263 } // namespace base 260 } // namespace base
OLDNEW
« no previous file with comments | « base/metrics/histogram_unittest.cc ('k') | base/metrics/sample_map_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698