From 9a7c71874aa02ad663ff149ce91458c5f821a52f Mon Sep 17 00:00:00 2001 From: deva Date: Mon, 16 Aug 2010 06:36:03 +0000 Subject: Basic test for AltComboBox. --- client/test/testaltcombobox.cc | 57 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 client/test/testaltcombobox.cc diff --git a/client/test/testaltcombobox.cc b/client/test/testaltcombobox.cc new file mode 100644 index 0000000..84d92ad --- /dev/null +++ b/client/test/testaltcombobox.cc @@ -0,0 +1,57 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +#include +#include "util.h" +#include "altcombobox.h" +#include + +static QString xml = + "\n" + " \n" + " \n" + " \n" + "\n"; + +class TestAltComboBox: public QObject +{ +Q_OBJECT +private slots: + void creation() { TEST_CREATION(AltComboBox); } + void disable() { TEST_DISABLE(AltComboBox); } + + void edit() + { + QDomDocument doc; doc.setContent(xml); + QDomElement e = doc.documentElement(); + AltComboBox cmb(e, createMacroWindow()); + + QTest::keyClicks(cmb.qwidget(), "Item 2"); + QCOMPARE(cmb.value(), QString("Item 2")); + } + + void arrow() + { + QDomDocument doc; doc.setContent(xml); + QDomElement e = doc.documentElement(); + + AltComboBox 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); + QDomElement e = doc.documentElement(); + AltComboBox cmb(e, createMacroWindow()); + QSignalSpy spy(&cmb, SIGNAL(wasChanged())); + QTest::keyClicks(cmb.qwidget(), "I"); + QCOMPARE(spy.count(), 1); + } +}; + +QTEST_MAIN(TestAltComboBox) +#include "testaltcombobox.moc" -- cgit v1.2.3