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

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

Issue 2611323002: Relanding "Multiprocess test client: Android child process launcher rework." (Closed)
Patch Set: Addressed nyquist@'s comment + sync Created 3 years, 11 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
« no previous file with comments | « build/android/pylib/gtest/gtest_test_instance.py ('k') | ipc/run_all_unittests.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 466
467 // Also make sure that the state is updated based on free avaiable memory. 467 // Also make sure that the state is updated based on free avaiable memory.
468 // Since the global state has changed in the previous task, we have to wait 468 // Since the global state has changed in the previous task, we have to wait
469 // for |minimum_transition|. 469 // for |minimum_transition|.
470 GetMockMemoryMonitor()->SetFreeMemoryUntilCriticalMB(40); 470 GetMockMemoryMonitor()->SetFreeMemoryUntilCriticalMB(40);
471 task_runner_->FastForwardBy(minimum_transition); 471 task_runner_->FastForwardBy(minimum_transition);
472 task_runner_->RunUntilIdle(); 472 task_runner_->RunUntilIdle();
473 EXPECT_EQ(base::MemoryState::THROTTLED, coordinator_->GetGlobalMemoryState()); 473 EXPECT_EQ(base::MemoryState::THROTTLED, coordinator_->GetGlobalMemoryState());
474 } 474 }
475 475
476 TEST_F(MemoryCoordinatorImplTest, GetStateForProcess) { 476
477 #if defined(OS_ANDROID)
478 // TODO(jcivelli): Broken on Android. http://crbug.com/678665
479 #define MAYBE_GetStateForProcess DISABLED_GetStateForProcess
480 #else
481 #define MAYBE_GetStateForProcess GetStateForProcess
482 #endif
483 TEST_F(MemoryCoordinatorImplTest, MAYBE_GetStateForProcess) {
477 EXPECT_EQ(base::MemoryState::UNKNOWN, 484 EXPECT_EQ(base::MemoryState::UNKNOWN,
478 coordinator_->GetStateForProcess(base::kNullProcessHandle)); 485 coordinator_->GetStateForProcess(base::kNullProcessHandle));
479 EXPECT_EQ(base::MemoryState::NORMAL, 486 EXPECT_EQ(base::MemoryState::NORMAL,
480 coordinator_->GetStateForProcess(base::GetCurrentProcessHandle())); 487 coordinator_->GetStateForProcess(base::GetCurrentProcessHandle()));
481 488
482 coordinator_->CreateChildMemoryCoordinator(1); 489 coordinator_->CreateChildMemoryCoordinator(1);
483 coordinator_->CreateChildMemoryCoordinator(2); 490 coordinator_->CreateChildMemoryCoordinator(2);
484 base::Process process1 = SpawnChild("process1"); 491 base::Process process1 = SpawnChild("process1");
485 base::Process process2 = SpawnChild("process2"); 492 base::Process process2 = SpawnChild("process2");
486 coordinator_->GetMockRenderProcessHost(1)->SetProcessHandle( 493 coordinator_->GetMockRenderProcessHost(1)->SetProcessHandle(
487 base::MakeUnique<base::ProcessHandle>(process1.Handle())); 494 base::MakeUnique<base::ProcessHandle>(process1.Handle()));
488 coordinator_->GetMockRenderProcessHost(2)->SetProcessHandle( 495 coordinator_->GetMockRenderProcessHost(2)->SetProcessHandle(
489 base::MakeUnique<base::ProcessHandle>(process2.Handle())); 496 base::MakeUnique<base::ProcessHandle>(process2.Handle()));
490 497
491 EXPECT_EQ(base::MemoryState::NORMAL, 498 EXPECT_EQ(base::MemoryState::NORMAL,
492 coordinator_->GetStateForProcess(process1.Handle())); 499 coordinator_->GetStateForProcess(process1.Handle()));
493 EXPECT_EQ(base::MemoryState::NORMAL, 500 EXPECT_EQ(base::MemoryState::NORMAL,
494 coordinator_->GetStateForProcess(process2.Handle())); 501 coordinator_->GetStateForProcess(process2.Handle()));
495 502
496 EXPECT_TRUE( 503 EXPECT_TRUE(
497 coordinator_->SetChildMemoryState(1, MemoryState::THROTTLED)); 504 coordinator_->SetChildMemoryState(1, MemoryState::THROTTLED));
498 EXPECT_EQ(base::MemoryState::THROTTLED, 505 EXPECT_EQ(base::MemoryState::THROTTLED,
499 coordinator_->GetStateForProcess(process1.Handle())); 506 coordinator_->GetStateForProcess(process1.Handle()));
500 EXPECT_EQ(base::MemoryState::NORMAL, 507 EXPECT_EQ(base::MemoryState::NORMAL,
501 coordinator_->GetStateForProcess(process2.Handle())); 508 coordinator_->GetStateForProcess(process2.Handle()));
502 } 509 }
503 510
504 } // namespace content 511 } // namespace content
OLDNEW
« no previous file with comments | « build/android/pylib/gtest/gtest_test_instance.py ('k') | ipc/run_all_unittests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698