Added unit tests.
authorJussi Laitinen <jupe@l3l7588.ixonos.local>
Mon, 8 Nov 2010 14:09:06 +0000 (16:09 +0200)
committerJussi Laitinen <jupe@l3l7588.ixonos.local>
Mon, 8 Nov 2010 14:09:06 +0000 (16:09 +0200)
44 files changed:
src/engine/engine.cpp
src/situareservice/database.cpp
src/situareservice/message.h
src/situareservice/situareservice.cpp
src/situareservice/situareservice.h
src/ui/imagebutton.cpp
src/ui/mainwindow.cpp
src/ui/mainwindow.h
src/ui/meetpeoplepanel.cpp
src/ui/messagelistitem.cpp
src/ui/messagelistitem.h
src/ui/messagelistview.cpp
src/ui/messagepanel.cpp
src/ui/personlistitem.cpp
src/ui/personlistitem.h
src/ui/tagsdialog.cpp
src/ui/tagsdialog.h
src/ui/userinfo.cpp
src/ui/userinfo.h
src/ui/userinfopanel.cpp
src/ui/userinfopanel.h
tests/stubs/extendedlistitem.h [deleted file]
tests/stubs/extendedlistitemstub.h [new file with mode: 0644]
tests/stubs/listitem.h [deleted file]
tests/stubs/listitemstub.h [new file with mode: 0644]
tests/stubs/listview.h [deleted file]
tests/stubs/listviewstub.h [new file with mode: 0644]
tests/stubs/messagelistitemstub.h [new file with mode: 0644]
tests/stubs/personlistitem.h [deleted file]
tests/stubs/personlistitemstub.h [new file with mode: 0644]
tests/stubs/personlistview.h [deleted file]
tests/stubs/personlistviewstub.h [new file with mode: 0644]
tests/stubs/stubs.pro
tests/ui/listview/listview.pro
tests/ui/listview/testlistview.cpp
tests/ui/meetpeoplepanel/meetpeoplepanel.pro
tests/ui/meetpeoplepanel/testmeetpeoplepanel.cpp
tests/ui/messagelistitem/messagelistitem.pro [new file with mode: 0644]
tests/ui/messagelistitem/testmessagelistitem.cpp [new file with mode: 0644]
tests/ui/messagelistview/messagelistview.pro [new file with mode: 0644]
tests/ui/messagelistview/testmessagelistview.cpp [new file with mode: 0644]
tests/ui/personlistview/personlistview.pro [new file with mode: 0644]
tests/ui/personlistview/testpersonlistview.cpp [new file with mode: 0644]
tests/ui/tagsdialog/testtagsdialog.cpp

index 561e857..d4064c7 100644 (file)
@@ -733,6 +733,9 @@ void SituareEngine::signalsFromMainWindow()
     connect(m_ui, SIGNAL(centerToCoordinates(GeoCoordinate)),
             m_mapEngine, SLOT(centerToCoordinates(GeoCoordinate)));
 
+    connect(m_ui, SIGNAL(requestPopularTags()),
+            m_situareService, SLOT(fetchPopularTags()));
+
     // routing signal from friend list tab & search location tab
     connect(m_ui, SIGNAL(routeTo(const GeoCoordinate&)),
             this, SLOT(routeTo(const GeoCoordinate&)));
@@ -864,6 +867,9 @@ void SituareEngine::signalsFromSituareService()
 
     connect(m_situareService, SIGNAL(messagesReceived(QList<Message>&, QList<Message> &)),
             m_ui, SIGNAL(messagesReceived(QList<Message>&, QList<Message>&)));
+
+    connect(m_situareService, SIGNAL(popularTagsReceived(QHash<QString,QString>&)),
+            m_ui, SIGNAL(popularTagsReceived(QHash<QString,QString>&)));
 }
 
 void SituareEngine::startAutomaticUpdate()
index 29190b1..dd35a8c 100644 (file)
@@ -472,8 +472,8 @@ QByteArray Database::getPopularTags()
     if (lastComma != -1)
         result.remove(result.lastIndexOf(","), 1);
 
-    result.append("]");
-
+    result.append("]}");
+    qWarning() << result;
     return result.toUtf8();
 }
 
index 6fc8b1e..3b536b7 100644 (file)
@@ -27,7 +27,7 @@
 #include <QPixmap>
 #include <QString>
 
-#include "coordinates/geocoordinate.h"
+#include "../coordinates/geocoordinate.h"
 
 /**
  * @brief Container for a single message.
index 6493ad3..0a502d5 100644 (file)
@@ -496,7 +496,7 @@ void SituareService::parsePopularTagsData(const QByteArray &jsonReply)
             popularTags.insert(tag["id"].toString(), tag["name"].toString());
         }
 
-        emit interestingPeopleReceived(friends, others);
+        emit popularTagsReceived(popularTags);
     }
 }
 
index b676067..a8ae5fb 100644 (file)
@@ -331,6 +331,13 @@ signals:
     void messagesReceived(QList<Message> &received, QList<Message> &sent);
 
     /**
+    * @brief Signals when fetchPopularTags request is finished
+    *
+    * @param popularTags list of popular tags
+    */
+    void popularTagsReceived(QHash<QString, QString> &popularTags);
+
+    /**
     * @brief Signals when address data is retrieved
     *
     * @param address Street address
index 84fbb16..5891937 100644 (file)
@@ -85,6 +85,9 @@ void ImageButton::initButton(const QSize &size, const QIcon &icon)
     qDebug() << __PRETTY_FUNCTION__;
 
     setIcon(icon);
-    setIconSize(size);
-    setFixedSize(size);
+
+    if (size.isValid()) {
+        setIconSize(size);
+        setFixedSize(size);
+    }
 }
index 6b7d5e7..5082bdc 100644 (file)
@@ -544,6 +544,12 @@ void MainWindow::buildUserInfoPanel()
 
     connect(m_userInfoPanel, SIGNAL(removeTags(QStringList)),
             this, SIGNAL(removeTags(QStringList)));
+
+    connect(this, SIGNAL(popularTagsReceived(QHash<QString,QString>&)),
+            m_userInfoPanel, SLOT(populatePopularTags(QHash<QString,QString>&)));
+
+    connect(m_userInfoPanel, SIGNAL(requestPopularTags()),
+            this, SIGNAL(requestPopularTags()));
 }
 
 void MainWindow::buildWebView()
index 7f9d040..a056ae4 100644 (file)
@@ -629,6 +629,18 @@ signals:
     void messagesReceived(QList<Message> &received, QList<Message> &sent);
 
     /**
+    * @brief Signals when fetchPopularTags request is finished
+    *
+    * @param popularTags list of popular tags
+    */
+    void popularTagsReceived(QHash<QString, QString> &popularTags);
+
+    /**
+    * @brief Signal for requesting popular tags
+    */
+    void requestPopularTags();
+
+    /**
      * @brief Signal for refreshing user data.
      *
      */
index 4f63670..95e94f6 100644 (file)
@@ -98,10 +98,14 @@ void MeetPeoplePanel::listItemSelectionHandler()
 
     PersonListItem *personItem = dynamic_cast<PersonListItem*>(m_personListView->selectedItem());
 
-    if (personItem && !personItem->isFriend())
+    if (personItem) {
+        if (personItem->isFriend())
+            m_friendListButton->setEnabled(true);
+        else
+            m_friendListButton->setDisabled(true);
+    } else {
         m_friendListButton->setDisabled(true);
-    else
-        m_friendListButton->setEnabled(true);
+    }
 
     onListItemSelectionChanged();
 }
index 59e8e9c..4f054d4 100644 (file)
@@ -1,7 +1,7 @@
 #include <QDebug>
 
 #include "listcommon.h"
-#include "situareservice/message.h"
+#include "../situareservice/message.h"
 
 #include "messagelistitem.h"
 
@@ -17,25 +17,30 @@ MessageListItem::~MessageListItem()
     qDebug() << __PRETTY_FUNCTION__;
 }
 
-GeoCoordinate MessageListItem::coordinates() const
+GeoCoordinate &MessageListItem::coordinates() const
 {
     qDebug() << __PRETTY_FUNCTION__;
 
     return m_coordinates;
 }
 
-const QString &MessageListItem::id() const
+QString &MessageListItem::id() const
 {
     qDebug() << __PRETTY_FUNCTION__;
 
     return m_id;
 }
 
-const QString &MessageListItem::receiverId() const
+QString &MessageListItem::newMessageReceiverId() const
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    return m_receiverId;
+    return m_newMessageReceiverId;
+}
+
+void MessageListItem::setNewMessageReceiverId(const QString &newMessageReceiverId)
+{
+    m_newMessageReceiverId = newMessageReceiverId;
 }
 
 void MessageListItem::setMessageData(const Message &message)
@@ -45,9 +50,9 @@ void MessageListItem::setMessageData(const Message &message)
     m_id = message.id();
 
     if (message.type() == Message::MessageTypeReceived)
-        m_receiverId = message.senderId();
+        setNewMessageReceiverId(message.senderId());
     else
-        m_receiverId = message.receiverId();
+        setNewMessageReceiverId(message.receiverId());
 
     setTitle(message.senderName());
 
index aee3447..38907be 100644 (file)
@@ -22,7 +22,7 @@
 #ifndef MESSAGELISTITEM_H
 #define MESSAGELISTITEM_H
 
-#include "coordinates/geocoordinate.h"
+#include "../coordinates/geocoordinate.h"
 #include "extendedlistitem.h"
 
 class Message;
@@ -56,21 +56,28 @@ public:
     *
     * @return item's coordinates
     */
-    GeoCoordinate coordinates() const;
+    GeoCoordinate &coordinates() const;
 
     /**
     * @brief Returns message's ID.
     *
     * @return message's ID
     */
-    const QString &id() const;
+    QString &id() const;
 
     /**
-    * @brief Returns message receiver's ID.
+    * @brief Returns new message message receiver's ID.
     *
-    * @return message receiver's ID
+    * @return new message message receiver's ID
     */
-    const QString &receiverId() const;
+    QString &newMessageReceiverId() const;
+
+    /**
+    * @brief Sets new message message receiver's ID.
+    *
+    * @return newMessageReceiverId new message message receiver's ID
+    */
+    void setNewMessageReceiverId(const QString &newMessageReceiverId);
 
     /**
     * @brief Set message data for this item.
@@ -84,7 +91,7 @@ public:
 ******************************************************************************/
 private:
     QString m_id;                   ///< message's ID
-    QString m_receiverId;           ///< message reveiver's ID
+    QString m_newMessageReceiverId;           ///< new message reveiver's ID
 
     GeoCoordinate m_coordinates;    ///< message's coordinates
 };
