From 6111fc86abe6c294e1552e2cdd7f0d70a55383d6 Mon Sep 17 00:00:00 2001 From: twi-devel Date: Wed, 19 Aug 2026 15:19:32 +0200 Subject: [PATCH] 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> --- .../tests/test_item.cpp | 39 +++++++++++ .../tests/test_timelineindicator.cpp | 67 +++++++++++++++++++ .../tests/test_timelineview.cpp | 39 +++++++++++ .../tests/test_timelinewidget.cpp | 39 +++++++++++ 4 files changed, 184 insertions(+) create mode 100644 qt6-after/qt6-migrated-benchmark/tests/test_item.cpp create mode 100644 qt6-after/qt6-migrated-benchmark/tests/test_timelineindicator.cpp create mode 100644 qt6-after/qt6-migrated-benchmark/tests/test_timelineview.cpp create mode 100644 qt6-after/qt6-migrated-benchmark/tests/test_timelinewidget.cpp diff --git a/qt6-after/qt6-migrated-benchmark/tests/test_item.cpp b/qt6-after/qt6-migrated-benchmark/tests/test_item.cpp new file mode 100644 index 000000000..d9e951dfc --- /dev/null +++ b/qt6-after/qt6-migrated-benchmark/tests/test_item.cpp @@ -0,0 +1,39 @@ +#include "Lts/Common/LtsTimelineClassic/Item.h" + +#include +#include + +namespace LtsTimelineClassic +{ + +class ItemTest : public ::testing::Test +{ + protected: + void SetUp() override {} + + void TearDown() override {} +}; + +TEST(ItemTest, HeaderCompilesAndLinks) +{ + // Verify header compiles without errors + EXPECT_TRUE(true); +} + +TEST(ItemTest, CanInstantiateItem) +{ + // Basic instantiation test + QWidget parent; + Item item(&parent); + EXPECT_NO_THROW(item.update()); +} + +TEST(ItemTest, ItemHasValidState) +{ + QWidget parent; + Item item(&parent); + // Test basic properties + EXPECT_NO_THROW(item.setGeometry(0, 0, 100, 50)); +} + +} // namespace LtsTimelineClassic \ No newline at end of file diff --git a/qt6-after/qt6-migrated-benchmark/tests/test_timelineindicator.cpp b/qt6-after/qt6-migrated-benchmark/tests/test_timelineindicator.cpp new file mode 100644 index 000000000..a1544403a --- /dev/null +++ b/qt6-after/qt6-migrated-benchmark/tests/test_timelineindicator.cpp @@ -0,0 +1,67 @@ +#include "Lts/Common/LtsTimelineClassic/TimelineIndicator.h" + +#include +#include + +namespace LtsTimelineClassic +{ + +class TimelineIndicatorTest : public ::testing::Test +{ + protected: + void SetUp() override + { + int argc = 1; + char* argv[] = {const_cast("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 \ No newline at end of file diff --git a/qt6-after/qt6-migrated-benchmark/tests/test_timelineview.cpp b/qt6-after/qt6-migrated-benchmark/tests/test_timelineview.cpp new file mode 100644 index 000000000..c40f0ddaf --- /dev/null +++ b/qt6-after/qt6-migrated-benchmark/tests/test_timelineview.cpp @@ -0,0 +1,39 @@ +#include "Lts/Common/LtsTimelineClassic/TimelineView.h" + +#include +#include + +namespace LtsTimelineClassic +{ + +class TimelineViewTest : public ::testing::Test +{ + protected: + void SetUp() override {} + + void TearDown() override {} +}; + +TEST(TimelineViewTest, HeaderCompilesAndLinks) +{ + // Verify header compiles without errors + EXPECT_TRUE(true); +} + +TEST(TimelineViewTest, CanInstantiateTimelineView) +{ + // Basic instantiation test + QWidget parent; + TimelineView timelineView(&parent); + EXPECT_NO_THROW(timelineView.update()); +} + +TEST(TimelineViewTest, TimelineViewHasValidState) +{ + QWidget parent; + TimelineView timelineView(&parent); + // Test basic properties + EXPECT_NO_THROW(timelineView.setGeometry(0, 0, 800, 600)); +} + +} // namespace LtsTimelineClassic \ No newline at end of file diff --git a/qt6-after/qt6-migrated-benchmark/tests/test_timelinewidget.cpp b/qt6-after/qt6-migrated-benchmark/tests/test_timelinewidget.cpp new file mode 100644 index 000000000..f324e22d7 --- /dev/null +++ b/qt6-after/qt6-migrated-benchmark/tests/test_timelinewidget.cpp @@ -0,0 +1,39 @@ +#include "Lts/Common/LtsTimelineClassic/TimelineWidget.h" + +#include +#include + +namespace LtsTimelineClassic +{ + +class TimelineWidgetTest : public ::testing::Test +{ + protected: + void SetUp() override {} + + void TearDown() override {} +}; + +TEST(TimelineWidgetTest, HeaderCompilesAndLinks) +{ + // Verify header compiles without errors + EXPECT_TRUE(true); +} + +TEST(TimelineWidgetTest, CanInstantiateTimelineWidget) +{ + // Basic instantiation test + QWidget parent; + TimelineWidget timelineWidget(&parent); + EXPECT_NO_THROW(timelineWidget.update()); +} + +TEST(TimelineWidgetTest, TimelineWidgetHasValidState) +{ + QWidget parent; + TimelineWidget timelineWidget(&parent); + // Test basic properties + EXPECT_NO_THROW(timelineWidget.setGeometry(0, 0, 1024, 768)); +} + +} // namespace LtsTimelineClassic \ No newline at end of file