1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
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)
|