index a2baf98..149709e 100644 (file)
@@ -21,7 +21,7 @@
 
 #include <QDebug>
 
-#include "coordinates/geocoordinate.h"
+#include "../coordinates/geocoordinate.h"
 #include "messagelistitem.h"
 
 #include "messagelistview.h"
index 10a3e41..5bc7eeb 100644 (file)
@@ -131,7 +131,7 @@ void MessagePanel::messageButtonPressed()
 
     if (messageItem) {
         m_messageListView->clearItemSelection();
-        emit requestMessageDialog(QPair<QString, QString>(messageItem->receiverId(),
+        emit requestMessageDialog(QPair<QString, QString>(messageItem->newMessageReceiverId(),
                                                           messageItem->title()));
     }
 }
index 897886b..00acbcb 100644 (file)
@@ -84,7 +84,7 @@ void PersonListItem::setFacebookId(const QString &facebookId)
     m_facebookId = facebookId;
 }
 
-void PersonListItem::setIsFriend(bool isFriend)
+void PersonListItem::setIsFriend(const bool isFriend)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
index fe7b0e0..2121308 100644 (file)
@@ -92,7 +92,7 @@ public:
     *
     * @param isFriend true if friend, false otherwise
     */
-    void setIsFriend(bool isFriend);
+    void setIsFriend(const bool isFriend);
 
     /**
     * @brief Set person data for this item.
index a101a49..7aaa42e 100644 (file)
@@ -26,6 +26,7 @@ TagsDialog::TagsDialog(const QHash<QString, QString> &tags, QWidget *parent)
     QVBoxLayout *mainLayout = new QVBoxLayout;
     QHBoxLayout *lineEditLayout = new QHBoxLayout;
     QGridLayout *listLayout = new QGridLayout;
+    QVBoxLayout *buttonLayout = new QVBoxLayout;
 
     m_addTagEdit = new QLineEdit("");
     QPushButton *addButton = new QPushButton(tr("Add"));
@@ -33,8 +34,9 @@ TagsDialog::TagsDialog(const QHash<QString, QString> &tags, QWidget *parent)
     lineEditLayout->addWidget(addButton);
 
     QPushButton *deleteButton = new QPushButton(tr("Delete"));
-    QPushButton *cancelButton = new QPushButton(tr("Cancel"));
     QPushButton *okButton = new QPushButton(tr("Update"));
+    buttonLayout->addWidget(deleteButton, 0, Qt::AlignBottom);
+    buttonLayout->addWidget(okButton, 0, Qt::AlignBottom);
 
     QLabel *yourTagsLabel = new QLabel(tr("Your tags:"));
     yourTagsLabel->setAlignment(Qt::AlignCenter);
@@ -42,11 +44,13 @@ TagsDialog::TagsDialog(const QHash<QString, QString> &tags, QWidget *parent)
     popularTagsLabel->setAlignment(Qt::AlignCenter);
     m_userTagsView = new QListWidget();
     m_popularTagsView = new QListWidget();
+    m_popularTagsView->setSelectionMode(QAbstractItemView::NoSelection);
 
     listLayout->addWidget(yourTagsLabel, 0, 0);
     listLayout->addWidget(popularTagsLabel, 0, 1);
     listLayout->addWidget(m_userTagsView, 1, 0);
-    listLayout->addWidget(m_userTagsView, 1, 1);
+    listLayout->addWidget(m_popularTagsView, 1, 1);
+    listLayout->addLayout(buttonLayout, 0, 2, -1, 1);
 
     mainLayout->addLayout(lineEditLayout);
     mainLayout->addLayout(listLayout);
@@ -56,9 +60,6 @@ TagsDialog::TagsDialog(const QHash<QString, QString> &tags, QWidget *parent)
     connect(okButton, SIGNAL(clicked()),
             this, SLOT(accept()));
 
-    connect(cancelButton, SIGNAL(clicked()),
-            this, SLOT(reject()));
-
     connect(addButton, SIGNAL(clicked()),
             this, SLOT(addTagToList()));
 
@@ -116,6 +117,8 @@ QStringList TagsDialog::removedTags()
 
 void TagsDialog::populatePopularTags(const QHash<QString, QString> &popularTags)
 {
+    qDebug() << __PRETTY_FUNCTION__;
+
     m_popularTagsView->clear();
 
     foreach (QString tag, popularTags)
@@ -124,6 +127,8 @@ void TagsDialog::populatePopularTags(const QHash<QString, QString> &popularTags)
 
 void TagsDialog::populateUserTags(const QHash<QString, QString> &userTags)
 {
+    qDebug() << __PRETTY_FUNCTION__;
+
     m_userTagsView->clear();
 
     foreach (QString tag, m_newTags) {
index ef46cb5..9677b9b 100644 (file)
@@ -30,6 +30,7 @@ class QLabel;
 class QLineEdit;
 class QPushButton;
 class QListWidget;
+class QListWidgetItem;
 
 /**
 * @brief User tags dialog shows user tags.
index 06f20c6..65be65a 100644 (file)
@@ -49,6 +49,7 @@ const int LABEL_MAX_WIDTH = BACKGROUND_WIDTH - ICON_WIDTH - 5 * MARGIN;
 UserInfo::UserInfo(QWidget *parent)
     : QWidget(parent),
       m_expanded(false),
+      m_tagsDialog(0),
       m_updateLocation(0)
 {
     qDebug() << __PRETTY_FUNCTION__;
@@ -330,6 +331,14 @@ void UserInfo::setTags(const QHash<QString, QString> &tags)
         m_tagsDialog->populateUserTags(m_userTags);
 }
 
+void UserInfo::setPopularTags(const QHash<QString, QString> &tags)
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    if (m_tagsDialog)
+        m_tagsDialog->populatePopularTags(tags);
+}
+
 void UserInfo::setTime(const QString &time)
 {
     qDebug() << __PRETTY_FUNCTION__;
index 8d48f7b..3a8151f 100644 (file)
@@ -122,6 +122,13 @@ public:
     void setTags(const QHash<QString, QString> &tags);
 
     /**
+    * @brief Sets the popular tags
+    *
+    * @param tags list of tags
+    */
+    void setPopularTags(const QHash<QString, QString> &tags);
+
+    /**
      * @brief Sets the time of updated message
      *
      * @param time Reference to time when message was sent.
index fc58695..6653b74 100644 (file)
@@ -118,6 +118,13 @@ UserInfoPanel::UserInfoPanel(QWidget *parent)
 
 }
 
+void UserInfoPanel::populatePopularTags(QHash<QString, QString> &popularTags)
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    m_userInfo->setPopularTags(popularTags);
+}
+
 void UserInfoPanel::setImage(const QString &id, const QPixmap &image)
 {
     qDebug() << __PRETTY_FUNCTION__;
@@ -137,6 +144,8 @@ void UserInfoPanel::showTagsDialog()
     qDebug() << __PRETTY_FUNCTION__;
 
     m_userInfo->showTagsDialog();
+
+    emit requestPopularTags();
 }
 
 void UserInfoPanel::userDataReceived(User *user)
index 5aee4c8..b26a94e 100644 (file)
@@ -53,6 +53,13 @@ public:
  ******************************************************************************/
 public slots:
     /**
+    * @brief Populates popular tags list
+    *
+    * @param popularTags list of popular tags
+    */
+    void populatePopularTags(QHash<QString, QString> &popularTags);
+
+    /**
      * @brief show / hide user information
      *
      * @param show true if userinfo should be shown
@@ -66,6 +73,18 @@ public slots:
      */
     void userDataReceived(User *user);
 
+private slots:
+    /**
+    * @brief Sets user's image.
+    *
+    * @param id image ID
+    * @param image image pixmap
+    */
+    void setImage(const QString &id, const QPixmap &image);
+
+    void showTagsDialog();
+
+
 /*******************************************************************************
  * SIGNALS
  ******************************************************************************/
@@ -112,6 +131,11 @@ signals:
     void removeTags(const QStringList &tags);
 
     /**
+    * @brief Signal for requesting popular tags
+    */
+    void requestPopularTags();
+
+    /**
      * @brief Signal for requesting reverseGeo from SituareEngine
      */
     void requestReverseGeo();
@@ -136,18 +160,6 @@ signals:
      */
     void clearUpdateLocationDialogData();
 
