summaryrefslogtreecommitdiff
path: root/client/test
diff options
context:
space:
mode:
Diffstat (limited to 'client/test')
-rw-r--r--client/test/testaltcombobox.cc57
1 files changed, 57 insertions, 0 deletions
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 <QtTest/QtTest>
+#include "util.h"
+#include "altcombobox.h"
+#include <QAbstractItemView>
+
+static QString xml =
+ "<altcombobox name=\"mycombobox\" type=\"search\">\n"
+ " <item value=\"item1\" caption=\"Item 1\"/>\n"
+ " <item value=\"item3\" caption=\"Item 3\"/>\n"
+ " <item value=\"item2\" caption=\"Item 2\"/>\n"
+ "</altcombobox>\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"