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

Side by Side Diff: content/browser/memory/memory_coordinator_impl_unittest.cc

Issue 2691393002: Fix auto raw pointer deduction on linux (Closed)
Patch Set: update Created 3 years, 10 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 unified diff | Download patch
OLDNEW
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_impl.h" 5 #include "content/browser/memory/memory_coordinator_impl.h"
6 6
7 #include "base/memory/memory_coordinator_client_registry.h" 7 #include "base/memory/memory_coordinator_client_registry.h"
8 #include "base/memory/memory_coordinator_proxy.h" 8 #include "base/memory/memory_coordinator_proxy.h"
9 #include "base/memory/memory_pressure_monitor.h" 9 #include "base/memory/memory_pressure_monitor.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 }; 201 };
202 202
203 TEST_F(MemoryCoordinatorImplTest, ChildRemovedOnConnectionError) { 203 TEST_F(MemoryCoordinatorImplTest, ChildRemovedOnConnectionError) {
204 coordinator_->CreateChildMemoryCoordinator(1); 204 coordinator_->CreateChildMemoryCoordinator(1);
205 ASSERT_EQ(1u, coordinator_->children().size()); 205 ASSERT_EQ(1u, coordinator_->children().size());
206 coordinator_->OnConnectionError(1); 206 coordinator_->OnConnectionError(1);
207 EXPECT_EQ(0u, coordinator_->children().size()); 207 EXPECT_EQ(0u, coordinator_->children().size());
208 } 208 }
209 209
210 TEST_F(MemoryCoordinatorImplTest, SetMemoryStateFailsInvalidState) { 210 TEST_F(MemoryCoordinatorImplTest, SetMemoryStateFailsInvalidState) {
211 auto cmc1 = coordinator_->CreateChildMemoryCoordinator(1); 211 auto* cmc1 = coordinator_->CreateChildMemoryCoordinator(1);
212 212
213 EXPECT_FALSE( 213 EXPECT_FALSE(
214 coordinator_->SetChildMemoryState(1, MemoryState::UNKNOWN)); 214 coordinator_->SetChildMemoryState(1, MemoryState::UNKNOWN));
215 EXPECT_EQ(0, cmc1->on_state_change_calls()); 215 EXPECT_EQ(0, cmc1->on_state_change_calls());
216 } 216 }
217 217
218 TEST_F(MemoryCoordinatorImplTest, SetMemoryStateFailsInvalidRenderer) { 218 TEST_F(MemoryCoordinatorImplTest, SetMemoryStateFailsInvalidRenderer) {
219 auto cmc1 = coordinator_->CreateChildMemoryCoordinator(1); 219 auto* cmc1 = coordinator_->CreateChildMemoryCoordinator(1);
220 220
221 EXPECT_FALSE( 221 EXPECT_FALSE(
222 coordinator_->SetChildMemoryState(2, MemoryState::THROTTLED)); 222 coordinator_->SetChildMemoryState(2, MemoryState::THROTTLED));
223 EXPECT_EQ(0, cmc1->on_state_change_calls()); 223 EXPECT_EQ(0, cmc1->on_state_change_calls());
224 } 224 }
225 225
226 TEST_F(MemoryCoordinatorImplTest, SetMemoryStateNotDeliveredNop) { 226 TEST_F(MemoryCoordinatorImplTest, SetMemoryStateNotDeliveredNop) {
227 auto cmc1 = coordinator_->CreateChildMemoryCoordinator(1); 227 auto* cmc1 = coordinator_->CreateChildMemoryCoordinator(1);
228 228
229 EXPECT_FALSE( 229 EXPECT_FALSE(
230 coordinator_->SetChildMemoryState(2, MemoryState::NORMAL)); 230 coordinator_->SetChildMemoryState(2, MemoryState::NORMAL));
231 EXPECT_EQ(0, cmc1->on_state_change_calls()); 231 EXPECT_EQ(0, cmc1->on_state_change_calls());
232 } 232 }
233 233
234 TEST_F(MemoryCoordinatorImplTest, SetMemoryStateDelivered) { 234 TEST_F(MemoryCoordinatorImplTest, SetMemoryStateDelivered) {
235 auto cmc1 = coordinator_->CreateChildMemoryCoordinator(1); 235 auto* cmc1 = coordinator_->CreateChildMemoryCoordinator(1);
236 auto cmc2 = coordinator_->CreateChildMemoryCoordinator(2); 236 auto* cmc2 = coordinator_->CreateChildMemoryCoordinator(2);
237 237
238 EXPECT_TRUE( 238 EXPECT_TRUE(
239 coordinator_->SetChildMemoryState(1, MemoryState::THROTTLED)); 239 coordinator_->SetChildMemoryState(1, MemoryState::THROTTLED));
240 EXPECT_EQ(1, cmc1->on_state_change_calls()); 240 EXPECT_EQ(1, cmc1->on_state_change_calls());
241 EXPECT_EQ(mojom::MemoryState::THROTTLED, cmc1->state()); 241 EXPECT_EQ(mojom::MemoryState::THROTTLED, cmc1->state());
242 242
243 EXPECT_TRUE( 243 EXPECT_TRUE(
244 coordinator_->SetChildMemoryState(2, MemoryState::SUSPENDED)); 244 coordinator_->SetChildMemoryState(2, MemoryState::SUSPENDED));
245 EXPECT_EQ(1, cmc2->on_state_change_calls()); 245 EXPECT_EQ(1, cmc2->on_state_change_calls());
246 // Child processes are considered as visible (foreground) by default, 246 // Child processes are considered as visible (foreground) by default,
247 // and visible ones won't be suspended but throttled. 247 // and visible ones won't be suspended but throttled.
248 EXPECT_EQ(mojom::MemoryState::THROTTLED, cmc2->state()); 248 EXPECT_EQ(mojom::MemoryState::THROTTLED, cmc2->state());
249 } 249 }
250 250
251 TEST_F(MemoryCoordinatorImplTest, PurgeMemoryChild) { 251 TEST_F(MemoryCoordinatorImplTest, PurgeMemoryChild) {
252 auto* child = coordinator_->CreateChildMemoryCoordinator(1); 252 auto* child = coordinator_->CreateChildMemoryCoordinator(1);
253 EXPECT_EQ(0, child->purge_memory_calls()); 253 EXPECT_EQ(0, child->purge_memory_calls());
254 child->PurgeMemory(); 254 child->PurgeMemory();
255 RunUntilIdle(); 255 RunUntilIdle();
256 EXPECT_EQ(1, child->purge_memory_calls()); 256 EXPECT_EQ(1, child->purge_memory_calls());
257 } 257 }
258 258
259 TEST_F(MemoryCoordinatorImplTest, SetChildMemoryState) { 259 TEST_F(MemoryCoordinatorImplTest, SetChildMemoryState) {
260 auto cmc = coordinator_->CreateChildMemoryCoordinator(1); 260 auto* cmc = coordinator_->CreateChildMemoryCoordinator(1);
261 auto iter = coordinator_->children().find(1); 261 auto iter = coordinator_->children().find(1);
262 auto* render_process_host = coordinator_->GetMockRenderProcessHost(1); 262 auto* render_process_host = coordinator_->GetMockRenderProcessHost(1);
263 ASSERT_TRUE(iter != coordinator_->children().end()); 263 ASSERT_TRUE(iter != coordinator_->children().end());
264 ASSERT_TRUE(render_process_host); 264 ASSERT_TRUE(render_process_host);
265 265
266 // Foreground 266 // Foreground
267 iter->second.is_visible = true; 267 iter->second.is_visible = true;
268 render_process_host->set_is_process_backgrounded(false); 268 render_process_host->set_is_process_backgrounded(false);
269 EXPECT_TRUE(coordinator_->SetChildMemoryState(1, MemoryState::NORMAL)); 269 EXPECT_TRUE(coordinator_->SetChildMemoryState(1, MemoryState::NORMAL));
270 EXPECT_EQ(mojom::MemoryState::NORMAL, cmc->state()); 270 EXPECT_EQ(mojom::MemoryState::NORMAL, cmc->state());
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 515
516 EXPECT_TRUE( 516 EXPECT_TRUE(
517 coordinator_->SetChildMemoryState(1, MemoryState::THROTTLED)); 517 coordinator_->SetChildMemoryState(1, MemoryState::THROTTLED));
518 EXPECT_EQ(base::MemoryState::THROTTLED, 518 EXPECT_EQ(base::MemoryState::THROTTLED,
519 coordinator_->GetStateForProcess(process1.Handle())); 519 coordinator_->GetStateForProcess(process1.Handle()));
520 EXPECT_EQ(base::MemoryState::NORMAL, 520 EXPECT_EQ(base::MemoryState::NORMAL,
521 coordinator_->GetStateForProcess(process2.Handle())); 521 coordinator_->GetStateForProcess(process2.Handle()));
522 } 522 }
523 523
524 } // namespace content 524 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698