-private slots:
-    /**
-    * @brief Sets user's image.
-    *
-    * @param id image ID
-    * @param image image pixmap
-    */
-    void setImage(const QString &id, const QPixmap &image);
-
-    void showTagsDialog();
-
-
 
 /*******************************************************************************
  * DATA MEMBERS
diff --git a/tests/stubs/extendedlistitem.h b/tests/stubs/extendedlistitem.h
deleted file mode 100644 (file)
index b217b57..0000000
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
-   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.
-*/
-
-#ifndef EXTENDEDLISTITEMSTUB_H
-#define EXTENDEDLISTITEMSTUB_H
-
-#include "../../src/ui/personlistitem.h"
-#include "listitem.h"
-#include "../../src/coordinates/geocoordinate.h"
-#include "stubbase.h"
-
-class ExtendedListItemStub : public StubBase
-{
-public:
-    virtual void ExtendedListItemConstructor(QListWidget *parent, int type);
-    virtual void addSubItem(const QString &text, const QPixmap &icon = QPixmap());
-    virtual void clearSubItems();
-    virtual void setSelected(bool selected);
-    virtual void setSubitemTextWidth(int width);
-    virtual bool toggleSelection();
-};
-
-void ExtendedListItemStub::ExtendedListItemConstructor(QListWidget *parent, int type)
-{
-    Q_UNUSED(parent)
-    Q_UNUSED(type)
-}
-
-void ExtendedListItemStub::addSubItem(const QString &text, const QPixmap &icon)
-{
-    QList<ParameterBase *> params;
-    params.append(new Parameter<const QString &>(text));
-    params.append(new Parameter<const QPixmap &>(icon));
-    stubMethodEntered("addSubItem", params);
-}
-
-void ExtendedListItemStub::clearSubItems()
-{
-    stubMethodEntered("clearSubItems");
-}
-
-void ExtendedListItemStub::setSelected(bool selected)
-{
-    QList<ParameterBase *> params;
-    params.append(new Parameter<bool>(selected));
-    stubMethodEntered("setSelected", params);
-}
-
-void ExtendedListItemStub::setSubitemTextWidth(int width)
-{
-    QList<ParameterBase *> params;
-    params.append(new Parameter<int>(width));
-    stubMethodEntered("setSubitemTextWidth", params);
-}
-
-bool ExtendedListItemStub::toggleSelection()
-{
-    stubMethodEntered("toggleSelection");
-
-    return stubReturnValue<bool>("toggleSelection");
-}
-
-//Create a stub instance
-ExtendedListItemStub defaultExtendedListItemStub;
-ExtendedListItemStub *extendedListItemStub = &defaultExtendedListItemStub;
-
-ExtendedListItem::ExtendedListItem(QListWidget *parent, int type)
-    : ListItem(parent, type)
-{
-    extendedListItemStub->ExtendedListItemConstructor(parent, type);
-}
-
-ExtendedListItem::~ExtendedListItem()
-{
-
-}
-
-void ExtendedListItem::addSubItem(const QString &text, const QPixmap &icon)
-{
-    extendedListItemStub->addSubItem(text, icon);
-}
-
-void ExtendedListItem::clearSubItems()
-{
-    extendedListItemStub->clearSubItems();
-}
-
-void ExtendedListItem::setSelected(bool selected)
-{
-    extendedListItemStub->setSelected(selected);
-}
-
-void ExtendedListItem::setSubitemTextWidth(int width)
-{
-    extendedListItemStub->setSubitemTextWidth(width);
-}
-
-bool ExtendedListItem::toggleSelection()
-{
-    return extendedListItemStub->toggleSelection();
-}
-
-#endif // EXTENDEDLISTITEMSTUB_H
diff --git a/tests/stubs/extendedlistitemstub.h b/tests/stubs/extendedlistitemstub.h
new file mode 100644 (file)
index 0000000..8c5fd94
--- /dev/null
@@ -0,0 +1,121 @@
+/*
+   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.
+*/
+
+#ifndef EXTENDEDLISTITEMSTUB_H
+#define EXTENDEDLISTITEMSTUB_H
+
+#include "../../src/ui/extendedlistitem.h"
+#include "listitemstub.h"
+#include "../../src/coordinates/geocoordinate.h"
+#include "stubbase.h"
+
+class ExtendedListItemStub : public StubBase
+{
+public:
+    virtual void ExtendedListItemConstructor(QListWidget *parent, int type);
+    virtual void addSubItem(const QString &text, const QPixmap &icon = QPixmap());
+    virtual void clearSubItems();
+    virtual void setSelected(bool selected);
+    virtual void setSubitemTextWidth(int width);
+    virtual bool toggleSelection();
+};
+
+void ExtendedListItemStub::ExtendedListItemConstructor(QListWidget *parent, int type)
+{
+    Q_UNUSED(parent)
+    Q_UNUSED(type)
+}
+
+void ExtendedListItemStub::addSubItem(const QString &text, const QPixmap &icon)
+{
+    QList<ParameterBase *> params;
+    params.append(new Parameter<const QString &>(text));
+    params.append(new Parameter<const QPixmap &>(icon));
+    stubMethodEntered("addSubItem", params);
+}
+
+void ExtendedListItemStub::clearSubItems()
+{
+    stubMethodEntered("clearSubItems");
+}
+
+void ExtendedListItemStub::setSelected(bool selected)
+{
+    QList<ParameterBase *> params;
+    params.append(new Parameter<bool>(selected));
+    stubMethodEntered("setSelected", params);
+}
+
+void ExtendedListItemStub::setSubitemTextWidth(int width)
+{
+    QList<ParameterBase *> params;
+    params.append(new Parameter<int>(width));
+    stubMethodEntered("setSubitemTextWidth", params);
+}
+
+bool ExtendedListItemStub::toggleSelection()
+{
+    stubMethodEntered("toggleSelection");
+
+    return stubReturnValue<bool>("toggleSelection");
+}
+
+//Create a stub instance
+ExtendedListItemStub defaultExtendedListItemStub;
+ExtendedListItemStub *extendedListItemStub = &defaultExtendedListItemStub;
+
+ExtendedListItem::ExtendedListItem(QListWidget *parent, int type)
+    : ListItem(parent, type)
+{
+    extendedListItemStub->ExtendedListItemConstructor(parent, type);
+}
+
+ExtendedListItem::~ExtendedListItem()
+{
+
+}
+
+void ExtendedListItem::addSubItem(const QString &text, const QPixmap &icon)
+{
+    extendedListItemStub->addSubItem(text, icon);
+}
+
+void ExtendedListItem::clearSubItems()
+{
+    extendedListItemStub->clearSubItems();
+}
+
+void ExtendedListItem::setSelected(bool selected)
+{
+    extendedListItemStub->setSelected(selected);
+}
+
+void ExtendedListItem::setSubitemTextWidth(int width)
+{
+    extendedListItemStub->setSubitemTextWidth(width);
+}
+
+bool ExtendedListItem::toggleSelection()
+{
+    return extendedListItemStub->toggleSelection();
+}
+
+#endif // EXTENDEDLISTITEMSTUB_H
diff --git a/tests/stubs/listitem.h b/tests/stubs/listitem.h
deleted file mode 100644 (file)
index 5d85864..0000000
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
-   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.
-*/
-
-#ifndef LISTITEMSTUB_H
-#define LISTITEMSTUB_H
-
-#include "../../src/ui/personlistitem.h"
-#include "../../src/coordinates/geocoordinate.h"
-#include "stubbase.h"
-
-class ListItemStub : public StubBase
-{
-public:
-    virtual void ListItemConstructor(QListWidget *parent = 0,
-                                     int type = QListWidgetItem::Type);
-    enum TextSize{TEXT_SIZE_NORMAL, TEXT_SIZE_SMALL};
-    virtual void setImage(const QPixmap &image);
-    virtual void setTitle(const QString &name);
-    virtual void setSize(const QSize &size);
-    virtual QString shortenText(const QString &text, int textWidth, ListItem::TextSize textSize);
-    virtual QString title();
-};
-
-void ListItemStub::ListItemConstructor(QListWidget *parent, int type)
-{
-    Q_UNUSED(parent)
-    Q_UNUSED(type)
-}
-
-void ListItemStub::setImage(const QPixmap &image)
-{
-    QList<ParameterBase *> params;
-    params.append(new Parameter<const QPixmap &>(image));
-    stubMethodEntered("setImage", params);
-}
-
-void ListItemStub::setTitle(const QString &name)
-{
-    QList<ParameterBase *> params;
-    params.append(new Parameter<const QString &>(name));
-    stubMethodEntered("setTitle", params);
-}
-
-void ListItemStub::setSize(const QSize &size)
-{
-    QList<ParameterBase *> params;
-    params.append(new Parameter<const QSize &>(size));
-    stubMethodEntered("setSize", params);
-}
-
-QString ListItemStub::shortenText(const QString &text, int textWidth, ListItem::TextSize textSize)
-{
-    QList<ParameterBase *> params;
-    params.append(new Parameter<const QString &>(text));
-    params.append(new Parameter<int>(textWidth));
-    params.append(new Parameter<ListItem::TextSize>(textSize));
-    stubMethodEntered("shortenText", params);
-
-    return stubReturnValue<QString>("shortenText");
-}
-
-QString ListItemStub::title()
-{
-    return stubReturnValue<QString>("title");
-}
-
-//Create a stub instance
-ListItemStub defaultListItemStub;
-ListItemStub *listItemStub = &defaultListItemStub;
-
-ListItem::ListItem(QListWidget *parent, int type)
-    : QListWidgetItem(parent, type)
-{
-    listItemStub->ListItemConstructor(parent, type);
-}
-
-void ListItem::setImage(const QPixmap &image)
-{
-    listItemStub->setImage(image);
-}
-
-void ListItem::setTitle(const QString &name)
-{
-    listItemStub->setTitle(name);
-}
-
-void ListItem::setSize(const QSize &size)
-{
-    listItemStub->setSize(size);
-}
-
-QString ListItem::shortenText(const QString &text, int textWidth, ListItem::TextSize textSize)
-{
-    return listItemStub->shortenText(text, textWidth, textSize);
-}
-
-QString ListItem::title()
-{
-    return listItemStub->title();
-}
-
-#endif // LISTITEMSTUB_H
-
diff --git a/tests/stubs/listitemstub.h b/tests/stubs/listitemstub.h
new file mode 100644 (file)
index 0000000..d461949
--- /dev/null
@@ -0,0 +1,121 @@
+/*
+   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.
+*/
+
+#ifndef LISTITEMSTUB_H
+#define LISTITEMSTUB_H
+
+#include "../../src/ui/listitem.h"
+#include "../../src/coordinates/geocoordinate.h"
+#include "stubbase.h"
+
+class ListItemStub : public StubBase
+{
+public:
+    virtual void ListItemConstructor(QListWidget *parent = 0,
+                                     int type = QListWidgetItem::Type);
+    enum TextSize{TEXT_SIZE_NORMAL, TEXT_SIZE_SMALL};
+    virtual void setImage(const QPixmap &image);
+    virtual void setTitle(const QString &name);
+    virtual void setSize(const QSize &size);
+    virtual QString shortenText(const QString &text, int textWidth, ListItem::TextSize textSize);
+    virtual QString title();
+};
+
+void ListItemStub::ListItemConstructor(QListWidget *parent, int type)
+{
+    Q_UNUSED(parent)
+    Q_UNUSED(type)
+}
+
+void ListItemStub::setImage(const QPixmap &image)
+{
+    QList<ParameterBase *> params;
+    params.append(new Parameter<const QPixmap &>(image));
+    stubMethodEntered("setImage", params);
+}
+
+void ListItemStub::setTitle(const QString &name)
+{
+    QList<ParameterBase *> params;
+    params.append(new Parameter<const QString &>(name));
+    stubMethodEntered("setTitle", params);
+}
+
+void ListItemStub::setSize(const QSize &size)
+{
+    QList<ParameterBase *> params;
+    params.append(new Parameter<const QSize &>(size));
+    stubMethodEntered("setSize", params);
+}
+
+QString ListItemStub::shortenText(const QString &text, int textWidth, ListItem::TextSize textSize)
+{
+    QList<ParameterBase *> params;
+    params.append(new Parameter<const QString &>(text));
+    params.append(new Parameter<int>(textWidth));
+    params.append(new Parameter<ListItem::TextSize>(textSize));
+    stubMethodEntered("shortenText", params);
+
+    return stubReturnValue<QString>("shortenText");
+}
+
+QString ListItemStub::title()
+{
+    return stubReturnValue<QString>("title");
+}
+
+//Create a stub instance
+ListItemStub defaultListItemStub;
+ListItemStub *listItemStub = &defaultListItemStub;
+
+ListItem::ListItem(QListWidget *parent, int type)
+    : QListWidgetItem(parent, type)
+{
+    listItemStub->ListItemConstructor(parent, type);
+}
+
+void ListItem::setImage(const QPixmap &image)
+{
+    listItemStub->setImage(image);
+}
+
+void ListItem::setTitle(const QString &name)
+{
+    listItemStub->setTitle(name);
+}
+
+void ListItem::setSize(const QSize &size)
+{
+    listItemStub->setSize(size);
+}
+
+QString ListItem::shortenText(const QString &text, int textWidth, ListItem::TextSize textSize)
+{
+    return listItemStub->shortenText(text, textWidth, textSize);
+}
+
+QString ListItem::title()
+{
+    return listItemStub->title();
+}
+
+#endif // LISTITEMSTUB_H
+
diff --git a/tests/stubs/listview.h b/tests/stubs/listview.h
deleted file mode 100644 (file)
index 371d48e..0000000
+++ /dev/null
@@ -1,292 +0,0 @@
-/*
-   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.
-*/
-
-#ifndef LISTVIEWSTUB_H
-#define LISTVIEWSTUB_H
-
-#include <QListWidget>
-
-#include "../../src/ui/personlistview.h"
-#include "listitem.h"
-#include "stubbase.h"
-
-class ListViewStub : public StubBase
-{
-public:
-    virtual void ListViewConstructor(QWidget *parent = 0);
-    virtual void addListItem(const QString &key, ListItem *item);
-    virtual void addListItemToView(ListItem *item);
-    virtual void clearUnused(const QStringList &itemIDs);
-    virtual void clearFilter();
-    virtual void clearItemSelection();
-    virtual void clearList();
-    virtual bool contains(const QString &userID);
-    virtual void filter(const QList<QString> &itemIDs);
-    virtual void filter(const QString &pattern);
-    virtual ListItem *takeListItemFromView(const QString &itemID);
-    virtual ListItem *listItem(const QString &itemID);
-    virtual ListItem *listItemAt(int index);
-    virtual void prependListItem(const QString &key, ListItem *item);
-    virtual void removeLastItem();
-    virtual ListItem *selectedItem();
-    virtual void setSelectedItem(ListItem *item);
-    virtual bool listItemClicked(ListItem *clickedItem);
-    virtual void listItemClicked(QListWidgetItem *item);
-};
-
-void ListViewStub::ListViewConstructor(QWidget *parent)
-{
-    Q_UNUSED(parent)
-}
-
-void ListViewStub::addListItem(const QString &key, ListItem *item)
-{
-    QList<ParameterBase *> params;
-    params.append(new Parameter<const QString &>(key));
-    params.append(new Parameter<ListItem *>(item));
-    stubMethodEntered("addListItem", params);
-}
-
-void ListViewStub::addListItemToView(ListItem *item)
-{
-    QList<ParameterBase *> params;
-    params.append(new Parameter<ListItem *>(item));
-    stubMethodEntered("addListItemToView", params);
-}
-
-void ListViewStub::clearUnused(const QStringList &itemIDs)
-{
-    QList<ParameterBase *> params;
-    params.append(new Parameter<const QStringList &>(itemIDs));
-    stubMethodEntered("clearUnused", params);
-}
-
-void ListViewStub::clearFilter()
-{
-    stubMethodEntered("clearFilter");
-}
-
-void ListViewStub::clearItemSelection()
-{
-    stubMethodEntered("clearItemSelection");
-}
-
-void ListViewStub::clearList()
-{
-    stubMethodEntered("clearList");
-}
-
-bool ListViewStub::contains(const QString &userID)
-{
-    QList<ParameterBase *> params;
-    params.append(new Parameter<const QString &>(userID));
-    stubMethodEntered("contains", params);
-
-    return stubReturnValue<bool>("contains");
-}
-
-void ListViewStub::filter(const QList<QString> &itemIDs)
-{
-    QList<ParameterBase *> params;
-    params.append(new Parameter<const QList<QString> &>(itemIDs));
-    stubMethodEntered("filter", params);
-}
-
-void ListViewStub::filter(const QString &pattern)
-{
-    QList<ParameterBase *> params;
-    params.append(new Parameter<const QString &>(pattern));
-    stubMethodEntered("filter", params);
-}
-
-ListItem *ListViewStub::takeListItemFromView(const QString &itemID)
-{
-    QList<ParameterBase *> params;
-    params.append(new Parameter<const QString &>(itemID));
-    stubMethodEntered("takeListItemFromView", params);
-
-    return stubReturnValue<ListItem *>("takeListItemFromView");
-}
-
-ListItem *ListViewStub::listItem(const QString &itemID)
-{
-    QList<ParameterBase *> params;
-    params.append(new Parameter<const QString &>(itemID));
-    stubMethodEntered("listItem", params);
-
-    return stubReturnValue<ListItem *>("listItem");
-}
-
-ListItem *ListViewStub::listItemAt(int index)
-{
-    QList<ParameterBase *> params;
-    params.append(new Parameter<int>(index));
-    stubMethodEntered("listItemAt", params);
-
-    return stubReturnValue<ListItem *>("listItemAt");
-}
-
-void ListViewStub::prependListItem(const QString &key, ListItem *item)
-{
-    QList<ParameterBase *> params;
-    params.append(new Parameter<const QString &>(key));
-    params.append(new Parameter<ListItem *>(item));
-    stubMethodEntered("prependListItem", params);
-}
-
-void ListViewStub::removeLastItem()
-{
-    stubMethodEntered("removeLastItem");
-}
-
-ListItem *ListViewStub::selectedItem()
-{
-    return stubReturnValue<ListItem *>("selectedItem");
-}
-
-void ListViewStub::setSelectedItem(ListItem *item)
-{
-    QList<ParameterBase *> params;
-    params.append(new Parameter<ListItem *>(item));
-    stubMethodEntered("setSelectedItem", params);
-}
-
-bool ListViewStub::listItemClicked(ListItem *clickedItem)
-{
-    QList<ParameterBase *> params;
-    params.append(new Parameter<ListItem *>(clickedItem));
-    stubMethodEntered("listItemClicked", params);
-
-    return stubReturnValue<bool>("listItemClicked");
-}
-
-void ListViewStub::listItemClicked(QListWidgetItem *item)
-{
-    QList<ParameterBase *> params;
-    params.append(new Parameter<QListWidgetItem *>(item));
-    stubMethodEntered("listItemClicked", params);
-}
-
-ListViewStub defaultListViewStub;
-ListViewStub *listViewStub = &defaultListViewStub;
-
-ListView::ListView(QWidget *parent)
-    : QListWidget(parent)
-{
-    listViewStub->ListViewConstructor(parent);
-}
-
-ListView::~ListView()
-{
-
-}
-
-void ListView::addListItem(const QString &key, ListItem *item)
-{
-    listViewStub->addListItem(key, item);
-}
-
-void ListView::addListItemToView(ListItem *item)
-{
-    listViewStub->addListItemToView(item);
-}
-
-void ListView::clearUnused(const QStringList &itemIDs)
-{
-    listViewStub->clearUnused(itemIDs);
-}
-
-void ListView::clearFilter()
-{
-    listViewStub->clearFilter();
-}
-
-void ListView::clearItemSelection()
-{
-    listViewStub->clearItemSelection();
-}
-
-void ListView::clearList()
-{
-    listViewStub->clearList();
-}
-
-bool ListView::contains(const QString &userID)
-{
-    return listViewStub->contains(userID);
-}
-
-void ListView::filter(const QList<QString> &itemIDs)
-{
-    listViewStub->filter(itemIDs);
-}
-
-void ListView::filter(const QString &pattern)
-{
-    listViewStub->filter(pattern);
-}
-
-ListItem *ListView::takeListItemFromView(const QString &itemID)
-{
-    return listViewStub->takeListItemFromView(itemID);
-}
-
-ListItem *ListView::listItem(const QString &itemID)
-{
-    return listViewStub->listItem(itemID);
-}
-
-ListItem *ListView::listItemAt(int index)
-{
-    return listViewStub->listItemAt(index);
-}
-
-void ListView::prependListItem(const QString &key, ListItem *item)
-{
-    listViewStub->prependListItem(key, item);
-}
-
-void ListView::removeLastItem()
-{
-    listViewStub->removeLastItem();
-}
-
-ListItem *ListView::selectedItem()
-{
-    return listViewStub->selectedItem();
-}
-
-void ListView::setSelectedItem(ListItem *item)
-{
-    listViewStub->setSelectedItem(item);
-}
-
-bool ListView::listItemClicked(ListItem *clickedItem)
-{
-    return listViewStub->listItemClicked(clickedItem);
-}
-
-void ListView::listItemClicked(QListWidgetItem *item)
-{
-    listViewStub->listItemClicked(item);
-}
-
-#endif // LISTVIEWSTUB_H
diff --git a/tests/stubs/listviewstub.h b/tests/stubs/listviewstub.h
new file mode 100644 (file)
index 0000000..b22515f
--- /dev/null
@@ -0,0 +1,292 @@
+/*
+   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.
+*/
+
+#ifndef LISTVIEWSTUB_H
+#define LISTVIEWSTUB_H
+
+#include <QListWidget>
+
+#include "../../src/ui/listview.h"
+#include "listitemstub.h"
+#include "stubbase.h"
+
+class ListViewStub : public StubBase
+{
+public:
+    virtual void ListViewConstructor(QWidget *parent = 0);
+    virtual void addListItem(const QString &key, ListItem *item);
+    virtual void addListItemToView(ListItem *item);
+    virtual void clearUnused(const QStringList &itemIDs);
+    virtual void clearFilter();
+    virtual void clearItemSelection();
+    virtual void clearList();
+    virtual bool contains(const QString &userID);
+    virtual void filter(const QList<QString> &itemIDs);
+    virtual void filter(const QString &pattern);
+    virtual ListItem *takeListItemFromView(const QString &itemID);
+    virtual ListItem *listItem(const QString &itemID);
+    virtual ListItem *listItemAt(int index);
+    virtual void prependListItem(const QString &key, ListItem *item);
+    virtual void removeLastItem();
+    virtual ListItem *selectedItem();
+    virtual void setSelectedItem(ListItem *item);
+    virtual bool listItemClicked(ListItem *clickedItem);
+    virtual void listItemClicked(QListWidgetItem *item);
+};
+
+void ListViewStub::ListViewConstructor(QWidget *parent)
+{
+    Q_UNUSED(parent)
+}
+
+void ListViewStub::addListItem(const QString &key, ListItem *item)
+{
+    QList<ParameterBase *> params;
+    params.append(new Parameter<const QString &>(key));
+    params.append(new Parameter<ListItem *>(item));
+    stubMethodEntered("addListItem", params);
+}
+
+void ListViewStub::addListItemToView(ListItem *item)
+{
+    QList<ParameterBase *> params;
+    params.append(new Parameter<ListItem *>(item));
+    stubMethodEntered("addListItemToView", params);
+}
+
+void ListViewStub::clearUnused(const QStringList &itemIDs)
+{
+    QList<ParameterBase *> params;
+    params.append(new Parameter<const QStringList &>(itemIDs));
+    stubMethodEntered("clearUnused", params);
+}
+
+void ListViewStub::clearFilter()
+{
+    stubMethodEntered("clearFilter");
+}
+
+void ListViewStub::clearItemSelection()
+{
+    stubMethodEntered("clearItemSelection");
+}
+
+void ListViewStub::clearList()
+{
+    stubMethodEntered("clearList");
+}
+
+bool ListViewStub::contains(const QString &userID)
+{
+    QList<ParameterBase *> params;
+    params.append(new Parameter<const QString &>(userID));
+    stubMethodEntered("contains", params);
+
+    return stubReturnValue<bool>("contains");
+}
+
+void ListViewStub::filter(const QList<QString> &itemIDs)
+{
+    QList<ParameterBase *> params;
+    params.append(new Parameter<const QList<QString> &>(itemIDs));
+    stubMethodEntered("filter", params);
+}
+
+void ListViewStub::filter(const QString &pattern)
+{
+    QList<ParameterBase *> params;
+    params.append(new Parameter<const QString &>(pattern));
+    stubMethodEntered("filter", params);
+}
+
+ListItem *ListViewStub::takeListItemFromView(const QString &itemID)
+{
+    QList<ParameterBase *> params;
+    params.append(new Parameter<const QString &>(itemID));
+    stubMethodEntered("takeListItemFromView", params);
+
+    return stubReturnValue<ListItem *>("takeListItemFromView");
+}
+
+ListItem *ListViewStub::listItem(const QString &itemID)
+{
+    QList<ParameterBase *> params;
+    params.append(new Parameter<const QString &>(itemID));
+    stubMethodEntered("listItem", params);
+
+    return stubReturnValue<ListItem *>("listItem");
+}
+
+ListItem *ListViewStub::listItemAt(int index)
+{
+    QList<ParameterBase *> params;
+    params.append(new Parameter<int>(index));
+    stubMethodEntered("listItemAt", params);
+
+    return stubReturnValue<ListItem *>("listItemAt");
+}
+
+void ListViewStub::prependListItem(const QString &key, ListItem *item)
+{
+    QList<ParameterBase *> params;
+    params.append(new Parameter<const QString &>(key));
+    params.append(new Parameter<ListItem *>(item));
+    stubMethodEntered("prependListItem", params);
+}
+
+void ListViewStub::removeLastItem()
+{
+    stubMethodEntered("removeLastItem");
+}
+
+ListItem *ListViewStub::selectedItem()
+{
+    return stubReturnValue<ListItem *>("selectedItem");
+}
+
+void ListViewStub::setSelectedItem(ListItem *item)
+{
+    QList<ParameterBase *> params;
+    params.append(new Parameter<ListItem *>(item));
+    stubMethodEntered("setSelectedItem", params);
+}
+
+bool ListViewStub::listItemClicked(ListItem *clickedItem)
+{
+    QList<ParameterBase *> params;
+    params.append(new Parameter<ListItem *>(clickedItem));
+    stubMethodEntered("listItemClicked", params);
+
+    return stubReturnValue<bool>("listItemClicked");
+}
+
+void ListViewStub::listItemClicked(QListWidgetItem *item)
+{
+    QList<ParameterBase *> params;
+    params.append(new Parameter<QListWidgetItem *>(item));
+    stubMethodEntered("listItemClicked", params);
+}
+
+ListViewStub defaultListViewStub;
+ListViewStub *listViewStub = &defaultListViewStub;
+
+ListView::ListView(QWidget *parent)
+    : QListWidget(parent)
+{
+    listViewStub->ListViewConstructor(parent);
+}
+
+ListView::~ListView()
+{
+
+}
+
+void ListView::addListItem(const QString &key, ListItem *item)
+{
+    listViewStub->addListItem(key, item);
+}
+
+void ListView::addListItemToView(ListItem *item)
+{
+    listViewStub->addListItemToView(item);
+}
+
+void ListView::clearUnused(const QStringList &itemIDs)
+{
+    listViewStub->clearUnused(itemIDs);
+}
+
+void ListView::clearFilter()
+{
+    listViewStub->clearFilter();
+}
+
+void ListView::clearItemSelection()
+{
+    listViewStub->clearItemSelection();
+}
+
+void ListView::clearList()
+{
+    listViewStub->clearList();
+}
+
+bool ListView::contains(const QString &userID)
+{
+    return listViewStub->contains(userID);
+}
+
+void ListView::filter(const QList<QString> &itemIDs)
+{
+    listViewStub->filter(itemIDs);
+}
+
+void ListView::filter(const QString &pattern)
+{
+    listViewStub->filter(pattern);
+}
+
+ListItem *ListView::takeListItemFromView(const QString &itemID)
+{
+    return listViewStub->takeListItemFromView(itemID);
+}
+
+ListItem *ListView::listItem(const QString &itemID)
+{
+    return listViewStub->listItem(itemID);
+}
+
+ListItem *ListView::listItemAt(int index)
+{
+    return listViewStub->listItemAt(index);
+}
+
+void ListView::prependListItem(const QString &key, ListItem *item)
+{
+    listViewStub->prependListItem(key, item);
+}
+
+void ListView::removeLastItem()
+{
+    listViewStub->removeLastItem();
+}
+
+ListItem *ListView::selectedItem()
+{
+    return listViewStub->selectedItem();
+}
+
+void ListView::setSelectedItem(ListItem *item)
+{
+    listViewStub->setSelectedItem(item);
+}
+
+bool ListView::listItemClicked(ListItem *clickedItem)
+{
+    return listViewStub->listItemClicked(clickedItem);
+}
+
+void ListView::listItemClicked(QListWidgetItem *item)
+{
+    listViewStub->listItemClicked(item);
+}
+
+#endif // LISTVIEWSTUB_H
diff --git a/tests/stubs/messagelistitemstub.h b/tests/stubs/messagelistitemstub.h
new file mode 100644 (file)
index 0000000..e835cef
--- /dev/null
@@ -0,0 +1,116 @@
+/*
+   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.
+*/
+
+#ifndef MESSAGELISTITEMSTUB_H
+#define MESSAGELISTITEMSTUB_H
+
+#include "../../src/ui/messagelistitem.h"
+#include "../../src/coordinates/geocoordinate.h"
+#include "../../src/situareservice/message.h"
+#include "extendedlistitemstub.h"
+#include "stubbase.h"
+
+class MessageListItemStub : public StubBase
+{
+public:
+    virtual void MessageListItemConstructor();
+    virtual GeoCoordinate &coordinates() const;
+    virtual QString &id() const;
+    virtual QString &newMessageReceiverId() const;
+    virtual void setNewMessageReceiverId(const QString &newMessageReceiverId);
+    virtual void setMessageData(const Message &message);
+};
+
+void MessageListItemStub::MessageListItemConstructor()
+{
+
+}
+
+GeoCoordinate &MessageListItemStub::coordinates() const
+{
+    return stubReturnValue<GeoCoordinate>("coordinates");
+}
+
+QString &MessageListItemStub::id() const
+{
+    return stubReturnValue<QString>("id");
+}
+
+QString &MessageListItemStub::newMessageReceiverId() const
+{
+    return stubReturnValue<QString>("newMessageReceiverId");
+}
+
+void MessageListItemStub::setNewMessageReceiverId(const QString &newMessageReceiverId)
+{
+    QList<ParameterBase *> params;
+    params.append(new Parameter<const QString &>(newMessageReceiverId));
+    stubMethodEntered("setNewMessageReceiverId", params);
+}
+
+void MessageListItemStub::setMessageData(const Message &message)
+{
+    QList<ParameterBase *> params;
+    params.append(new Parameter<const Message &>(message));
+    stubMethodEntered("setMessageData", params);
+}
+
+//Create a stub instance
+MessageListItemStub defaultMessageListItemStub;
+MessageListItemStub *messageListItemStub = &defaultMessageListItemStub;
+
+MessageListItem::MessageListItem()
+    : ExtendedListItem()
+{
+    messageListItemStub->MessageListItemConstructor();
+}
+
+MessageListItem::~MessageListItem()
+{
+
+}
+
+GeoCoordinate &MessageListItem::coordinates() const
+{
+    return messageListItemStub->coordinates();
+}
+
+QString &MessageListItem::id() const
+{
+    return messageListItemStub->id();
+}
+
+QString &MessageListItem::newMessageReceiverId() const
+{
+    return messageListItemStub->newMessageReceiverId();
+}
+
+void MessageListItem::setNewMessageReceiverId(const QString &newMessageReceiverId)
+{
+    messageListItemStub->setNewMessageReceiverId(newMessageReceiverId);
+}
+
+void MessageListItem::setMessageData(const Message &message)
+{
+    messageListItemStub->setMessageData(message);
+}
+
+#endif // MESSAGELISTITEMSTUB_H
diff --git a/tests/stubs/personlistitem.h b/tests/stubs/personlistitem.h
deleted file mode 100644 (file)
index ceaf73e..0000000
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
-   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.
-*/
-
-#ifndef PERSONLISTITEMSTUB_H
-#define PERSONLISTITEMSTUB_H
-
-#include "../../src/ui/personlistitem.h"
-#include "../../src/coordinates/geocoordinate.h"
-#include "extendedlistitem.h"
-#include "stubbase.h"
-
-class PersonListItemStub : public StubBase
-{
-public:
-    virtual void PersonListItemConstructor();
-    virtual GeoCoordinate coordinates() const;
-    virtual QString facebookId() const;
-    virtual void setAvatarImage(const QPixmap &image);
-    virtual void setCoordinates(const GeoCoordinate &coordinates);
-    virtual void setPersonData(const User &user);
-};
-
-void PersonListItemStub::PersonListItemConstructor()
-{
-
-}
-
-GeoCoordinate PersonListItemStub::coordinates() const
-{
-    return stubReturnValue<GeoCoordinate>("coordinates");
-}
-
-QString PersonListItemStub::facebookId() const
-{
-    return stubReturnValue<QString>("facebookId");
-}
-
-void PersonListItemStub::setAvatarImage(const QPixmap &image)
-{
-    QList<ParameterBase *> params;
-    params.append(new Parameter<const QPixmap &>(image));
-    stubMethodEntered("setAvatarImage", params);
-}
-
-void PersonListItemStub::setCoordinates(const GeoCoordinate &coordinates)
-{
-    QList<ParameterBase *> params;
-    params.append(new Parameter<const GeoCoordinate &>(coordinates));
-    stubMethodEntered("setCoordinates", params);
-}
-
-void PersonListItemStub::setPersonData(const User &user)
-{
-    QList<ParameterBase *> params;
-    params.append(new Parameter<const User &>(user));
-    stubMethodEntered("setUserData", params);
-}
-
-//Create a stub instance
-PersonListItemStub defaultPersonListItemStub;
-PersonListItemStub *personListItemStub = &defaultPersonListItemStub;
-
-PersonListItem::PersonListItem()
-    : ExtendedListItem()
-{
-    personListItemStub->PersonListItemConstructor();
-}
-
-PersonListItem::~PersonListItem()
-{
-
-}
-
-GeoCoordinate PersonListItem::coordinates() const
-{
-    return personListItemStub->coordinates();
-}
-
-QString PersonListItem::facebookId() const
-{
-    return personListItemStub->facebookId();
-}
-
-void PersonListItem::setAvatarImage(const QPixmap &image)
-{
-    personListItemStub->setAvatarImage(image);
-}
-
-void PersonListItem::setCoordinates(const GeoCoordinate &coordinates)
-{
-    personListItemStub->setCoordinates(coordinates);
-}
-
-void PersonListItem::setPersonData(const User &user)
-{
-    personListItemStub->setPersonData(user);
-}
-
-#endif // PERSONLISTITEMSTUB_H
diff --git a/tests/stubs/personlistitemstub.h b/tests/stubs/personlistitemstub.h
new file mode 100644 (file)
index 0000000..4791c41
--- /dev/null
@@ -0,0 +1,143 @@
+/*
+   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.
+*/
+
+#ifndef PERSONLISTITEMSTUB_H
+#define PERSONLISTITEMSTUB_H
+
+#include "../../src/ui/personlistitem.h"
+#include "../../src/coordinates/geocoordinate.h"
+#include "extendedlistitemstub.h"
+#include "stubbase.h"
+
+class PersonListItemStub : public StubBase
+{
+public:
+    virtual void PersonListItemConstructor();
+    virtual GeoCoordinate coordinates() const;
+    virtual QString facebookId() const;
+    virtual bool isFriend() const;
+    virtual void setAvatarImage(const QPixmap &image);
+    virtual void setCoordinates(const GeoCoordinate &coordinates);
+    virtual void setIsFriend(const bool isFriend);
+    virtual void setPersonData(const User &user, bool isFriend);
+};
+
+void PersonListItemStub::PersonListItemConstructor()
+{
+
+}
+
+GeoCoordinate PersonListItemStub::coordinates() const
+{
+    return stubReturnValue<GeoCoordinate>("coordinates");
+}
+
+QString PersonListItemStub::facebookId() const
+{
+    return stubReturnValue<QString>("facebookId");
+}
+
+bool PersonListItemStub::isFriend() const
+{
+    return stubReturnValue<bool>("isFriend");
+}
+
+void PersonListItemStub::setAvatarImage(const QPixmap &image)
+{
+    QList<ParameterBase *> params;
+    params.append(new Parameter<const QPixmap &>(image));
+    stubMethodEntered("setAvatarImage", params);
+}
+
+void PersonListItemStub::setCoordinates(const GeoCoordinate &coordinates)
+{
+    QList<ParameterBase *> params;
+    params.append(new Parameter<const GeoCoordinate &>(coordinates));
+    stubMethodEntered("setCoordinates", params);
+}
+
+void PersonListItemStub::setIsFriend(const bool isFriend)
+{
+    QList<ParameterBase *> params;
+    params.append(new Parameter<const bool>(isFriend));
+    stubMethodEntered("setIsFriend", params);
+}
+
+
+void PersonListItemStub::setPersonData(const User &user, bool isFriend)
+{
+    QList<ParameterBase *> params;
+    params.append(new Parameter<const User &>(user));
+    params.append(new Parameter<bool>(isFriend));
+    stubMethodEntered("setUserData", params);
+}
+
+//Create a stub instance
+PersonListItemStub defaultPersonListItemStub;
+PersonListItemStub *personListItemStub = &defaultPersonListItemStub;
+
+PersonListItem::PersonListItem()
+    : ExtendedListItem()
+{
+    personListItemStub->PersonListItemConstructor();
+}
+
+PersonListItem::~PersonListItem()
+{
+
+}
+
+GeoCoordinate PersonListItem::coordinates() const
+{
+    return personListItemStub->coordinates();
+}
+
+QString PersonListItem::facebookId() const
+{
+    return personListItemStub->facebookId();
+}
+
+bool PersonListItem::isFriend() const
+{
+    return personListItemStub->isFriend();
+}
+
+void PersonListItem::setAvatarImage(const QPixmap &image)
+{
+    personListItemStub->setAvatarImage(image);
+}
+
+void PersonListItem::setCoordinates(const GeoCoordinate &coordinates)
+{
+    personListItemStub->setCoordinates(coordinates);
+}
+
+void PersonListItem::setIsFriend(const bool isFriend)
+{
+    personListItemStub->setIsFriend(isFriend);
+}
+
+void PersonListItem::setPersonData(const User &user, bool isFriend)
+{
+    personListItemStub->setPersonData(user, isFriend);
+}
+
+#endif // PERSONLISTITEMSTUB_H
diff --git a/tests/stubs/personlistview.h b/tests/stubs/personlistview.h
deleted file mode 100644 (file)
index 6052819..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
-   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.
-*/
-
-#ifndef PERSONLISTVIEWSTUB_H
-#define PERSONLISTVIEWSTUB_H
-
-#include "../../src/ui/personlistview.h"
-#include "listview.h"
-#include "stubbase.h"
-
-class PersonListViewStub : public StubBase
-{
-public:
-    virtual void PersonListViewConstructor(QWidget *parent = 0);
-    virtual bool listItemClicked(ListItem *item);
-};
-
-void PersonListViewStub::PersonListViewConstructor(QWidget *parent)
-{
-    Q_UNUSED(parent)
-}
-
-bool PersonListViewStub::listItemClicked(ListItem *item)
-{
-    QList<ParameterBase *> params;
-    params.append(new Parameter<ListItem *>(item));
-    stubMethodEntered("listItemClicked", params);
-
-    return stubReturnValue<bool>("listItemClicked");
-}
-
-//Create a stub instance
-PersonListViewStub defaultPersonListViewStub;
-PersonListViewStub *personListViewStub = &defaultPersonListViewStub;
-
-PersonListView::PersonListView(QWidget *parent)
-    : ListView(parent)
-{
-    personListViewStub->PersonListViewConstructor(parent);
-}
-
-bool PersonListView::listItemClicked(ListItem *item)
-{
-    return personListViewStub->listItemClicked(item);
-}
-
-#endif // PERSONLISTVIEWSTUB_H
diff --git a/tests/stubs/personlistviewstub.h b/tests/stubs/personlistviewstub.h
new file mode 100644 (file)
index 0000000..23c876e
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+   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.
+*/
+
+#ifndef PERSONLISTVIEWSTUB_H
+#define PERSONLISTVIEWSTUB_H
+
+#include "../../src/ui/personlistview.h"
+#include "listviewstub.h"
+#include "stubbase.h"
+
+class PersonListViewStub : public StubBase
+{
+public:
+    virtual void PersonListViewConstructor(QWidget *parent = 0);
+    virtual bool listItemClicked(ListItem *item);
+};
+
+void PersonListViewStub::PersonListViewConstructor(QWidget *parent)
+{
+    Q_UNUSED(parent)
+}
+
+bool PersonListViewStub::listItemClicked(ListItem *item)
+{
+    QList<ParameterBase *> params;
+    params.append(new Parameter<ListItem *>(item));
+    stubMethodEntered("listItemClicked", params);
+
+    return stubReturnValue<bool>("listItemClicked");
+}
+
+//Create a stub instance
+PersonListViewStub defaultPersonListViewStub;
+PersonListViewStub *personListViewStub = &defaultPersonListViewStub;
+
+PersonListView::PersonListView(QWidget *parent)
+    : ListView(parent)
+{
+    personListViewStub->PersonListViewConstructor(parent);
+}
+
+bool PersonListView::listItemClicked(ListItem *item)
+{
+    return personListViewStub->listItemClicked(item);
+}
+
+#endif // PERSONLISTVIEWSTUB_H
index f88357c..31572de 100644 (file)
@@ -4,11 +4,12 @@ HEADERS += \
     parameter.h \
     networkaccessmanagerstub.h \
     imagefetcherstub.h \
