1 // Copyright 2015 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.
5 #ifndef COMPONENTS_MEMORY_PRESSURE_TEST_MEMORY_PRESSURE_CALCULATOR_H_
6 #define COMPONENTS_MEMORY_PRESSURE_TEST_MEMORY_PRESSURE_CALCULATOR_H_
8 #include "components/memory_pressure/memory_pressure_calculator.h"
10 namespace memory_pressure
{
12 #if defined(MEMORY_PRESSURE_IS_POLLING)
14 // A mock memory pressure calculator for unittesting.
15 class TestMemoryPressureCalculator
: public MemoryPressureCalculator
{
17 TestMemoryPressureCalculator();
18 ~TestMemoryPressureCalculator() override
{}
20 // MemoryPressureCalculator implementation.
21 MemoryPressureLevel
CalculateCurrentPressureLevel() override
;
23 // Sets the mock calculator to return no pressure.
26 // Sets the mock calculator to return moderate pressure.
29 // Sets the mock calculator to return critical pressure.
32 // Resets the call counter to 'CalculateCurrentPressureLevel'.
35 // Returns the number of calls to 'CalculateCurrentPressureLevel'.
36 int calls() const { return calls_
; }
39 MemoryPressureLevel level_
;
42 DISALLOW_COPY_AND_ASSIGN(TestMemoryPressureCalculator
);
45 #endif // defined(MEMORY_PRESSURE_IS_POLLING)
47 } // namespace memory_pressure
49 #endif // COMPONENTS_MEMORY_PRESSURE_TEST_MEMORY_PRESSURE_CALCULATOR_H_