Add test for LtsTimelineClassic Event.cpp
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
1 file changed
+66
@@ -0,0 +1,66 @@
|
||||
#include "Lts/Common/LtsTimelineClassic/Event.h"
|
||||
|
||||
#include <QColor>
|
||||
#include <QJsonObject>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
namespace LtsTimelineClassic
|
||||
{
|
||||
|
||||
class EventTest : public ::testing::Test
|
||||
{
|
||||
protected:
|
||||
void SetUp() override {}
|
||||
|
||||
void TearDown() override {}
|
||||
};
|
||||
|
||||
TEST(EventTest, ConstructorInitializesMembers)
|
||||
{
|
||||
QStringList path = {"actuator", "subactuator"};
|
||||
QJsonObject detailData;
|
||||
detailData["key"] = "value";
|
||||
QColor color(Qt::red);
|
||||
|
||||
Event event(1, 2, 1000, 2000, 3, 4, 5, path, nullptr, color, detailData);
|
||||
|
||||
EXPECT_EQ(event.uniqueId(), 1);
|
||||
EXPECT_EQ(event.typeId(), 2);
|
||||
EXPECT_EQ(event.startTime(), 1000);
|
||||
EXPECT_EQ(event.endTime(), 2000);
|
||||
EXPECT_EQ(event.playerId(), 3);
|
||||
EXPECT_EQ(event.partyId(), 4);
|
||||
EXPECT_EQ(event.equipmentId(), 5);
|
||||
EXPECT_EQ(event.getActuator(), path);
|
||||
EXPECT_EQ(event.getColor(), color);
|
||||
}
|
||||
|
||||
TEST(EventTest, DurationCalculation)
|
||||
{
|
||||
Event event(1, 2, 1000, 3000, 0, 0, 0, QStringList(), nullptr, QColor());
|
||||
|
||||
qint64 duration = event.duration(true);
|
||||
|
||||
EXPECT_EQ(duration, 2000);
|
||||
}
|
||||
|
||||
TEST(EventTest, VisibilityToggle)
|
||||
{
|
||||
Event event;
|
||||
|
||||
EXPECT_TRUE(event.isVisible());
|
||||
|
||||
event.hide();
|
||||
EXPECT_FALSE(event.isVisible());
|
||||
|
||||
event.show();
|
||||
EXPECT_TRUE(event.isVisible());
|
||||
|
||||
event.setVisible(false);
|
||||
EXPECT_FALSE(event.isVisible());
|
||||
|
||||
event.setVisible(true);
|
||||
EXPECT_TRUE(event.isVisible());
|
||||
}
|
||||
|
||||
} // namespace LtsTimelineClassic
|
||||
Reference in new issue
Block a user