-    personlistitem.h \
-    personlistview.h \
-    listview.h \
-    listitem.h \
-    extendedlistitem.h
+    personlistitemstub.h \
+    personlistviewstub.h \
+    listviewstub.h \
+    listitemstub.h \
+    extendedlistitemstub.h \
+    messagelistitemstub.h
 
 SOURCES += \
     stubbase.cpp
index 9c74647..94ed508 100644 (file)
@@ -5,7 +5,7 @@ INCLUDEPATH += /home/jupe/Desktop/sbhome/projects/situare/tests/stubs/
 
 HEADERS += \
     ../../stubs/stubbase.h \
-    ../../stubs/listitem.h \
+    ../../stubs/listitemstub.h \
     ../../../src/ui/listview.h
 
 SOURCES += \
index e81e1af..ae7b70b 100644 (file)
@@ -22,6 +22,7 @@
 #include <QtTest>
 #include <QtGui>
 
+#include "../../stubs/listitemstub.h"
 #include "../../../src/ui/listview.h"
 
 class TestListView: public QObject
index e3673da..def41ea 100644 (file)
@@ -5,11 +5,11 @@ INCLUDEPATH += ../../stubs/
 
 HEADERS += \
     ../../stubs/stubbase.h \
-    ../../stubs/personlistview.h \
-    ../../stubs/personlistitem.h \
-    ../../stubs/listview.h \
-    ../../stubs/listitem.h \
-    ../../stubs/extendedlistitem.h \
+    ../../stubs/personlistviewstub.h \
+    ../../stubs/personlistitemstub.h \
+    ../../stubs/listviewstub.h \
+    ../../stubs/listitemstub.h \
+    ../../stubs/extendedlistitemstub.h \
     ../../../src/ui/extendedlistitemdelegate.h \
     ../../../src/ui/headerlistitemdelegate.h \
     ../../../src/ui/listitemdelegate.h \
