| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/browser/memory/memory_coordinator.h" | 5 #include "content/browser/memory/memory_coordinator.h" |
| 6 | 6 |
| 7 #include "base/memory/memory_pressure_monitor.h" | 7 #include "base/memory/memory_pressure_monitor.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "mojo/public/cpp/bindings/binding.h" | 10 #include "mojo/public/cpp/bindings/binding.h" |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 // Test fixture. | 86 // Test fixture. |
| 87 class MemoryCoordinatorTest : public testing::Test { | 87 class MemoryCoordinatorTest : public testing::Test { |
| 88 private: | 88 private: |
| 89 // Needed for mojo. | 89 // Needed for mojo. |
| 90 base::MessageLoop message_loop_; | 90 base::MessageLoop message_loop_; |
| 91 }; | 91 }; |
| 92 | 92 |
| 93 TEST_F(MemoryCoordinatorTest, ChildRemovedOnConnectionError) { | 93 TEST_F(MemoryCoordinatorTest, ChildRemovedOnConnectionError) { |
| 94 TestMemoryCoordinator mc; | 94 TestMemoryCoordinator mc; |
| 95 mc.CreateChildMemoryCoordinator(1); | 95 mc.CreateChildMemoryCoordinator(1); |
| 96 ASSERT_EQ(1u, mc.NumChildrenForTesting()); | 96 ASSERT_EQ(1u, mc.children().size()); |
| 97 mc.OnConnectionError(1); | 97 mc.OnConnectionError(1); |
| 98 EXPECT_EQ(0u, mc.NumChildrenForTesting()); | 98 EXPECT_EQ(0u, mc.children().size()); |
| 99 } | 99 } |
| 100 | 100 |
| 101 TEST_F(MemoryCoordinatorTest, SetMemoryStateFailsInvalidState) { | 101 TEST_F(MemoryCoordinatorTest, SetMemoryStateFailsInvalidState) { |
| 102 TestMemoryCoordinator mc; | 102 TestMemoryCoordinator mc; |
| 103 auto cmc1 = mc.CreateChildMemoryCoordinator(1); | 103 auto cmc1 = mc.CreateChildMemoryCoordinator(1); |
| 104 | 104 |
| 105 EXPECT_FALSE(mc.SetChildMemoryState(1, mojom::MemoryState::UNKNOWN)); | 105 EXPECT_FALSE(mc.SetChildMemoryState(1, mojom::MemoryState::UNKNOWN)); |
| 106 EXPECT_EQ(0, cmc1->on_state_change_calls()); | 106 EXPECT_EQ(0, cmc1->on_state_change_calls()); |
| 107 } | 107 } |
| 108 | 108 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 130 EXPECT_TRUE(mc.SetChildMemoryState(1, mojom::MemoryState::THROTTLED)); | 130 EXPECT_TRUE(mc.SetChildMemoryState(1, mojom::MemoryState::THROTTLED)); |
| 131 EXPECT_EQ(1, cmc1->on_state_change_calls()); | 131 EXPECT_EQ(1, cmc1->on_state_change_calls()); |
| 132 EXPECT_EQ(mojom::MemoryState::THROTTLED, cmc1->state()); | 132 EXPECT_EQ(mojom::MemoryState::THROTTLED, cmc1->state()); |
| 133 | 133 |
| 134 EXPECT_TRUE(mc.SetChildMemoryState(2, mojom::MemoryState::SUSPENDED)); | 134 EXPECT_TRUE(mc.SetChildMemoryState(2, mojom::MemoryState::SUSPENDED)); |
| 135 EXPECT_EQ(1, cmc2->on_state_change_calls()); | 135 EXPECT_EQ(1, cmc2->on_state_change_calls()); |
| 136 EXPECT_EQ(mojom::MemoryState::SUSPENDED, cmc2->state()); | 136 EXPECT_EQ(mojom::MemoryState::SUSPENDED, cmc2->state()); |
| 137 } | 137 } |
| 138 | 138 |
| 139 } // namespace content | 139 } // namespace content |
| OLD | NEW |