66 lines
1.4 KiB
C++
66 lines
1.4 KiB
C++
#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
|