/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
#include <QtTest/QtTest>
#include "util.h"
#include "lineedit.h"

static QString xml = "<lineedit name=\"mylineedit\"/>\n";

class TestLineEdit: public QObject
{
Q_OBJECT
private slots:
  void creation() { TEST_CREATION(LineEdit); }
  void disable() { TEST_DISABLE(LineEdit); }
  void value() { TEST_VALUE(LineEdit); }
  void edit()
	{
		QDomDocument doc;	doc.setContent(xml);
    QDomElement e = doc.documentElement();
    LineEdit le(e, NULL);
		QString teststring("hello");
    QTest::keyClicks(&le, teststring);
    QCOMPARE(le.getValue(), teststring);
  }

	void changeEmits()
	{
		QDomDocument doc;	doc.setContent(xml);
    QDomElement e = doc.documentElement();
    LineEdit le(e, NULL);
		QSignalSpy spy(&le, SIGNAL(wasChanged()));
    QTest::keyClicks(&le, "h");
		QCOMPARE(spy.count(), 1);
	}
};

QTEST_MAIN(TestLineEdit)
#include "testlineedit.moc"