| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 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_histogram_allocator.h" | 5 #include "base/metrics/persistent_histogram_allocator.h" |
| 6 | 6 |
| 7 #include "base/files/scoped_temp_dir.h" | 7 #include "base/files/scoped_temp_dir.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/metrics/bucket_ranges.h" | 10 #include "base/metrics/bucket_ranges.h" |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 recovered->CheckName("TestCustomHistogram"); | 124 recovered->CheckName("TestCustomHistogram"); |
| 125 | 125 |
| 126 recovered = histogram_iter.GetNext(); | 126 recovered = histogram_iter.GetNext(); |
| 127 EXPECT_FALSE(recovered); | 127 EXPECT_FALSE(recovered); |
| 128 } | 128 } |
| 129 | 129 |
| 130 TEST_F(PersistentHistogramAllocatorTest, CreateWithFileTest) { | 130 TEST_F(PersistentHistogramAllocatorTest, CreateWithFileTest) { |
| 131 const char temp_name[] = "CreateWithFileTest"; | 131 const char temp_name[] = "CreateWithFileTest"; |
| 132 ScopedTempDir temp_dir; | 132 ScopedTempDir temp_dir; |
| 133 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 133 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
| 134 FilePath temp_file = temp_dir.path().AppendASCII(temp_name); | 134 FilePath temp_file = temp_dir.GetPath().AppendASCII(temp_name); |
| 135 const size_t temp_size = 64 << 10; // 64 KiB | 135 const size_t temp_size = 64 << 10; // 64 KiB |
| 136 | 136 |
| 137 // Test creation of a new file. | 137 // Test creation of a new file. |
| 138 GlobalHistogramAllocator::ReleaseForTesting(); | 138 GlobalHistogramAllocator::ReleaseForTesting(); |
| 139 GlobalHistogramAllocator::CreateWithFile(temp_file, temp_size, 0, temp_name); | 139 GlobalHistogramAllocator::CreateWithFile(temp_file, temp_size, 0, temp_name); |
| 140 EXPECT_EQ(std::string(temp_name), | 140 EXPECT_EQ(std::string(temp_name), |
| 141 GlobalHistogramAllocator::Get()->memory_allocator()->Name()); | 141 GlobalHistogramAllocator::Get()->memory_allocator()->Name()); |
| 142 | 142 |
| 143 // Test re-open of a possibly-existing file. | 143 // Test re-open of a possibly-existing file. |
| 144 GlobalHistogramAllocator::ReleaseForTesting(); | 144 GlobalHistogramAllocator::ReleaseForTesting(); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 // Ensure that the data got merged, too. | 200 // Ensure that the data got merged, too. |
| 201 std::unique_ptr<HistogramSamples> snapshot = found->SnapshotSamples(); | 201 std::unique_ptr<HistogramSamples> snapshot = found->SnapshotSamples(); |
| 202 EXPECT_EQ(recovered->SnapshotSamples()->TotalCount(), snapshot->TotalCount()); | 202 EXPECT_EQ(recovered->SnapshotSamples()->TotalCount(), snapshot->TotalCount()); |
| 203 EXPECT_EQ(1, snapshot->GetCount(3)); | 203 EXPECT_EQ(1, snapshot->GetCount(3)); |
| 204 EXPECT_EQ(2, snapshot->GetCount(1)); | 204 EXPECT_EQ(2, snapshot->GetCount(1)); |
| 205 EXPECT_EQ(1, snapshot->GetCount(4)); | 205 EXPECT_EQ(1, snapshot->GetCount(4)); |
| 206 EXPECT_EQ(1, snapshot->GetCount(6)); | 206 EXPECT_EQ(1, snapshot->GetCount(6)); |
| 207 } | 207 } |
| 208 | 208 |
| 209 } // namespace base | 209 } // namespace base |
| OLD | NEW |