| 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..9ba50c3109022be8757370123d8e38c2ba819fde 100644
|
| --- a/content/browser/mach_broker_mac_unittest.cc
|
| +++ b/content/browser/mach_broker_mac_unittest.cc
|
| @@ -12,13 +12,17 @@ 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 GetChildProcessCount(int child_process_id) {
|
| + return broker_.child_process_id_map_.count(child_process_id);
|
| }
|
|
|
| // Helper function to acquire/release locks and call |FinalizePid()|.
|
| @@ -39,7 +43,7 @@ TEST_F(MachBrokerTest, Locks) {
|
|
|
| TEST_F(MachBrokerTest, AddPlaceholderAndFinalize) {
|
| // Add a placeholder for PID 1.
|
| - AddPlaceholderForPid(1);
|
| + AddPlaceholderForPid(1, 1);
|
| EXPECT_EQ(0u, broker_.TaskForPid(1));
|
|
|
| // Finalize PID 1.
|
| @@ -50,15 +54,26 @@ TEST_F(MachBrokerTest, AddPlaceholderAndFinalize) {
|
| EXPECT_EQ(0u, broker_.TaskForPid(2));
|
| }
|
|
|
| -TEST_F(MachBrokerTest, Invalidate) {
|
| - AddPlaceholderForPid(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));
|
| - InvalidatePid(1u);
|
| + InvalidateChildProcessId(50);
|
| EXPECT_EQ(0u, broker_.TaskForPid(1));
|
| }
|
|
|
| +TEST_F(MachBrokerTest, ValidateChildProcessIdMap) {
|
| + // Add a placeholder for PID 1 and child process id 50.
|
| + AddPlaceholderForPid(1, 50);
|
| + FinalizePid(1, 100u);
|
| +
|
| + EXPECT_EQ(1, GetChildProcessCount(50));
|
| + InvalidateChildProcessId(50);
|
| + EXPECT_EQ(0, GetChildProcessCount(50));
|
| +}
|
| +
|
| TEST_F(MachBrokerTest, FinalizeUnknownPid) {
|
| // Finalizing an entry for an unknown pid should not add it to the map.
|
| FinalizePid(1u, 100u);
|
|
|