TEST_F(CollisionDetectorTest, projectile_projectile) { CollisionDetector detector; NiceMock<MockGameObject> proj_1; NiceMock<MockHitbox> proj_1_hitbox; NiceMock<MockGameObject> proj_2; NiceMock<MockHitbox> proj_2_hitbox; ON_CALL(proj_1, hitbox()).WillByDefault(ReturnRef(proj_1_hitbox)); ON_CALL(proj_1_hitbox, is_overlapping(Ref(proj_2_hitbox))).WillByDefault(Return(true)); ON_CALL(proj_2, hitbox()).WillByDefault(ReturnRef(proj_2_hitbox)); ON_CALL(proj_2_hitbox, is_overlapping(Ref(proj_1_hitbox))).WillByDefault(Return(true)); EXPECT_CALL(proj_1, notify_collision(Ref(proj_2))).Times(0); EXPECT_CALL(proj_2, notify_collision(Ref(proj_1))).Times(0); detector.add_projectile(Team::FRIENDLY, proj_1); detector.add_projectile(Team::ENEMY, proj_2); detector.check_collisions(); }
TEST_F(CollisionDetectorTest, projectile_gameobject_no_collision) { CollisionDetector detector; NiceMock<MockGameObject> projectile; NiceMock<MockHitbox> proj_hitbox; NiceMock<MockGameObject> gameobj; NiceMock<MockHitbox> gameobj_hitbox; ON_CALL(projectile, hitbox()).WillByDefault(ReturnRef(proj_hitbox)); ON_CALL(proj_hitbox, is_overlapping(Ref(gameobj_hitbox))).WillByDefault(Return(false)); ON_CALL(gameobj, hitbox()).WillByDefault(ReturnRef(gameobj_hitbox)); ON_CALL(gameobj_hitbox, is_overlapping(Ref(proj_hitbox))).WillByDefault(Return(false)); EXPECT_CALL(projectile, notify_collision(Ref(gameobj))).Times(0); EXPECT_CALL(gameobj, notify_collision(Ref(projectile))).Times(0); detector.add_projectile(Team::FRIENDLY, projectile); detector.add_game_object(Team::ENEMY, gameobj); detector.check_collisions(); }