Added MessageDialog unit test.
authorJussi Laitinen <jupe@l3l7588.ixonos.local>
Wed, 3 Nov 2010 08:27:54 +0000 (10:27 +0200)
committerJussi Laitinen <jupe@l3l7588.ixonos.local>
Wed, 3 Nov 2010 08:27:54 +0000 (10:27 +0200)
src/ui/messagedialog.h
tests/ui/messagedialog/messagedialog.pro [new file with mode: 0644]
tests/ui/messagedialog/testmessagedialog.cpp [new file with mode: 0644]

index 8578a35..e7e173c 100644 (file)
@@ -38,9 +38,16 @@ class MessageDialog : public QDialog
 
 public:
     /**
+    * @brief Unit test class
+    */
+    friend class TestMessageDialog;
+
+    /**
     * @brief Constructor
     *
-    * @param parent Instance of parent widget
+    * @param id message receiver's ID
+    * @param receiver message receiver's name
+    * @param parent QWidget
     */
     MessageDialog(const QString &id, const QString &receiver, QWidget *parent = 0);
 
@@ -50,7 +57,7 @@ public:
     /**
     * @brief Gets users input
     *
-    * @returns users input
+    * @returns users input as id and message text pair
     */
     QPair<QString, QString> input();
 
diff --git a/tests/ui/messagedialog/messagedialog.pro b/tests/ui/messagedialog/messagedialog.pro
new file mode 100644 (file)
index 0000000..e45f0e6
--- /dev/null
@@ -0,0 +1,11 @@
+CONFIG += qtestlib
+DEFINES += QT_NO_DEBUG_OUTPUT
+INCLUDEPATH += . \
+    ../../../src/
+
+SOURCES += \
+    testmessagedialog.cpp \
+    ../../../src/ui/messagedialog.cpp
+
+HEADERS += \
+    ../../../src/ui/messagedialog.h
diff --git a/tests/ui/messagedialog/testmessagedialog.cpp b/tests/ui/messagedialog/testmessagedialog.cpp
new file mode 100644 (file)
index 0000000..25d51a0
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+   Situare - A location system for Facebook
+   Copyright (C) 2010  Ixonos Plc. Authors:
+
+       Jussi Laitinen - jussi.laitinen@ixonos.com
+
+   Situare is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License
+   version 2 as published by the Free Software Foundation.
+
+   Situare is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with Situare; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
+   USA.
+*/
+
+#include <QtTest>
+#include <QtGui>
+
+#include "../../../src/ui/messagedialog.h"
+
+class TestMessageDialog: public QObject
+{
+    Q_OBJECT
+
+private slots:
+    void cleanup();
+    void init();
+    void input();
+    void sendButtonPressed();
+
+private:
+    QHash<QString, QString> m_tags;
+    MessageDialog *m_messageDialog;
+};
+
+void TestMessageDialog::cleanup()
+{
+    delete m_messageDialog;
+}
+
+void TestMessageDialog::init()
+{
+    m_messageDialog = new MessageDialog("1", "John Doe");
+    QVERIFY(m_messageDialog);
+}
+
+void TestMessageDialog::input()
+{
+    m_messageDialog->m_messageField->setText("Hello world");
+    QCOMPARE(m_messageDialog->input().first, QString("1"));
+    QCOMPARE(m_messageDialog->input().second, QString("Hello world"));
+}
+
+QTEST_MAIN(TestMessageDialog)
+#include "testmessagedialog.moc"