31 #include <QSortFilterProxyModel>
34 #include <private/qcombobox_p.h>
35 #include <private/qguiapplication_p.h>
36 #include <qpa/qplatformtheme.h>
69 #include "../../../shared/platforminputcontext.h"
70 #include <private/qinputmethod_p.h>
72 #include <QtTest/private/qtesthelpers_p.h>
85 void cleanupTestCase();
87 void ensureReturnIsIgnored();
90 void sizeAdjustPolicy();
92 void insertPolicy_data();
94 void virtualAutocompletion();
95 void autoCompletionCaseSensitivity();
97 void currentIndex_data();
99 void insertItems_data();
101 void insertItem_data();
103 void insertOnCurrentIndex();
104 void textpixmapdata_data();
105 void textpixmapdata();
106 void currentTextChanged_data();
107 void currentTextChanged();
108 void editTextChanged();
112 void setCurrentIndex();
113 void setCurrentText_data();
114 void setCurrentText();
115 void convenienceViews();
116 void findText_data();
118 void flaggedItems_data();
121 #if QT_CONFIG(wheelevent)
122 void mouseWheel_data();
124 void popupWheelHandling();
126 void layoutDirection();
127 void itemListPosition();
128 void separatorItem_data();
129 void separatorItem();
130 #ifndef QT_NO_STYLE_FUSION
131 void task190351_layout();
132 void task191329_size();
134 void task166349_setEditableOnReturn();
135 void task190205_setModelAdjustToContents();
136 void task248169_popupWithMinimalSize();
137 void task247863_keyBoardSelection();
138 void task220195_keyBoardSelection2();
139 void setModelColumn();
140 void noScrollbar_data();
142 void setItemDelegate();
143 void task253944_itemDelegateIsReset();
144 void subControlRectsWithOffset_data();
145 void subControlRectsWithOffset();
146 #ifndef QT_NO_STYLE_WINDOWS
147 void task260974_menuItemRectangleForComboBoxPopup();
151 void keyBoardNavigationWithMouse();
152 void task_QTBUG_1071_changingFocusEmitsActivated();
153 void maxVisibleItems_data();
154 void maxVisibleItems();
155 void task_QTBUG_10491_currentIndexAndModelColumn();
156 void highlightedSignal();
158 void task_QTBUG_31146_popupCompletion();
159 void task_QTBUG_41288_completerChangesCurrentIndex();
160 void task_QTBUG_54191_slotOnEditTextChangedSetsComboBoxToReadOnly();
161 void keyboardSelection();
162 void setCustomModelAndView();
163 void updateDelegateOnEditableChange();
164 void respectChangedOwnershipOfItemView();
165 void task_QTBUG_39088_inputMethodHints();
166 void task_QTBUG_49831_scrollerNotActivated();
167 void task_QTBUG_56693_itemFontFromModel();
168 void inputMethodUpdate();
169 void task_QTBUG_52027_mapCompleterIndex();
170 void checkMenuItemPosWhenStyleSheetIsSet();
171 void checkEmbeddedLineEditWhenStyleSheetIsSet();
172 void propagateStyleChanges();
182 void paint(QPainter *,
const QStyleOptionViewItem &,
const QModelIndex &)
const override {}
217 void setSelection(
const QRect &, QItemSelectionModel::SelectionFlags)
override {}
221 void tst_QComboBox::initTestCase()
224 inputMethodPrivate->
testContext = &m_platformInputContext;
227 void tst_QComboBox::cleanupTestCase()
234 void tst_QComboBox::getSetCheck()
239 obj1.setMaxVisibleItems(100);
240 QCOMPARE(100, obj1.maxVisibleItems());
241 obj1.setMaxVisibleItems(0);
242 QCOMPARE(obj1.maxVisibleItems(), 0);
244 "Invalid max visible items (-2147483648) must be >= 0");
245 obj1.setMaxVisibleItems(INT_MIN);
246 QCOMPARE(obj1.maxVisibleItems(), 0);
247 obj1.setMaxVisibleItems(INT_MAX);
248 QCOMPARE(INT_MAX, obj1.maxVisibleItems());
256 obj1.setMaxCount(INT_MIN);
259 obj1.setMaxCount(INT_MAX);
264 obj1.setCompleter(
nullptr);
265 QCOMPARE(
nullptr, obj1.completer());
268 QVERIFY(obj1.completer() ==
nullptr);
272 obj1.setDuplicatesEnabled(
false);
273 QCOMPARE(
false, obj1.duplicatesEnabled());
274 obj1.setDuplicatesEnabled(
true);
275 QCOMPARE(
true, obj1.duplicatesEnabled());
305 obj1.setMinimumContentsLength(0);
306 QCOMPARE(0, obj1.minimumContentsLength());
307 obj1.setMinimumContentsLength(100);
308 QCOMPARE(100, obj1.minimumContentsLength());
309 obj1.setMinimumContentsLength(INT_MIN);
310 QCOMPARE(100, obj1.minimumContentsLength());
311 obj1.setMinimumContentsLength(INT_MAX);
312 QCOMPARE(INT_MAX, obj1.minimumContentsLength());
317 obj1.setLineEdit(var8);
325 QVERIFY(obj1.completer() !=
nullptr);
330 obj1.setValidator(var9);
333 QCOMPARE(obj1.validator(),
nullptr);
339 obj1.setItemDelegate(var10);
340 QCOMPARE(obj1.itemDelegate(), var10);
343 QCOMPARE(obj1.itemDelegate(), var10);
349 obj1.setModel(var11);
359 obj1.setModelColumn(0);
361 obj1.setModelColumn(INT_MIN);
363 obj1.setModelColumn(INT_MAX);
364 QCOMPARE(INT_MAX, obj1.modelColumn());
365 obj1.setModelColumn(0);
379 obj1.setEditable(
false);
382 obj1.setCurrentIndex(INT_MIN);
384 obj1.setCurrentIndex(INT_MAX);
386 obj1.addItems(
QStringList() <<
"1" <<
"2" <<
"3" <<
"4" <<
"5");
387 obj1.setCurrentIndex(0);
389 obj1.setCurrentIndex(INT_MIN);
391 obj1.setCurrentIndex(4);
393 obj1.setCurrentIndex(INT_MAX);
396 obj1.setIconSize(QSize(64, 32));
397 QCOMPARE(obj1.iconSize(), QSize(64, 32));
398 obj1.setIconSize(QSize());
400 QCOMPARE(obj1.iconSize(), QSize(iconWidth, iconWidth));
402 const QString placeholderText(
"Please select");
403 obj1.setCurrentIndex(1);
404 obj1.setPlaceholderText(placeholderText);
405 QCOMPARE(obj1.placeholderText(), placeholderText);
408 obj1.setPlaceholderText(
QString());
413 obj1.setPlaceholderText(placeholderText);
414 obj1.addItems({
"1",
"2",
"3",
"4",
"5"});
417 obj1.setPlaceholderText(
QString());
435 m_comboBox->setGeometry(0, 0, 100, 100);
436 m_comboBox->setObjectName(
"testObject");
437 m_comboBox->setEditable(
false);
443 QComboBox *m_comboBox;
448 void tst_QComboBox::setEditable()
453 QComboBox *testWidget = topLevel.
comboBox();
455 QVERIFY(!testWidget->lineEdit());
457 testWidget->setEditable(
true);
458 QVERIFY(testWidget->lineEdit());
459 testWidget->addItem(
"foo");
466 testWidget->setEditable(
false);
467 QVERIFY(!testWidget->lineEdit());
473 void tst_QComboBox::setPalette()
477 QSKIP(
"This test doesn't make sense for pixmap-based styles");
483 QComboBox *testWidget = topLevel.
comboBox();
484 QPalette pal = testWidget->palette();
486 testWidget->setPalette(pal);
487 testWidget->setEditable(!testWidget->isEditable());
490 testWidget->setPalette(pal);
492 const QObjectList comboChildren = testWidget->children();
493 for (
int i = 0;
i < comboChildren.
size(); ++
i) {
494 QObject *
o = comboChildren.
at(
i);
495 if (
o->isWidgetType()) {
500 testWidget->setEditable(
true);
503 testWidget->lineEdit()->setPalette(pal);
504 QVERIFY(testWidget->palette() != pal);
505 QCOMPARE(testWidget->lineEdit()->palette(), pal);
508 testWidget->setPalette(pal);
509 QCOMPARE(testWidget->palette(), pal);
510 QCOMPARE(testWidget->lineEdit()->palette(), pal);
513 void tst_QComboBox::sizeAdjustPolicy()
518 QComboBox *testWidget = topLevel.
comboBox();
522 QVERIFY(testWidget->isVisible());
523 QSize firstShow = testWidget->sizeHint();
524 testWidget->addItem(
"normal item");
525 QCOMPARE(testWidget->sizeHint(), firstShow);
529 testWidget->setMinimumContentsLength(30);
530 QSize minimumContentsLength = testWidget->sizeHint();
531 QVERIFY(minimumContentsLength.width() > firstShow.width());
532 testWidget->setMinimumContentsLength(60);
533 QVERIFY(minimumContentsLength.width() < testWidget->sizeHint().width());
534 minimumContentsLength = testWidget->sizeHint();
535 testWidget->setIconSize(QSize(128,128));
536 QVERIFY(minimumContentsLength.width() < testWidget->sizeHint().width());
540 QSize content = testWidget->sizeHint();
541 testWidget->addItem(
"small");
542 QCOMPARE(testWidget->sizeHint(), content);
543 testWidget->addItem(
"looooooooooooooooooooooong item");
546 QCOMPARE(testWidget->sizeHint(), content);
548 testWidget->addItem(
"loooooooooooooooooooooooooooooooooooooooooooooo"
549 "ooooooooooooooooooooooooooooooooooooooooooooooo"
550 "ooooooooooooooooooooooooooooong item");
551 QVERIFY(testWidget->sizeHint().width() > content.width());
554 content = testWidget->sizeHint();
555 for (
int i=0;
i<testWidget->count(); ++
i)
556 testWidget->setItemText(
i,
"XXXXXXXXXX");
557 QVERIFY(testWidget->sizeHint().width() < content.width());
560 content = testWidget->sizeHint();
561 while (testWidget->count())
562 testWidget->removeItem(0);
563 QCOMPARE(testWidget->sizeHint(), content);
564 testWidget->setMinimumContentsLength(0);
565 QVERIFY(testWidget->sizeHint().width() < content.width());
568 content = testWidget->sizeHint();
570 testWidget->setModel(
model);
571 QVERIFY(testWidget->sizeHint().width() < content.width());
574 content = testWidget->sizeHint();
577 QVERIFY(testWidget->sizeHint().width() > content.width());
580 content = testWidget->sizeHint();
582 QVERIFY(testWidget->sizeHint().width() < content.width());
585 void tst_QComboBox::clear()
590 QComboBox *testWidget = topLevel.
comboBox();
592 testWidget->addItem(
"foo");
593 testWidget->addItem(
"bar");
594 QVERIFY(testWidget->count() > 0);
595 QCOMPARE(testWidget->currentIndex(), 0);
599 QCOMPARE(testWidget->currentIndex(), -1);
600 QVERIFY(testWidget->currentText().isEmpty());
604 testWidget->setEditable(
true);
605 testWidget->addItem(
"foo");
606 testWidget->addItem(
"bar");
607 QVERIFY(testWidget->count() > 0);
608 QCOMPARE(testWidget->currentIndex(), 0);
609 QVERIFY(testWidget->lineEdit());
610 QVERIFY(!testWidget->lineEdit()->text().isEmpty());
613 QCOMPARE(testWidget->currentIndex(), -1);
614 QVERIFY(testWidget->currentText().isEmpty());
615 QVERIFY(testWidget->lineEdit()->text().isEmpty());
618 void tst_QComboBox::insertPolicy_data()
620 QTest::addColumn<QStringList>(
"initialEntries");
621 QTest::addColumn<QComboBox::InsertPolicy>(
"insertPolicy");
622 QTest::addColumn<int>(
"currentIndex");
623 QTest::addColumn<QString>(
"userInput");
624 QTest::addColumn<QStringList>(
"result");
645 fiveEntries <<
"One" <<
"Two" <<
"Three" <<
"Four" <<
"Five";
659 oneAtTop <<
"insert" <<
"One";
661 fiveAtTop <<
"insert" <<
"One" <<
"Two" <<
"Three" <<
"Four" <<
"Five";
674 fiveAtCurrentFirst <<
"insert" <<
"Two" <<
"Three" <<
"Four" <<
"Five";
676 fiveAtCurrentThird <<
"One" <<
"Two" <<
"insert" <<
"Four" <<
"Five";
678 fiveAtCurrentLast <<
"One" <<
"Two" <<
"Three" <<
"Four" <<
"insert";
690 oneAtBottom <<
"One" <<
"insert";
692 fiveAtBottom <<
"One" <<
"Two" <<
"Three" <<
"Four" <<
"Five" <<
"insert";
704 oneAfterCurrent <<
"One" <<
"insert";
706 fiveAfterCurrentFirst <<
"One" <<
"insert" <<
"Two" <<
"Three" <<
"Four" <<
"Five";
708 fiveAfterCurrentThird <<
"One" <<
"Two" <<
"Three" <<
"insert" <<
"Four" <<
"Five";
710 fiveAfterCurrentLast <<
"One" <<
"Two" <<
"Three" <<
"Four" <<
"Five" <<
"insert";
722 oneBeforeCurrent <<
"insert" <<
"One";
724 fiveBeforeCurrentFirst <<
"insert" <<
"One" <<
"Two" <<
"Three" <<
"Four" <<
"Five";
726 fiveBeforeCurrentThird <<
"One" <<
"Two" <<
"insert" <<
"Three" <<
"Four" <<
"Five";
728 fiveBeforeCurrentLast <<
"One" <<
"Two" <<
"Three" <<
"Four" <<
"insert" <<
"Five";
739 oneEntry <<
"foobar";
741 fiveEntries <<
"bar" <<
"foo" <<
"initial" <<
"Item" <<
"stamp";
745 oneAlphabetically <<
"foobar" <<
"insert";
747 fiveAlphabetically <<
"bar" <<
"foo" <<
"initial" <<
"insert" <<
"Item" <<
"stamp";
757 void tst_QComboBox::insertPolicy()
761 QFETCH(
int, currentIndex);
768 QComboBox *testWidget = topLevel.
comboBox();
770 testWidget->setInsertPolicy(insertPolicy);
771 testWidget->addItems(initialEntries);
772 testWidget->setEditable(
true);
773 if (initialEntries.count() > 0)
774 testWidget->setCurrentIndex(currentIndex);
780 QTest::keyClicks(testWidget->lineEdit(), userInput);
789 for (
int i=0;
i<testWidget->count(); ++
i) {
796 void tst_QComboBox::virtualAutocompletion()
801 QComboBox *testWidget = topLevel.
comboBox();
803 testWidget->addItem(
"Foo");
804 testWidget->addItem(
"Bar");
805 testWidget->addItem(
"Boat");
806 testWidget->addItem(
"Boost");
807 testWidget->clearEditText();
812 #if defined(Q_PROCESSOR_ARM) || defined(Q_PROCESSOR_MIPS)
828 qApp->processEvents();
837 qApp->processEvents();
842 qApp->processEvents();
844 #if defined(Q_PROCESSOR_ARM) || defined(Q_PROCESSOR_MIPS)
849 void tst_QComboBox::autoCompletionCaseSensitivity()
852 QSKIP(
"Wayland: This fails. Figure out why.");
858 QComboBox *testWidget = topLevel.
comboBox();
859 qApp->setActiveWindow(&topLevel);
860 testWidget->setFocus();
865 testWidget->addItem(
"Cow");
866 testWidget->addItem(
"irrelevant1");
867 testWidget->addItem(
"aww");
868 testWidget->addItem(
"A*");
869 testWidget->addItem(
"irrelevant2");
870 testWidget->addItem(
"aBCDEF");
871 testWidget->addItem(
"irrelevant3");
872 testWidget->addItem(
"abcdef");
873 testWidget->addItem(
"abCdef");
874 testWidget->setEditable(
true);
877 testWidget->clearEditText();
882 QTest::keyClick(testWidget->lineEdit(),
Qt::Key_A);
883 qApp->processEvents();
887 QTest::keyClick(testWidget->lineEdit(),
Qt::Key_B);
888 qApp->processEvents();
894 qApp->processEvents();
898 testWidget->clearEditText();
899 QTest::keyClick(testWidget->lineEdit(),
'c');
904 testWidget->clearEditText();
905 QTest::keyClick(testWidget->lineEdit(),
'a');
906 QTest::keyClick(testWidget->lineEdit(),
'*');
912 testWidget->clearEditText();
915 QTest::keyClick(testWidget->lineEdit(),
Qt::Key_A);
916 qApp->processEvents();
918 QTest::keyClick(testWidget->lineEdit(),
Qt::Key_B);
919 qApp->processEvents();
922 testWidget->setCurrentIndex(0);
923 testWidget->clearEditText();
924 QTest::keyClick(testWidget->lineEdit(),
'a');
925 QTest::keyClick(testWidget->lineEdit(),
'b');
927 QTest::keyClick(testWidget->lineEdit(),
'C');
928 qApp->processEvents();
931 qApp->processEvents();
934 testWidget->clearEditText();
935 QTest::keyClick(testWidget->lineEdit(),
'c');
938 QTest::keyClick(testWidget->lineEdit(),
'C');
943 testWidget->clearEditText();
944 QTest::keyClick(testWidget->lineEdit(),
'a');
945 QTest::keyClick(testWidget->lineEdit(),
'*');
951 void tst_QComboBox::hide()
956 QComboBox *testWidget = topLevel.
comboBox();
957 testWidget->addItem(
"foo");
958 testWidget->showPopup();
962 testWidget->hidePopup();
966 QVERIFY(!testWidget->isVisible());
971 void tst_QComboBox::currentIndex_data()
973 QTest::addColumn<QStringList>(
"initialItems");
974 QTest::addColumn<int>(
"setCurrentIndex");
975 QTest::addColumn<int>(
"removeIndex");
976 QTest::addColumn<int>(
"insertIndex");
977 QTest::addColumn<QString>(
"insertText");
978 QTest::addColumn<int>(
"expectedCurrentIndex");
979 QTest::addColumn<QString>(
"expectedCurrentText");
980 QTest::addColumn<int>(
"expectedSignalCount");
987 int expectedCurrentIndex;
989 int expectedSignalCount;
992 initialItems.clear();
993 initialItems <<
"foo" <<
"bar";
994 setCurrentIndex = -2;
998 expectedCurrentIndex = 0;
999 expectedCurrentText =
"foo";
1000 expectedSignalCount = 1;
1001 QTest::newRow(
"first added item is set to current if there is no current")
1002 << initialItems << setCurrentIndex << removeIndex
1003 << insertIndex << insertText << expectedCurrentIndex << expectedCurrentText
1004 << expectedSignalCount;
1007 initialItems.clear();
1008 initialItems <<
"foo" <<
"bar";
1009 setCurrentIndex = 1;
1013 expectedCurrentIndex = 1;
1014 expectedCurrentText =
"bar";
1015 expectedSignalCount = 2;
1017 << initialItems << setCurrentIndex << removeIndex
1018 << insertIndex << insertText << expectedCurrentIndex << expectedCurrentText
1019 << expectedSignalCount;
1023 initialItems.clear();
1024 initialItems <<
"foo" <<
"bar";
1025 setCurrentIndex = -1;
1029 expectedCurrentIndex = -1;
1030 expectedCurrentText =
"";
1031 expectedSignalCount = 2;
1033 << initialItems << setCurrentIndex << removeIndex
1034 << insertIndex << insertText << expectedCurrentIndex << expectedCurrentText
1035 << expectedSignalCount;
1039 initialItems.clear();
1040 initialItems <<
"foo";
1041 setCurrentIndex = 0;
1045 expectedCurrentIndex = -1;
1046 expectedCurrentText =
"";
1047 expectedSignalCount = 2;
1048 QTest::newRow(
"check that current index is invalid when removing the only item")
1049 << initialItems << setCurrentIndex << removeIndex
1050 << insertIndex << insertText << expectedCurrentIndex << expectedCurrentText
1051 << expectedSignalCount;
1054 initialItems.clear();
1055 initialItems <<
"foo" <<
"bar";
1056 setCurrentIndex = 1;
1060 expectedCurrentIndex = 0;
1061 expectedCurrentText =
"bar";
1062 expectedSignalCount = 3;
1063 QTest::newRow(
"check that the current index follows the item when removing an item above")
1064 << initialItems << setCurrentIndex << removeIndex
1065 << insertIndex << insertText << expectedCurrentIndex << expectedCurrentText
1066 << expectedSignalCount;
1070 initialItems.clear();
1071 initialItems <<
"foo" <<
"bar" <<
"baz";
1072 setCurrentIndex = 1;
1076 expectedCurrentIndex = 1;
1077 expectedCurrentText =
"baz";
1078 expectedSignalCount = 3;
1079 QTest::newRow(
"check that the current index uses the next item if current is removed")
1080 << initialItems << setCurrentIndex << removeIndex
1081 << insertIndex << insertText << expectedCurrentIndex << expectedCurrentText
1082 << expectedSignalCount;
1085 initialItems.clear();
1086 initialItems <<
"foo" <<
"bar" <<
"baz";
1087 setCurrentIndex = 2;
1091 expectedCurrentIndex = 1;
1092 expectedCurrentText =
"bar";
1093 expectedSignalCount = 3;
1094 QTest::newRow(
"check that the current index is moved to the one before if current is removed")
1095 << initialItems << setCurrentIndex << removeIndex
1096 << insertIndex << insertText << expectedCurrentIndex << expectedCurrentText
1097 << expectedSignalCount;
1100 initialItems.clear();
1101 initialItems <<
"foo" <<
"bar" <<
"baz";
1102 setCurrentIndex = 1;
1106 expectedCurrentIndex = 1;
1107 expectedCurrentText =
"bar";
1108 expectedSignalCount = 2;
1109 QTest::newRow(
"check that the current index is unchanged if you remove an item after")
1110 << initialItems << setCurrentIndex << removeIndex
1111 << insertIndex << insertText << expectedCurrentIndex << expectedCurrentText
1112 << expectedSignalCount;
1115 initialItems.clear();
1116 initialItems <<
"foo" <<
"bar";
1117 setCurrentIndex = 1;
1121 expectedCurrentIndex = 2;
1122 expectedCurrentText =
"bar";
1123 expectedSignalCount = 3;
1124 QTest::newRow(
"check that the current index follows the item if you insert before current")
1125 << initialItems << setCurrentIndex << removeIndex
1126 << insertIndex << insertText << expectedCurrentIndex << expectedCurrentText
1127 << expectedSignalCount;
1130 initialItems.clear();
1131 initialItems <<
"foo";
1132 setCurrentIndex = 0;
1136 expectedCurrentIndex = 1;
1137 expectedCurrentText =
"foo";
1138 expectedSignalCount = 2;
1139 QTest::newRow(
"check that the current index follows the item if you insert on the current")
1140 << initialItems << setCurrentIndex << removeIndex
1141 << insertIndex << insertText << expectedCurrentIndex << expectedCurrentText
1142 << expectedSignalCount;
1145 initialItems.clear();
1146 initialItems <<
"foo";
1147 setCurrentIndex = 0;
1151 expectedCurrentIndex = 0;
1152 expectedCurrentText =
"foo";
1153 expectedSignalCount = 1;
1154 QTest::newRow(
"check that the current index stays the same if you insert after the current")
1155 << initialItems << setCurrentIndex << removeIndex
1156 << insertIndex << insertText << expectedCurrentIndex << expectedCurrentText
1157 << expectedSignalCount;
1161 void tst_QComboBox::currentIndex()
1164 QFETCH(
int, setCurrentIndex);
1165 QFETCH(
int, removeIndex);
1166 QFETCH(
int, insertIndex);
1168 QFETCH(
int, expectedCurrentIndex);
1170 QFETCH(
int, expectedSignalCount);
1175 QComboBox *testWidget = topLevel.
comboBox();
1178 testWidget->clear();
1179 testWidget->setEditable(
edit ?
true :
false);
1181 QVERIFY(testWidget->lineEdit());
1185 QCOMPARE(testWidget->currentIndex(), -1);
1186 QVERIFY(testWidget->currentText().isEmpty());
1192 foreach(
QString text, initialItems) {
1193 testWidget->addItem(text);
1195 QCOMPARE(testWidget->count(), initialItems.count());
1198 if (setCurrentIndex >= -1) {
1199 testWidget->setCurrentIndex(setCurrentIndex);
1200 QCOMPARE(testWidget->currentIndex(), setCurrentIndex);
1203 if (removeIndex >= 0)
1204 testWidget->removeItem(removeIndex);
1205 if (insertIndex >= 0)
1206 testWidget->insertItem(insertIndex, insertText);
1209 QCOMPARE(testWidget->currentIndex(), expectedCurrentIndex);
1210 QCOMPARE(testWidget->currentText(), expectedCurrentText);
1213 QCOMPARE(indexChangedInt.count(), expectedSignalCount);
1216 if (indexChangedInt.count())
1217 QCOMPARE(indexChangedInt.at(indexChangedInt.count() - 1).at(0).toInt(),
1218 testWidget->currentIndex());
1221 testWidget->setCurrentIndex(-1);
1223 QTest::keyPress(testWidget,
'a');
1224 QTest::keyPress(testWidget,
'b');
1226 QCOMPARE(testWidget->currentIndex(), -1);
1227 int numItems = testWidget->count();
1229 QCOMPARE(testWidget->count(), numItems + 1);
1230 QCOMPARE(testWidget->currentIndex(), numItems);
1231 testWidget->setCurrentIndex(-1);
1232 QTest::keyPress(testWidget,
'a');
1233 QTest::keyPress(testWidget,
'b');
1234 QCOMPARE(testWidget->currentIndex(), -1);
1239 void tst_QComboBox::insertItems_data()
1241 QTest::addColumn<QStringList>(
"initialItems");
1242 QTest::addColumn<QStringList>(
"insertedItems");
1243 QTest::addColumn<int>(
"insertIndex");
1244 QTest::addColumn<int>(
"expectedIndex");
1249 initialItems <<
"foo" <<
"bar";
1250 insertedItems <<
"mongo";
1252 QTest::newRow(
"prepend") << initialItems << insertedItems << 0 << 0;
1253 QTest::newRow(
"prepend with negative value") << initialItems << insertedItems << -1 << 0;
1254 QTest::newRow(
"append") << initialItems << insertedItems << initialItems.count() << initialItems.count();
1255 QTest::newRow(
"append with too high value") << initialItems << insertedItems << 999 << initialItems.count();
1256 QTest::newRow(
"insert") << initialItems << insertedItems << 1 << 1;
1259 void tst_QComboBox::insertItems()
1263 QFETCH(
int, insertIndex);
1264 QFETCH(
int, expectedIndex);
1269 QComboBox *testWidget = topLevel.
comboBox();
1270 testWidget->insertItems(0, initialItems);
1271 QCOMPARE(testWidget->count(), initialItems.count());
1273 testWidget->insertItems(insertIndex, insertedItems);
1275 QCOMPARE(testWidget->count(), initialItems.count() + insertedItems.count());
1276 for (
int i=0;
i<insertedItems.count(); ++
i)
1277 QCOMPARE(testWidget->itemText(expectedIndex +
i), insertedItems.at(
i));
1280 void tst_QComboBox::insertItem_data()
1282 QTest::addColumn<QStringList>(
"initialItems");
1283 QTest::addColumn<int>(
"insertIndex");
1284 QTest::addColumn<QString>(
"itemLabel");
1285 QTest::addColumn<int>(
"expectedIndex");
1286 QTest::addColumn<bool>(
"editable");
1289 initialItems <<
"foo" <<
"bar";
1290 for(
int e = 0 ;
e<2 ;
e++) {
1291 bool editable = (
e==0);
1292 QTest::newRow(
"Insert less then 0") << initialItems << -1 <<
"inserted" << 0 << editable;
1293 QTest::newRow(
"Insert at 0") << initialItems << 0 <<
"inserted" << 0 << editable;
1294 QTest::newRow(
"Insert beyond count") << initialItems << 3 <<
"inserted" << 2 << editable;
1295 QTest::newRow(
"Insert at count") << initialItems << 2 <<
"inserted" << 2 << editable;
1296 QTest::newRow(
"Insert in the middle") << initialItems << 1 <<
"inserted" << 1 << editable;
1300 void tst_QComboBox::insertItem()
1303 QFETCH(
int, insertIndex);
1305 QFETCH(
int, expectedIndex);
1311 QComboBox *testWidget = topLevel.
comboBox();
1312 testWidget->insertItems(0, initialItems);
1313 QCOMPARE(testWidget->count(), initialItems.count());
1315 testWidget->setEditable(
true);
1317 testWidget->setEditText(
"FOO");
1318 testWidget->insertItem(insertIndex, itemLabel);
1320 QCOMPARE(testWidget->count(), initialItems.count() + 1);
1321 QCOMPARE(testWidget->itemText(expectedIndex), itemLabel);
1327 void tst_QComboBox::insertOnCurrentIndex()
1332 QComboBox *testWidget = topLevel.
comboBox();
1333 testWidget->setEditable(
true);
1334 testWidget->addItem(
"first item");
1335 testWidget->setCurrentIndex(0);
1336 testWidget->insertItem(0,
"second item");
1340 void tst_QComboBox::textpixmapdata_data()
1342 QTest::addColumn<QStringList>(
"text");
1343 QTest::addColumn<IconList>(
"icons");
1344 QTest::addColumn<VariantList>(
"variant");
1354 text <<
"foo" <<
"bar";
1355 icon << QIcon() << QIcon();
1362 icon << QIcon(QPixmap(qtlogoPath)) << QIcon(QPixmap(qtlogoinvertedPath));
1369 icon << QIcon() << QIcon();
1375 text <<
"foo" <<
"bar";
1376 icon << QIcon(QPixmap(qtlogoPath)) << QIcon(QPixmap(qtlogoinvertedPath));
1382 void tst_QComboBox::textpixmapdata()
1393 QComboBox *testWidget = topLevel.
comboBox();
1395 testWidget->insertItem(
i,
text.
at(
i));
1396 testWidget->setItemIcon(
i, icons.at(
i));
1403 QIcon
icon = testWidget->itemIcon(
i);
1405 QPixmap original = icons.at(
i).pixmap(1024);
1417 void tst_QComboBox::setCurrentIndex()
1422 QComboBox *testWidget = topLevel.
comboBox();
1424 testWidget->addItem(
"foo");
1425 testWidget->addItem(
"bar");
1428 QCOMPARE(testWidget->currentIndex(), 0);
1429 testWidget->setCurrentIndex(0);
1432 testWidget->setCurrentIndex(1);
1435 testWidget->setCurrentIndex(0);
1439 void tst_QComboBox::setCurrentText_data()
1441 QTest::addColumn<bool>(
"editable");
1446 void tst_QComboBox::setCurrentText()
1453 QComboBox *testWidget = topLevel.
comboBox();
1455 testWidget->addItems(
QStringList() <<
"foo" <<
"bar");
1458 testWidget->setEditable(editable);
1459 testWidget->setCurrentIndex(0);
1460 QCOMPARE(testWidget->currentIndex(), 0);
1465 testWidget->setCurrentText(
QString(
"bar"));
1468 QCOMPARE(testWidget->currentIndex(), 0);
1470 QCOMPARE(testWidget->currentIndex(), 1);
1472 testWidget->setCurrentText(
QString(
"foo"));
1473 QCOMPARE(testWidget->currentIndex(), 0);
1477 testWidget->setCurrentText(
QString(
"qt"));
1478 QCOMPARE(testWidget->currentIndex(), 0);
1484 #ifndef QT_NO_PROPERTIES
1486 testWidget->setCurrentIndex(0);
1489 testWidget->setProperty(
n,
QString(
"bar"));
1494 void tst_QComboBox::currentTextChanged_data()
1496 QTest::addColumn<bool>(
"editable");
1501 void tst_QComboBox::currentTextChanged()
1508 QComboBox *testWidget = topLevel.
comboBox();
1510 testWidget->addItems(
QStringList() <<
"foo" <<
"bar");
1515 testWidget->setEditable(editable);
1518 testWidget->setCurrentIndex(0);
1519 QCOMPARE(testWidget->currentIndex(), 0);
1521 testWidget->setCurrentText(
QString(
"bar"));
1526 testWidget->setCurrentIndex(0);
1527 QCOMPARE(testWidget->currentIndex(), 0);
1529 testWidget->setCurrentText(
QString(
"qt"));
1538 testWidget->setCurrentIndex(0);
1539 QCOMPARE(testWidget->currentIndex(), 0);
1541 testWidget->setItemText(0,
QString(
"ape"));
1546 testWidget->setItemText(0,
QString(
"foo"));
1551 void tst_QComboBox::editTextChanged()
1556 QComboBox *testWidget = topLevel.
comboBox();
1558 testWidget->addItem(
"foo");
1559 testWidget->addItem(
"bar");
1563 testWidget->setEditable(
false);
1564 QCOMPARE(testWidget->isEditable(),
false);
1569 QCOMPARE(testWidget->currentIndex(), 0);
1570 testWidget->setCurrentIndex(0);
1571 QCOMPARE(testWidget->currentIndex(), 0);
1575 QCOMPARE(testWidget->currentIndex(), 0);
1576 testWidget->setCurrentIndex(1);
1577 QCOMPARE(testWidget->currentIndex(), 1);
1581 testWidget->setEditable(
true);
1582 QCOMPARE(testWidget->isEditable(),
true);
1583 testWidget->setCurrentIndex(0);
1587 QCOMPARE(testWidget->currentIndex(), 0);
1588 testWidget->setCurrentIndex(0);
1589 QCOMPARE(testWidget->currentIndex(), 0);
1593 QCOMPARE(testWidget->currentIndex(), 0);
1594 testWidget->setCurrentIndex(1);
1595 QCOMPARE(testWidget->currentIndex(), 1);
1602 QTest::keyClicks(testWidget,
"bingo");
1607 void tst_QComboBox::setModel()
1613 box.setCurrentIndex(1);
1623 oldModel =
box.model();
1630 rootModelIndex =
box.model()->index(0, 0);
1632 box.setRootModelIndex(rootModelIndex);
1636 oldModel =
box.model();
1640 QVERIFY(
box.rootModelIndex() != rootModelIndex);
1644 box.setCurrentIndex(1);
1646 box.setModel(
box.model());
1650 rootModelIndex =
box.model()->index(0, 0);
1652 box.setRootModelIndex(rootModelIndex);
1654 box.setModel(
box.model());
1659 box.setEditable(
true);
1663 QCOMPARE(listModel->rowCount(), 2);
1664 box.setModel(listModel);
1665 QCOMPARE(listModel->rowCount(), 2);
1668 void tst_QComboBox::setCustomModelAndView()
1672 combo.setWindowTitle(
"QTBUG-27597, setCustomModelAndView");
1673 combo.setEditable(
true);
1674 combo.setMinimumWidth(400);
1676 combo.move(availableGeometry.center() - QPoint(200, 20));
1688 item->appendRow(subItem);
1691 view->setHeaderHidden(
true);
1695 combo.setModel(
model);
1696 combo.setView(
view);
1701 const QRect subItemRect =
view->visualRect(
model->indexFromItem(subItem));
1714 void tst_QComboBox::modelDeleted()
1730 void tst_QComboBox::setMaxCount()
1733 items <<
"1" <<
"2" <<
"3" <<
"4" <<
"5";
1752 box.insertItem(0,
"0");
1791 void tst_QComboBox::convenienceViews()
1794 QComboBox listCombo;
1796 listCombo.setModel(
list->model());
1797 listCombo.setView(
list);
1799 list->addItem(
"list0");
1800 listCombo.addItem(
"list1");
1806 QComboBox treeCombo;
1811 treeCombo.setView(tree);
1814 treeCombo.addItem(
"tree1");
1820 QComboBox tableCombo;
1822 table->verticalHeader()->hide();
1823 table->horizontalHeader()->hide();
1824 tableCombo.setModel(
table->model());
1825 tableCombo.setView(
table);
1829 tableCombo.addItem(
"table1");
1842 QComboBox *
box =
new QComboBox(
this);
1843 box->setEditable(
true);
1861 void tst_QComboBox::ensureReturnIsIgnored()
1875 void tst_QComboBox::findText_data()
1877 QTest::addColumn<QStringList>(
"items");
1878 QTest::addColumn<int>(
"matchflags");
1879 QTest::addColumn<QString>(
"search");
1880 QTest::addColumn<int>(
"result");
1883 list <<
"One" <<
"Two" <<
"Three" <<
"Four" <<
"Five" <<
"Six" <<
"one";
1897 void tst_QComboBox::findText()
1907 QComboBox *testWidget = topLevel.
comboBox();
1908 testWidget->clear();
1909 testWidget->addItems(
items);
1911 QCOMPARE(testWidget->findText(search, (Qt::MatchFlags)matchflags),
result);
1918 void tst_QComboBox::flaggedItems_data()
1920 QTest::addColumn<QStringList>(
"itemList");
1921 QTest::addColumn<IntList>(
"deselectFlagList");
1922 QTest::addColumn<IntList>(
"disableFlagList");
1923 QTest::addColumn<KeyList>(
"keyMovementList");
1924 QTest::addColumn<bool>(
"editable");
1925 QTest::addColumn<int>(
"expectedIndex");
1927 for (
int editable=0;editable<2;editable++) {
1928 QString testCase = editable ?
"editable:" :
"non-editable:";
1930 itemList <<
"One" <<
"Two" <<
"Three" <<
"Four" <<
"Five" <<
"Six" <<
"Seven" <<
"Eight";
1936 QTest::newRow(testCase.
toLatin1() +
"normal") << itemList << deselectFlagList << disableFlagList << keyMovementList << bool(editable) << 4;
1938 deselectFlagList.
clear();
1939 disableFlagList.
clear();
1940 deselectFlagList << 1 << 3;
1941 QTest::newRow(testCase.
toLatin1() +
"non-selectable") << itemList << deselectFlagList << disableFlagList << keyMovementList << bool(editable) << 4;
1943 deselectFlagList.
clear();
1944 disableFlagList.
clear();
1945 disableFlagList << 2;
1946 QTest::newRow(testCase.
toLatin1() +
"disabled") << itemList << deselectFlagList << disableFlagList << keyMovementList << bool(editable) << 5;
1948 deselectFlagList.
clear();
1949 disableFlagList.
clear();
1950 deselectFlagList << 1 << 3;
1951 disableFlagList << 2 << 3;
1952 QTest::newRow(testCase.
toLatin1() +
"mixed") << itemList << deselectFlagList << disableFlagList << keyMovementList << bool(editable) << 6;
1953 deselectFlagList.
clear();
1954 disableFlagList.
clear();
1955 disableFlagList << 0 << 1 << 2 << 3 << 4 << 5 << 6;
1956 QTest::newRow(testCase.
toLatin1() +
"nearly-empty") << itemList << deselectFlagList << disableFlagList << keyMovementList << bool(editable) << 7;
1958 deselectFlagList.
clear();
1959 disableFlagList.
clear();
1960 disableFlagList << 0 << 1 << 2 << 3 << 5 << 6 << 7;
1961 keyMovementList.
clear();
1962 QTest::newRow(testCase.
toLatin1() +
"only one enabled") << itemList << deselectFlagList << disableFlagList << keyMovementList << bool(editable) << 4;
1965 deselectFlagList.
clear();
1966 disableFlagList.
clear();
1967 keyMovementList.
clear();
1968 disableFlagList << 0 << 2 << 3;
1970 QTest::newRow(testCase.
toLatin1() +
"home-disabled") << itemList << deselectFlagList << disableFlagList << keyMovementList << bool(editable) << 1;
1972 keyMovementList.
clear();
1974 QTest::newRow(testCase.
toLatin1() +
"end-key") << itemList << deselectFlagList << disableFlagList << keyMovementList << bool(editable) << 7;
1976 disableFlagList.
clear();
1977 disableFlagList << 1 ;
1979 QTest::newRow(testCase.
toLatin1() +
"keyboard-search") << itemList << deselectFlagList << disableFlagList << keyMovementList << bool(editable) << 2;
1981 itemList <<
"nine" <<
"ten";
1983 QTest::newRow(testCase.
toLatin1() +
"search same start letter") << itemList << deselectFlagList << disableFlagList << keyMovementList << bool(editable) << 2;
1985 keyMovementList.
clear();
1987 QTest::newRow(testCase.
toLatin1() +
"keyboard search item") << itemList << deselectFlagList << disableFlagList << keyMovementList << bool(editable) << 2;
1989 disableFlagList.
clear();
1990 disableFlagList << 1 << 3 << 5 << 7 << 9;
1991 keyMovementList.
clear();
1993 QTest::newRow(testCase.
toLatin1() +
"all key combinations") << itemList << deselectFlagList << disableFlagList << keyMovementList << bool(editable) << 4;
1995 deselectFlagList.
clear();
1996 disableFlagList.
clear();
1997 disableFlagList << 1;
1998 keyMovementList.
clear();
2000 QTest::newRow(testCase.
toLatin1() +
"disabled") << itemList << deselectFlagList << disableFlagList << keyMovementList << bool(editable) << 2;
2001 QTest::newRow(testCase.
toLatin1() +
"broken autocompletion") << itemList << deselectFlagList << disableFlagList << keyMovementList << bool(editable) << 2;
2006 void tst_QComboBox::flaggedItems()
2009 QSKIP(
"Wayland: This fails. Figure out why.");
2016 QFETCH(
int, expectedIndex);
2019 setFrameless(&comboBox);
2023 comboBox.setEditable(editable);
2024 foreach (
int index, deselectFlagList)
2027 foreach (
int index, disableFlagList)
2030 comboBox.setModel(listWidget.
model());
2031 comboBox.setView(&listWidget);
2032 comboBox.move(200, 200);
2035 comboBox.activateWindow();
2036 comboBox.setFocus();
2042 comboBox.lineEdit()->selectAll();
2044 for (
int i = 0;
i < keyMovementList.count(); ++
i) {
2046 QTest::keyClick(&comboBox,
key);
2049 QCOMPARE(comboBox.currentIndex() , expectedIndex);
2052 void tst_QComboBox::pixmapIcon()
2057 QPixmap
pix(10, 10);
2072 #if QT_CONFIG(wheelevent)
2074 #define WHEEL_DELTA 120
2076 void tst_QComboBox::mouseWheel_data()
2078 QTest::addColumn<IntList>(
"disabledItems");
2079 QTest::addColumn<int>(
"startIndex");
2080 QTest::addColumn<int>(
"wheelDirection");
2081 QTest::addColumn<int>(
"expectedIndex");
2093 if (!allowsWheelScroll)
2101 disabled << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9;
2108 void tst_QComboBox::mouseWheel()
2112 QFETCH(
int, wheelDirection);
2113 QFETCH(
int, expectedIndex);
2116 QVERIFY(applicationInstance != 0);
2120 list <<
"one" <<
"two" <<
"three" <<
"four" <<
"five" <<
"six" <<
"seven" <<
"eight" <<
"nine" <<
"ten";
2125 foreach (
int index, disabledItems)
2129 box.setView(&listWidget);
2130 for (
int i=0;
i < 2; ++
i) {
2131 box.setEditable(
i==0?
false:
true);
2132 box.setCurrentIndex(startIndex);
2134 const QPoint wheelPoint =
box.rect().bottomRight();
2135 QWheelEvent
event(wheelPoint,
box.mapToGlobal(wheelPoint), QPoint(), QPoint(0,
WHEEL_DELTA * wheelDirection),
2143 void tst_QComboBox::popupWheelHandling()
2148 QWidget *
widget =
new QWidget;
2153 QComboBox *comboBox =
new QComboBox;
2156 layout->addWidget(comboBox);
2162 comboBox->showPopup();
2163 QTRY_VERIFY(comboBox->view() && comboBox->view()->isVisible());
2164 const QPoint popupPos = comboBox->view()->pos();
2165 const QPoint wheelPoint(10, 10);
2170 QVERIFY(comboBox->view()->isVisible());
2171 QCOMPARE(comboBox->view()->pos(), popupPos);
2175 void tst_QComboBox::layoutDirection()
2188 box.setEditable(
true);
2203 box.setEditable(
true);
2212 void tst_QComboBox::itemListPosition()
2222 QHBoxLayout *
layout =
new QHBoxLayout(&topLevel);
2226 layout->addWidget(&combo);
2228 bool useFullScreenForPopupMenu =
false;
2231 const QRect
screen = useFullScreenForPopupMenu ?
2233 combo.screen()->availableGeometry();
2235 topLevel.move(
screen.width() - topLevel.sizeHint().width() - 10, 0);
2237 topLevel.showNormal();
2244 QVERIFY( combo.view()->window()->x() + combo.view()->window()->width() <=
screen.x() +
screen.width() );
2247 void tst_QComboBox::separatorItem_data()
2249 QTest::addColumn<QStringList>(
"items");
2250 QTest::addColumn<IntList>(
"separators");
2256 void tst_QComboBox::separatorItem()
2263 foreach(
int index, separators)
2266 for (
int i = 0,
s = 0;
i <
box.count(); ++
i) {
2267 if (
i == separators.at(
s)) {
2277 #ifndef QT_NO_STYLE_FUSION
2278 void tst_QComboBox::task190351_layout()
2283 QComboBox listCombo;
2284 listCombo.move(200, 200);
2285 setFrameless(&listCombo);
2287 listCombo.setModel(
list->model());
2288 listCombo.setView(
list);
2289 for(
int i = 1;
i < 150;
i++)
2295 listCombo.setCurrentIndex(70);
2296 listCombo.showPopup();
2302 #ifdef QT_BUILD_INTERNAL
2309 QCOMPARE(
top->mapToGlobal(QPoint(0,
top->height())).y(),
list->mapToGlobal(QPoint()).
y());
2323 list <<
"one" <<
"two";
2324 connect(
this,
SIGNAL(currentIndexChanged(
int)),
this,
SLOT(onCurrentIndexChanged(
int)));
2330 setEditable(
index % 2 == 1);
2334 void tst_QComboBox::task166349_setEditableOnReturn()
2344 #ifndef QT_NO_STYLE_FUSION
2345 void tst_QComboBox::task191329_size()
2351 QComboBox tableCombo;
2352 setFrameless(&tableCombo);
2353 tableCombo.move(200, 200);
2369 table->verticalHeader()->hide();
2370 table->horizontalHeader()->hide();
2371 tableCombo.setView(
table);
2372 tableCombo.setModel(&
model);
2376 tableCombo.showPopup();
2380 #ifdef QT_BUILD_INTERNAL
2394 void tst_QComboBox::task190205_setModelAdjustToContents()
2398 initialContent <<
"foo" <<
"bar";
2399 finalContent <<
"bar" <<
"foooooooobar";
2405 box.addItems(initialContent);
2413 QComboBox correctBox;
2414 setFrameless(&correctBox);
2415 correctBox.move(400, 100);
2417 correctBox.addItems(finalContent);
2418 correctBox.showNormal();
2427 void tst_QComboBox::task248169_popupWithMinimalSize()
2430 initialContent <<
"foo" <<
"bar" <<
"foobar";
2433 comboBox.addItems(initialContent);
2435 comboBox.view()->setMinimumWidth(desktopSize.width() / 2);
2437 comboBox.setGeometry(desktopSize.width() - (desktopSize.width() / 4), (desktopSize.width() / 4), (desktopSize.width() / 2), (desktopSize.width() / 4));
2439 comboBox.showNormal();
2442 comboBox.showPopup();
2447 #if defined QT_BUILD_INTERNAL
2454 void tst_QComboBox::task247863_keyBoardSelection()
2457 setFrameless(&combo);
2458 combo.move(200, 200);
2459 combo.setEditable(
false);
2470 QTest::keyClick(
static_cast<QWidget *
>(0),
Qt::Key_Down);
2476 void tst_QComboBox::task220195_keyBoardSelection2()
2479 QSKIP(
"Wayland: This fails. Figure out why.");
2482 setFrameless(&combo);
2483 combo.move(200, 200);
2484 combo.setEditable(
false);
2492 combo.setCurrentIndex(-1);
2493 QVERIFY(combo.currentText().isNull());
2495 QTest::keyClick(&combo,
'f');
2498 QTest::keyClick(&combo,
'f');
2501 QTest::keyClick(&combo,
'f');
2504 QTest::keyClick(&combo,
'f');
2508 combo.setCurrentIndex(1);
2510 QTest::keyClick(&combo,
'f');
2515 void tst_QComboBox::setModelColumn()
2537 box.setModelColumn(1);
2541 void tst_QComboBox::noScrollbar_data()
2543 QTest::addColumn<QString>(
"stylesheet");
2550 " padding: 12px 15px 13px 10px; margin: 12px 15px 13px 10px; }");
2552 " padding: 2px 5px 3px 1px; margin: 2px 5px 3px 1px; } "
2553 " QAbstractItemView::item { border: 2px solid green; "
2554 " padding: 1px 1px 2px 2px; margin: 1px; } " );
2557 void tst_QComboBox::noScrollbar()
2560 initialContent <<
"foo" <<
"bar" <<
"foobar" <<
"moo";
2563 qApp->setStyleSheet(stylesheet);
2567 QComboBox comboBox(&topLevel);
2568 comboBox.addItems(initialContent);
2569 topLevel.move(200, 200);
2571 comboBox.resize(200, comboBox.height());
2573 comboBox.showPopup();
2577 QVERIFY(!comboBox.view()->horizontalScrollBar()->isVisible());
2578 QVERIFY(!comboBox.view()->verticalScrollBar()->isVisible());
2584 comboBox.setModel(
table->model());
2585 comboBox.setView(
table);
2586 comboBox.move(200, 200);
2589 comboBox.resize(200, comboBox.height());
2590 comboBox.showPopup();
2594 QVERIFY(!comboBox.view()->horizontalScrollBar()->isVisible());
2595 QVERIFY(!comboBox.view()->verticalScrollBar()->isVisible());
2598 qApp->setStyleSheet(oldCss);
2601 void tst_QComboBox::setItemDelegate()
2605 comboBox.setItemDelegate(itemDelegate);
2610 void tst_QComboBox::task253944_itemDelegateIsReset()
2614 comboBox.setItemDelegate(itemDelegate);
2618 comboBox.setEditable(
true);
2621 comboBox.setStyleSheet(
"QComboBox { border: 1px solid gray; }");
2626 void tst_QComboBox::subControlRectsWithOffset_data()
2628 QTest::addColumn<bool>(
"editable");
2634 void tst_QComboBox::subControlRectsWithOffset()
2639 class FriendlyCombo :
public QComboBox {
2642 initStyleOption(optCombo);
2646 combo.styleOption(&optCombo);
2649 const QRect rectAtOrigin(0, 0, 80, 30);
2650 const QPoint
offset(25, 50);
2651 const QRect rectWithOffset = rectAtOrigin.translated(
offset);
2658 optCombo.
rect = rectAtOrigin;
2663 optCombo.
rect = rectWithOffset;
2668 QCOMPARE(editFieldRect, editFieldRectWithOffset.translated(-
offset));
2670 QCOMPARE(listboxRect, listboxRectWithOffset.translated(-
offset));
2675 #ifndef QT_NO_STYLE_WINDOWS
2676 void tst_QComboBox::task260974_menuItemRectangleForComboBoxPopup()
2685 if (hint == SH_ComboBox_Popup)
return 1;
2691 if (element == CE_MenuItem)
2692 discoveredRect =
option->rect;
2695 mutable QRect discoveredRect;
2701 comboBox.setStyle(&
style);
2702 comboBox.addItem(
"Item 1");
2703 comboBox.move(200, 200);
2707 comboBox.showPopup();
2716 void tst_QComboBox::removeItem()
2733 void tst_QComboBox::resetModel()
2762 void tst_QComboBox::keyBoardNavigationWithMouse()
2765 QSKIP(
"Wayland: This fails. Figure out why.");
2768 combo.setEditable(
false);
2769 setFrameless(&combo);
2770 for (
int i = 0;
i < 200;
i++)
2773 combo.move(200, 200);
2791 #define GET_SELECTION(SEL) \
2792 QCOMPARE(combo.view()->selectionModel()->selection().count(), 1); \
2793 QCOMPARE(combo.view()->selectionModel()->selection().indexes().count(), 1); \
2794 SEL = combo.view()->selectionModel()->selection().indexes().first().row()
2799 const int final = 40;
2809 #undef GET_SELECTION
2812 void tst_QComboBox::task_QTBUG_1071_changingFocusEmitsActivated()
2815 QSKIP(
"Wayland: This fails. Figure out why.");
2821 cb.setEditable(
true);
2837 QTest::keyClick(
static_cast<QWidget *
>(0),
'1');
2844 void tst_QComboBox::maxVisibleItems_data()
2846 QTest::addColumn<int>(
"spacing");
2852 void tst_QComboBox::maxVisibleItems()
2857 QCOMPARE(comboBox.maxVisibleItems(), 10);
2860 for(
int i = 1;
i < 50;
i++)
2863 comboBox.addItems(content);
2864 comboBox.move(200, 200);
2866 comboBox.
resize(200, comboBox.height());
2869 comboBox.setMaxVisibleItems(5);
2870 QCOMPARE(comboBox.maxVisibleItems(), 5);
2872 comboBox.showPopup();
2887 QCOMPARE(
listView->viewport()->height(), itemHeight * comboBox.maxVisibleItems());
2890 void tst_QComboBox::task_QTBUG_10491_currentIndexAndModelColumn()
2895 for (
int i = 0;
i < 4;
i++){
2902 comboBox.setModel(&
model);
2903 comboBox.setModelColumn(0);
2910 void tst_QComboBox::highlightedSignal()
2927 for (
int i = 0;
i < 5;
i++)
2929 comboBox.setModel(&
model);
2933 QVERIFY(initialItemSelectionModel != comboBox.view()->selectionModel());
2938 void tst_QComboBox::itemData()
2941 const int itemCount = 10;
2945 for (
int i = 0;
i < itemCount; ++
i) {
2947 comboBox.addItem(itemText);
2950 for (
int i = 0;
i < itemCount; ++
i) {
2952 QCOMPARE(comboBox.itemText(
i), itemText);
2956 comboBox.setCurrentIndex(
i);
2958 QCOMPARE(comboBox.currentText(), itemText);
2963 for (
int i = 0;
i < itemCount; ++
i)
2966 for (
int i = 0;
i < itemCount; ++
i) {
2968 QCOMPARE(comboBox.itemText(
i), itemText);
2972 comboBox.setCurrentIndex(
i);
2974 QCOMPARE(comboBox.currentText(), itemText);
2979 for (
int i = 0;
i < itemCount; ++
i) {
2985 for (
int i = 0;
i < itemCount; ++
i) {
2987 QCOMPARE(comboBox.itemText(
i), itemText);
2991 comboBox.setCurrentIndex(
i);
2993 QCOMPARE(comboBox.currentText(), itemText);
2998 for (
int i = 0;
i < itemCount; ++
i) {
3004 for (
int i = 0;
i < itemCount; ++
i) {
3006 QCOMPARE(comboBox.itemText(
i), itemText);
3010 comboBox.setCurrentIndex(
i);
3012 QCOMPARE(comboBox.currentText(), itemText);
3021 for (
int i = 0;
i < itemCount; ++
i) {
3026 for (
int i = 0;
i < itemCount; ++
i) {
3032 QCOMPARE(comboBox.itemData(
i).toString(), itemDataText);
3034 comboBox.setCurrentIndex(
i);
3038 QCOMPARE(comboBox.currentData().toString(), itemDataText);
3050 QIcon
icon = QIcon(QPixmap(qtlogoPath));
3051 for (
int i = 0;
i < itemCount; ++
i) {
3056 comboBox.addItem(itemText);
3062 for (
int i = 0;
i < itemCount; ++
i) {
3073 comboBox.setCurrentIndex(
i);
3082 void tst_QComboBox::task_QTBUG_31146_popupCompletion()
3085 QSKIP(
"Wayland: This fails. Figure out why.");
3088 comboBox.setEditable(
true);
3096 comboBox.activateWindow();
3099 QCOMPARE(comboBox.currentIndex(), 0);
3101 comboBox.lineEdit()->selectAll();
3102 QTest::keyClicks(comboBox.lineEdit(),
"item");
3104 QTest::keyClick(comboBox.completer()->popup(),
Qt::Key_Down);
3105 QTest::keyClick(comboBox.completer()->popup(),
Qt::Key_Down);
3106 QTest::keyClick(comboBox.completer()->popup(),
Qt::Key_Enter);
3107 QCOMPARE(comboBox.currentIndex(), 1);
3109 comboBox.lineEdit()->selectAll();
3110 QTest::keyClicks(comboBox.lineEdit(),
"item");
3112 QTest::keyClick(comboBox.completer()->popup(),
Qt::Key_Up);
3113 QTest::keyClick(comboBox.completer()->popup(),
Qt::Key_Up);
3114 QTest::keyClick(comboBox.completer()->popup(),
Qt::Key_Enter);
3115 QCOMPARE(comboBox.currentIndex(), 0);
3118 void tst_QComboBox::task_QTBUG_41288_completerChangesCurrentIndex()
3121 QSKIP(
"Wayland: This fails. Figure out why.");
3124 comboBox.setEditable(
true);
3129 comboBox.activateWindow();
3134 comboBox.lineEdit()->selectAll();
3135 QTest::keyClicks(comboBox.lineEdit(),
"222");
3137 QCOMPARE(comboBox.currentIndex(), 1);
3140 comboBox.lineEdit()->selectAll();
3142 QCOMPARE(comboBox.currentIndex(), 0);
3147 comboBox.lineEdit()->selectAll();
3148 QTest::keyClicks(comboBox.lineEdit(),
"222");
3150 QCOMPARE(comboBox.currentIndex(), 1);
3152 comboBox.setCurrentIndex(0);
3153 comboBox.lineEdit()->selectAll();
3155 QCOMPARE(comboBox.currentIndex(), 0);
3160 struct SetReadOnly {
3162 explicit SetReadOnly(QComboBox *
cb) :
cb(
cb) {}
3164 {
cb->setEditable(
false); }
3168 void tst_QComboBox::task_QTBUG_54191_slotOnEditTextChangedSetsComboBoxToReadOnly()
3172 cb.setEditable(
true);
3173 cb.setCurrentIndex(0);
3178 cb.setCurrentIndex(1);
3183 void tst_QComboBox::keyboardSelection()
3188 list <<
"OA" <<
"OB" <<
"OC" <<
"OO" <<
"OP" <<
"PP";
3189 comboBox.addItems(
list);
3210 void tst_QComboBox::updateDelegateOnEditableChange()
3216 box.setEditable(
false);
3221 bool menuDelegateBefore = qobject_cast<QComboMenuDelegate *>(
box.itemDelegate()) != 0;
3222 d->updateDelegate();
3223 bool menuDelegateAfter = qobject_cast<QComboMenuDelegate *>(
box.itemDelegate()) != 0;
3224 QCOMPARE(menuDelegateAfter, menuDelegateBefore);
3227 box.setEditable(
true);
3230 bool menuDelegateBefore = qobject_cast<QComboMenuDelegate *>(
box.itemDelegate()) != 0;
3231 d->updateDelegate();
3232 bool menuDelegateAfter = qobject_cast<QComboMenuDelegate *>(
box.itemDelegate()) != 0;
3233 QCOMPARE(menuDelegateAfter, menuDelegateBefore);
3237 void tst_QComboBox::task_QTBUG_39088_inputMethodHints()
3240 box.setEditable(
true);
3245 void tst_QComboBox::respectChangedOwnershipOfItemView()
3266 void tst_QComboBox::task_QTBUG_49831_scrollerNotActivated()
3269 for (
int i = 0;
i < 1000;
i++)
3275 box.setCurrentIndex(500);
3307 if (
index.row() < 5) {
3309 font.setItalic(
true);
3330 if (element == CE_MenuItem)
3332 if (menuItem->font.italic())
3335 baseStyle()->drawControl(element,
opt,
p,
w);
3341 void tst_QComboBox::task_QTBUG_56693_itemFontFromModel()
3344 if (!qobject_cast<QComboMenuDelegate *>(
box.itemDelegate()))
3345 QSKIP(
"Only for combo boxes using QComboMenuDelegate");
3351 box.setStyle(proxyStyle);
3354 for (
int i = 0;
i < 10;
i++)
3369 void tst_QComboBox::inputMethodUpdate()
3372 QSKIP(
"Wayland: This fails. Figure out why.");
3377 QComboBox *testWidget = topLevel.
comboBox();
3379 QVERIFY(!testWidget->lineEdit());
3381 testWidget->setEditable(
true);
3382 QVERIFY(testWidget->lineEdit());
3384 testWidget->activateWindow();
3385 testWidget->setFocus();
3389 m_platformInputContext.m_updateCallCount = 0;
3395 QVERIFY(m_platformInputContext.m_updateCallCount >= 1);
3397 m_platformInputContext.m_updateCallCount = 0;
3404 QVERIFY(m_platformInputContext.m_updateCallCount >= 1);
3406 m_platformInputContext.m_updateCallCount = 0;
3410 event.setCommitString(
"preedit text");
3413 QVERIFY(m_platformInputContext.m_updateCallCount >= 1);
3416 m_platformInputContext.m_updateCallCount = 0;
3423 QVERIFY(m_platformInputContext.m_updateCallCount >= 1);
3426 void tst_QComboBox::task_QTBUG_52027_mapCompleterIndex()
3429 QSKIP(
"Wayland: This fails. Figure out why.");
3432 words <<
"" <<
"foobar1" <<
"foobar2";
3435 altWords <<
"foobar2" <<
"hello" <<
"," <<
"world" <<
"" <<
"foobar0" <<
"foobar1";
3438 setFrameless(&cbox);
3439 cbox.setEditable(
true);
3441 cbox.addItems(words);
3449 cbox.move(200, 200);
3454 QTest::keyClicks(&cbox,
"foobar2");
3464 cbox.lineEdit()->selectAll();
3465 cbox.lineEdit()->del();
3468 model->setSourceModel(cbox.model());
3469 model->setFilterFixedString(
"foobar1");
3473 qWarning(
"Offscreen platform requires explicit activateWindow()");
3474 cbox.activateWindow();
3480 QTest::keyClicks(&cbox,
"foobar1");
3491 void tst_QComboBox::checkMenuItemPosWhenStyleSheetIsSet()
3493 QString newCss =
"QComboBox {font-size: 18pt;}";
3495 qApp->setStyleSheet(newCss);
3498 QVBoxLayout *
layout =
new QVBoxLayout(&topLevel);
3500 layout->addWidget(stack);
3501 QWidget *container =
new QWidget(&topLevel);
3502 QHBoxLayout *cLayout =
new QHBoxLayout(container);
3503 QComboBox *cBox =
new QComboBox;
3514 cBox->setModel(
model);
3516 cLayout->addWidget(cBox);
3524 int menuHeight = cBox->view()->geometry().height();
3525 QRect menuItemRect = cBox->view()->visualRect(
model->indexFromItem(
item));
3527 QCOMPARE(menuHeight, menuItemRect.y() + menuItemRect.height());
3529 qApp->setStyleSheet(oldCss);
3532 void tst_QComboBox::checkEmbeddedLineEditWhenStyleSheetIsSet()
3534 QString newCss =
"QWidget { background-color: red; color: white; }";
3536 qApp->setStyleSheet(newCss);
3539 auto layout =
new QVBoxLayout(&topLevel);
3540 topLevel.setLayout(
layout);
3541 auto comboBox =
new QComboBox;
3542 layout->addWidget(comboBox);
3544 comboBox->setEditable(
true);
3548 QImage grab = comboBox->grab().toImage();
3549 auto color = grab.pixelColor(grab.rect().center());
3555 qApp->setStyleSheet(oldCss);
3565 void tst_QComboBox::propagateStyleChanges()
3570 FrameStyle(
int frameStyle,
QStyle *
style =
nullptr)
3585 mutable bool inquired =
false;
3593 combo.setStyle(&framelessStyle);
3594 QVERIFY(framelessStyle.inquired);
3599 combo.setStyle(&frameStyle);
3604 #include "tst_qcombobox.moc"
small capitals from c petite p scientific i
[1]
void paint(QPainter *, const QStyleOptionViewItem &, const QModelIndex &) const override
QSize sizeHint(const QStyleOptionViewItem &, const QModelIndex &) const override
bool setData(const QModelIndex &, const QVariant &, int) override
QVariant data(const QModelIndex &, int) const override
bool insertColumns(int, int, const QModelIndex &) override
bool removeRows(int, int, const QModelIndex &) override
int columnCount(const QModelIndex &) const override
QModelIndex parent(const QModelIndex &) const override
bool insertRows(int, int, const QModelIndex &) override
bool removeColumns(int, int, const QModelIndex &) override
QModelIndex index(int, int, const QModelIndex &) const override
bool hasChildren(const QModelIndex &) const override
void setPersistent(const QModelIndex &, const QModelIndex &)
int rowCount(const QModelIndex &) const override
QRegion visualRegionForSelection(const QItemSelection &) const override
int verticalOffset() const override
QModelIndex indexAt(const QPoint &) const override
void scrollTo(const QModelIndex &, ScrollHint) override
bool isIndexHidden(const QModelIndex &) const override
int horizontalOffset() const override
void setSelection(const QRect &, QItemSelectionModel::SelectionFlags) override
QRect visualRect(const QModelIndex &) const override
QModelIndex moveCursor(CursorAction, Qt::KeyboardModifiers) override
The QAbstractItemDelegate class is used to display and edit data items from a model.
The QAbstractItemModel class provides the abstract interface for item model classes.
virtual Q_INVOKABLE bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole)
virtual Q_INVOKABLE QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const =0
The QAbstractItemView class provides the basic functionality for item view classes.
QAbstractItemModel * model() const
void setCurrentIndex(const QModelIndex &index)
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
static void setStyle(QStyle *)
int doubleClickInterval
the time limit in milliseconds that distinguishes a double click from two consecutive mouse clicks
static QWidget * activeWindow()
int keyboardInputInterval
the time limit in milliseconds that distinguishes a key press from two consecutive key presses
static void setKeyboardInputInterval(int)
static void setActiveWindow(QWidget *act)
The QByteArray class provides an array of bytes.
@ AdjustToMinimumContentsLengthWithIcon
@ AdjustToContentsOnFirstShow
void activated(int index)
void editTextChanged(const QString &)
void currentIndexChanged(int index)
int styleHint(StyleHint sh, const QStyleOption *opt=nullptr, const QWidget *w=nullptr, QStyleHintReturn *shret=nullptr) const override
The QCompleter class provides completions based on an item model.
QAbstractItemView * popup() const
void setModel(QAbstractItemModel *c)
void setCaseSensitivity(Qt::CaseSensitivity caseSensitivity)
static QCoreApplication * instance()
static bool sendEvent(QObject *receiver, QEvent *event)
static void processEvents(QEventLoop::ProcessEventsFlags flags=QEventLoop::AllEvents)
The QFontComboBox widget is a combobox that lets the user select a font family.
The QFrame class is the base class of widgets that can have a frame.
QScreen * primaryScreen
the primary (or default) screen of the application.
static void setLayoutDirection(Qt::LayoutDirection direction)
QString platformName
The name of the underlying platform plugin.
static QPlatformTheme * platformTheme()
The QIntValidator class provides a validator that ensures a string contains a valid integer within a ...
The QItemSelection class manages information about selected items in a model.
The QKeyEvent class describes a key event.
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal.
The QLineEdit widget is a one-line text editor.
qsizetype size() const noexcept
bool isEmpty() const noexcept
const_reference at(qsizetype i) const noexcept
qsizetype count() const noexcept
The QListView class provides a list or icon view onto a model.
void setSpacing(int space)
int spacing
the space around the items in the layout
QRect visualRect(const QModelIndex &index) const override
The QModelIndex class is used to locate data in a data model.
constexpr bool isValid() const noexcept
T findChild(const QString &aName=QString(), Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
QString objectName
the name of this object
QList< T > findChildren(const QString &aName, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
The QProxyStyle class is a convenience class that simplifies dynamically overriding QStyle elements.
int styleHint(StyleHint hint, const QStyleOption *option=nullptr, const QWidget *widget=nullptr, QStyleHintReturn *returnData=nullptr) const override
The QRegion class specifies a clip region for a painter.
QRect availableGeometry
the screen's available geometry in pixels
QRect geometry
the screen's geometry in pixels
The QSortFilterProxyModel class provides support for sorting and filtering data passed between anothe...
int rowCount(const QModelIndex &parent=QModelIndex()) const override
int columnCount(const QModelIndex &parent=QModelIndex()) const override
The QStandardItem class provides an item for use with the QStandardItemModel class.
The QStandardItemModel class provides a generic model for storing custom data.\inmodule QtGui.
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
The QString class provides a Unicode character string.
QByteArray toLatin1() const &
static QString fromLatin1(QByteArrayView ba)
const QChar at(qsizetype i) const
static QString number(int, int base=10)
void resize(qsizetype size)
The QStringList class provides a list of strings.
The QStringListModel class provides a model that supplies strings to views.
QStringListModel(QObject *parent=nullptr)
The QStyleFactory class creates QStyle objects.
static QStyle * create(const QString &)
the exposed rectangle, in item coordinates
The QStyle class is an abstract base class that encapsulates the look and feel of a GUI.
@ SH_ComboBox_PopupFrameStyle
@ SH_ComboBox_LayoutDirection
@ SH_ComboBox_AllowWheelScrolling
virtual int styleHint(StyleHint stylehint, const QStyleOption *opt=nullptr, const QWidget *widget=nullptr, QStyleHintReturn *returnData=nullptr) const =0
@ SC_ComboBoxListBoxPopup
an OR combination of the tool button's features
The QStyleOption class stores the parameters used by QStyle functions.
void initFrom(const QWidget *w)
Qt::LayoutDirection direction
The QStyledItemDelegate class provides display and editing facilities for data items from a model.
QTBUG_56693_Model(QObject *parent=nullptr)
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p, const QWidget *w=nullptr) const override
QTBUG_56693_ProxyStyle(QStyle *style)
The QTableView class provides a default model/view implementation of a table view.
The QTreeView class provides a default model/view implementation of a tree view.
QHeaderView * header() const
The QValidator class provides validation of input text. \inmodule QtGui.
The QVariant class acts like a union for the most common Qt data types.
static auto fromValue(const T &value) -> std::enable_if_t< std::is_copy_constructible_v< T >, QVariant >
int toInt(bool *ok=nullptr) const
ReturnClass(QWidget *parent=nullptr)
void keyPressEvent(QKeyEvent *e) override
void onCurrentIndexChanged(int index)
task166349_ComboBox(QWidget *parent=nullptr)
object setObjectName("A new object name")
QSignalSpy spy(myCustomObject, SIGNAL(mySignal(int, QString, double)))
[0]
QList< QVariant > arguments
void drawControl(ControlElement element, QPainter *painter, const QWidget *widget, const QRect &rect, const QColorGroup &colorGroup, SFlags how=Style_Default, const QStyleOption &option=QStyleOption::Default) const
[1]
constexpr T & operator()(T &v) const
Q_TESTLIB_EXPORT QTestData & newRow(const char *dataTag)
Q_GUI_EXPORT bool qWaitForWindowActive(QWindow *window, int timeout=5000)
Q_GUI_EXPORT bool qWaitForWindowExposed(QWindow *window, int timeout=5000)
void mouseMove(QWindow *window, QPoint pos=QPoint(), int delay=-1)
Q_TESTLIB_EXPORT void ignoreMessage(QtMsgType type, const char *message)
void mouseDClick(QWindow *window, Qt::MouseButton button, Qt::KeyboardModifiers stateKey=Qt::KeyboardModifiers(), QPoint pos=QPoint(), int delay=-1)
void mouseClick(QWindow *window, Qt::MouseButton button, Qt::KeyboardModifiers stateKey=Qt::KeyboardModifiers(), QPoint pos=QPoint(), int delay=-1)
Q_CORE_EXPORT void qWait(int ms)
QTextStream & center(QTextStream &stream)
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool startsWith(QByteArrayView haystack, QByteArrayView needle) noexcept
QList< QString > QStringList
GLint GLfloat GLfloat GLfloat v2
GLfloat GLfloat GLfloat w
[0]
GLint GLsizei GLsizei height
GLdouble GLdouble GLdouble GLdouble top
GLenum GLuint GLintptr offset
GLsizei const GLint * box
GLenum GLenum GLsizei void GLsizei void * column
GLenum GLenum GLsizei void * row
GLenum GLenum GLenum input
GLenum GLenum GLsizei void * table
SSL_CTX int(* cb)(SSL *ssl, unsigned char **out, unsigned char *outlen, const unsigned char *in, unsigned int inlen, void *arg)
#define QStringLiteral(str)
#define QTEST_MAIN(TestObject)
#define QSKIP(statement,...)
#define QFETCH(Type, name)
#define QTRY_COMPARE(expr, expected)
#define QVERIFY(statement)
#define QFINDTESTDATA(basepath)
#define QTRY_VERIFY(expr)
view setModel(model)
[17] //! [18]
QSqlQueryModel * model
[16]
connect(quitButton, &QPushButton::clicked, &app, &QCoreApplication::quit, Qt::QueuedConnection)
QItemSelection * selection
[0]
QCompleter * completer
[0]
QList< QVariant > VariantList
#define GET_SELECTION(SEL)
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent