This source file includes following definitions.
- AddPlaceholderForPid
- InvalidatePid
- FinalizePid
- TEST_F
- TEST_F
- TEST_F
- TEST_F
#include "content/browser/mach_broker_mac.h"
#include "base/synchronization/lock.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace content {
class MachBrokerTest : public testing::Test {
public:
void AddPlaceholderForPid(base::ProcessHandle pid) {
base::AutoLock lock(broker_.GetLock());
broker_.AddPlaceholderForPid(pid);
}
void InvalidatePid(base::ProcessHandle pid) {
broker_.InvalidatePid(pid);
}
void FinalizePid(base::ProcessHandle pid,
mach_port_t task_port) {
base::AutoLock lock(broker_.GetLock());
broker_.FinalizePid(pid, task_port);
}
protected:
MachBroker broker_;
};
TEST_F(MachBrokerTest, Locks) {
base::AutoLock lock(broker_.GetLock());
}
TEST_F(MachBrokerTest, AddPlaceholderAndFinalize) {
AddPlaceholderForPid(1);
EXPECT_EQ(0u, broker_.TaskForPid(1));
FinalizePid(1, 100u);
EXPECT_EQ(100u, broker_.TaskForPid(1));
EXPECT_EQ(0u, broker_.TaskForPid(2));
}
TEST_F(MachBrokerTest, Invalidate) {
AddPlaceholderForPid(1);
FinalizePid(1, 100u);
EXPECT_EQ(100u, broker_.TaskForPid(1));
InvalidatePid(1u);
EXPECT_EQ(0u, broker_.TaskForPid(1));
}
TEST_F(MachBrokerTest, FinalizeUnknownPid) {
FinalizePid(1u, 100u);
EXPECT_EQ(0u, broker_.TaskForPid(1u));
}
}