2023-12-15 05:43:08 +00:00
|
|
|
#include "GameDependencies.h"
|
|
|
|
#include <gtest/gtest.h>
|
|
|
|
|
|
|
|
#include "BitStream.h"
|
|
|
|
#include "PetComponent.h"
|
|
|
|
#include "Entity.h"
|
|
|
|
#include "eReplicaComponentType.h"
|
|
|
|
#include "ePetAbilityType.h"
|
|
|
|
#include "eStateChangeType.h"
|
|
|
|
|
|
|
|
class PetTest : public GameDependenciesTest {
|
|
|
|
protected:
|
|
|
|
Entity* baseEntity;
|
|
|
|
PetComponent* petComponent;
|
|
|
|
CBITSTREAM
|
2023-12-15 11:34:38 +00:00
|
|
|
|
2023-12-15 05:43:08 +00:00
|
|
|
void SetUp() override {
|
|
|
|
SetUpDependencies();
|
|
|
|
|
|
|
|
// Set up entity and pet component
|
2023-12-15 11:34:38 +00:00
|
|
|
baseEntity = new Entity(15, GameDependenciesTest::info);
|
2023-12-15 05:43:08 +00:00
|
|
|
petComponent = baseEntity->AddComponent<PetComponent>(1);
|
|
|
|
|
|
|
|
// Initialize some values to be not default
|
2023-12-15 20:36:27 +00:00
|
|
|
|
2023-12-15 05:43:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TearDown() override {
|
|
|
|
delete baseEntity;
|
|
|
|
TearDownDependencies();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2024-04-20 02:53:52 +00:00
|
|
|
TEST_F(PetTest, PlacementNewAddComponentTest) {
|
|
|
|
using enum PetFlag;
|
|
|
|
|
|
|
|
// Test adding component
|
|
|
|
ASSERT_NE(petComponent, nullptr);
|
|
|
|
baseEntity->AddComponent<PetComponent>(1);
|
|
|
|
ASSERT_NE(baseEntity->GetComponent<PetComponent>(), nullptr);
|
|
|
|
|
|
|
|
// Test getting initial status
|
|
|
|
ASSERT_EQ(petComponent->GetParent()->GetObjectID(), 15);
|
2024-04-20 22:32:19 +00:00
|
|
|
ASSERT_EQ(petComponent->GetPetAiState(), PetAiState::spawn);
|
2024-04-20 02:53:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-04-01 02:49:59 +00:00
|
|
|
TEST_F(PetTest, PetAiState) {
|
|
|
|
const auto initialState = petComponent->GetPetAiState();
|
2024-04-20 22:32:19 +00:00
|
|
|
ASSERT_EQ(initialState, PetAiState::spawn);
|
2024-04-01 02:49:59 +00:00
|
|
|
|
2024-04-20 22:32:19 +00:00
|
|
|
petComponent->SetPetAiState(PetAiState::follow);
|
|
|
|
ASSERT_EQ(PetAiState::follow, petComponent->GetPetAiState());
|
2024-04-01 02:49:59 +00:00
|
|
|
|
2024-04-20 22:32:19 +00:00
|
|
|
petComponent->SetPetAiState(PetAiState::idle);
|
|
|
|
ASSERT_EQ(PetAiState::idle, petComponent->GetPetAiState());
|
2024-04-01 02:49:59 +00:00
|
|
|
|
2024-04-20 22:32:19 +00:00
|
|
|
petComponent->SetPetAiState(PetAiState::interact);
|
|
|
|
ASSERT_EQ(PetAiState::interact, petComponent->GetPetAiState());
|
2024-04-01 02:49:59 +00:00
|
|
|
|
2024-04-20 22:32:19 +00:00
|
|
|
petComponent->SetPetAiState(PetAiState::despawn);
|
|
|
|
ASSERT_EQ(PetAiState::despawn, petComponent->GetPetAiState());
|
2024-04-01 02:49:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Test the pet use logic
|
|
|
|
TEST_F(PetTest, PetUse) {
|
|
|
|
ASSERT_FALSE(petComponent->IsReadyToInteract());
|
|
|
|
|
|
|
|
petComponent->SetIsReadyToInteract(true);
|
|
|
|
ASSERT_TRUE(petComponent->IsReadyToInteract());
|
|
|
|
|
|
|
|
// Test bouncer logic
|
|
|
|
ASSERT_FALSE(petComponent->IsHandlingInteraction());
|
|
|
|
petComponent->OnUse(baseEntity);
|
|
|
|
|
|
|
|
// need to add a destroyable component to the test entity and test the imagination drain
|
|
|
|
|
|
|
|
}
|