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

Unified Diff: content/child/memory/child_memory_message_filter_unittest.cc

Issue 1332583002: Architecture for cross-process memory notification suppressing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address nasko's comments Created 5 years, 3 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
Index: content/child/memory/child_memory_message_filter_unittest.cc
diff --git a/content/child/memory/child_memory_message_filter_unittest.cc b/content/child/memory/child_memory_message_filter_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..cd6acedefb1866e72f51320728a66441bc6fa7c6
--- /dev/null
+++ b/content/child/memory/child_memory_message_filter_unittest.cc
@@ -0,0 +1,52 @@
+// 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 "content/child/memory/child_memory_message_filter.h"
Primiano Tucci (use gerrit) 2015/09/17 18:23:49 To be honest the child side is so naive (receive m
petrcermak 2015/09/18 10:19:12 I thought a lot about this and I guess it's fine t
+
+#include "base/memory/memory_pressure_listener.h"
+#include "content/common/memory_messages.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace content {
+
+class ChildMemoryMessageFilterTest : public testing::Test {
+ protected:
+ void SetUp() override {
+ filter_ = new ChildMemoryMessageFilter;
+ filter_->OnChannelConnected(0);
+ filter_->OnFilterAdded(nullptr);
+ testing::Test::SetUp();
+ }
+
+ void TearDown() override {
+ filter_->OnChannelClosing();
+ filter_->OnFilterRemoved();
+ filter_ = nullptr;
+ testing::Test::TearDown();
+ }
+
+ void ReceiveSetPressureNotificationsSuppressedMessage(bool suppressed) {
+ MemoryMsg_SetPressureNotificationsSuppressed message(suppressed);
+ filter_->OnMessageReceived(message);
+ }
+
+ private:
+ scoped_refptr<ChildMemoryMessageFilter> filter_;
+};
+
+TEST_F(ChildMemoryMessageFilterTest, SetPressureNotificationsSuppressed) {
+ ReceiveSetPressureNotificationsSuppressedMessage(false);
+ EXPECT_FALSE(base::MemoryPressureListener::AreNotificationsSuppressed());
+
+ ReceiveSetPressureNotificationsSuppressedMessage(true);
+ EXPECT_TRUE(base::MemoryPressureListener::AreNotificationsSuppressed());
+
+ ReceiveSetPressureNotificationsSuppressedMessage(true);
+ EXPECT_TRUE(base::MemoryPressureListener::AreNotificationsSuppressed());
+
+ ReceiveSetPressureNotificationsSuppressedMessage(false);
+ EXPECT_FALSE(base::MemoryPressureListener::AreNotificationsSuppressed());
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698