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

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: Remove unnecessary includes 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..5c17c59b708084c49d0556961676927286e30e61
--- /dev/null
+++ b/content/child/memory/child_memory_message_filter_unittest.cc
@@ -0,0 +1,54 @@
+// 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"
+
+#include "base/memory/memory_pressure_listener.h"
+#include "content/common/memory_messages.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace content {
+namespace {
nasko 2015/09/16 21:18:37 Why the anonymous namespace? Tests usually just li
petrcermak 2015/09/17 15:24:53 Done.
+
+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
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698