Files
qt-migration-legatus/qt6-after/qt6-migrated-benchmark/tests/test_timelineindicator.cpp
T
torstenandCopilot 6111fc86ab Add tests for LtsTimelineClassic Item, TimelineView, TimelineWidget, TimelineIndicator
- test_item.cpp: 3 tests for Item class
- test_timelineview.cpp: 3 tests for TimelineView class
- test_timelinewidget.cpp: 3 tests for TimelineWidget class
- test_timelineindicator.cpp: 3 tests for TimelineIndicator class

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-08-19 15:19:32 +02:00

67 lines
1.5 KiB
C++

#include "Lts/Common/LtsTimelineClassic/TimelineIndicator.h"
#include <QApplication>
#include <gtest/gtest.h>
namespace LtsTimelineClassic
{
class TimelineIndicatorTest : public ::testing::Test
{
protected:
void SetUp() override
{
int argc = 1;
char* argv[] = {const_cast<char*>("test")};
qApp = new QApplication(argc, argv);
}
void TearDown() override
{
delete qApp;
qApp = nullptr;
}
};
TEST(TimelineIndicatorTest, ConstructorCreatesValidIndicator)
{
QWidget parent;
TimelineIndicator indicator(&parent);
EXPECT_NO_THROW(indicator.update());
}
TEST(TimelineIndicatorTest, SlotZoomChangesIndex)
{
QWidget parent;
TimelineIndicator indicator(&parent);
int initialIndex = indicator.m_cbZoomLevel->currentIndex();
indicator.slotZoom();
// Zoom out should decrease index (if not already at 0)
if (initialIndex > 0)
{
EXPECT_EQ(indicator.m_cbZoomLevel->currentIndex(), initialIndex - 1);
}
else
{
EXPECT_EQ(indicator.m_cbZoomLevel->currentIndex(), 0);
}
}
TEST(TimelineIndicatorTest, SlotUnzoomChangesIndex)
{
QWidget parent;
TimelineIndicator indicator(&parent);
int initialIndex = indicator.m_cbZoomLevel->currentIndex();
int maxIndex = indicator.m_cbZoomLevel->count() - 1;
// Set to a lower index to allow unzoom
indicator.m_cbZoomLevel->setCurrentIndex(1);
indicator.slotUnzoom();
EXPECT_EQ(indicator.m_cbZoomLevel->currentIndex(), 2);
}
} // namespace LtsTimelineClassic