summaryrefslogtreecommitdiffstats
path: root/Tests/CMakeGUI/CMakeGUITest.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Tests/CMakeGUI/CMakeGUITest.cxx')
-rw-r--r--Tests/CMakeGUI/CMakeGUITest.cxx75
1 files changed, 75 insertions, 0 deletions
diff --git a/Tests/CMakeGUI/CMakeGUITest.cxx b/Tests/CMakeGUI/CMakeGUITest.cxx
index a7a5d17..4087d6b 100644
--- a/Tests/CMakeGUI/CMakeGUITest.cxx
+++ b/Tests/CMakeGUI/CMakeGUITest.cxx
@@ -2,8 +2,10 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "CMakeGUITest.h"
+#include "QCMake.h"
#include <QApplication>
#include <QEventLoop>
+#include <QMessageBox>
#include <QSettings>
#include <QString>
#include <QStringList>
@@ -13,6 +15,9 @@
#include "CMakeSetupDialog.h"
+#include "CatchShow.h"
+#include "FirstConfigure.h"
+
namespace {
void loopSleep(int msecs = 100)
{
@@ -28,6 +33,44 @@ CMakeGUITest::CMakeGUITest(CMakeSetupDialog* window, QObject* parent)
{
}
+void CMakeGUITest::tryConfigure(int expectedResult, int timeout)
+{
+ auto* cmake = this->m_window->findChild<QCMakeThread*>()->cmakeInstance();
+
+ bool done = false;
+ CatchShow catchConfigure;
+ catchConfigure.setCallback<FirstConfigure>([&done](FirstConfigure* dialog) {
+ if (done) {
+ return;
+ }
+ done = true;
+
+ dialog->findChild<StartCompilerSetup*>()->setCurrentGenerator(
+ CMAKE_GENERATOR);
+ dialog->accept();
+ });
+
+ CatchShow catchMessages;
+ catchMessages.setCallback<QMessageBox>([](QMessageBox* box) {
+ if (box->text().contains("Build directory does not exist")) {
+ box->accept();
+ }
+
+ if (box->text().contains("Error in configuration process")) {
+ box->accept();
+ }
+ });
+
+ QSignalSpy configureDoneSpy(cmake, &QCMake::configureDone);
+ QVERIFY(configureDoneSpy.isValid());
+ QMetaObject::invokeMethod(
+ this->m_window, [this]() { this->m_window->ConfigureButton->click(); },
+ Qt::QueuedConnection);
+ QVERIFY(configureDoneSpy.wait(timeout));
+
+ QCOMPARE(configureDoneSpy, { { expectedResult } });
+}
+
void CMakeGUITest::sourceBinaryArgs()
{
QFETCH(QString, sourceDir);
@@ -68,6 +111,38 @@ void CMakeGUITest::sourceBinaryArgs_data()
<< CMakeGUITest_BINARY_DIR "/sourceBinaryArgs-noExistConfigExists/build";
}
+void CMakeGUITest::simpleConfigure()
+{
+ QFETCH(QString, sourceDir);
+ QFETCH(QString, binaryDir);
+ QFETCH(int, expectedResult);
+
+ this->m_window->SourceDirectory->setText(sourceDir);
+ this->m_window->BinaryDirectory->setCurrentText(binaryDir);
+
+ // Wait a bit for everything to update
+ loopSleep();
+
+ this->tryConfigure(expectedResult, 1000);
+}
+
+void CMakeGUITest::simpleConfigure_data()
+{
+ QTest::addColumn<QString>("sourceDir");
+ QTest::addColumn<QString>("binaryDir");
+ QTest::addColumn<int>("expectedResult");
+
+ QTest::newRow("success") << CMakeGUITest_BINARY_DIR
+ "/simpleConfigure-success/src"
+ << CMakeGUITest_BINARY_DIR
+ "/simpleConfigure-success/build"
+ << 0;
+ QTest::newRow("fail") << CMakeGUITest_BINARY_DIR "/simpleConfigure-fail/src"
+ << CMakeGUITest_BINARY_DIR
+ "/simpleConfigure-fail/build"
+ << -1;
+}
+
void SetupDefaultQSettings()
{
QSettings::setDefaultFormat(QSettings::IniFormat);