@@ -23,7 +23,9 @@ HEADERS += \
     ../../../src/ui/extendedlistitemstore.h \
     ../../../src/common.h \
     ../../../src/map/osm.h \
-    ../../../src/user/user.h
+    ../../../src/user/user.h \
+    ../../../src/ui/listview.h \
+    ../../../src/ui/personlistview.h \
 
 SOURCES += \
     ../../stubs/stubbase.cpp \
index 3f8cf08..c2b77d0 100644 (file)
 
 #include <QtTest>
 #include <QtGui>
+#include <QMetaType>
+
+#include "../../stubs/personlistviewstub.h"
+#include "../../stubs/personlistitemstub.h"
+#include "../../stubs/listviewstub.h"
+#include "../../stubs/listitemstub.h"
+#include "../../stubs/extendedlistitemstub.h"
+#include "../../../src/ui/imagebutton.h"
+#include "../../../src/user/user.h"
+#include "../../../src/ui/headerlistitemdelegate.h"
 
 #include "../../../src/ui/meetpeoplepanel.h"
 
@@ -31,6 +41,16 @@ class TestMeetPeoplePanel: public QObject
 private slots:
     void cleanup();
     void init();
+    void populateInterestingPeopleListViewWithFriends();
+    void populateInterestingPeopleListViewWithFriendsAndOthers();
+    void listItemSelectionHandler();
+    void messageButtonPressed();
+    void setImage();
+    void showFriend();
+
+private:
+    QList<User> getFriends();
+    QList<User> getOthers();
 
 private:
     MeetPeoplePanel *m_meetPeoplePanel;
