Added test case and setting Test configuration

This commit is contained in:
berrux-dev committed 2026-09-11 13:41:20 +02:00
1 parent f815271486
commit a86f9b5bac
48 files changed
+423 -168

No files matched your search

@@ -17,18 +17,16 @@
#include <QtGui/QWheelEvent>
#include <gtest/gtest.h>
// Ensure QApplication is initialized for widget tests
static bool appInitialized = false;
// La QApplication est desormais creee par le main() de la suite (gtest_qt_main.cpp).
//
// Ce fichier en creait une seconde, en statique locale : Qt n'admet qu'une instance,
// et celle-ci etait detruite par exit() APRES celle du main(), d'ou un SIGSEGV dans
// ~QGuiApplication a l'extinction du processus. On se contente donc de verifier
// qu'une instance existe.
static void ensureAppInitialized()
{
if (!appInitialized)
{
static int argc = 1;
static char* argv[] = {(char*)"test_ltswidgets_qt6", nullptr};
static QApplication app(argc, argv);
appInitialized = true;
}
ASSERT_NE(QCoreApplication::instance(), nullptr)
<< "QApplication absente : elle doit etre creee par gtest_qt_main.cpp";
}
// Test 1: QRandomGenerator bounded generation (used in lts_tab_widget.cpp)
@@ -90,9 +88,9 @@ TEST(LtsWidgetsQt6, QComboBoxCurrentTextChangedSignal)
ensureAppInitialized();
QComboBox comboBox;
comboBox.addItem("Option1");
comboBox.addItem("Option2");
comboBox.addItem("Option3");
comboBox.addItem(QStringLiteral("Option1"));
comboBox.addItem(QStringLiteral("Option2"));
comboBox.addItem(QStringLiteral("Option3"));
bool signalReceived = false;
QString receivedText;
@@ -105,7 +103,7 @@ TEST(LtsWidgetsQt6, QComboBoxCurrentTextChangedSignal)
comboBox.setCurrentIndex(1);
EXPECT_TRUE(signalReceived);
EXPECT_EQ(receivedText, "Option2");
EXPECT_EQ(receivedText, QStringLiteral("Option2"));
}
// Test 5: QComboBox activated signal with int parameter (Qt6)
@@ -115,9 +113,9 @@ TEST(LtsWidgetsQt6, QComboBoxActivatedIntSignal)
ensureAppInitialized();
QComboBox comboBox;
comboBox.addItem("First");
comboBox.addItem("Second");
comboBox.addItem("Third");
comboBox.addItem(QStringLiteral("First"));
comboBox.addItem(QStringLiteral("Second"));
comboBox.addItem(QStringLiteral("Third"));
bool signalReceived = false;
int receivedIndex = -1;
@@ -145,7 +143,7 @@ TEST(LtsWidgetsQt6, QStyleOptionInitFrom)
{
ensureAppInitialized();
QPushButton button("Test");
QPushButton button(QStringLiteral("Test"));
button.resize(100, 30);
button.setEnabled(true);
@@ -163,8 +161,8 @@ TEST(LtsWidgetsQt6, QStyleOptionInitFromMultipleWidgets)
{
ensureAppInitialized();
QPushButton button1("Btn1");
QPushButton button2("Btn2");
QPushButton button1(QStringLiteral("Btn1"));
QPushButton button2(QStringLiteral("Btn2"));
button1.setEnabled(true);
button2.setEnabled(false);