20
20
21
21
// Qt includes
22
22
#include < QApplication>
23
+ #include < QTimer>
23
24
24
25
// CTK includes
25
26
#include " ctkComboBox.h"
@@ -33,8 +34,73 @@ int ctkComboBoxTest1(int argc, char * argv [] )
33
34
{
34
35
QApplication app (argc, argv);
35
36
36
- ctkComboBox ctkObject;
37
+ ctkComboBox comboBox (0 );
38
+ if (!comboBox.defaultText ().isEmpty ())
39
+ {
40
+ std::cerr << " non empty default defaultText" << std::endl;
41
+ return EXIT_FAILURE;
42
+ }
43
+ comboBox.setDefaultText (" Select..." );
44
+ if (comboBox.defaultText () != " Select..." )
45
+ {
46
+ std::cerr << " ctkComboBox::setDefaultText() failed"
47
+ << comboBox.defaultText ().toStdString () << std::endl;
48
+ return EXIT_FAILURE;
49
+ }
50
+ if (comboBox.currentText () == " Select..." )
51
+ {
52
+ std::cerr << " ctkComboBox::setDefaultText() failed" << std::endl;
53
+ return EXIT_FAILURE;
54
+ }
55
+ QIcon icon = comboBox.style ()->standardIcon (QStyle::SP_MessageBoxQuestion);
56
+ comboBox.setDefaultIcon (icon);
57
+ if (comboBox.defaultIcon ().pixmap (20 ).toImage () !=
58
+ icon.pixmap (20 ).toImage ())
59
+ {
60
+ std::cerr << " ctkComboBox::setDefaultIcon() failed" << std::endl;
61
+ return EXIT_FAILURE;
62
+ }
63
+ if (comboBox.isDefaultForced ())
64
+ {
65
+ std::cerr << " default of ctkComboBox::isDefaultForced() failed" << std::endl;
66
+ return EXIT_FAILURE;
67
+ }
68
+ comboBox.forceDefault (true );
69
+ if (!comboBox.isDefaultForced ())
70
+ {
71
+ std::cerr << " ctkComboBox::setDefaultForced() failed" << std::endl;
72
+ return EXIT_FAILURE;
73
+ }
74
+ if (comboBox.elideMode () != Qt::ElideNone)
75
+ {
76
+ std::cerr << " Wrong default elide mode" << std::endl;
77
+ return EXIT_FAILURE;
78
+ }
79
+ comboBox.setElideMode (Qt::ElideRight);
80
+ if (comboBox.elideMode () != Qt::ElideRight)
81
+ {
82
+ std::cerr << " ctkComboBox::setElideMode() failed" << std::endl;
83
+ return EXIT_FAILURE;
84
+ }
85
+ comboBox.addItem (" Item Item Item Item Item Item Item Item 1" );
86
+ comboBox.addItem (" Item Item Item Item Item Item Item Item 2" );
87
+ comboBox.addItem (" Item Item Item Item Item Item Item Item 3" );
88
+ // adding items shouldn't change anything to the combobox current text
89
+ if (comboBox.currentIndex () != 0 ||
90
+ comboBox.currentText () != " Item Item Item Item Item Item Item Item 1" )
91
+ {
92
+ std::cerr << " ctkComboBox::addItem failed:"
93
+ << comboBox.currentIndex () << " "
94
+ << comboBox.currentText ().toStdString () << std::endl;
95
+ return EXIT_FAILURE;
96
+ }
97
+ comboBox.show ();
37
98
38
- return EXIT_SUCCESS;
99
+ if (argc < 2 || QString (argv[1 ]) != " -I" )
100
+ {
101
+ QTimer::singleShot (200 , &app, SLOT (quit ()));
102
+ }
103
+
104
+ return app.exec ();
39
105
}
40
106
0 commit comments