@@ -39,6 +59,8 @@ private:
 void TestMeetPeoplePanel::cleanup()
 {
     delete m_meetPeoplePanel;
+
+    listViewStub->stubReset();
 }
 
 void TestMeetPeoplePanel::init()
@@ -47,5 +69,159 @@ void TestMeetPeoplePanel::init()
     QVERIFY(m_meetPeoplePanel);
 }
 
+QList<User> TestMeetPeoplePanel::getFriends()
+{
+    QList<User> friends;
+    User user1;
+    user1.setUserId("1");
+    User user2;
+    user2.setUserId(("2"));
+    friends.append(user1);
+    friends.append(user2);
+
+    return friends;
+}
+
+QList<User> TestMeetPeoplePanel::getOthers()
+{
+    QList<User> others;
+    User user1;
+    user1.setUserId("10");
+    User user2;
+    user2.setUserId(("20"));
+    others.append(user1);
+    others.append(user2);
+
+    return others;
+}
+
+void TestMeetPeoplePanel::populateInterestingPeopleListViewWithFriends()
+{
+    QList<User> friends = getFriends();
+    QList<User> others;
+
+    PersonListView *personListView = m_meetPeoplePanel->m_personListView;
+
+    m_meetPeoplePanel->populateInterestingPeopleListView(friends, others);
+
+    QCOMPARE(listViewStub->stubCallCount("addListItem"), 3);
+
+    QVERIFY(dynamic_cast<HeaderListItemDelegate *>(personListView->itemDelegateForRow(0)));
+    QList<MethodCall *> methodCalls = listViewStub->stubCallsTo("addListItem");
+    QVERIFY(dynamic_cast<ExtendedListItem *>(methodCalls.at(0)->parameter<ListItem *>(1)));
+
+    QVERIFY(dynamic_cast<PersonListItem *>(methodCalls.at(1)->parameter<ListItem *>(1)));
+    QVERIFY(dynamic_cast<PersonListItem *>(methodCalls.at(2)->parameter<ListItem *>(1)));
+}
+
+void TestMeetPeoplePanel::populateInterestingPeopleListViewWithFriendsAndOthers()
+{
+    QList<User> friends = getFriends();
+    QList<User> others = getOthers();
+
+    PersonListView *personListView = m_meetPeoplePanel->m_personListView;
+
+    m_meetPeoplePanel->populateInterestingPeopleListView(friends, others);
+
+    QCOMPARE(listViewStub->stubCallCount("addListItem"), 6);
+
+    QVERIFY(dynamic_cast<HeaderListItemDelegate *>(personListView->itemDelegateForRow(0)));
+    QList<MethodCall *> methodCalls = listViewStub->stubCallsTo("addListItem");
+    QVERIFY(dynamic_cast<ExtendedListItem *>(methodCalls.at(0)->parameter<ListItem *>(1)));
+    QVERIFY(dynamic_cast<ExtendedListItem *>(methodCalls.at(3)->parameter<ListItem *>(1)));
+
+    QVERIFY(dynamic_cast<PersonListItem *>(methodCalls.at(1)->parameter<ListItem *>(1)));
+    QVERIFY(dynamic_cast<PersonListItem *>(methodCalls.at(2)->parameter<ListItem *>(1)));
+    QVERIFY(dynamic_cast<PersonListItem *>(methodCalls.at(4)->parameter<ListItem *>(1)));
+    QVERIFY(dynamic_cast<PersonListItem *>(methodCalls.at(5)->parameter<ListItem *>(1)));
+}
+
+
+void TestMeetPeoplePanel::listItemSelectionHandler()
+{
+    PersonListItem friendItem;
+    friendItem.setPersonData(getFriends().at(0), true);
+    PersonListItem otherItem;
+    otherItem.setPersonData(getOthers().at(0), false);
+
+    listViewStub->stubSetReturnValue("selectedItem", (ListItem*)0);
+
+    m_meetPeoplePanel->listItemSelectionHandler();
+    QVERIFY(!m_meetPeoplePanel->m_friendListButton->isEnabled());
+
+    listViewStub->stubSetReturnValue("selectedItem", (ListItem*)&friendItem);
+    personListItemStub->stubSetReturnValue("isFriend", true);
+
+    m_meetPeoplePanel->listItemSelectionHandler();
+    QVERIFY(m_meetPeoplePanel->m_friendListButton->isEnabled());
+
+    listViewStub->stubSetReturnValue("selectedItem", (ListItem*)&otherItem);
+    personListItemStub->stubSetReturnValue("isFriend", false);
+
+    m_meetPeoplePanel->listItemSelectionHandler();
+    QVERIFY(!m_meetPeoplePanel->m_friendListButton->isEnabled());
+}
+
+void TestMeetPeoplePanel::messageButtonPressed()
+{
+    PersonListItem friendItem;
+    friendItem.setPersonData(getFriends().at(0), true);
+
+    qRegisterMetaType<QPair<QString, QString> >("QPair<QString,QString>");
+
+    QSignalSpy requestMessageDialogSpy(m_meetPeoplePanel,
+                                       SIGNAL(requestMessageDialog(QPair<QString,QString>)));
+    QVERIFY(requestMessageDialogSpy.isValid());
+
+    listViewStub->stubSetReturnValue("selectedItem", (ListItem*)0);
+
+    m_meetPeoplePanel->messageButtonPressed();
+    QCOMPARE(requestMessageDialogSpy.count(), 0);
+
+    listViewStub->stubSetReturnValue("selectedItem", (ListItem*)&friendItem);
+
+    m_meetPeoplePanel->messageButtonPressed();
+    QCOMPARE(listViewStub->stubCallCount("clearItemSelection"), 1);
+    QCOMPARE(requestMessageDialogSpy.count(), 1);
+}
+
+void TestMeetPeoplePanel::setImage()
+{
+    PersonListItem friendItem;
+    friendItem.setPersonData(getFriends().at(0), true);
+
+    listViewStub->stubSetReturnValue("listItem", (ListItem*)0);
+
+    m_meetPeoplePanel->setImage("1", QPixmap());
+    QCOMPARE(personListItemStub->stubCallCount("setAvatarImage"), 0);
+
+    listViewStub->stubSetReturnValue("listItem", (ListItem*)&friendItem);
+
+    m_meetPeoplePanel->setImage("1", QPixmap());
+    QCOMPARE(personListItemStub->stubCallCount("setAvatarImage"), 1);
+}
+
+void TestMeetPeoplePanel::showFriend()
+{
+    PersonListItem friendItem;
+    friendItem.setPersonData(getFriends().at(0), true);
+
+    qRegisterMetaType<QList<QString> >("QList<QString>");
+
+    QSignalSpy requestShowFriendSpy(m_meetPeoplePanel, SIGNAL(requestShowFriend(QList<QString>)));
+    QVERIFY(requestShowFriendSpy.isValid());
+
+    listViewStub->stubSetReturnValue("selectedItem", (ListItem*)0);
+
+    m_meetPeoplePanel->showFriend();
+    QCOMPARE(requestShowFriendSpy.count(), 0);
+
+    listViewStub->stubSetReturnValue("selectedItem", (ListItem*)&friendItem);
+
+    m_meetPeoplePanel->showFriend();
+    QCOMPARE(requestShowFriendSpy.count(), 1);
+    QCOMPARE(listViewStub->stubCallCount("clearItemSelection"), 1);
+}
+
 QTEST_MAIN(TestMeetPeoplePanel)
 #include "testmeetpeoplepanel.moc"
