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

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

Issue 2691393002: Fix auto raw pointer deduction on linux (Closed)
Patch Set: rebase 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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 }; 192 };
193 193
194 TEST_F(MemoryCoordinatorImplTest, ChildRemovedOnConnectionError) { 194 TEST_F(MemoryCoordinatorImplTest, ChildRemovedOnConnectionError) {
195 coordinator_->CreateChildMemoryCoordinator(1); 195 coordinator_->CreateChildMemoryCoordinator(1);
196 ASSERT_EQ(1u, coordinator_->children().size()); 196 ASSERT_EQ(1u, coordinator_->children().size());
197 coordinator_->OnConnectionError(1); 197 coordinator_->OnConnectionError(1);
198 EXPECT_EQ(0u, coordinator_->children().size()); 198 EXPECT_EQ(0u, coordinator_->children().size());
199 } 199 }
200 200
201 TEST_F(MemoryCoordinatorImplTest, SetMemoryStateFailsInvalidState) { 201 TEST_F(MemoryCoordinatorImplTest, SetMemoryStateFailsInvalidState) {
202 auto cmc1 = coordinator_->CreateChildMemoryCoordinator(1); 202 auto* cmc1 = coordinator_->CreateChildMemoryCoordinator(1);
203 203
204 EXPECT_FALSE( 204 EXPECT_FALSE(
205 coordinator_->SetChildMemoryState(1, MemoryState::UNKNOWN)); 205 coordinator_->SetChildMemoryState(1, MemoryState::UNKNOWN));
206 EXPECT_EQ(0, cmc1->on_state_change_calls()); 206 EXPECT_EQ(0, cmc1->on_state_change_calls());
207 } 207 }
208 208
209 TEST_F(MemoryCoordinatorImplTest, SetMemoryStateFailsInvalidRenderer) { 209 TEST_F(MemoryCoordinatorImplTest, SetMemoryStateFailsInvalidRenderer) {
210 auto cmc1 = coordinator_->CreateChildMemoryCoordinator(1); 210 auto* cmc1 = coordinator_->CreateChildMemoryCoordinator(1);
211 211
212 EXPECT_FALSE( 212 EXPECT_FALSE(
213 coordinator_->SetChildMemoryState(2, MemoryState::THROTTLED)); 213 coordinator_->SetChildMemoryState(2, MemoryState::THROTTLED));
214 EXPECT_EQ(0, cmc1->on_state_change_calls()); 214 EXPECT_EQ(0, cmc1->on_state_change_calls());
215 } 215 }
216 216
217 TEST_F(MemoryCoordinatorImplTest, SetMemoryStateNotDeliveredNop) { 217 TEST_F(MemoryCoordinatorImplTest, SetMemoryStateNotDeliveredNop) {
218 auto cmc1 = coordinator_->CreateChildMemoryCoordinator(1); 218 auto* cmc1 = coordinator_->CreateChildMemoryCoordinator(1);
219 219
220 EXPECT_FALSE( 220 EXPECT_FALSE(
221 coordinator_->SetChildMemoryState(2, MemoryState::NORMAL)); 221 coordinator_->SetChildMemoryState(2, MemoryState::NORMAL));
222 EXPECT_EQ(0, cmc1->on_state_change_calls()); 222 EXPECT_EQ(0, cmc1->on_state_change_calls());
223 } 223 }
224 224
225 TEST_F(MemoryCoordinatorImplTest, SetMemoryStateDelivered) { 225 TEST_F(MemoryCoordinatorImplTest, SetMemoryStateDelivered) {
226 auto cmc1 = coordinator_->CreateChildMemoryCoordinator(1); 226 auto* cmc1 = coordinator_->CreateChildMemoryCoordinator(1);
227 auto cmc2 = coordinator_->CreateChildMemoryCoordinator(2); 227 auto* cmc2 = coordinator_->CreateChildMemoryCoordinator(2);
228 228
229 EXPECT_TRUE( 229 EXPECT_TRUE(
230 coordinator_->SetChildMemoryState(1, MemoryState::THROTTLED)); 230 coordinator_->SetChildMemoryState(1, MemoryState::THROTTLED));
231 EXPECT_EQ(1, cmc1->on_state_change_calls()); 231 EXPECT_EQ(1, cmc1->on_state_change_calls());
232 EXPECT_EQ(mojom::MemoryState::THROTTLED, cmc1->state()); 232 EXPECT_EQ(mojom::MemoryState::THROTTLED, cmc1->state());
233 233
234 EXPECT_TRUE( 234 EXPECT_TRUE(
235 coordinator_->SetChildMemoryState(2, MemoryState::SUSPENDED)); 235 coordinator_->SetChildMemoryState(2, MemoryState::SUSPENDED));
236 EXPECT_EQ(1, cmc2->on_state_change_calls()); 236 EXPECT_EQ(1, cmc2->on_state_change_calls());
237 // Child processes are considered as visible (foreground) by default, 237 // Child processes are considered as visible (foreground) by default,
238 // and visible ones won't be suspended but throttled. 238 // and visible ones won't be suspended but throttled.
239 EXPECT_EQ(mojom::MemoryState::THROTTLED, cmc2->state()); 239 EXPECT_EQ(mojom::MemoryState::THROTTLED, cmc2->state());
240 } 240 }
241 241
242 TEST_F(MemoryCoordinatorImplTest, PurgeMemoryChild) { 242 TEST_F(MemoryCoordinatorImplTest, PurgeMemoryChild) {
243 auto* child = coordinator_->CreateChildMemoryCoordinator(1); 243 auto* child = coordinator_->CreateChildMemoryCoordinator(1);
244 EXPECT_EQ(0, child->purge_memory_calls()); 244 EXPECT_EQ(0, child->purge_memory_calls());
245 child->PurgeMemory(); 245 child->PurgeMemory();
246 RunUntilIdle(); 246 RunUntilIdle();
247 EXPECT_EQ(1, child->purge_memory_calls()); 247 EXPECT_EQ(1, child->purge_memory_calls());
248 } 248 }
249 249
250 TEST_F(MemoryCoordinatorImplTest, SetChildMemoryState) { 250 TEST_F(MemoryCoordinatorImplTest, SetChildMemoryState) {
251 auto cmc = coordinator_->CreateChildMemoryCoordinator(1); 251 auto* cmc = coordinator_->CreateChildMemoryCoordinator(1);
252 auto iter = coordinator_->children().find(1); 252 auto iter = coordinator_->children().find(1);
253 auto* render_process_host = coordinator_->GetMockRenderProcessHost(1); 253 auto* render_process_host = coordinator_->GetMockRenderProcessHost(1);
254 ASSERT_TRUE(iter != coordinator_->children().end()); 254 ASSERT_TRUE(iter != coordinator_->children().end());
255 ASSERT_TRUE(render_process_host); 255 ASSERT_TRUE(render_process_host);
256 256
257 // Foreground 257 // Foreground
258 iter->second.is_visible = true; 258 iter->second.is_visible = true;
259 render_process_host->set_is_process_backgrounded(false); 259 render_process_host->set_is_process_backgrounded(false);
260 EXPECT_TRUE(coordinator_->SetChildMemoryState(1, MemoryState::NORMAL)); 260 EXPECT_TRUE(coordinator_->SetChildMemoryState(1, MemoryState::NORMAL));
261 EXPECT_EQ(mojom::MemoryState::NORMAL, cmc->state()); 261 EXPECT_EQ(mojom::MemoryState::NORMAL, cmc->state());
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 506
507 EXPECT_TRUE( 507 EXPECT_TRUE(
508 coordinator_->SetChildMemoryState(1, MemoryState::THROTTLED)); 508 coordinator_->SetChildMemoryState(1, MemoryState::THROTTLED));
509 EXPECT_EQ(base::MemoryState::THROTTLED, 509 EXPECT_EQ(base::MemoryState::THROTTLED,
510 coordinator_->GetStateForProcess(process1.Handle())); 510 coordinator_->GetStateForProcess(process1.Handle()));
511 EXPECT_EQ(base::MemoryState::NORMAL, 511 EXPECT_EQ(base::MemoryState::NORMAL,
512 coordinator_->GetStateForProcess(process2.Handle())); 512 coordinator_->GetStateForProcess(process2.Handle()));
513 } 513 }
514 514
515 } // namespace content 515 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/media/session/audio_focus_manager.cc ('k') | content/browser/renderer_host/media/media_devices_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698