OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "base/memory/memory_pressure_monitor.h" |
| 6 |
| 7 #include "base/macros.h" |
| 8 #include "base/memory/memory_pressure_listener.h" |
| 9 #include "base/test/histogram_tester.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 |
| 12 namespace base { |
| 13 |
| 14 TEST(MemoryPressureMonitorTest, RecordMemoryPressure) { |
| 15 base::HistogramTester tester; |
| 16 const char* kHistogram = "Memory.PressureLevel"; |
| 17 |
| 18 MemoryPressureMonitor::RecordMemoryPressure( |
| 19 MemoryPressureListener::MEMORY_PRESSURE_LEVEL_NONE, 3); |
| 20 tester.ExpectTotalCount(kHistogram, 3); |
| 21 tester.ExpectBucketCount(kHistogram, 0, 3); |
| 22 |
| 23 MemoryPressureMonitor::RecordMemoryPressure( |
| 24 MemoryPressureListener::MEMORY_PRESSURE_LEVEL_MODERATE, 2); |
| 25 tester.ExpectTotalCount(kHistogram, 5); |
| 26 tester.ExpectBucketCount(kHistogram, 1, 2); |
| 27 |
| 28 MemoryPressureMonitor::RecordMemoryPressure( |
| 29 MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL, 1); |
| 30 tester.ExpectTotalCount(kHistogram, 6); |
| 31 tester.ExpectBucketCount(kHistogram, 2, 1); |
| 32 } |
| 33 } // namespace base |
OLD | NEW |