/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ #include #include "util.h" #include "combobox.h" #include static QString xml_search = "\n" " \n" " \n" " \n" "\n"; static QString xml_edit = "\n" " \n" " \n" " \n" "\n"; static QString xml_select = "\n" " \n" " \n" " \n" "\n"; class TestComboBoxEdit: public QObject { Q_OBJECT private slots: void creation() { TEST_CREATION(ComboBox); } void disable() { TEST_DISABLE(ComboBox); } void editSelect() { QDomDocument doc; doc.setContent(xml_search); QDomElement e = doc.documentElement(); ComboBox cmb(e, createMacroWindow()); QTest::keyClicks(cmb.qwidget(), "Item 2"); QCOMPARE(cmb.value(), QString("item2")); } void arrowSelect() { QDomDocument doc; doc.setContent(xml_select); QDomElement e = doc.documentElement(); ComboBox cmb(e, createMacroWindow()); cmb.qwidget()->setFocus(); QTest::keyPress(cmb.qwidget(), Qt::Key_Down); QTest::keyPress(cmb.qwidget(), Qt::Key_Down); QTest::keyPress(cmb.qwidget(), Qt::Key_Enter); QCOMPARE(cmb.value(), QString("item3")); } void changeEmits() { QDomDocument doc; doc.setContent(xml_search); QDomElement e = doc.documentElement(); ComboBox cmb(e, createMacroWindow()); QSignalSpy spy(&cmb, SIGNAL(wasChanged())); QTest::keyClicks(cmb.qwidget(), "I"); QCOMPARE(spy.count(), 1); } }; QTEST_MAIN(TestComboBoxEdit) #include "testcomboboxedit.moc"