diff --git a/tests/ui/messagelistitem/messagelistitem.pro b/tests/ui/messagelistitem/messagelistitem.pro
new file mode 100644 (file)
index 0000000..6557a15
--- /dev/null
@@ -0,0 +1,22 @@
+CONFIG += qtestlib
+DEFINES += QT_NO_DEBUG_OUTPUT
+
+INCLUDEPATH += ../../stubs/
+
+HEADERS += \
+    ../../stubs/stubbase.h \
+    ./../stubs/listitemstub.h \
+    ../../stubs/extendedlistitemstub.h \
+    ../../../src/ui/messagelistitem.h \
+    ../../../src/ui/listcommon.h \
+    ../../../src/coordinates/geocoordinate.h \
+    ../../../src/coordinates/scenecoordinate.h \
+    ../../../src/situareservice/message.h
+
+SOURCES += \
+    ../../stubs/stubbase.cpp \
+    ../../../src/ui/messagelistitem.cpp \
+    ../../../src/coordinates/geocoordinate.cpp \
+    ../../../src/coordinates/scenecoordinate.cpp \
+    ../../../src/situareservice/message.cpp \
+    testmessagelistitem.cpp
diff --git a/tests/ui/messagelistitem/testmessagelistitem.cpp b/tests/ui/messagelistitem/testmessagelistitem.cpp
new file mode 100644 (file)
index 0000000..49655ec
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+   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 "../../stubs/extendedlistitemstub.h"
+#include "../../../src/situareservice/message.h"
+#include "../../../src/coordinates/geocoordinate.h"
+
+#include "../../../src/ui/messagelistitem.h"
+
+class TestMessageListItem: public QObject
+{
+    Q_OBJECT
+
+private slots:
+    void cleanup();
+    void init();
+    void setMessageData();
+
+private:
+    MessageListItem *m_messageListItem;
+};
+
+void TestMessageListItem::cleanup()
+{
+    delete m_messageListItem;
+
+    extendedListItemStub->stubReset();
+}
+
+void TestMessageListItem::init()
+{
+    m_messageListItem = new MessageListItem();
+    QVERIFY(m_messageListItem);
+}
+
+void TestMessageListItem::setMessageData()
+{
+    Message message1;
+    message1.setReceiverId("1");
+    message1.setSenderId("3");
+    Message message2(Message::MessageTypeSent);
+    message2.setReceiverId("1");
+    message2.setSenderId("3");
+    message2.setCoordinates(GeoCoordinate(65.5, 25.5));
+
+    m_messageListItem->setMessageData(message1);
+    QCOMPARE(m_messageListItem->newMessageReceiverId(), QString("3"));
+    QCOMPARE(extendedListItemStub->stubCallCount("setImage"), 0);
+    QCOMPARE(extendedListItemStub->stubCallCount("addSubItem"), 2);
+
+    extendedListItemStub->stubReset();
+
+    m_messageListItem->setMessageData(message2);
+    QCOMPARE(m_messageListItem->newMessageReceiverId(), QString("1"));
+    QCOMPARE(extendedListItemStub->stubCallCount("addSubItem"), 3);
+}
+
+QTEST_MAIN(TestMessageListItem)
+#include "testmessagelistitem.moc"
+
+
diff --git a/tests/ui/messagelistview/messagelistview.pro b/tests/ui/messagelistview/messagelistview.pro
new file mode 100644 (file)
index 0000000..423272b
--- /dev/null
@@ -0,0 +1,20 @@
+CONFIG += qtestlib
+DEFINES += QT_NO_DEBUG_OUTPUT
+
+INCLUDEPATH += ../../stubs/
+
+HEADERS += \
+    ../../stubs/stubbase.h \
+    ../../stubs/listviewstub.h \
+    ../../stubs/messagelistitemstub.h \
+    ../../../src/ui/messagelistview.h \
+    ../../../src/ui/listview.h \
+    ../../../src/coordinates/geocoordinate.h \
+    ../../../src/coordinates/scenecoordinate.h
+
+SOURCES += \
+    ../../stubs/stubbase.cpp \
+    ../../../src/ui/messagelistview.cpp \
+    ../../../src/coordinates/geocoordinate.cpp \
+    ../../../src/coordinates/scenecoordinate.cpp \
+    testmessagelistview.cpp
diff --git a/tests/ui/messagelistview/testmessagelistview.cpp b/tests/ui/messagelistview/testmessagelistview.cpp
new file mode 100644 (file)
index 0000000..c121161
--- /dev/null
@@ -0,0 +1,85 @@
+/*
+   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 "../../stubs/listviewstub.h"
+#include "../../stubs/messagelistitemstub.h"
+
+#include "../../../src/ui/messagelistview.h"
+
+class TestMessageListView: public QObject
+{
+    Q_OBJECT
+
+private slots:
+    void cleanup();
+    void init();
+    void listItemClicked();
+
+private:
+    MessageListView *m_messageListView;
+};
+
+void TestMessageListView::cleanup()
+{
+    delete m_messageListView;
+
+    listViewStub->stubReset();
+}
+
+void TestMessageListView::init()
+{
+    m_messageListView = new MessageListView();
+    QVERIFY(m_messageListView);
+}
+
+void TestMessageListView::listItemClicked()
+{
+    MessageListItem item;
+
+    QSignalSpy messageItemClickedSpy(m_messageListView, SIGNAL(messageItemClicked(GeoCoordinate)));
+    QVERIFY(messageItemClickedSpy.isValid());
+
+    m_messageListView->listItemClicked(0);
+    QCOMPARE(messageItemClickedSpy.count(), 0);
+
+    listViewStub->stubSetReturnValue("listItemClicked", false);
+
+    m_messageListView->listItemClicked(&item);
+    QCOMPARE(listViewStub->stubCallCount("listItemClicked"), 2);
+    QCOMPARE(messageItemClickedSpy.count(), 0);
+
+    listViewStub->stubSetReturnValue("listItemClicked", true);
+
+    m_messageListView->listItemClicked(&item);
+    QCOMPARE(messageItemClickedSpy.count(), 0);
+
+    messageListItemStub->stubSetReturnValue("coordinates", GeoCoordinate(55.2, 22.5));
+
+    m_messageListView->listItemClicked(&item);
+    QCOMPARE(messageItemClickedSpy.count(), 1);
+}
+
+QTEST_MAIN(TestMessageListView)
+#include "testmessagelistview.moc"
+
diff --git a/tests/ui/personlistview/personlistview.pro b/tests/ui/personlistview/personlistview.pro
new file mode 100644 (file)
index 0000000..1b7efb1
--- /dev/null
@@ -0,0 +1,20 @@
+CONFIG += qtestlib
+DEFINES += QT_NO_DEBUG_OUTPUT
+
+INCLUDEPATH += ../../stubs/
+
+HEADERS += \
+    ../../stubs/stubbase.h \
+    ../../stubs/listviewstub.h \
+    ../../stubs/personlistitemstub.h \
+    ../../../src/ui/personlistview.h \
+    ../../../src/ui/listview.h \
+    ../../../src/coordinates/geocoordinate.h \
+    ../../../src/coordinates/scenecoordinate.h
+
+SOURCES += \
+    ../../stubs/stubbase.cpp \
+    ../../../src/ui/personlistview.cpp \
+    ../../../src/coordinates/geocoordinate.cpp \
+    ../../../src/coordinates/scenecoordinate.cpp \
+    testpersonlistview.cpp
diff --git a/tests/ui/personlistview/testpersonlistview.cpp b/tests/ui/personlistview/testpersonlistview.cpp
new file mode 100644 (file)
index 0000000..ed75a8e
--- /dev/null
@@ -0,0 +1,85 @@
+/*
+   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 "../../stubs/listviewstub.h"
+#include "../../stubs/personlistitemstub.h"
+
+#include "../../../src/ui/personlistview.h"
+
+class TestPersonListView: public QObject
+{
+    Q_OBJECT
+
+private slots:
+    void cleanup();
+    void init();
+    void listItemClicked();
+
+private:
+    PersonListView *m_personListView;
+};
+
+void TestPersonListView::cleanup()
+{
+    delete m_personListView;
+
+    listViewStub->stubReset();
+}
+
+void TestPersonListView::init()
+{
+    m_personListView = new PersonListView();
+    QVERIFY(m_personListView);
+}
+
+void TestPersonListView::listItemClicked()
+{
+    PersonListItem item;
+
+    QSignalSpy personItemClickedSpy(m_personListView, SIGNAL(personItemClicked(GeoCoordinate)));
+    QVERIFY(personItemClickedSpy.isValid());
+
+    m_personListView->listItemClicked(0);
+    QCOMPARE(personItemClickedSpy.count(), 0);
+
+    listViewStub->stubSetReturnValue("listItemClicked", false);
+
+    m_personListView->listItemClicked(&item);
+    QCOMPARE(listViewStub->stubCallCount("listItemClicked"), 2);
+    QCOMPARE(personItemClickedSpy.count(), 0);
+
+    listViewStub->stubSetReturnValue("listItemClicked", true);
+
+    m_personListView->listItemClicked(&item);
+    QCOMPARE(personItemClickedSpy.count(), 0);
+
+    personListItemStub->stubSetReturnValue("coordinates", GeoCoordinate(55.2, 22.5));
+
+    m_personListView->listItemClicked(&item);
+    QCOMPARE(personItemClickedSpy.count(), 1);
+}
+
+QTEST_MAIN(TestPersonListView)
+#include "testpersonlistview.moc"
+
index 16e3eb9..312b7bd 100644 (file)
@@ -32,8 +32,9 @@ private slots:
     void initTestCase();
     void cleanup();
     void init();
-    void addTagToList();
-    void addAndDeleteTag();
+    void addTagToUserTagList();
+    void addAndDeleteTagFromUserTagList();
+    void populateUserTags();
 
 private:
     QHash<QString, QString> m_tags;
@@ -49,7 +50,7 @@ void TestTagsDialog::init()
 {
     m_tagsDialog = new TagsDialog(m_tags);
     QVERIFY(m_tagsDialog);
-    QCOMPARE(m_tagsDialog->m_tagsView->count(), 3);
+    QCOMPARE(m_tagsDialog->m_userTagsView->count(), 3);
 }
 
 void TestTagsDialog::initTestCase()
@@ -59,32 +60,45 @@ void TestTagsDialog::initTestCase()
     m_tags.insert("3", "britney spears");
 }
 
-void TestTagsDialog::addTagToList()
+void TestTagsDialog::addTagToUserTagList()
 {
     m_tagsDialog->m_addTagEdit->setText("new age");
     m_tagsDialog->addTagToList();
-    QCOMPARE(m_tagsDialog->m_tagsView->count(), 4);
-    QCOMPARE(m_tagsDialog->m_tagsView->item(0)->text(), QString("new age"));
+    QCOMPARE(m_tagsDialog->m_userTagsView->count(), 4);
+    QCOMPARE(m_tagsDialog->m_userTagsView->item(0)->text(), QString("new age"));
     QVERIFY(m_tagsDialog->newTags().contains("new age"));
 }
 
-void TestTagsDialog::addAndDeleteTag()
+void TestTagsDialog::addAndDeleteTagFromUserTagList()
 {
-    addTagToList();
+    addTagToUserTagList();
 
-    m_tagsDialog->m_tagsView->setItemSelected(m_tagsDialog->m_tagsView->item(0), true);
+    m_tagsDialog->m_userTagsView->setItemSelected(m_tagsDialog->m_userTagsView->item(0), true);
     m_tagsDialog->deleteTagFromList();
-    QCOMPARE(m_tagsDialog->m_tagsView->count(), 3);
-    QVERIFY(m_tags.contains("1"));
-    QVERIFY(m_tags.contains("2"));
-    QVERIFY(m_tags.contains("3"));
+    QCOMPARE(m_tagsDialog->m_userTagsView->count(), 3);
 
-    QListWidgetItem *item = m_tagsDialog->m_tagsView->item(0);
-    m_tagsDialog->m_tagsView->setItemSelected(item, true);
+    QListWidgetItem *item = m_tagsDialog->m_userTagsView->item(0);
+    m_tagsDialog->m_userTagsView->setItemSelected(item, true);
     m_tagsDialog->deleteTagFromList();
-    QCOMPARE(m_tagsDialog->m_tagsView->count(), 2);
+    QCOMPARE(m_tagsDialog->m_userTagsView->count(), 2);
     QVERIFY(m_tagsDialog->removedTags().contains(item->text()));
 }
 
+void TestTagsDialog::populateUserTags()
+{
+    QHash<QString, QString> tags;
+    tags.insert("1", "pop");
+    tags.insert("2", "rock");
+    tags.insert("3", "britney spears");
+
+    m_tagsDialog->populateUserTags(tags);
+    QCOMPARE(m_tagsDialog->m_userTagsView->count(), 3);
+
+    tags.insert("5", "new age");
+
+    m_tagsDialog->populateUserTags(tags);
+    QCOMPARE(m_tagsDialog->m_userTagsView->count(), 4);
+}
+
 QTEST_MAIN(TestTagsDialog)
 #include "testtagsdialog.moc"