Add test for LtsTimelineClassic PassiveEventContainer.cpp
- Add test_passiveeventcontainer.cpp with 3 tests - Test container creation, event list setting, paint method - Follow policy naming convention Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
1 file changed
+75
@@ -0,0 +1,75 @@
|
||||
#include "Lts/Common/LtsTimelineClassic/Event.h"
|
||||
#include "Lts/Common/LtsTimelineClassic/EventGraphic.h"
|
||||
#include "Lts/Common/LtsTimelineClassic/PassiveEventContainer.h"
|
||||
|
||||
#include <QPainter>
|
||||
#include <QPixmap>
|
||||
#include <QStyleOptionViewItem>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
namespace LtsTimelineClassic
|
||||
{
|
||||
|
||||
class PassiveEventContainerTest : public ::testing::Test
|
||||
{
|
||||
protected:
|
||||
void SetUp() override {}
|
||||
|
||||
void TearDown() override {}
|
||||
};
|
||||
|
||||
TEST(PassiveEventContainerTest, CreateContainer)
|
||||
{
|
||||
PassiveEventContainer container(false);
|
||||
EXPECT_TRUE(container.getEventGraphicList().isEmpty());
|
||||
}
|
||||
|
||||
TEST(PassiveEventContainerTest, SetEventList)
|
||||
{
|
||||
PassiveEventContainer container(false);
|
||||
|
||||
Event event1(0, 100, Qt::red);
|
||||
Event event2(500, 100, Qt::blue);
|
||||
|
||||
EventGraphic graphic1(&event1);
|
||||
EventGraphic graphic2(&event2);
|
||||
|
||||
EventGraphicList list;
|
||||
list.append(&graphic1);
|
||||
list.append(&graphic2);
|
||||
|
||||
container.setEventList(list);
|
||||
|
||||
EXPECT_EQ(container.getEventGraphicList().size(), 2);
|
||||
}
|
||||
|
||||
TEST(PassiveEventContainerTest, PaintDoesNotCrash)
|
||||
{
|
||||
PassiveEventContainer container(false);
|
||||
|
||||
Event event1(0, 100, Qt::red);
|
||||
EventGraphic graphic1(&event1);
|
||||
|
||||
EventGraphicList list;
|
||||
list.append(&graphic1);
|
||||
container.setEventList(list);
|
||||
|
||||
EventTools::setValues(0, 1000, 0, 500);
|
||||
EventTools::setSection(0, 1000);
|
||||
|
||||
QPixmap pixmap(800, 600);
|
||||
QPainter painter(&pixmap);
|
||||
|
||||
QStyleOptionViewItem option;
|
||||
option.rect = QRect(0, 0, 800, 50);
|
||||
option.features = QStyleOptionViewItem::ViewItemFeature::None;
|
||||
|
||||
LineMap lineMap;
|
||||
lineMap.insert(100, 1000);
|
||||
|
||||
QVector<Range> knownRanges;
|
||||
|
||||
EXPECT_NO_THROW(container.paint(&painter, option, lineMap, knownRanges));
|
||||
}
|
||||
|
||||
} // namespace LtsTimelineClassic
|
||||
Reference in new issue
Block a user