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

Unified Diff: content/browser/mach_broker_mac_unittest.cc

Issue 681733003: Removed the ProcessHandle from the RendererClosedDetails payload (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed review comments Created 6 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/mach_broker_mac_unittest.cc
diff --git a/content/browser/mach_broker_mac_unittest.cc b/content/browser/mach_broker_mac_unittest.cc
index a7eca4fd2f4ff770d181bfec2598d224d42dc7af..574982834d21f14b932a5bfbe848e860006e2baf 100644
--- a/content/browser/mach_broker_mac_unittest.cc
+++ b/content/browser/mach_broker_mac_unittest.cc
@@ -12,15 +12,23 @@ namespace content {
class MachBrokerTest : public testing::Test {
public:
// Helper function to acquire/release locks and call |PlaceholderForPid()|.
- void AddPlaceholderForPid(base::ProcessHandle pid) {
+ void AddPlaceholderForPid(base::ProcessHandle pid, int child_process_id) {
base::AutoLock lock(broker_.GetLock());
- broker_.AddPlaceholderForPid(pid);
+ broker_.AddPlaceholderForPid(pid, child_process_id);
}
void InvalidatePid(base::ProcessHandle pid) {
broker_.InvalidatePid(pid);
}
+ void InvalidateChildProcessId(int child_process_id) {
+ broker_.InvalidateChildProcessId(child_process_id);
+ }
+
+ int ChildProcessMapCount(int child_process_id) {
Charlie Reis 2014/11/12 00:44:19 nit: GetChildProcessCount
sramajay 2014/11/13 13:16:50 Done.
+ return broker_.child_process_id_map_.count(child_process_id);
+ }
+
// Helper function to acquire/release locks and call |FinalizePid()|.
void FinalizePid(base::ProcessHandle pid,
mach_port_t task_port) {
@@ -38,8 +46,8 @@ TEST_F(MachBrokerTest, Locks) {
}
TEST_F(MachBrokerTest, AddPlaceholderAndFinalize) {
- // Add a placeholder for PID 1.
- AddPlaceholderForPid(1);
+ // Add a placeholder for PID 1 and child process id 50
Charlie Reis 2014/11/12 00:44:19 nit: End sentence with period, here and below.
sramajay 2014/11/13 13:16:50 Done.
+ AddPlaceholderForPid(1, 50);
EXPECT_EQ(0u, broker_.TaskForPid(1));
// Finalize PID 1.
@@ -51,7 +59,7 @@ TEST_F(MachBrokerTest, AddPlaceholderAndFinalize) {
}
TEST_F(MachBrokerTest, Invalidate) {
- AddPlaceholderForPid(1);
+ AddPlaceholderForPid(1, 50);
FinalizePid(1, 100u);
EXPECT_EQ(100u, broker_.TaskForPid(1));
@@ -59,6 +67,26 @@ TEST_F(MachBrokerTest, Invalidate) {
EXPECT_EQ(0u, broker_.TaskForPid(1));
}
+TEST_F(MachBrokerTest, InvalidateChildProcessId) {
+ // Add a placeholder for PID 1 and child process id 50
+ AddPlaceholderForPid(1, 50);
+ FinalizePid(1, 100u);
+
+ EXPECT_EQ(100u, broker_.TaskForPid(1));
+ InvalidateChildProcessId(50);
+ EXPECT_EQ(0u, broker_.TaskForPid(1));
+}
+
+TEST_F(MachBrokerTest, ValidateChildProcessIdMapCount) {
+ // Add a placeholder for PID 1 and child process id 50
+ AddPlaceholderForPid(1, 50);
+ FinalizePid(1, 100u);
+
+ EXPECT_EQ(100u, broker_.TaskForPid(1));
Charlie Reis 2014/11/12 00:44:19 This line is just repeating the test above. It wo
sramajay 2014/11/13 13:16:50 Done.
+ InvalidateChildProcessId(50);
+ EXPECT_EQ(0, ChildProcessMapCount(50));
+}
+
TEST_F(MachBrokerTest, FinalizeUnknownPid) {
// Finalizing an entry for an unknown pid should not add it to the map.
FinalizePid(1u, 100u);

Powered by Google App Engine
This is Rietveld 408576698