diff options
author | Kyle Edwards <kyle.edwards@kitware.com> | 2020-09-25 20:56:27 (GMT) |
---|---|---|
committer | Kyle Edwards <kyle.edwards@kitware.com> | 2020-09-28 13:46:35 (GMT) |
commit | d6c051c126a8cba8adec39b6ae3ae09cc773633f (patch) | |
tree | b91277b250ce42dab4e5169f6eec9ee3f834c755 /Tests/CMakeGUI | |
parent | 7cd95d99965bf59e2ba8e5cb2835fb9d5d1b3abe (diff) | |
download | CMake-d6c051c126a8cba8adec39b6ae3ae09cc773633f.zip CMake-d6c051c126a8cba8adec39b6ae3ae09cc773633f.tar.gz CMake-d6c051c126a8cba8adec39b6ae3ae09cc773633f.tar.bz2 |
Tests: Add some basic configure tests for the CMake GUI
Diffstat (limited to 'Tests/CMakeGUI')
-rw-r--r-- | Tests/CMakeGUI/CMakeGUITest.cmake | 3 | ||||
-rw-r--r-- | Tests/CMakeGUI/CMakeGUITest.cxx | 75 | ||||
-rw-r--r-- | Tests/CMakeGUI/CMakeGUITest.h | 4 | ||||
-rw-r--r-- | Tests/CMakeGUI/CMakeLists.txt | 1 | ||||
-rw-r--r-- | Tests/CMakeGUI/simpleConfigure-fail/CMakeLists.txt.in | 5 | ||||
-rw-r--r-- | Tests/CMakeGUI/simpleConfigure-success/CMakeLists.txt.in | 4 |
6 files changed, 92 insertions, 0 deletions
diff --git a/Tests/CMakeGUI/CMakeGUITest.cmake b/Tests/CMakeGUI/CMakeGUITest.cmake index 3d8c27e..632ab09 100644 --- a/Tests/CMakeGUI/CMakeGUITest.cmake +++ b/Tests/CMakeGUI/CMakeGUITest.cmake @@ -109,3 +109,6 @@ run_cmake_gui_test(sourceBinaryArgs:noExistConfigExists ARGS "${CMakeGUITest_BINARY_DIR}/sourceBinaryArgs-noExistConfigExists/noexist" ) + +run_cmake_gui_test(simpleConfigure:success) +run_cmake_gui_test(simpleConfigure:fail) 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); diff --git a/Tests/CMakeGUI/CMakeGUITest.h b/Tests/CMakeGUI/CMakeGUITest.h index 55a885b..f39dcc1 100644 --- a/Tests/CMakeGUI/CMakeGUITest.h +++ b/Tests/CMakeGUI/CMakeGUITest.h @@ -15,7 +15,11 @@ public: private: CMakeSetupDialog* m_window = nullptr; + void tryConfigure(int expectedResult = 0, int timeout = 60000); + private slots: void sourceBinaryArgs(); void sourceBinaryArgs_data(); + void simpleConfigure(); + void simpleConfigure_data(); }; diff --git a/Tests/CMakeGUI/CMakeLists.txt b/Tests/CMakeGUI/CMakeLists.txt index b94afe5..ea97fa0 100644 --- a/Tests/CMakeGUI/CMakeLists.txt +++ b/Tests/CMakeGUI/CMakeLists.txt @@ -27,6 +27,7 @@ target_link_libraries(CMakeGUITest CMakeGUIMainLib CMakeGUITestLib Qt5::Core Qt5 target_compile_definitions(CMakeGUITest PRIVATE "CMakeGUITest_SOURCE_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}\"" "CMakeGUITest_BINARY_DIR=\"${CMAKE_CURRENT_BINARY_DIR}\"" + "CMAKE_GENERATOR=\"${CMAKE_GENERATOR}\"" ) add_test(NAME CMakeGUI COMMAND ${CMAKE_CMAKE_COMMAND} diff --git a/Tests/CMakeGUI/simpleConfigure-fail/CMakeLists.txt.in b/Tests/CMakeGUI/simpleConfigure-fail/CMakeLists.txt.in new file mode 100644 index 0000000..dc55064 --- /dev/null +++ b/Tests/CMakeGUI/simpleConfigure-fail/CMakeLists.txt.in @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 3.18) +project(simpleConfigure-fail NONE) + +message(STATUS "This is a failed configure") +message(FATAL_ERROR "Error") diff --git a/Tests/CMakeGUI/simpleConfigure-success/CMakeLists.txt.in b/Tests/CMakeGUI/simpleConfigure-success/CMakeLists.txt.in new file mode 100644 index 0000000..fc42c00 --- /dev/null +++ b/Tests/CMakeGUI/simpleConfigure-success/CMakeLists.txt.in @@ -0,0 +1,4 @@ +cmake_minimum_required(VERSION 3.18) +project(simpleConfigure-success NONE) + +message(STATUS "This is a successful configure") |