Chromium Code Reviews| 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 |