From eedcfd2f8b9e17f0903b7ff85421636830d2291d Mon Sep 17 00:00:00 2001 From: deva Date: Mon, 31 Aug 2009 15:01:56 +0000 Subject: Some more tests. --- client/test/testcomboboxedit.cc | 72 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 client/test/testcomboboxedit.cc (limited to 'client/test/testcomboboxedit.cc') diff --git a/client/test/testcomboboxedit.cc b/client/test/testcomboboxedit.cc new file mode 100644 index 0000000..5294886 --- /dev/null +++ b/client/test/testcomboboxedit.cc @@ -0,0 +1,72 @@ +#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 TestComboBox: 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, NULL); + + QTest::keyClicks(&cmb, "Item 2"); + QCOMPARE(cmb.getValue(), QString("Item 2")); + } + + void arrowSelect() + { + QDomDocument doc; doc.setContent(xml_select); + QDomElement e = doc.documentElement(); + + ComboBox cmb(e, NULL); + + cmb.setFocus(); + QTest::keyPress(&cmb, Qt::Key_Down); + QTest::keyPress(&cmb, Qt::Key_Down); + QTest::keyPress(&cmb, Qt::Key_Enter); + QCOMPARE(cmb.getValue(), QString("item3")); + } + + void changeEmits() + { + QDomDocument doc; doc.setContent(xml_search); + QDomElement e = doc.documentElement(); + ComboBox cmb(e, NULL); + QSignalSpy spy(&cmb, SIGNAL(wasChanged())); + QTest::keyClicks(&cmb, "I"); + QCOMPARE(spy.count(), 1); + } +}; + +QTEST_MAIN(TestComboBox) +#include "testcombobox.moc" + + -- cgit v1.2.3