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

Unified Diff: base/mac/memory_pressure_monitor_mac_unittest.cc

Issue 1128733002: Update from https://crrev.com/328418 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/mac/memory_pressure_monitor_mac.cc ('k') | base/mac/scoped_nsobject.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/mac/memory_pressure_monitor_mac_unittest.cc
diff --git a/base/mac/memory_pressure_monitor_mac_unittest.cc b/base/mac/memory_pressure_monitor_mac_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..24ee09aeee1cef3b80b8a46bcdcd323a5d269926
--- /dev/null
+++ b/base/mac/memory_pressure_monitor_mac_unittest.cc
@@ -0,0 +1,59 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/mac/memory_pressure_monitor_mac.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace base {
+
+class TestMemoryPressureMonitorMac : public MemoryPressureMonitorMac {
+ public:
+ using MemoryPressureMonitorMac::MemoryPressureLevelForMacMemoryPressure;
+
+ TestMemoryPressureMonitorMac() { }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(TestMemoryPressureMonitorMac);
+};
+
+TEST(TestMemoryPressureMonitorMac, MemoryPressureFromMacMemoryPressure) {
+ EXPECT_EQ(MemoryPressureListener::MEMORY_PRESSURE_LEVEL_NONE,
+ TestMemoryPressureMonitorMac::
+ MemoryPressureLevelForMacMemoryPressure(
+ DISPATCH_MEMORYPRESSURE_NORMAL));
+ EXPECT_EQ(MemoryPressureListener::MEMORY_PRESSURE_LEVEL_MODERATE,
+ TestMemoryPressureMonitorMac::
+ MemoryPressureLevelForMacMemoryPressure(
+ DISPATCH_MEMORYPRESSURE_WARN));
+ EXPECT_EQ(MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL,
+ TestMemoryPressureMonitorMac::
+ MemoryPressureLevelForMacMemoryPressure(
+ DISPATCH_MEMORYPRESSURE_CRITICAL));
+ EXPECT_EQ(MemoryPressureListener::MEMORY_PRESSURE_LEVEL_NONE,
+ TestMemoryPressureMonitorMac::
+ MemoryPressureLevelForMacMemoryPressure(0));
+ EXPECT_EQ(MemoryPressureListener::MEMORY_PRESSURE_LEVEL_NONE,
+ TestMemoryPressureMonitorMac::
+ MemoryPressureLevelForMacMemoryPressure(3));
+ EXPECT_EQ(MemoryPressureListener::MEMORY_PRESSURE_LEVEL_NONE,
+ TestMemoryPressureMonitorMac::
+ MemoryPressureLevelForMacMemoryPressure(5));
+ EXPECT_EQ(MemoryPressureListener::MEMORY_PRESSURE_LEVEL_NONE,
+ TestMemoryPressureMonitorMac::
+ MemoryPressureLevelForMacMemoryPressure(-1));
+}
+
+TEST(TestMemoryPressureMonitorMac, CurrentMemoryPressure) {
+ TestMemoryPressureMonitorMac monitor;
+ MemoryPressureListener::MemoryPressureLevel memory_pressure =
+ monitor.GetCurrentPressureLevel();
+ EXPECT_TRUE(memory_pressure ==
+ MemoryPressureListener::MEMORY_PRESSURE_LEVEL_NONE ||
+ memory_pressure ==
+ MemoryPressureListener::MEMORY_PRESSURE_LEVEL_MODERATE ||
+ memory_pressure ==
+ MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL);
+}
+
+} // namespace base
« no previous file with comments | « base/mac/memory_pressure_monitor_mac.cc ('k') | base/mac/scoped_nsobject.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698