summaryrefslogtreecommitdiffstats
path: root/Tests/CMakeGUI/QCMakePresetComboBoxTest.cxx
diff options
context:
space:
mode:
authorKyle Edwards <kyle.edwards@kitware.com>2020-09-29 14:17:47 (GMT)
committerKyle Edwards <kyle.edwards@kitware.com>2020-10-05 13:49:59 (GMT)
commita4382f72d7fb924f9649ae352d70a36df2d662a8 (patch)
tree15855284a47a3f3ab4a14f945559266ebabbb0a5 /Tests/CMakeGUI/QCMakePresetComboBoxTest.cxx
parent8617479061039e2b357b7efc922f1b88648dce42 (diff)
downloadCMake-a4382f72d7fb924f9649ae352d70a36df2d662a8.zip
CMake-a4382f72d7fb924f9649ae352d70a36df2d662a8.tar.gz
CMake-a4382f72d7fb924f9649ae352d70a36df2d662a8.tar.bz2
CMake GUI: Add presets functionality
Diffstat (limited to 'Tests/CMakeGUI/QCMakePresetComboBoxTest.cxx')
-rw-r--r--Tests/CMakeGUI/QCMakePresetComboBoxTest.cxx80
1 files changed, 80 insertions, 0 deletions
diff --git a/Tests/CMakeGUI/QCMakePresetComboBoxTest.cxx b/Tests/CMakeGUI/QCMakePresetComboBoxTest.cxx
new file mode 100644
index 0000000..6ee55c3
--- /dev/null
+++ b/Tests/CMakeGUI/QCMakePresetComboBoxTest.cxx
@@ -0,0 +1,80 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#include "QCMakePresetComboBoxTest.h"
+
+#include <QtTest>
+
+void QCMakePresetComboBoxTest::changePresets()
+{
+ QCMakePresetComboBox box;
+ QSignalSpy presetChanged(&box, &QCMakePresetComboBox::presetChanged);
+
+ QCOMPARE(presetChanged.size(), 0);
+
+ box.setPresets({});
+ QCOMPARE(presetChanged.size(), 0);
+
+ box.setPresetName(QString{});
+ QCOMPARE(presetChanged.size(), 0);
+
+ box.setPresets({
+ {
+ /*name=*/"preset",
+ /*description=*/"",
+ /*description=*/"",
+ /*generator=*/"Ninja",
+ /*architecture=*/"",
+ /*toolset=*/"",
+ /*setGenConfig=*/true,
+ /*enabled=*/true,
+ },
+ });
+ QCOMPARE(presetChanged.size(), 0);
+
+ box.setPresetName(QString{});
+ QCOMPARE(presetChanged.size(), 0);
+
+ box.setPresetName("noexist");
+ QCOMPARE(presetChanged.size(), 0);
+
+ box.setPresetName("preset");
+ QCOMPARE(presetChanged.size(), 1);
+ QCOMPARE(presetChanged.last(), QList<QVariant>{ "preset" });
+
+ box.setPresets({
+ {
+ /*name=*/"preset",
+ /*description=*/"",
+ /*description=*/"",
+ /*generator=*/"Ninja Multi-Config",
+ /*architecture=*/"",
+ /*toolset=*/"",
+ /*setGenConfig=*/true,
+ /*enabled=*/true,
+ },
+ });
+ QCOMPARE(presetChanged.size(), 1);
+
+ box.setPresetName("noexist");
+ QCOMPARE(presetChanged.size(), 2);
+ QCOMPARE(presetChanged.last(), QList<QVariant>{ QString{} });
+
+ box.setPresetName("preset");
+ QCOMPARE(presetChanged.size(), 3);
+ QCOMPARE(presetChanged.last(), QList<QVariant>{ "preset" });
+
+ box.blockSignals(true);
+ box.setPresetName(QString{});
+ box.blockSignals(false);
+ QCOMPARE(presetChanged.size(), 3);
+
+ box.setPresetName("preset");
+ QCOMPARE(presetChanged.size(), 4);
+ QCOMPARE(presetChanged.last(), QList<QVariant>{ "preset" });
+
+ box.setPresets({});
+ QCOMPARE(presetChanged.size(), 5);
+ QCOMPARE(presetChanged.last(), QList<QVariant>{ QString{} });
+}
+
+QTEST_MAIN(QCMakePresetComboBoxTest)